Exemplo n.º 1
0
 /// <summary>
 /// 勝ったプレイヤーの取得
 /// </summary>
 /// <param name="score">スコア</param>
 /// <returns>勝ったプレイヤー</returns>
 public Pong.PlayerConstant.Position GetWinner(Pong.PlayerScore score)
 {
     UnityEngine.Assertions.Assert.IsTrue(CheckEnd(score));
     if (score.Get(Pong.PlayerConstant.Position.Left) > score.Get(Pong.PlayerConstant.Position.Right))
     {
         return(PlayerConstant.Position.Left);
     }
     return(PlayerConstant.Position.Right);
 }
Exemplo n.º 2
0
 /// <summary>
 /// ゲームが終了したかチェック
 /// </summary>
 /// <param name="score">スコア</param>
 /// <returns>trueなら終了</returns>
 public bool CheckEnd(Pong.PlayerScore score)
 {
     if (score.Get(Pong.PlayerConstant.Position.Left) >= EndScore)
     {
         return(true);
     }
     if (score.Get(Pong.PlayerConstant.Position.Right) >= EndScore)
     {
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
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;
            }
        }