public void mine(float deltaTime) { if (planetScript.planetResource.count <= 0) { return; } partlyMined += deltaTime * minePerSecond * planetScript.planetResource.resource.miningTimeMultiplicator; if (partlyMined < 1) { return; } int mined = (int)partlyMined; partlyMined = partlyMined - mined; planetScript.planetResource.count -= mined; if (planetScript.planetResource.count <= 0) { planetScript.planetResource.count = 0; if (ownedBy == OwnedByPlayer.PLAYER_2) { ownedBy = OwnedByPlayer.DESTROYED; } } this.planetScript.resourcesMined(mined); }
public void conquer(OwnedByPlayer from, float deltaTime) { Debug.Log("Owned By: " + this.ownedBy); Debug.Log("Is Already beeing conquered: " + (currentlyBeeingConqueredBy != OwnedByPlayer.NO_ONE && currentlyBeeingConqueredBy != from)); Debug.Log("Times up? : " + (this.currentConquerTime >= this.secondsToConquer)); if ((this.ownedBy != OwnedByPlayer.DESTROYED || this.ownedBy != OwnedByPlayer.NO_ONE) && ( (currentlyBeeingConqueredBy != OwnedByPlayer.NO_ONE && currentlyBeeingConqueredBy != from) || this.currentConquerTime >= this.secondsToConquer)) { return; } this.currentlyBeeingConqueredBy = from; this.currentConquerTime += deltaTime; float conquerPercentage = this.currentConquerTime / this.secondsToConquer; Debug.Log("Current Conquering Time: " + this.currentConquerTime + "(" + conquerPercentage + "%)"); this.spriteIndex = (int)Math.Floor(this.conquerStagesPlayer1.Count * conquerPercentage); if (this.spriteIndex < this.conquerStagesPlayer1.Count) { this.GetComponent <SpriteRenderer>().sprite = this.conquerStagesPlayer1[spriteIndex]; } if (this.currentConquerTime >= this.secondsToConquer) { this.ownedBy = from; Debug.Log("Conquered by: " + from); this.GetComponent <SpriteRenderer>().sprite = this.inhabitedStages[0]; } }
public void abortConquering() { if (this.ownedBy != OwnedByPlayer.DESTROYED || this.ownedBy != OwnedByPlayer.NO_ONE) { return; } Debug.Log("Aborting Conquering"); this.currentConquerTime = 0; this.currentlyBeeingConqueredBy = OwnedByPlayer.NO_ONE; this.GetComponent <SpriteRenderer>().sprite = this.uninhibited; }