private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.CompareTag(_obstacleTag)) { GameLose?.Invoke(); } }
//IEnumerator MoveCorutine() //{ // while (true) // { // yield return new WaitForSeconds(_speed); // Move(); // if (curGameState == GameState.Immun) // _immunTime -= _speed; // //Debug.Log(immunTime); // if (_immunTime <= 0 && curGameState == GameState.Immun) // { // curGameState = GameState.Game; // } // } //} IEnumerator RemoveTail() { yield return(new WaitForSeconds(1.0f)); RemoveTailEvent?.Invoke(); while (_tail.Count != 0) { Destroy(_tail.Last().transform.gameObject); _tail.Remove(_tail.Last()); yield return(new WaitForSeconds(_realTailDestroyTime)); } if (curGameState == GameState.Win) { GameWin?.Invoke(); } else { GameLose?.Invoke(); } ResetGame(); }