Пример #1
0
        public override void Execute()
        {
            /*
             * bool flag = true, living = false;
             * int startx = (int)m_pCharacter.Position.x;
             * int endx = startx + ((int)m_pCharacter.m_pInfo.m_iFacing) * (m_pCharacter.m_pInfo.m_pInstructionData.be_attack_box_max_x - m_pCharacter.m_pInfo.m_pInstructionData.be_attack_box_min_x) / 2;
             * int nowx = startx;
             * int stepx = endx > nowx ? 1 : -1;
             * MapManager pMap = GameGOW.Get().MapMgr;
             * Vector2 p1 = Vector2.zero;
             * do
             * {
             *  Vector2 p = pMap.FindYLineNotEmptyPointUp(nowx, (int)m_pCharacter.Position.y + m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_y,
             *      (int)pMap.m_stBound.height);
             *  if (m_pCharacter.Position == p) flag = false;
             *  if (p != Vector2.zero) living = true;
             *  if (nowx == startx) p1 = p;
             *  nowx = nowx + stepx;
             * } while (nowx != endx);
             * if (flag)
             * {
             *  if (living)
             *  {
             *      BaseAction act = ObjectPools.CheckOut<CharacterFallingAction>(m_pCharacter, p1, true, false);
             *      m_pCharacter.Act(act);
             *  }
             *  else
             *  {
             *      p1 = new Vector2(startx, pMap.m_stBound.yMin);
             *      BaseAction act = ObjectPools.CheckOut<CharacterFallingAction>(m_pCharacter, p1, false, false);
             *      m_pCharacter.Act(act);
             *  }
             * }
             */

            int        tx   = (int)m_pCharacter.Position.x;
            MapManager pMap = GameGOW.Get().MapMgr;
            Vector2    p    = pMap.FindYLineNotEmptyPointUp_(tx, (int)m_pCharacter.Position.y + m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_y,
                                                             (int)pMap.m_stBound.height);

            // Debug.Log("xxxxxxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"+p.x+"-"+p.y+"-----"+GameGOW.Get().MapMgr.IsEmpty((int)p.x,(int)p.y)+" "+ GameGOW.Get().MapMgr.IsEmpty((int)p.x-3, (int)p.y)+"  "+ GameGOW.Get().MapMgr.IsEmpty((int)p.x+3, (int)p.y));
            //for(int i=0;i)
            //   p.x -= 3;

            if (m_pCharacter.Position != p)
            {
                if (p != Vector2.zero)
                {
                    BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, true, false);
                    m_pCharacter.Act(act);
                }
                else
                {
                    p = new Vector2(tx, pMap.m_stBound.yMin);
                    BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, false, false);
                    m_pCharacter.Act(act);
                }
            }

            _isFinished = true;
        }
Пример #2
0
        override public void Execute()
        {
            if (Network.NetworkMode == false)
            {
                if (m_pCharacter.m_pInfo.m_iDirectionKeys != 0 && //方向键已经按下
                    m_pCharacter.m_pInfo.m_iMoveEnergy > 0 &&     //还有移动能量
                    m_pCharacter.m_pInfo.m_bIsInRound
                    )
                {
                    Vector2 p = m_pCharacter.GetNextWalkPoint(m_pCharacter.m_pInfo.m_iFacing);
                    if (p != Vector2.zero)
                    {
                        --m_pCharacter.m_pInfo.m_iMoveEnergy;
                        m_pCharacter.Position = p;
                        m_pCharacter.Body.DoAction(CharacterStateType.WALK);
                        m_iCount++;
                        if (m_iCount >= SEND_MSG_COUNT)
                        {
                            SendAction();
                        }
                    }
                    else
                    {
                        SendAction();
                        Finish();
                        int tx = (int)m_pCharacter.Position.x + m_pCharacter.m_pInfo.m_iFacing * m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_x;
                        if (m_pCharacter.CanMoveDirection(m_pCharacter.m_pInfo.m_iFacing) && m_pCharacter.CanStand(tx, (int)m_pCharacter.Position.y) == false)
                        {
                            MapManager pMap = GameGOW.Get().MapMgr;
                            p = pMap.FindYLineNotEmptyPointUp(tx, (int)m_pCharacter.Position.y + m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_y,
                                                              (int)pMap.m_stBound.height);
                            if (p != Vector2.zero)
                            {
                                BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, true, false);
                                m_pCharacter.Act(act);
                            }
                            else
                            {
                                p = new Vector2(tx, pMap.m_stBound.yMin);


                                BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, false, false);
                                m_pCharacter.go_down = true;
                                m_pCharacter.Act(act);
                            }
                        }
                    }
                }
                else
                {
                    if (m_pCharacter.m_pInfo.m_iMoveEnergy <= 0)
                    {
                    }
                    SendAction();
                    Finish();
                }
            }
            else
            {
                if (m_pCharacter.m_pInfo.m_iDirectionKeys != 0 && //方向键已经按下
                    m_pCharacter.m_pInfo.m_iMoveEnergy > 0        //还有移动能量
                    )
                {
                    Vector2 p = m_pCharacter.GetNextWalkPoint(m_pCharacter.m_pInfo.m_iFacing);
                    if (p != Vector2.zero)
                    {
                        --m_pCharacter.m_pInfo.m_iMoveEnergy;
                        m_pCharacter.Position = p;
                        m_pCharacter.Body.DoAction(CharacterStateType.WALK);
                        m_iCount++;
                        if (m_iCount >= SEND_MSG_COUNT)
                        {
                            SendAction();
                        }
                    }
                    else if (Network.gamemode != BattleType.AI_1v1 || GameGOW.Get().BattleMgr.m_pCurrentPlayer.ID == Network.playerid)
                    {
                        SendAction();
                        Finish();
                        int tx = (int)m_pCharacter.Position.x + m_pCharacter.m_pInfo.m_iFacing * m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_x;
                        if (m_pCharacter.CanMoveDirection(m_pCharacter.m_pInfo.m_iFacing) && m_pCharacter.CanStand(tx, (int)m_pCharacter.Position.y) == false)
                        {
                            MapManager pMap = GameGOW.Get().MapMgr;
                            p = pMap.FindYLineNotEmptyPointUp(tx, (int)m_pCharacter.Position.y + m_pCharacter.m_pInfo.m_pInstructionData.walk_speed_y,
                                                              (int)pMap.m_stBound.height);
                            if (p != Vector2.zero)
                            {
                                BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, true, false);
                                m_pCharacter.Act(act);
                            }
                            else
                            {
                                p = new Vector2(tx, pMap.m_stBound.yMin);
                                BaseAction act = ObjectPools.CheckOut <CharacterFallingAction>(m_pCharacter, p, false, false);
                                m_pCharacter.go_down = true;
                                m_pCharacter.Act(act);
                            }
                        }
                    }
                }
                else
                {
                    if (m_pCharacter.m_pInfo.m_iMoveEnergy <= 0)
                    {
                    }
                    SendAction();
                    Finish();
                }
            }
        }