public void Defend(BaseUnit unit, bool isCustomMoveLegion = true)
        {
            if (unit == null)
            {
                return;
            }
            var castle = unit as TCastle;

            if (castle == null)
            {
                CLog.Error("Defend:castle == null)");
                return;
            }
            if (IsInDefend())
            {
                return;
            }
            if (!SelfUnit.IsSelf(castle))
            {
                return;
            }
            if (castle.CastleStationedMgr.IsHaveDefender())
            {
                return;
            }
            PreDefendCastle = DefendCastle;
            DefendCastle    = castle;
            castle.CastleStationedMgr.OnBeDefend(SelfUnit);
            OnDefend(castle, isCustomMoveLegion);
            Callback_OnDefendChanged?.Invoke(PreDefendCastle, DefendCastle);
        }
 public void TestLeaveSiege()
 {
     if (IsInSiege() && !SelfUnit.IsEnemy(SiegeCastle))
     {
         LeaveSiege(true);
     }
 }
        public void Siege(BaseUnit unit)
        {
            if (unit == null)
            {
                return;
            }
            var castle = unit as TCastle;

            if (castle == null)
            {
                CLog.Error("Siege:castle == null)");
                return;
            }
            if (IsInDefend())
            {
                return;
            }
            if (IsInSiege())
            {
                return;
            }
            if (!SelfUnit.IsEnemy(castle))
            {
                return;
            }
            PreSiegeCastle = SiegeCastle;
            SiegeCastle    = castle;
            castle.CastleStationedMgr.OnBeSiege(SelfUnit);
            OnSiege();
            Callback_OnSiegeChanged?.Invoke(PreSiegeCastle, SiegeCastle);
        }
        public void MoveoutLegion()
        {
            var inBlockerUnits = AStarMgr.GetBlockerUnits(SelfUnit, false);

            foreach (var item in inBlockerUnits)
            {
                if (SelfUnit.IsSelf(item))
                {
                    continue;
                }
                if (item is TLegion legion)
                {
                    legion.LegionStationedMgr.LeaveBlocker(SelfUnit);
                }
            }
            if (IsHaveDefender())
            {
                Defender.LegionStationedMgr.LeaveDefend(true);
            }
            if (IsInSiege())
            {
                Attackers.ForSafe(x =>
                {
                    x.LegionStationedMgr.LeaveSiege(true);
                });
            }
        }
示例#5
0
 protected bool IsLocalPlayer()
 {
     return(SelfUnit.IsPlayer());
 }