Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing the warning (sign that is used on the base before attack)
- Loading branch information
1 parent
0b41d62
commit 4a2ff24
Showing
9 changed files
with
204 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
core/src/com/coldwild/dodginghero/graph/effects/Effect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.coldwild.dodginghero.graph.effects; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.utils.Pool; | ||
|
||
/** | ||
* Created by comrad_gremlin on 9/9/2016. | ||
*/ | ||
public abstract class Effect implements Pool.Poolable { | ||
|
||
protected boolean isAlive; | ||
protected float timeAlive; | ||
|
||
public Effect() | ||
{ | ||
isAlive = false; | ||
timeAlive = 0; | ||
} | ||
|
||
@Override | ||
public void reset() { | ||
|
||
} | ||
|
||
public void init(EffectEngine parent) | ||
{ | ||
isAlive = true; | ||
timeAlive = 0; | ||
parent.add(this); | ||
} | ||
|
||
public void update(float delta) | ||
{ | ||
timeAlive += delta; | ||
} | ||
|
||
public abstract void draw(SpriteBatch batch); | ||
|
||
public boolean isAlive() | ||
{ | ||
return isAlive; | ||
} | ||
|
||
public abstract void release(); | ||
} |
58 changes: 58 additions & 0 deletions
58
core/src/com/coldwild/dodginghero/graph/effects/EffectEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.coldwild.dodginghero.graph.effects; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Created by comrad_gremlin on 9/9/2016. | ||
*/ | ||
public class EffectEngine { | ||
|
||
List<Effect> effects; | ||
public EffectEngine() | ||
{ | ||
effects = new ArrayList<Effect>(); | ||
} | ||
|
||
public void add(Effect effect) | ||
{ | ||
effects.add(effect); | ||
} | ||
|
||
public void update(float delta) | ||
{ | ||
int i = 0; | ||
while (i < effects.size()) | ||
{ | ||
effects.get(i).update(delta); | ||
if (effects.get(i).isAlive()) | ||
{ | ||
i++; | ||
} | ||
else | ||
{ | ||
effects.get(i).release(); | ||
effects.remove(i); | ||
} | ||
} | ||
} | ||
|
||
public void draw(SpriteBatch batch) | ||
{ | ||
for (int i = 0; i < effects.size(); i++) | ||
{ | ||
effects.get(i).draw(batch); | ||
} | ||
} | ||
|
||
public void clear() | ||
{ | ||
while (effects.size() > 0) | ||
{ | ||
effects.get(0).release(); | ||
effects.remove(0); | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
core/src/com/coldwild/dodginghero/graph/effects/WarningEffect.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package com.coldwild.dodginghero.graph.effects; | ||
|
||
import com.badlogic.gdx.graphics.g2d.SpriteBatch; | ||
import com.badlogic.gdx.utils.Pool; | ||
import com.coldwild.dodginghero.Resources; | ||
import com.coldwild.dodginghero.graph.SizeEvaluator; | ||
|
||
/** | ||
* Created by comrad_gremlin on 9/9/2016. | ||
*/ | ||
public class WarningEffect extends Effect { | ||
|
||
private static final float WARNING_TIME = 2.0f; | ||
private int fieldX; | ||
private int fieldY; | ||
private SizeEvaluator sizeEvaluator; | ||
private Resources resources; | ||
|
||
public static WarningEffect Create(int fx, | ||
int fy, | ||
EffectEngine engine, | ||
SizeEvaluator sz, | ||
Resources res) | ||
{ | ||
WarningEffect effect = warningPool.obtain(); | ||
effect.init(fx, fy, engine, sz, res); | ||
return effect; | ||
} | ||
|
||
public WarningEffect() | ||
{ | ||
|
||
} | ||
|
||
public void init(int fx, int fy, EffectEngine parent, SizeEvaluator sz, Resources res) | ||
{ | ||
fieldX = fx; | ||
fieldY = fy; | ||
sizeEvaluator = sz; | ||
resources = res; | ||
super.init(parent); | ||
} | ||
|
||
@Override | ||
public void draw(SpriteBatch batch) { | ||
batch.begin(); | ||
batch.draw(resources.warning, | ||
sizeEvaluator.getBaseScreenX(fieldX), | ||
sizeEvaluator.getBaseScreenY(fieldY)); | ||
batch.end(); | ||
} | ||
|
||
@Override | ||
public void update(float delta) | ||
{ | ||
super.update(delta); | ||
if (timeAlive > WARNING_TIME) | ||
{ | ||
isAlive = false; | ||
} | ||
} | ||
|
||
@Override | ||
public void release() { | ||
warningPool.free(this); | ||
} | ||
|
||
static Pool<WarningEffect> warningPool = new Pool<WarningEffect>() { | ||
@Override | ||
protected WarningEffect newObject() { | ||
return new WarningEffect(); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters