コード例 #1
0
 public void RemoveArrivedSoldier(UnitSoldier _soldier)
 {
     if (MoveSoldierList.Contains(_soldier))
     {
         MoveSoldierList.Remove(_soldier);
         _soldier.ClearUnit();
     }
 }
コード例 #2
0
    /// <summary>
    /// 攻击士兵
    /// </summary>
    /// <param name="_starID"></param>
    /// <param name="_buildingTime"></param>
    public void AttackSoldier(uint _playerId, int _starID, int _soldierType, int _Energy, int _type)
    {
        /*LoggerHelper.Error("_playerId:" + _playerId + "_starID:" + _starID +
         *  "_soldierType:" + _soldierType + "_Energy:" + _Energy );*/
        if (_Energy < 0)
        {
            _Energy = 0;
        }
        UnitStar    _star    = GetUnitStarById(_starID);
        UnitSoldier _Soldier = _star.GetSoldierById(_playerId, _soldierType);

        if (_Soldier != null)
        {
            _Soldier.RemoveSoldier(_Energy);
            //LoggerHelper.Error(_Soldier.BaseSoldierData.energy + " CurEnergy:" + _Soldier.CurEnergy);
            if (_star.IsExplore && (_Energy >= _Soldier.BaseSoldierData.energy))
            {
                ShowFloatText(string.Concat(-(_Energy / _Soldier.BaseSoldierData.energy)), _Soldier.PositionX, _Soldier.PositionY, _Soldier.BaseSoldierData.float_color);
            }
            //LoggerHelper.Error("_playerId:" + _playerId + " _Energy" + (_Energy / _Soldier.BaseSoldierData.energy));
        }
        else
        {
            //LoggerHelper.Debug("没有该类士兵");
            return;
        }

        switch (_type)
        { //0建筑 1hit 2侵入
        case 0:
            _Soldier.OnIntrusion(_Energy);
            break;

        case 1:
            if (_Soldier.CurEnergy <= 0)
            {
                _Soldier.OnDead();
                _star.showAttackSoldierEffect(_playerId, _Soldier.UnitGO.transform.localPosition);
            }
            else
            {
                _Soldier.OnHit();
                _star.showAttackSoldierEffect(_playerId, _Soldier.UnitGO.transform.localPosition);
            }

            break;

        case 2:
            _Soldier.OnIntrusion(_Energy);
            break;
        }
        //type 类型士兵全军覆没
        if (_Soldier.CurEnergy <= 0)
        {
            _star.RemoveSoldier(_playerId, _soldierType);
            _Soldier.ClearUnit();

            IsAttackStar(_star);
        }
        _star.CulAllSoldierAttack();

        m_starDataManager.StarOrEndStartFighting(_star);
    }