/// <summary> /// Try to attack a player clone /// </summary> /// <param name="enemy"></param> /// <returns></returns> public IEnumerator EnemyAttack(PlayerUnit target) { yield return(new WaitForSeconds(animationInterval)); // If target is within attack range if (MapManager.sMapManager.GetManhattenDistance(GetComponent <MapObjectInfo>().currentOccupyingTile, target.GetComponent <MapObjectInfo>().currentOccupyingTile) <= attackRange) { target.health -= attackPower; // Decrease enemy health // If the player clone dead if (target.health <= 0) { target.CloneDie(); } } isInSomeMove = false; // Finish attack }
/// <summary> /// Upgrade one of the abilities for new player clones /// 1: move /// 2: hp /// 3: power /// 4: range /// </summary> public void UpgradeAbility() { if (upgradingAbility == 1) { playerUnitEvolvedMoveRange++; } if (upgradingAbility == 2) { playerUnitEvolvedMaxHealth++; } if (upgradingAbility == 3) { playerUnitEvolvedAttackPower++; } if (upgradingAbility == 4) { playerUnitEvolvedAttackRange++; } // Make the spent clone die cloneToSpend.CloneDie(); cloneToSpend = null; }