private void Start() { OnStart(); if (Snake != null) { Snake.InitBoard(this); Observable.EveryUpdate().Where(_ => IsPlay && !State.GameOver).Subscribe ( _ => { Timer += Time.deltaTime; } ).AddTo(this); Observable.EveryUpdate().Where(_ => Timer > BoardSpeed).Subscribe ( _ => { Timer = 0f; State.Next(Direction); Snake.MakeDecision(State); if (State.GameOver) { Snake.OnGameOver(); } else if (State.Win) { Snake.OnWin(); } else if (State.Eat) { Snake.OnEat(); Score.SetValueAndForceNotify(Score.Value + 1); } RenderState(); } ).AddTo(this); } else { Debug.LogWarning("Snake Controller is null."); } Score.SetValueAndForceNotify(0); SetStateObject(); RenderState(); IsPlay = true; }