示例#1
0
        public static Entity NewGoalBlock(Vector3 positionValues, Texture2D texture)
        {
            Entity        player        = NewBlock(positionValues, texture, GOAL);
            GoalComponent goalComponent = new GoalComponent(player);

            ComponentManager.Instance.AddComponentToEntity(player, goalComponent);
            return(player);
        }
示例#2
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "Goal")
     {
         GoalComponent goal = collision.gameObject.GetComponent <GoalComponent>();
         this.pongCtrl.CollisionEnter(this, goal);
         Destroy(this.gameObject);
         this.pongCtrl.ballList.Remove(this);
     }
 }
示例#3
0
    /// <summary>
    /// 他オブジェクトに接触->ゴールオブジェクトの場合はゴール処理を実行
    /// </summary>
    /// <param name="other">Other.</param>
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Goal")
        {
            GoalComponent goal = other.gameObject.GetComponent <GoalComponent>();

            if (this.goalAction != null)
            {
                this.goalAction(this, goal);
            }
            Destroy(this.gameObject);
        }
    }
    /// <summary>
    /// ボールがゴールに衝突
    /// </summary>
    /// <param name="ball">Ball.</param>
    /// <param name="goal">Goal.</param>
    public void CollisionEnter(BallComponent ball, GoalComponent goal)
    {
        this.scoreMgr.AddScore(goal.playerId);
        this.UpdateScoreLabel();

        if (this.scoreMgr.isGameSet)
        {
            this.GameSet();
        }
        else
        {
            this.InitBall();
        }
    }
示例#5
0
        void HandleGoal(GoalEvent goalEvent)
        {
            GoalComponent goalComp = goalEvent.Goal.GetComponent <GoalComponent>();

            _owner.Engine.DestroyEntity(goalEvent.Ball);

            if (goalComp.For.Index == 0)
            {
                if (--player1Lives <= 0)
                {
                    EventManager.Instance.QueueEvent(new PlayerLostEvent(_owner.Player1, _owner.Player2));
                    return;
                }
            }
            if (goalComp.For.Index == 1)
            {
                if (--player2Lives <= 0)
                {
                    EventManager.Instance.QueueEvent(new PlayerLostEvent(_owner.Player2, _owner.Player1));
                    return;
                }
            }

            // Queue processes for next ball serve
            Process ballPlayProcess = new DelegateCommand(() =>
            {
                if (goalComp.For.Index == 0)
                {
                    PlayNewBall(_owner.Player1, true);
                }
                if (goalComp.For.Index == 1)
                {
                    PlayNewBall(_owner.Player2, true);
                }
            });

            // If there is a fluctuation, attach the serve to the fluctuation's end
            if (_fluctuationActive)
            {
                WaitForEvent fluctuationEnd = new WaitForEvent(typeof(FluctuationEndEvent));
                fluctuationEnd.SetNext(ballPlayProcess);
                _processManager.Attach(fluctuationEnd);
                return;
            }

            // Attach the serve
            _processManager.Attach(ballPlayProcess);
        }