public void MoveOne(Transform target) { if (Data.Population >= 1) { Spawn(target, Data.Controller); Data.AddUnits(-1, false); } }
public void Harmonize() { float population = Data.Population; float rounded = Mathf.RoundToInt(population) - population; Data.AddUnits(rounded); }
// Unit enter in collision with tower. void OnTriggerEnter(Collider unit) { ActualizeController(); if (unit.gameObject.CompareTag("Unit")) { // Verify unit's player info unitData = unit.GetComponent <UnitData>(); if (unitData.Origin != location) { unitController = unitData.Controller; if (unitController == towerController) { Data.AddUnits(1); } else { // Combat Process unitControllerData = unitData.ControllerData; float attackerCombatPower = unitControllerData.CombatPower / towerControllerData.CombatPower; // TO DO : Add Zone Power float population = Data.Population; // If defender wins if (population >= attackerCombatPower) { Data.AddUnits(-attackerCombatPower); } // If attacker wins else { float leftover = attackerCombatPower - population; Data.AddUnits(-population); Hub.ChangeController(unitController); Data.AddUnits(leftover); } // Manage cooldown until harmonization Harmonizer.StartCountdown(); } Debug.Log("Appel des particules"); Particles.PlayAttaque(); Destroy(unit.gameObject); } } }
public void LevelUP() { if (isOperational) { int currentLevel = Data.Level; float cost = UpgradeCost[currentLevel]; if (currentLevel < 2 && Data.Population >= cost) { Data.AddUnits(-cost); isOperational = false; newLevel = currentLevel + 1; newType = Data.Type; Particles.PlayTinker(); } } }