Exemple #1
0
        public override void SetCommand(BattleCommand cmd)
        {
            base.SetCommand(cmd);
            m_cmd = cmd as CmdEraseBall;

            m_isOver = false;
        }
Exemple #2
0
        public void HandleFireBall(CmdFireBall cmd)
        {
            ServerBubble bubble = new ServerBubble(NewBubbleId, (ELevelBallType)cmd.BallType, new List <GridPosition>()
            {
                cmd.DestGrid
            });

            // 碰撞检测Here

            ResetVisitFlag();
            List <ServerBubble> eraseBubbles = new List <ServerBubble>();

            TryEraseBubble(bubble, bubble.Type, eraseBubbles);
            if (eraseBubbles.Count > 2)
            {
                // Send CmdFireBallResponse
                CmdFireBallResponse response = new CmdFireBallResponse(cmd.Side, (int)cmd.Type, cmd.StartPosition, cmd.Dir, cmd.CollisionPoint, cmd.DestGrid, bubble.Id, m_bubbleSpeed, 0);
                BattleServer.Instance.SendResponse(response);

                List <int> eraseIds = new List <int>();
                for (int i = 0; i < eraseBubbles.Count; i++)
                {
                    eraseIds.Add(eraseBubbles[i].Id);
                    RemoveBubble(eraseBubbles[i]);
                }

                // Send CmdEraseBall
                CmdEraseBall command = new CmdEraseBall(cmd.Side, 0, eraseIds, bubble.Id);
                BattleServer.Instance.SendResponse(command);

                ResetVisitFlag();

                List <ServerBubble> rootBubbles = GetRootBubbles();
                for (int i = 0; i < rootBubbles.Count; i++)
                {
                    VisitBubble(rootBubbles[i]);
                }

                List <ServerBubble> fallenBubbles = new List <ServerBubble>();
                for (int i = 0; i < m_bubbleDic.Count; i++)
                {
                    if (m_bubbleDic[i].isVisited == false)
                    {
                        fallenBubbles.Add(m_bubbleDic[i]);
                    }
                }

                if (fallenBubbles.Count > 0)
                {
                    List <int> fallenIds = new List <int>();
                    for (int i = 0; i < fallenBubbles.Count; i++)
                    {
                        fallenIds.Add(fallenBubbles[i].Id);
                        RemoveBubble(fallenBubbles[i]);
                    }

                    // Send CmdFallBall
                    CmdFallBall command1 = new CmdFallBall(cmd.Side, 0, eraseIds, bubble.Id);
                    BattleServer.Instance.SendResponse(command1);
                }
            }
            else
            {
                AddBubble(bubble);
                CmdFireBallResponse response = new CmdFireBallResponse(cmd.Side, (int)cmd.Type, cmd.StartPosition, cmd.Dir, cmd.CollisionPoint, cmd.DestGrid, bubble.Id, m_bubbleSpeed, 1);
                BattleServer.Instance.SendResponse(response);
            }
        }