public void Die() { // play death noise SoundManager.Get().PlaySoundEffect(SoundManager.SoundEffect.Death); // play death poof animation // If it's a castle, check to see they win if (TroopType == ArmyManager.Troop.Castle) { ArmyManager.Get().CastleDeath(this); } // if this is an enemy else if (!isFriendly) { Player.Get().AddCharisma(1, TroopType); } if (this is Player) { // TODO: Game over SceneManager.LoadScene("Loss", LoadSceneMode.Single); } // Inform the spawner we came from that we perished! if (gSpawner != null) { this.gSpawner.OnEntityDeath(this); } Destroy(this.gameObject); }
public void Attack() { canAttack = false; lastAttackTime = Time.time; Attack attack = GameObject.Instantiate(this.AttackPrefab, transform).GetComponent <Attack>(); attack.FriendlyAttack = this.isFriendly; attack.direction = this.isFriendly ? ArmyManager.Get().cursorDirection: direction; attack.facing = this.isFriendly ? ArmyManager.Get().cursorDirection : facing; }
public void AddCharisma(int amount, ArmyManager.Troop type) { gCharisma += amount; if (gCharisma >= Charisma) { // we have enough to recruit! gCharisma -= Charisma; ArmyManager.Get().AddUnit(type); Speak(RecruitMessages[Random.Range(0, RecruitMessages.Length)], 1.5f); } BarCharisma.SetPercent(gCharisma / Charisma); }