-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlantCard.java
More file actions
92 lines (73 loc) · 2.4 KB
/
PlantCard.java
File metadata and controls
92 lines (73 loc) · 2.4 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
// PlantCard.java
// David Wang
// Makes the plant seeds to click to plant plants
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.geom.*;
public class PlantCard{
private Rectangle cardRect;
private int plantType;
private int cost,recharge,charge;
public Image image, unactiveImage;
private boolean active;
public static final int PEASHOOTER = 0, SUNFLOWER = 1, CHERRYBOMB = 2, WALLNUT = 3, THREEPEATER = 4, SNOWPEA = 5, TALLNUT = 6,
REPEATER = 7, POTATOMINE = 8, SQUASH = 9, JALAPENO = 10, SPIKEWEED = 11, TORCHWOOD = 12,
TWINSUNFLOWER = 13, GATLINGPEA = 14, BONKCHOY = 15, PIKAPEA = 16, FIREPEA = 17;
public static final int[] costs = new int[]{100,50,150,50,325,175,125,200,25,50,125,100,175,150,250,150,175,175};
public static final int[] recharges = new int[]{750,750,5000,3000,750,750,3000,750,3000,3000,5000,750,750,5000,5000,750,750,750};
public static ArrayList<Image> seedPackets = new ArrayList<Image>();
public PlantCard(Rectangle rect, int type){
plantType = type;
cardRect = rect;
active = true;
cost = costs[type];
recharge = recharges[type];
charge = 0;
image = seedPackets.get(type);
unactiveImage = new ImageIcon("Images/Game/Seeds/seedcover.png").getImage();
}
public static void getImages(){
for (int i = 1; i <19; i++){
seedPackets.add(new ImageIcon(String.format("Images/Game/Seeds/seed%s.png",i)).getImage());
}
}
public void setRect(int x, int y, int width, int height){
cardRect = new Rectangle(x,y,width,height);
}
public boolean getActive(){
return active;
}
public void setActive(boolean newAc){
active = newAc;
}
public int getCost(){
return cost;
}
public Rectangle getRect(){
return cardRect;
}
public int getType(){
return plantType;
}
public int getRecharge(){
return recharge;
}
public int getCharge(){
return charge;
}
public void addCharge(){
charge ++;
}
public void setCharge(int newcharge){
charge = newcharge;
}
public void draw(Graphics g,JPanel j){
g.drawImage(image,(int)cardRect.getX(),(int)cardRect.getY(),j);
if (!active){
g.drawImage(unactiveImage,(int)cardRect.getX(),(int)cardRect.getY(),j);
}
}
}