-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHoldShopItem.cs
More file actions
211 lines (155 loc) · 5.96 KB
/
HoldShopItem.cs
File metadata and controls
211 lines (155 loc) · 5.96 KB
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
202
203
204
205
206
207
208
209
210
211
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;
using System.Diagnostics;
using Microsoft.Xna.Framework.Input;
namespace monowizard
{
internal class HoldShopItem : HoldItem
{
HoldItem trueItem = null;
public bool ishovered = false;
public UIString uinum = null;
public int price;
public int shopind;
public Rectangle shoprect;
public Rectangle symbdrawrect;
public CantripScroll sepll;
public HoldShopItem(CollisionCheck check, Player player,HoldItem truth,int shopind,int price) : base(check, player)
{
this.id = 200;
this.player = player;
this.check = check;
this.price = price;
throwvel = 13;
spriteEffects = SpriteEffects.None;
trueItem = truth;
this.shopind = shopind;
shoprect = new Rectangle((shopind % 4) *960, (shopind / 4) * 960,960,960);
if (trueItem is CantripScroll)
{
// Debug.WriteLine("Cantrip");
sepll = trueItem as CantripScroll;
sepll.symbols = player.itemManager.magicsymbols;
sepll.texture = player.itemManager.libitems1;
}
setDefaultValues();
}
public void setDefaultValues()
{
hitbox.X = 200;
hitbox.Y = 200;
hitbox.Width = trueItem.hitbox.Width;
hitbox.Height = trueItem.hitbox.Height;
croprect.X = trueItem.croprect.X;
croprect.Y = trueItem.croprect.Y;
croprect.Width = trueItem.croprect.Width;
croprect.Height = trueItem.croprect.Height;
holdoffset = trueItem.holdoffset;
xmidoffset = trueItem.xmidoffset;
xleftholdoffset = trueItem.xleftholdoffset;
xrightholdoffset = trueItem.xrightholdoffset;
id = trueItem.id;
drawrect = trueItem.drawrect;
bounce = 5;
}
public override void update()
{
base.update();
if (hitbox.Intersects(shoprect))
{
if (hitbox.Intersects(player.hitbox) && uinum == null)
{
ishovered = true;
uinum = player.ui.addUINumber(drawrect.X - 40, drawrect.Y - 100, price);
// Debug.WrihitbteLine("Player hit");
}
else if (!hitbox.Intersects(player.hitbox) && uinum != null)
{
ishovered = false;
player.ui.items.Remove(uinum);
//sDebug.WriteLine(uinum != null);
uinum = null;
}
else
{
if (uinum != null && this == player.heldItem)
{
// Debug.WriteLine("gos is sed");
drawrect.X = (int)hitbox.X - player.centerWorldX + player.centerX;
drawrect.Y = (int)hitbox.Y - player.centerWorldY + player.centerY;
uinum.Relocate(drawrect.X - 40, drawrect.Y - 200, 80, 80);
if (player.epressed)
{
if (player.mana > price)
{
delete();
player.itemManager.itemsinshop.Remove(this);
player.changeMana(-price);
}
}
}
}
}
else {
//robbery
//delete();
player.itemManager.robbedShop();
}
}
public void delete()
{
if (trueItem is HoldBook)
{
player.itemManager.addBook(hitbox.X, hitbox.Y);
}
else if (trueItem is HoldCrystalRock)
{
player.itemManager.addCrystalRock(hitbox.X, hitbox.Y);
}
else if (trueItem is HoldMKey)
{
player.itemManager.addMKey(hitbox.X, hitbox.Y);
}
else if (trueItem is CantripScroll)
{
player.itemManager.addMagicScroll(hitbox.X, hitbox.Y,sepll.cantripnum);
}
else if (trueItem is HoldMinorHealWand)
{
player.itemManager.addMinorHealWand(hitbox.X, hitbox.Y);
}
else if (trueItem is HoldMagicArrowWand)
{
player.itemManager.addMagicArrowWand(hitbox.X, hitbox.Y);
}
if (this == player.heldItem)
{
player.heldItem = player.itemManager.items.Last();
}
//player.changeMana(-10);
player.itemManager.addMomentum(xvel, yvel);
ishovered = false;
player.ui.items.Remove(uinum);
uinum = null;
player.itemManager.items.Remove(this);
//player.itemManager.itemsinshop.Remove(this);
}
public override void draw(SpriteBatch _spriteBatch)
{
drawrect.X = (int)hitbox.X - player.centerWorldX + player.centerX;
drawrect.Y = (int)hitbox.Y - player.centerWorldY + player.centerY;
_spriteBatch.Draw(texture, drawrect, croprect, Color.White, 0, Vector2.Zero, spriteEffects, 1);
if (trueItem is CantripScroll)
{
sepll.drawrect.X = (int)hitbox.X - player.centerWorldX + player.centerX;
sepll.drawrect.Y = (int)hitbox.Y - player.centerWorldY + player.centerY;
sepll.drawforshop(_spriteBatch);
}
}
}
}