public override void SetCommand(BattleCommand cmd) { base.SetCommand(cmd); m_cmd = cmd as CmdFallBall; m_fallSpeed = GlobalData.m_ballFallSpeed; m_missionFinishNum = 0; for (int i = 0; i != m_cmd.BallIds.Count; ++i) { int ballId = m_cmd.BallIds[i]; if (m_balls.ContainsKey(ballId)) { m_balls.GetValue(ballId).GetComponent <Collider2D>().enabled = false; if (m_balls.GetBallType(ballId) == ELevelBallType.Crown) { ++m_missionFinishNum; } } } if (GameCore.Instance.MySide == 0) { m_fallSpeed = -m_fallSpeed; } m_timer = 0f; m_isOver = false; }
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); } }