-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMagicWitchBolt1.cs
201 lines (130 loc) · 4.29 KB
/
MagicWitchBolt1.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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace monowizard
{
internal class MagicWitchBolt1 : Entity
{
int maxVel = 25;
int hitVel = 5;
Player player;
CollisionCheck check;
float directionX;
float directionY;
MagicManager manager;
Rectangle cropbox;
float rotat;
Vector2 middlepoint = new Vector2(32, 32);
SpriteEffects spriteEffects = SpriteEffects.None;
int offsetx;
int offsety;
int aniframe = 0;
Entity magcol;
int[] crazywalk;
int crazypoint = 0;
int[] crazywalky;
int crazypointy = 0;
public MagicWitchBolt1(CollisionCheck collisionCheck, Player player, int x, int y, float dirx, float diry, MagicManager magicManager)
{
this.player = player;
check = collisionCheck;
manager = magicManager;
id = 1001;
hitrank = 3;
drawrect = new Rectangle(x, y, 64, 64);
hitbox = new Rectangle(x, y, 40, 40);
cropbox = new Rectangle(0, 768, 128, 128);
directionX = dirx;
directionY = diry;
bounce = 86;
crazywalk = new int[] {-5,-5,-5,-5,-10,-8,5,5,5,5,10,8};
crazywalky = new int[] { -5, -5, -5, -5, 5, 5, 5, 5 };
}
public override void update()
{
if(crazypoint >= crazywalk.Length-1)
{
crazypoint = 0;
}
else
{
crazypoint++;
}
if (crazypointy >= crazywalky.Length - 1)
{
crazypointy = 0;
}
else
{
crazypointy++;
}
xvel = (int)Math.Floor(directionX * 10) + crazywalky[crazypointy];
yvel = (int)Math.Floor(directionY * 10)+ crazywalk[crazypoint];
colliding = false;
grounded = false;
check.checkTile(this);
if (colliding || grounded)
{
manager.items.Remove(this);
}
//hit checl
hitCheck();
//applie sphysiocs
hitbox.X += xvel;
hitbox.Y += yvel;
//animete
aniframe = (aniframe + 1) % 31;
cropbox.X = (aniframe > 20) ? 256 : (aniframe / 10) * 128;
}
public override void hit(Entity entity)
{
}
public void hitCheck()
{
if (hitbox.Intersects(player.hitbox))
{
player.hit(this);
manager.items.Remove(this);
}
for (int i = 0; i < player.itemManager.items.Count; i++)
{
if (hitbox.Intersects(player.itemManager.items[i].hitbox))
{
player.itemManager.items[i].hit(this);
manager.items.Remove(this);
}
}
for (int i = 0; i < manager.items.Count; i++)
{
if (manager.items[i] != this)
{
if (hitbox.Intersects(manager.items[i].hitbox))
{
magcol = manager.items[i];
if (magcol.hitrank == 3 || magcol.hitrank == 4 || magcol.hitrank == 5)
{
manager.items.Remove(this);
}
}
}
}
if (magcol != null)
{
if (magcol.hitrank == 1 || magcol.hitrank == 2 || magcol.hitrank == 3)
{
manager.items.Remove(magcol);
}
}
}
public override void draw(SpriteBatch _spriteBatch)
{
drawrect.X = (int)hitbox.X + offsetx - player.centerWorldX + player.centerX;
drawrect.Y = (int)hitbox.Y + offsety - player.centerWorldY + player.centerY;
_spriteBatch.Draw(texture, drawrect, cropbox, Color.White, 0, Vector2.Zero, spriteEffects, 1);
}
}
}