Exemple #1
0
 /// <summary>
 /// ゴールを通知する
 /// </summary>
 /// <param name="position"></param>
 public void NotifyObservers(PlayerConstant.Position position)
 {
     foreach (var observer in observers)
     {
         observer.Goal(position);
     }
     ExecuteRequestRemove();
 }
Exemple #2
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;
            }
        }
 /// <summary>
 /// 遅い反応が発生したか
 /// </summary>
 /// <param name="position">プレイヤーの場所</param>
 /// <param name="ballX">ボールの位置</param>
 /// <returns>trueなら遅い反応が発生した</returns>
 private bool IsSlowReflection(PlayerConstant.Position position, float ballX)
 {
     // CPUは相手に打たれてすぐ動かない
     if ((position == PlayerConstant.Position.Right) &&
         (ballX < -SlowReflectionPositionX))
     {
         return(true);
     }
     if ((position == PlayerConstant.Position.Left) &&
         (ballX > SlowReflectionPositionX))
     {
         return(true);
     }
     return(false);
 }