-
Notifications
You must be signed in to change notification settings - Fork 2
/
Bonus.java
95 lines (75 loc) · 1.92 KB
/
Bonus.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package com.coldwild.dodginghero.logic.objects;
import com.badlogic.gdx.graphics.g2d.Sprite;
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/27/2016.
*/
public class Bonus extends Sprite implements Pool.Poolable {
public static byte BONUS_TYPE_ATTACK = 0;
public static byte BONUS_TYPE_HEALTH = 1;
public static byte BONUS_TYPE_COIN = 2;
private int fieldX;
private int fieldY;
private byte bonusType;
public Bonus()
{
}
public void setup(int fx, int fy, byte bType, Resources res)
{
fieldX = fx;
fieldY = fy;
bonusType = bType;
if (bType == BONUS_TYPE_ATTACK)
{
set(res.attackBonus);
}
else if (bType == BONUS_TYPE_HEALTH)
{
set(res.healthBonus);
}
else if (bType == BONUS_TYPE_COIN)
{
set(res.coinBonus);
}
}
@Override
public void reset() {
}
static final Pool<Bonus> bonusPool = new Pool<Bonus>() {
@Override
protected Bonus newObject() {
return new Bonus();
}
};
public void release()
{
bonusPool.free(this);
}
public static Bonus Create(int fx, int fy, byte bType, Resources res)
{
Bonus bonus = bonusPool.obtain();
bonus.setup(fx, fy, bType, res);
return bonus;
}
public void draw(SpriteBatch batch, SizeEvaluator sizeEvaluator)
{
setPosition(sizeEvaluator.getBaseScreenX(fieldX),
sizeEvaluator.getBaseScreenY(fieldY));
super.draw(batch);
}
public int getFieldX()
{
return fieldX;
}
public int getFieldY()
{
return fieldY;
}
public byte getBonusType()
{
return bonusType;
}
}