/// <summary> /// 对星球增加士兵 /// </summary> /// <param name="_starID"></param> /// <param name="_buildingTime"></param> public void addSoldierToStar(uint _playerId, int _starID, int _soldierType, int _Energy, int _isSelfProduce, bool _isMoveAnimation = true) { UnitStar _star = GetUnitStarById(_starID); UnitSoldier _Soldier = _star.GetSoldierById(_playerId, _soldierType); if (_star.BelongTo != null && _star.BelongTo.ID == MogoWorld.thePlayer.ID && _starID == CurStarID) { EventDispatcher.TriggerEvent(Events.StarUIEvent.AddSoldierEvent);//发送我方当前星球添加兵力的消息 } if (_Soldier != null) { _Soldier.AddSoldier(_Energy, _isSelfProduce); _star.CulAllSoldierAttack(); if (_isMoveAnimation && (_Soldier.GetGatherSoldierNum() > 0)) { m_starDataManager.StarTogether(_star); } m_starDataManager.StarOrEndStartFighting(_star); return; } _Soldier = GetUnitSoldierFromPool(); SoldierIndex++; _Soldier.UnitId = SoldierIndex; _Soldier.BelongTo = MogoWorld.GetEntityById(_playerId); _Soldier.BaseSoldierData = SoldierData.dataMap.Get(_soldierType); Vector2 _pos = _star.GetSoliderPositionById(_soldierType); //LoggerHelper.Error("_pos.x:" + _pos.x + "_pos.y:" + _pos.y); _Soldier.PositionX = _pos.x; _Soldier.PositionY = _pos.y; _Soldier.UnitParent = SoldierLyaer; _Soldier.AddSoldier(_Energy, _isSelfProduce); _Soldier.BelongToStar = _star; _Soldier.IsMoveAnimation = _isMoveAnimation; _Soldier.InitUnit(); _Soldier.SetGroup(GetGroupByPalyerId(_playerId));//设置阵营信息 _star.AddSoldier(_playerId, _soldierType, _Soldier); _star.CulAllSoldierAttack(); m_starDataManager.StarOrEndStartFighting(_star); if (_isMoveAnimation && (_Soldier.GetGatherSoldierNum() > 0)) { m_starDataManager.StarTogether(_star); //_Soldier.CallBack = SoldierCallback; } IsAttackStar(_star); }
/// <summary> /// 士兵攻击星球 /// </summary> /// <param name="_starID"></param> /// <param name="_buildingTime"></param> public void ShowSoldierIntrusionStar(uint _playerId, int _starID, int _soldierType, int _Energy, float _PositionX, float _PositionY) { UnitStar _star = GetUnitStarById(_starID); UnitSoldier _Soldier = GetUnitSoldierFromPool(); SoldierIndex++; _Soldier.UnitId = SoldierIndex; _Soldier.BelongTo = MogoWorld.GetEntityById(_playerId); _Soldier.BaseSoldierData = SoldierData.dataMap.Get(_soldierType); _Soldier.PositionX = _PositionX; _Soldier.PositionY = _PositionY; _Soldier.UnitParent = SoldierLyaer; _Soldier.AddSoldier(_Energy, 1); _Soldier.BelongToStar = _star; _Soldier.IsMoveAnimation = false; _Soldier.IsShowSoldierIntrusionStar = true; _Soldier.InitUnit(); _Soldier.SetGroup(GetGroupByPalyerId(_playerId));//设置阵营信息 }