-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMiningAndMaterial.java
More file actions
executable file
·48 lines (44 loc) · 1.4 KB
/
MiningAndMaterial.java
File metadata and controls
executable file
·48 lines (44 loc) · 1.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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* Write a description of class MiningAndMaterial here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class MiningAndMaterial extends Industry {
private int SI = -2;
private int EPR = +2;
private int CWI = -1;
private int type = 5;
/** Constructor for MiningAndMaterial */
public MiningAndMaterial() {
super(-2, +2, -1, 5);
L1 = new GreenfootImage("images/industry/Material1.png");
L2 = new GreenfootImage("images/industry/Material2.png");
L3 = new GreenfootImage("images/industry/Material3.png");
}
/**
* Act - do whatever the MiningAndMaterial wants to do. This method is called whenever the 'Act'
* or 'Run' button gets pressed in the environment.
*/
public void act() {
checkNextLevel();
checkImage();
}
/** Checks if it can level up based on the criteria */
public void checkNextLevel() {
if (MainWorld.getTotalCoin() >= 1500 && level == 0) {
levelUp();
MainWorld.changeTotalCoin(-1500);
MainWorld.changeEPR(1);
} else if (MainWorld.getTotalCoin() >= 2250 && level == 1) {
levelUp();
MainWorld.changeTotalCoin(-2250);
MainWorld.changeEPR(2);
} else if (MainWorld.getTotalCoin() >= 1125 && level == 2) {
levelUp();
MainWorld.changeTotalCoin(-1125);
MainWorld.changeEPR(1);
}
}
}