-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathbaseInfo.java
More file actions
97 lines (77 loc) · 2.7 KB
/
baseInfo.java
File metadata and controls
97 lines (77 loc) · 2.7 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
package core;
//store all the information about a base, eg current credit, number of structures , current power level, tech trees and etc...
public class baseInfo {
public int numberOfPowerPlant;
public int numberOfConstructionYard;
public int numberOfRefinery;
public int numberOfFactory;
public int numberOfCommunicationCenter;
public int numberOfTechCenter;
public int numberOfGunTurret;
public int numberOfMissileTurret, numberOfOverChargedMissileTurret;
public boolean canBuildPowerPlant, canBuildRefinery, canBuildFactory, canBuildCommunicationCenter, canBuildTechCenter, canBuildGunTurret, canBuildMissileTurret;
public boolean canBuildLightTank, canBuildRocketTank, canBuildDrone, canBuildStealthTank, canBuildHeavyTank, canBuildMCV, canBuildHarvester;
public int currentCredit;
public int currentPowerLevel;
public int currentPowerConsumption;
public int powerStatus;
public boolean lowPower;
public baseInfo(){
currentCredit = 5000;
}
public void update(){
//update tech tree
canBuildPowerPlant = true;
canBuildRefinery = false;
canBuildFactory = false;
canBuildCommunicationCenter= false;
canBuildTechCenter = false;
canBuildGunTurret = false;
canBuildMissileTurret= false;
canBuildLightTank = true;
canBuildRocketTank = true;
canBuildDrone = true;
canBuildHarvester = false;
canBuildMCV = false;
canBuildHeavyTank = false;
canBuildStealthTank = false;
if(numberOfPowerPlant > 0){
canBuildRefinery = true;
}
if(numberOfRefinery > 0){
canBuildFactory = true;
canBuildHarvester = true;
}
if(numberOfFactory > 0){
canBuildCommunicationCenter = true;
canBuildGunTurret = true;
}
if(numberOfCommunicationCenter > 0){
canBuildMissileTurret = true;
canBuildTechCenter = true;
canBuildStealthTank = true;
canBuildMCV = true;
}
if(numberOfTechCenter > 0){
canBuildHeavyTank = true;
}
reCalculatePower();
//calculate power level and power consumption
if(currentPowerLevel == 0){
powerStatus = -1;
}else{
powerStatus = currentPowerConsumption * 100 / currentPowerLevel;
}
if(powerStatus == -1 || powerStatus > 100)
lowPower = true;
else
lowPower = false;
if(powerStatus != -1){
powerStatus = currentPowerConsumption << 16 | currentPowerLevel;
}
}
public void reCalculatePower() {
currentPowerLevel = numberOfPowerPlant*500 + numberOfConstructionYard*100;
currentPowerConsumption = numberOfRefinery*150 + numberOfFactory*200 + numberOfCommunicationCenter*250 + numberOfGunTurret*100 + numberOfMissileTurret*200 + numberOfOverChargedMissileTurret*150 + numberOfTechCenter*400;
}
}