public IEnumerator Update() { Snake.Initialize(); Pellet.Update(); IsOver = false; while (!IsOver) { var cell = Snake.GetNextCell(); if (cell.IsActive() && Pellet.Cell != cell) { EndGame(false); } else { Snake.AddHead(cell); if (Pellet.Cell == cell) { UpdatePelletScore(); } else { Snake.RemoveTail(); } } yield return(new WaitForSeconds(TimeSkipPerFrame)); } }
private void UpdatePelletScore() { if (Score >= MaxScore) { EndGame(true); } else { Pellet.Update(); UpdateScoreSignal.Dispatch(++Score); } }