-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPickup.cs
164 lines (152 loc) · 5.48 KB
/
Pickup.cs
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
namespace Nitemare3D
{
public enum PickupType
{
RedKey,
GreenKey,
BlueKey,
YellowKey,
RedIDCard,
YellowIDCard,
RedPotion,
BluePotion,
Eyeball,
CrystallBall,
PlasmaPistol,
MagicWand,
Pistol,
AutoPlasmaPistol
}
public class Pickup : Entity, ISprite
{
public int spriteIndex {get; set;}
public bool visible{get;set;} = true;
public Vec2 spritePosition{get;set;} = new Vec2();
public float yOffset{get;set;}
AnimationHandler anim = new AnimationHandler();
static Animation[] animations = new Animation[]
{
new Animation(189, 1, 125), //red key
new Animation(190, 1, 125), //green key
new Animation(191, 1, 125), //blue key
new Animation(192, 1, 125), //yellow key
new Animation(193, 1, 125), //red card
new Animation(194, 1, 125), //yellow card
new Animation(204, 4, 125), //red potion
new Animation(208, 4, 125), //blue potion
new Animation(215, 6, 125), //eye thing
new Animation(221, 6, 125), //crystal ball
new Animation(235, 1, 125), //plasma pistol
new Animation(236, 1, 125), //magic wand
new Animation(237, 1, 125), //revolver
new Animation(238, 1, 125) //plasma auto pistol
};
PickupType type;
public Pickup(PickupType type)
{
this.type = type;
anim.LoadAnimation(animations[(int)type]);
Game.player.AddSprite(this);
anim.index = animations[(int)type].frames[0].index;
hasCollision = false;
switch (type)
{
case PickupType.RedKey:
break;
case PickupType.GreenKey:
break;
case PickupType.BlueKey:
break;
case PickupType.YellowKey:
break;
case PickupType.RedIDCard:
break;
case PickupType.YellowIDCard:
break;
case PickupType.RedPotion:
break;
case PickupType.BluePotion:
break;
case PickupType.Eyeball:
yOffset = 32;
break;
case PickupType.CrystallBall:
break;
case PickupType.PlasmaPistol:
break;
case PickupType.MagicWand:
break;
case PickupType.Pistol:
break;
case PickupType.AutoPlasmaPistol:
break;
}
}
public override void Update()
{
anim.Update();
spriteIndex = anim.index;
spritePosition = position;
if((int)position.X == (int)Game.player.position.X && (int)position.Y == (int)Game.player.position.Y)
{
OnTouchPlayer();
}
}
void OnTouchPlayer()
{
switch (type)
{
case PickupType.RedKey:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.GreenKey:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.BlueKey:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.YellowKey:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.RedIDCard:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.YellowIDCard:
SoundEffect.PlaySound(SoundConsts.PICKUP_KEY);
break;
case PickupType.RedPotion:
break;
case PickupType.BluePotion:
break;
case PickupType.Eyeball:
SoundEffect.PlaySound(SoundConsts.PICKUP_EYE);
break;
case PickupType.CrystallBall:
SoundEffect.PlaySound(SoundConsts.PICKUP_GLASSBALL);
break;
case PickupType.PlasmaPistol:
SoundEffect.PlaySound(SoundConsts.PICKUP_WEAPON);
Game.player.weaponIndex = 0;
Game.player.weapons[0].hasWeapon = true;
break;
case PickupType.MagicWand:
SoundEffect.PlaySound(SoundConsts.PICKUP_WEAPON);
Game.player.weaponIndex = 1;
Game.player.weapons[1].hasWeapon = true;
break;
case PickupType.Pistol:
SoundEffect.PlaySound(SoundConsts.PICKUP_WEAPON);
Game.player.weaponIndex = 2;
Game.player.weapons[2].hasWeapon = true;
break;
case PickupType.AutoPlasmaPistol:
SoundEffect.PlaySound(SoundConsts.PICKUP_WEAPON);
Game.player.weaponIndex = 3;
Game.player.weapons[3].hasWeapon = true;
break;
}
Entity.Remove(this);
visible = false;
}
}
}