forked from CuteLunaMoon/Survival-Pixel-Dungeon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWndHuntressNPC.java
93 lines (74 loc) · 3.07 KB
/
WndHuntressNPC.java
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
/*
* Pixel Dungeon
* Copyright (C) 2012-2015 Oleg Dolya
*
* Shattered Pixel Dungeon
* Copyright (C) 2014-2018 Evan Debenham
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.windows;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.HuntressNPC;
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline;
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
public class WndHuntressNPC extends Window {
private static final int WIDTH = 120;
private static final int BTN_HEIGHT = 20;
private static final float GAP = 2;
private int price =50;
public WndWandmaker( final HUntressNOC huntress, final Item item ) {
super();
IconTitle titlebar = new IconTitle();
titlebar.icon(new ItemSprite(item.image(), null));
titlebar.label(Messages.titleCase(item.name()));
titlebar.setRect(0, 0, WIDTH, 0);
add( titlebar );
msg =" I have hunted some dungeon crabs earlier, wanna buy some fresh crustacean meat?";
RenderedTextMultiline message = PixelScene.renderMultiline( msg, 6 );
message.maxWidth(WIDTH);
message.setPos(0, titlebar.bottom() + GAP);
add( message );
RedButton btnWand1 = new RedButton( "Buy :", price ) {
@Override
protected void onClick() {
BuyMeat();
}
};
btnWand1.setRect(0, message.top() + message.height() + GAP, WIDTH, BTN_HEIGHT);
add( btnWand1 );
}
private void BuyMeat(){
Hero hero = Dungeon.hero;
MysteryMeat meat = new MysteryMeat();
if(Dungeon.gold <= price){
Dungeon.gold -= price;
if (!meat.doPickUp( hero )) {
Dungeon.level.drop( item, heap.pos ).sprite.drop();
}
}else{
GLog.n("You don't have enough money");
}
}
}