Beispiel #1
0
    public void StarBelong(uint _playerId, int _starId)
    {
        UnitStar _star = GetUnitStarById(_starId);

        _star.BelongTo = MogoWorld.GetEntityById(_playerId);
        _star.SetGroup(GetGroupByPalyerId(_playerId));//设置阵营信息
    }
Beispiel #2
0
    /// <summary>
    /// 显示攻击者 攻击建筑时的表示
    /// </summary>
    public void showAttackBuildingEffect(Vector3 _position)
    {
        EntityParent _gethitEntity = BelongTo;

        EntityParent _attackEntity;
        Dictionary <int, UnitSoldier> _dicSoldier;

        foreach (var _key in SoldierDic.Keys)
        {
            _attackEntity = MogoWorld.GetEntityById(_key);

            if (_attackEntity.TeamId == _gethitEntity.TeamId)//同阵营
            {
                continue;
            }

            _dicSoldier = SoldierDic[_key];
            foreach (var _soldierItem in _dicSoldier.Values)
            {
                if (_soldierItem.BaseSoldierData.attack_object.Contains(1))//可以攻击建筑
                {
                    _soldierItem.OnAttack(_position);
                }
            }
        }
    }
Beispiel #3
0
    /// <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);
    }
Beispiel #4
0
    /// <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));//设置阵营信息
    }
Beispiel #5
0
    /// <summary>
    /// 通过玩家id获得阵营信息
    /// </summary>
    /// <param name="playerId"></param>
    /// <returns></returns>
    public GroupData GetGroupByPalyerId(uint playerId)
    {
        //Debug.Log("playerId:" + playerId);

        EntityParent _entiy = MogoWorld.GetEntityById(playerId);

        if (_entiy == null)
        {
            return(null);
        }
        //LoggerHelper.Error("playerId:" + playerId + "TeamId:" + _entiy.TeamId);
        if (GroupDic.ContainsKey(_entiy.TeamId))
        {
            return(GroupDic[_entiy.TeamId]);
        }

        GroupDic[_entiy.TeamId] = GroupData.dataMap[(int)_entiy.TeamId + 1];//初始化阵营

        return(GroupDic[_entiy.TeamId]);
    }
Beispiel #6
0
    /// <summary>
    /// 摆阵
    /// </summary>
    public void ArrayedSoldier()
    {
        int _indexX   = 0;
        int _MyindexX = 0;
        int _indexY   = -3;
        Dictionary <int, UnitSoldier> dic;
        EntityParent _entity;

        foreach (var _soldiers in SoldierDic)
        {
            _entity = MogoWorld.GetEntityById(_soldiers.Key);

            dic = _soldiers.Value;
            if (_entity.TeamId == MogoWorld.thePlayer.TeamId)
            {
                _MyindexX++;
                _indexY = -3;
                foreach (var _soldierItem in dic.Values)
                {
                    var x = PositionX - 100 * _MyindexX;
                    var y = PositionY - _indexY * 30;
                    _soldierItem.Move(x, y, 0.1f);
                    //_soldierItem.OnAttack(new Vector3(x + 200, y, 0));
                    _indexY++;
                }
            }
            else
            {
                _indexX++;
                _indexY = -3;
                foreach (var _soldierItem in dic.Values)
                {
                    var x = PositionX + 100 * _indexX;
                    var y = PositionY - _indexY * 30;
                    _soldierItem.Move(x, y, 0.1f);
                    //_soldierItem.OnAttack(new Vector3(x - 200, y, 0));
                    _indexY++;
                }
            }
        }
    }
Beispiel #7
0
    /// <summary>
    /// 显示攻击者 攻击士兵时的表现
    /// </summary>
    public void showAttackSoldierEffect(uint gethitPlayer, Vector3 _position)
    {
        ///士兵
        EntityParent _gethitEntity = MogoWorld.GetEntityById(gethitPlayer);
        EntityParent _attackEntity;
        Dictionary <int, UnitSoldier> _dicSoldier;

        foreach (var _key in SoldierDic.Keys)
        {
            _attackEntity = MogoWorld.GetEntityById(_key);

            if (_attackEntity.TeamId == _gethitEntity.TeamId)//同阵营
            {
                continue;
            }

            _dicSoldier = SoldierDic[_key];
            foreach (var _soldierItem in _dicSoldier.Values)
            {
                if (_soldierItem.BaseSoldierData.attack_object.Contains(2))//可以攻击士兵
                {
                    _soldierItem.OnAttack(_position);
                }
            }
        }

        ///建筑
        if ((BelongTo != null) && (BelongTo.TeamId != _gethitEntity.TeamId))
        {
            foreach (var _buildingItem in BuildingDic.Values)
            {
                if (_buildingItem.BaseBuildingData.attack > 0)
                {
                    _buildingItem.OnAttack(_position);
                }
            }
        }
    }