-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathManaSmall.cs
149 lines (96 loc) · 3.15 KB
/
ManaSmall.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
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 ManaSmall : Entity
{
public int maxVel = 25;
public int hitVel = 5;
public Rectangle croprect;
int hoverframes = 0;
int hoverdir = 1;
int aniframe;
int drawbuff;
int playerdistx;
int playerdisty;
float manavalue = 0.2f;
public SpriteEffects spriteEffects;
CollisionCheck check;
Player player;
ParticleManager particleManager;
public ManaSmall(CollisionCheck check, Player player, ParticleManager particleManager, int size, float mana)
{
id = 9888;
this.player = player;
this.check = check;
spriteEffects = SpriteEffects.None;
manavalue = mana;
hitbox.X = 200;
hitbox.Y = 200;
hitbox.Width = size/2;
hitbox.Height = size / 2;
drawbuff = size / 4;
drawrect = new Rectangle(0, 0, size, size);
croprect = new Rectangle(128, 384, 128, 128);
bounce = 5;
this.particleManager = particleManager;
}
public override void update()
{
//gravity
yvel = (player.frameCounter.frame % 2)*hoverdir;
playerdistx = hitbox.X - (player.hitbox.X+40);
playerdisty = hitbox.Y - (player.hitbox.Y+40);
if (playerdistx < 200 && playerdistx > -200)
{
if (playerdisty < 200 && playerdisty > -200)
{
yvel = -(playerdisty / 40);
xvel = -(playerdistx / 40);
}
}
colliding = false;
grounded = false;
check.checkTile(this);
if (grounded)
{
hoverframes = 100;
}
if (hoverframes == 0)
{
hoverdir = 1;
}
else
{
hoverdir = -1;
hoverframes--;
}
//applie sphysiocs
hitbox.X += xvel;
hitbox.Y += yvel;
playerhitcheck();
//animate
aniframe = (aniframe + 1) % 41;
croprect.X = (aniframe > 30) ? 384 : (aniframe / 10) * 128;
}
public void playerhitcheck()
{
if (hitbox.Intersects(player.hitbox))
{
particleManager.items.Remove(this);
player.changeMana(manavalue);
}
}
public override void draw(SpriteBatch _spriteBatch)
{
drawrect.X = (int)hitbox.X - drawbuff - player.centerWorldX + player.centerX;
drawrect.Y = (int)hitbox.Y - drawbuff - player.centerWorldY + player.centerY;
_spriteBatch.Draw(texture, drawrect, croprect, Color.White, 0, Vector2.Zero, spriteEffects, 1);
}
}
}