public void StartUpgrade() { Debug.Log("Start upgrade!"); if (CurrentUpgradeLevel + 1 >= GameController.PlanetTypes[CurrentType].UpgradeLevels.Length) { return; } int cost = GameController.PlanetTypes[CurrentType].UpgradeLevels[CurrentUpgradeLevel + 1].Cost; if (AvailablePopulation < cost) { return; } IsUpgrading = true; _upgradeTimer = 0; Population -= cost; OnPopulationChange?.Invoke(); //HideUpgradeMenu(); }
public void StartConversion(int newType) { int cost = GameController.PlanetTypes[newType].UpgradeLevels[0].Cost; if (AvailablePopulation < cost || CurrentType == newType) { return; } Debug.Log("Start conversion!"); IsUpgrading = true; IsConverting = true; _targetType = newType; _upgradeTimer = 0; Population -= cost; OnPopulationChange?.Invoke(); //HideUpgradeMenu(); }
//public void SetOneInfected() { // populationManager.SetNumberOfInfectedOnStart(1); //} //public void SetThreeInfected() { // populationManager.SetNumberOfInfectedOnStart(3); //} //public void SetFiveInfected() { // populationManager.SetNumberOfInfectedOnStart(5); //} public void IncreasePopulationCount(SubjectManager subjectManager) { populationScore++; onPopulationChange.Invoke(GetGameStats()); }
protected override void Update() { // Ship generation if (CurrentUpgrade.PopGenerationRate > 0 && Population < CurrentUpgrade.PopGenerationLimit) { _shipGenerationTimer += Time.DeltaTime; if (_shipGenerationTimer > CurrentUpgrade.PopGenerationRate) { Population++; _shipGenerationTimer = 0; OnPopulationChange?.Invoke(); } } // Fire if (CurrentUpgrade.FireRate > 0) { _fireTimer += Time.DeltaTime; if (_fireTimer > CurrentUpgrade.FireRate) { Shoot(); _fireTimer = 0; } } // Ship launch ProcessShipLaunch(); if (_underAttackTimer > 0.3f) { IsUnderAttack = false; } else { _underAttackTimer += Time.DeltaTime; } // Upgrade if (IsUpgrading && _upgradeTimer > 0) { if (IsConverting) { ChangePlanetType(_targetType); } else { UpgradePlanet(); } _upgradeTimer = 0; } else { _upgradeTimer += Time.DeltaTime; } // Animations if (!IsHovered) { _planetOutline.Transform.Rotation += Time.DeltaTime * 0.25f; } _rangeOutline.Transform.Rotation += Time.DeltaTime * 0.02f; /*_animator.SetBool("IsHovered", IsHovered); * _animator.SetBool("IsUnderAttack", IsUnderAttack); * _animator.SetBool("IsUpgrading", IsUpgrading);*/ }