/// <summary> /// Increments the repair progress every frame. /// </summary> /// <returns></returns> private IEnumerator IncrementRepairProgress() { #region Wait Each Frame while (true) { if (CheckMouseCollision() && hit.collider.tag == "BrokenArea") { BrokenArea effectedArea = hit.collider.gameObject.GetComponent <BrokenArea>(); float increment = effectedArea.GetRepairIncrement(); effectedArea.SetIsGettingFixed(Input.GetMouseButton(0)); effectedArea.SetIsGettingFixed(Input.GetMouseButton(0)); //Update textUI UIManager.Instance.SetAreaTextInfo(effectedArea.GetGeneralArea() + " (" + effectedArea.GetSeverity() + ")"); UIManager.Instance.SetProgressionInfo(effectedArea.GetRepairProgress(true)); if (Input.GetMouseButton(0)) { switch (effectedArea.GetIsInteractable()) { case false: if (effectedArea.GetSpawnerOrigin().severityState != SeverityState.IRREPARABLE) { effectedArea.GetSpawnerOrigin().SendAlert(1); } else { effectedArea.GetSpawnerOrigin().SendAlert(2); } break; case true: UpdateIsRepairing(Input.GetMouseButton(0)); effectedArea.IncrementRepairProgressValue(increment); effectedArea.GetSpawnerOrigin().SendAlert(reset); break; } } } else { UpdateIsRepairing(false); UIManager.Instance.SetAreaTextInfo("???"); UIManager.Instance.SetProgressionInfo((float)reset); } yield return(new WaitForEndOfFrame()); #endregion } }
/// <summary> /// If something got repair, pass in that value relative to the spawner. /// </summary> /// <param name="_index"></param> public void RemoveBrokenArea(int _index) { BrokenArea targetObj = brokenAreaInstances[_index]; //Destroy and remove object from list Message.Publish(new RepairCompleted()); brokenAreaInstances.Remove(targetObj); Destroy(targetObj.gameObject); UpdateBAID(); SendAlert(3); }