Exemplo n.º 1
0
        /// <summary>
        /// ゴールイベント
        /// </summary>
        /// <param name="position">ゴールした方のプレイヤー</param>
        public void Goal(PlayerConstant.Position position)
        {
            // Ball削除(オブザーバー解除してからオブジェクトを削除)
            RequestRemoveObserver(ballScript);
            Destroy(ball.gameObject);
            ballScript = null;
            ball       = null;

            if (position == PlayerConstant.Position.Left)
            {
                Debug.Log("GameTask(Goal) Left");
            }
            else
            {
                Debug.Log("GameTask(Goal) Right");
            }
            // スコアの加算
            score.Add(position);
            Debug.Log("score left  " + score.Get(PlayerConstant.Position.Left));
            Debug.Log("score right " + score.Get(PlayerConstant.Position.Right));
            // スコア更新通知
            scoreSubject.NotifyObservers(score);

            // ゲーム終了したか
            if (gameRule.CheckEnd(score))
            {
                // 文字列の設定
                if (gameRule.GetWinner(score) == PlayerConstant.Position.Left)
                {
                    SetResultLeftWin();
                }
                else
                {
                    SetResultRightWin();
                }

                // タッチしたままEndにいった
                if (touchAction.IsDragging() || touchAction.IsTouchStationary())
                {
                    isResultTouchPushing = true;
                }

                scene = Scene.Ended;
            }
            else
            {
                scene = Scene.GoalSeStart;
            }
        }