Commit e98949e1 authored by 18김민수's avatar 18김민수

Ending game is almost done.

parent a7164a7d
......@@ -38,6 +38,9 @@ public class EndingGameManager : MonoBehaviour
TurnOnAndOffNextWaveButton();
}
private Coroutine _production;
private Coroutine _bar;
public bool isInWave = false;
public Transform unitPrefab;
......@@ -69,10 +72,14 @@ public class EndingGameManager : MonoBehaviour
food.text = "음식: " + game.town.remainFoodAmount;
iron.text = "철: " + game.town.totalIronAmount;
horse.text = "말: " + game.town.totalHorseAmount;
wave.text = (currentWaveNumber + 1) + "번째 공세";
_CheckProducibleUnits();
}
public void UpdateWaveNumber()
{
wave.text = (currentWaveNumber + 1) + "번째 공세";
}
private void _UpdateProductionQueue()
{
for (int i = 0; i < productionQueue.Count; i++)
......@@ -163,7 +170,7 @@ public class EndingGameManager : MonoBehaviour
isInWave = true;
TurnOnAndOffNextWaveButton();
StartCoroutine(_StartWave());
StartCoroutine(StartMakingUnits());
_production = StartCoroutine(StartMakingUnits());
}
private IEnumerator _StartWave()
......@@ -374,7 +381,7 @@ public class EndingGameManager : MonoBehaviour
string unitName = productionQueue.Dequeue();
_UpdateProductionQueue();
float productionTime = _GetProductionTime(unitName);
yield return StartCoroutine(_ProgressBarHandler(productionTime));
yield return (_bar = StartCoroutine(_ProgressBarHandler(productionTime)));
MakeAllyUnit(unitName);
}
}
......@@ -402,12 +409,15 @@ public class EndingGameManager : MonoBehaviour
knightButton.interactable = isInWave;
}
public void CleanUpAllyUnits()
public void CleanUp()
{
foreach (GameObject e in deployedAllyUnits)
Destroy(e);
while (deployedAllyUnits.Count == 0)
deployedEnemyUnits.Dequeue();
StopCoroutine(StartMakingUnits());
foreach (GameObject e in deployedAllyUnits) Destroy(e);
while (deployedAllyUnits.Count != 0) deployedAllyUnits.Dequeue();
while (productionQueue.Count != 0) productionQueue.Dequeue();
StopCoroutine(_production);
StopCoroutine(_bar);
progressBar.value = progressBar.minValue;
_UpdateProductionQueue();
UpdateWaveNumber();
}
}
......@@ -86,7 +86,7 @@ public abstract class EndingGameUnit : MonoBehaviour
{
EndingGameManager.instance.isInWave = false;
EndingGameManager.instance.TurnOnAndOffNextWaveButton();
EndingGameManager.instance.CleanUpAllyUnits();
EndingGameManager.instance.CleanUp();
}
}
......
......@@ -34,12 +34,19 @@ public class NKSoldier : EndingGameUnit
if (!isInBattleState && !isTooCloseFrontUnit)
transform.Translate(moveSpeed * Time.deltaTime, 0, 0);
if (endingGame.deployedAllyUnits.Count > 0)
if (endingGame.deployedAllyUnits.Peek().GetComponent<EndingGameUnit>().unitNumber == 8
if (endingGame.deployedAllyUnits.Peek()?.GetComponent<EndingGameUnit>().unitNumber == 8
&& !endingGame.deployedEnemyUnits.Any(u => u.GetComponent<EndingGameUnit>().unitNumber == 10))
{
endingGame.deployedEnemyUnits.Dequeue();
Destroy(gameObject);
if (endingGame.deployedEnemyUnits.Count == 0)
{
endingGame.isInWave = false;
endingGame.TurnOnAndOffNextWaveButton();
endingGame.CleanUp();
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment