Esempio n. 1
0
 public void MoveToNextStar()
 {
     if ((m_iCurMoveStep + 1) < m_listMovePath.PassedStars.Count)
     {
         UnitStar _startStar = m_listMovePath.PassedStars[m_iCurMoveStep];
         UnitStar _endStar   = m_listMovePath.PassedStars[m_iCurMoveStep + 1];
         float    distace    = Vector2.Distance(new Vector2(_startStar.PositionX, _startStar.PositionY), new Vector2(_endStar.PositionX, _endStar.PositionY));
         m_fMoveTime = distace / BaseSoldierData.move;
         Move(_endStar.PositionX, _endStar.PositionY, m_fMoveTime - 0.01f);
         if (BelongTo.ID != MogoWorld.thePlayer.ID)
         {
             ShowUnit(_endStar.IsExplore);
         }
     }
     else
     {
         if (BelongTo.ID == MogoWorld.thePlayer.ID)
         {
             MogoWorld.thePlayer.RpcCall("AddSoldier", BelongTo.ID, m_listMovePath.PassedStars[m_iCurMoveStep].UnitId, BaseSoldierData.id, CurEnergy, 0);
         }
         m_fMoveTime    = 1000;
         m_listMovePath = null;
         ClearUnit();
         MogoWorld.m_dataMapManager.RemoveArrivedSoldier(this);
     }
 }
Esempio n. 2
0
    /// <param name="playerId">玩家id</param>
    /// <param name="startStarId">出发星球</param>
    /// <param name="endStarId">目标星球</param>
    /// <param name="isSelfProduce">1表示只出战自产兵,0表示全部出战</param>
    /// <param name="soldierTypeList">出战兵种id列表</param>
    /// <param name="percent">出战兵种数量百分比,0表示只出战一个</param>
    public void SendSoldier(LuaTable lt)
    {
        uint        _playerId           = Convert.ToUInt32(lt["0"]);
        UnitStar    _StartStar          = GetUnitStarById(Convert.ToInt32(lt["1"]));
        UnitStar    _endStar            = GetUnitStarById(Convert.ToInt32(lt["2"]));
        int         isSelfProduce       = Convert.ToInt32(lt["3"]);
        LuaTable    soldierTypeluatable = lt["4"] as LuaTable;
        float       percent             = (float)Convert.ToDouble(lt["5"]);
        int         _soldierType        = 0;
        UnitSoldier _soldier;

        MapUtil.RoutePlanResult _result = MapUtil.Plan(_StartStar, _endStar);
        for (int i = 0; i < soldierTypeluatable.Count; i++)
        {
            _soldierType = Convert.ToInt32(soldierTypeluatable[i.ToString()]);

            _soldier = _StartStar.GetSoldierById(_playerId, _soldierType);

            if (_soldier == null)
            {
                continue;
            }

            if (isSelfProduce == 1 && _soldier.SelfProduceEnergy <= 0)
            {
                continue;
            }

            _soldier = _StartStar.RemoveSoldier(_playerId, _soldierType);

            int _moveOrdinaryEnergy;
            int _OrdinaryEnergy = _soldier.CurEnergy - _soldier.SelfProduceEnergy;
            if (isSelfProduce == 0)//移动全部士兵
            {
                _moveOrdinaryEnergy = (int)(_OrdinaryEnergy * percent);
            }
            else
            {//移动自产士兵
                _moveOrdinaryEnergy = 0;
            }
            int _moveSelfProduceEnergy = (int)(_soldier.SelfProduceEnergy * percent);

            /*if (_soldier.BaseSoldierData.id == 1)
             * {
             *  LoggerHelper.Error("_moveSelfProduceEnergy:" + _moveSelfProduceEnergy + " percent:" + percent + " _soldier.SelfProduceEnergy:" + _soldier.SelfProduceEnergy);
             * }*/
            int _leftOrinaryEnergy     = _OrdinaryEnergy - _moveOrdinaryEnergy;
            int _leftSelfProduceEnergy = _soldier.SelfProduceEnergy - _moveSelfProduceEnergy;
            _soldier.RemoveSoldier(_leftOrinaryEnergy, false);
            _soldier.RemoveSoldier(_leftSelfProduceEnergy);
            if (_leftOrinaryEnergy > 0)
            {
                addSoldierToStar(_playerId, _StartStar.UnitId, _soldierType, _leftOrinaryEnergy, 0, false);
            }
            if (_leftSelfProduceEnergy > 0)
            {
                addSoldierToStar(_playerId, _StartStar.UnitId, _soldierType, _leftSelfProduceEnergy, 1, false);
            }

            if (_soldier != null)
            {
                _soldier.MovePath = _result;
                MoveSoldierList.Add(_soldier);
            }
        }
    }