Added shield effects
This commit is contained in:
@@ -6,12 +6,14 @@ import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.state;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
/** Updates the campaign universe. Has no relevance to other gamemodes. */
|
||||
public class Universe{
|
||||
private long seconds;
|
||||
private float secondCounter;
|
||||
private int turn;
|
||||
private float turnCounter;
|
||||
|
||||
public Universe(){
|
||||
load();
|
||||
@@ -35,6 +37,7 @@ public class Universe{
|
||||
|
||||
public void update(){
|
||||
secondCounter += Time.delta() / 60f;
|
||||
|
||||
if(secondCounter >= 1){
|
||||
seconds += (int)secondCounter;
|
||||
secondCounter %= 1f;
|
||||
@@ -45,6 +48,15 @@ public class Universe{
|
||||
}
|
||||
}
|
||||
|
||||
//update turn state - happens only in-game
|
||||
turnCounter += Time.delta();
|
||||
|
||||
if(turnCounter >= turnDuration){
|
||||
turn ++;
|
||||
turnCounter = 0;
|
||||
onTurn();
|
||||
}
|
||||
|
||||
if(state.hasSector()){
|
||||
//update sector light
|
||||
float light = state.getSector().getLight();
|
||||
@@ -56,6 +68,10 @@ public class Universe{
|
||||
}
|
||||
}
|
||||
|
||||
private void onTurn(){
|
||||
//create a random event here, e.g. invasion
|
||||
}
|
||||
|
||||
public float secondsMod(float mod, float scale){
|
||||
return (seconds / scale) % mod;
|
||||
}
|
||||
@@ -69,11 +85,16 @@ public class Universe{
|
||||
}
|
||||
|
||||
private void save(){
|
||||
Core.settings.putSave("utime", seconds);
|
||||
Core.settings.put("utime", seconds);
|
||||
Core.settings.put("turn", turn);
|
||||
Core.settings.put("turntime", turnCounter);
|
||||
Core.settings.save();
|
||||
}
|
||||
|
||||
private void load(){
|
||||
seconds = Core.settings.getLong("utime");
|
||||
turn = Core.settings.getInt("turn");
|
||||
turnCounter = Core.settings.getFloat("turntime");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user