diff --git a/Assets/Scripts/Games/ShootEmUp/Ship.cs b/Assets/Scripts/Games/ShootEmUp/Ship.cs index 02c7d3728..e8925b15e 100644 --- a/Assets/Scripts/Games/ShootEmUp/Ship.cs +++ b/Assets/Scripts/Games/ShootEmUp/Ship.cs @@ -13,6 +13,7 @@ namespace HeavenStudio.Games.Scripts_ShootEmUp public Animator damageAnim; public bool isDamage = false; + // int life = 24; public void Shoot() { @@ -22,6 +23,12 @@ namespace HeavenStudio.Games.Scripts_ShootEmUp public void Damage() { + // if (life > 0) { + // life = Mathf.Max(life - 8, 0); + // } else { + // // Gameover if you miss in next interval + // } + isDamage = true; shipAnim.Play("shipDamage", 0, 0); damageAnim.Play("damage", 0, 0); diff --git a/Assets/Scripts/Games/ShootEmUp/ShootEmUp.cs b/Assets/Scripts/Games/ShootEmUp/ShootEmUp.cs index 0045b55c2..a677e3c78 100644 --- a/Assets/Scripts/Games/ShootEmUp/ShootEmUp.cs +++ b/Assets/Scripts/Games/ShootEmUp/ShootEmUp.cs @@ -154,7 +154,7 @@ namespace HeavenStudio.Games { foreach (var crEvent in crHandlerInstance.queuedEvents) { - SpawnEnemy(crEvent.beat, crEvent.DynamicData["pos"], false, crHandlerInstance.intervalLength); + SpawnEnemy(crEvent.beat, crEvent.DynamicData["pos"], false, crHandlerInstance.intervalLength, true); } } } @@ -227,13 +227,15 @@ namespace HeavenStudio.Games } } - public void SpawnEnemy(double beat, Vector2 pos, bool active = true, float interval = 4f) + public void SpawnEnemy(double beat, Vector2 pos, bool active = true, float interval = 4f, bool awake = false) { - if (crHandlerInstance.queuedEvents.Count > 0 && crHandlerInstance.queuedEvents.Find(x => x.beat == beat || (beat >= x.beat && beat <= x.beat + x.length)) != null) return; - - crHandlerInstance.AddEvent(beat, crParams: new(){ - new CallAndResponseHandler.CallAndResponseEventParam("pos", pos), - }); + if (!awake) + { + if (crHandlerInstance.queuedEvents.Count > 0 && crHandlerInstance.queuedEvents.Find(x => x.beat == beat || (beat >= x.beat && beat <= x.beat + x.length)) != null) return; + crHandlerInstance.AddEvent(beat, crParams: new(){ + new CallAndResponseHandler.CallAndResponseEventParam("pos", pos), + }); + } var newEnemy = Instantiate(baseEnemy, enemyHolder).GetComponent(); spawnedEnemies.Add(newEnemy);