-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmagicfireball1.cs
154 lines (94 loc) · 3.16 KB
/
magicfireball1.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
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 magicfireball1 : 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;
public magicfireball1(CollisionCheck collisionCheck, Player player, int x, int y, float dirx, float diry, MagicManager magicManager)
{
this.player = player;
check = collisionCheck;
manager = magicManager;
id = 1001;
hitrank = 1;
drawrect = new Rectangle(x, y, 64, 64);
hitbox = new Rectangle(x, y, 40, 40);
cropbox = new Rectangle(256, 0, 128, 128);
directionX = dirx;
directionY = diry;
bounce = 85;
}
public override void update()
{
xvel = (int)Math.Floor(directionX * 10);
yvel = (int)Math.Floor(directionY * 10);
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.Y = (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 (hitbox.Intersects(manager.items[i].hitbox))
{
manager.items[i].hit(this);
manager.items.Remove(this);
}
}*/
}
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);
}
}
}