//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // Called each frame. /// </summary> protected override void Update() { base.Update(); // Force the building to skip the deployable state and go straight to being active in the world if (_ObjectState == WorldObjectStates.Deployable) { _ObjectState = WorldObjectStates.Active; OnActiveState(); } // Update building queue if (_BuildingQueue != null) { if (_BuildingQueue.Count > 0) { // Check if current building is complete _BuildingQueue[0]._ObjectState = WorldObjectStates.Building; if (_BuildingQueue[0].GetCurrentBuildTimeRemaining() <= 0f) { // Remove from queue _BuildingQueue.RemoveAt(0); // Start building next item if (_BuildingQueue.Count > 0) { _BuildingQueue[0].StartBuildingObject(); } // Update building queue UI _BuildingQueueUI.UpdateQueueItemList(); } } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> // Called each frame. /// </summary> protected override void Update() { base.Update(); // Force the building to skip the deployable state and go straight to being active in the world if (_ObjectState == WorldObjectStates.Deployable) { _ObjectState = WorldObjectStates.Active; OnActiveState(); } // Update building queue if (_BuildingQueue != null) { if (_BuildingQueue.Count > 0) { // Check if current building is complete _BuildingQueue[0]._ObjectState = WorldObjectStates.Building; if (_BuildingQueue[0].GetCurrentBuildTimeRemaining() <= 0f) { // Play "on selectable built" particle effect if neccessary if (EffectPlayedOnBuiltSelectable != null) { // Assign internal effect & play _SelectableBuiltEffect = ObjectPooling.Spawn(EffectPlayedOnBuiltSelectable.gameObject, BuiltSelectableEffectPosition.position, transform.rotation).GetComponent <ParticleSystem>(); _SelectableBuiltEffect.Play(); // Despawn particle effect when it has finished its cycle ************************************************************************************************************* float duration = _SelectableBuiltEffect.duration + _SelectableBuiltEffect.startLifetime; StartCoroutine(ParticleDespawn(_SelectableBuiltEffect, duration)); } // Remove from queue _BuildingQueue.RemoveAt(0); // Start building next item if (_BuildingQueue.Count > 0) { _BuildingQueue[0].StartBuildingObject(AttachedBuildingSlot); _IsBuildingSomething = true; } else { _IsBuildingSomething = false; } // Update building queue UI _BuildingQueueUI.UpdateQueueItemList(); } // Currently building something else { _IsBuildingSomething = true; _BuildingStarted = false; // Play "on building selectable" particle effect if neccessary if (EffectPlayedWhenBuildingSelectable != null && _SelectableBuildingEffect == null) { // Assign internal effect & play _SelectableBuildingEffect = ObjectPooling.Spawn(EffectPlayedWhenBuildingSelectable.gameObject, BuiltSelectableEffectPosition.position, transform.rotation).GetComponent <ParticleSystem>(); _SelectableBuildingEffect.Play(); // Despawn particle effect when it has finished its cycle ************************************************************************************************************* float duration = _BuildingQueue[0].BuildingTime; StartCoroutine(ParticleDespawn(_SelectableBuildingEffect, duration)); } if (_SelectableBuildingEffect != null) { // Building particle is complete so null the reference (so next time its used - it repools a new instance) if (!_SelectableBuildingEffect.isPlaying) { _SelectableBuildingEffect = null; } } // Update radial wheel building queue item counters if (_BuildingQueueUI != null) { // Get selection wheel reference SelectionWheel selectionWheel = null; if (GameManager.Instance._IsRadialMenu) { selectionWheel = GameManager.Instance.SelectionWheel.GetComponentInChildren <SelectionWheel>(); } else { selectionWheel = GameManager.Instance.selectionWindow.GetComponentInChildren <SelectionWheel>(); } // Only update the selection wheel item counters if the UI widget is currently being displayed if (selectionWheel.gameObject.activeInHierarchy) { _BuildingQueueUI.UpdateSelectionWheelItemCounters(); selectionWheel.UpdateLogoSliders(_BuildingQueue[0]); } } } } else { _BuildingStarted = false; } } }