Example #1
0
        protected override void AISearch(GameTime gameTime)
        {
            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
            {
                if (o != this && o.GetType().IsSubclassOf(typeof(UnitTurret)))
                {
                    float d = Vector2.Distance(getPosition(), o.getPosition());
                    if (d < BestDistance)
                    {
                        UnitTurret s = (UnitTurret)o;
                        if (s.GetTeam() == WaveManager.ActiveTeam && s.ShutDownTime < 1 && !s.Dead && !s.IsAlly(this) && s.Resistence != AttackType.Green)
                        {
                            if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), o.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }
        public override void Create()
        {
            base.Create();

            AddTag(GameObjectTag._2DOverDraw);

            this.Size.set(new Vector2(32));
            this.Position.set(ToPosition);

            NodeValue = PathFindingManager.GetCellValue(this.Position.get());

            bool Found = false;
            LinkedListNode <PathFindingNode> NextNode = AllNodes.First;

            if (AllNodes.Count > 0)
            {
                do
                {
                    if (NextNode.Value.NodeValue < NodeValue)
                    {
                        AllNodes.AddBefore(NextNode, this);
                        Found = true;
                        break;
                    }

                    NextNode = NextNode.Next;
                }while (NextNode != null);
            }

            if (!Found)
            {
                AllNodes.AddLast(this);
            }
        }
        protected override void AISearch(GameTime gameTime)
        {
            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
            {
                if (o != this)
                {
                    float d = Vector2.Distance(getPosition(), o.getPosition());
                    if (d < BestDistance && o.GetType().IsSubclassOf(typeof(BasicShipGameObject)) && !o.GetType().Equals(typeof(PlayerShip)))
                    {
                        BasicShipGameObject s = (BasicShipGameObject)o;
                        if (s.GetTeam() == WaveManager.ActiveTeam && !s.Dead && !s.IsAlly(this) && s.CanBeTargeted())
                        {
                            if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }
        protected virtual void AISearch(GameTime gameTime)
        {
            AngerTime -= gameTime.ElapsedGameTime.Milliseconds;
            if (AngerTime > 0 && CurrentAttackTarget != null && CurrentAttackTarget.CanBeTargeted())
            {
                return;
            }

            CurrentAttackTarget = null;
            float BestDistance = 1000000;

            StarshipScene scene = (StarshipScene)Parent2DScene;

            if (GetTeam() != WaveManager.ActiveTeam)
            {
                foreach (Basic2DObject o in FactionManager.SortedUnits[WaveManager.ActiveTeam])
                {
                    if (o != this)
                    {
                        float d = Vector2.Distance(Position.get(), o.getPosition());
                        if (d < BestDistance && o.GetType().IsSubclassOf(typeof(UnitBasic)))
                        {
                            UnitBasic s = (UnitBasic)o;
                            if (s.GetTeam() == WaveManager.ActiveTeam && s.CanBeTargeted())
                            {
                                if (d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                                {
                                    BestDistance        = d / s.ThreatLevel;
                                    CurrentAttackTarget = s;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (Basic2DObject o in Parent2DScene.GetList(GameObjectTag._2DSolid))
                {
                    if (o != this && o.GetType().IsSubclassOf(typeof(UnitBasic)) && !o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                    {
                        float d = Vector2.Distance(Position.get(), o.getPosition());

                        if (d < BestDistance)
                        {
                            UnitBasic s = (UnitBasic)o;
                            if (!IsAlly(s) && s.CanBeTargeted() &&
                                d / s.ThreatLevel < BestDistance && !PathFindingManager.CollisionLine(Position.get(), s.Position.get()))
                            {
                                BestDistance        = d / s.ThreatLevel;
                                CurrentAttackTarget = s;
                            }
                        }
                    }
                }
            }
        }
        public PathFindingNode Get()
        {
            if (PathFindingManager.GetCellValue(Position.get()) != PathFindingManager.StartingCell)
            {
                if (NextNode == null)
                {
                    NextNode = new PathFindingNode(PathFindingManager.TraceCellPoint(Position.get(), 8));
                    GameManager.GetLevel().AddObject(NextNode);
                }
            }

            return(this);
        }
Example #6
0
        public PathfindingFlare(PathFindingManager Parent, int CellX, int CellY, int CellXOffset, int CellYOffset, Color LineColor)
        {
            this.Parent    = Parent;
            this.CellX     = CellX;
            this.CellY     = CellY;
            this.LineColor = LineColor;

            Vector2 Position2 = Parent.WorldPosition(CellX, CellY);

            From      = new Vector3(Position2.X, 0, Position2.Y);
            Position2 = Parent.WorldPosition(CellXOffset + CellX, CellYOffset + CellY);
            To        = new Vector3(Position2.X, 0, Position2.Y);
        }
        public override void Damage(float damage, float pushTime, Vector2 pushSpeed, BasicShipGameObject Damager, AttackType attackType)
        {
            if ((InvTime < 1 && (FieldStateTime < 1 || fieldState != FieldState.Cloaked)) || attackType == AttackType.Explosion || attackType == AttackType.Melee)
            {
                if (CanCloak)
                {
                    SoundManager.Play3DSound("UnitCloak", new Vector3(Position.X(), Y, Position.Y()), 0.25f, 800, 2);

                    fieldState     = FieldState.Cloaked;
                    HasCloaked     = true;
                    CanCloak       = false;
                    FieldStateTime = GetCloakTime();
                }
                else
                {
                    if (attackType != AttackType.White)
                    {
                        SummonUnits();
                    }

                    NoShootTime = MaxNoShootTime;
                    if (attackType == AttackType.White)
                    {
                        ThreatLevel *= 1.5f;
                    }

                    if (!PathFindingManager.CollisionLine(Position.get(), Damager.Position.get()))
                    {
                        AngerTime           = MaxAngerTime;
                        CurrentAttackTarget = Damager;
                    }

                    base.Damage(damage, pushTime, pushSpeed, Damager, attackType);

                    if (HullDamage >= HullToughness && Damager.FactionNumber != NeutralManager.NeutralFaction && ScoreToGive > 0)
                    {
                        if (CanDeathSound)
                        {
                            SoundManager.Play3DSound(DeathSound, new Vector3(Position.X(), Y, Position.Y()), DeathVolume * 0.5f, DeathDistance, DeathExponenent * 2);
                        }

                        ScoreToGive = (int)(ScoreToGive * (0.75f + 0.25f * UnitLevel) * (IsHuge ? 1.25f : 1) *
                                            (HasCloaked || CanCloak ? 1.5f : 1) * (CanSummon || HasSummoned ? 4 : 1));
                        TextParticleSystem.AddParticle(new Vector3(Position.X(), Y, Position.Y()), ScoreToGive.ToString(), (byte)Damager.GetTeam());
                        FactionManager.AddScore(Damager.FactionNumber, ScoreToGive);
                        FactionManager.Factions[Damager.FactionNumber].roundReport.UnitKills++;
                        ScoreToGive = 0;
                    }
                }
            }
        }
        public static PathFindingNode GetBestNode(Vector2 Position)
        {
            foreach (PathFindingNode node in AllNodes)
            {
                if (!PathFindingManager.CollisionLine(Position, node.Position.get()))
                {
                    return(node.Get());
                }
            }

            PathFindingNode Node = new PathFindingNode(Position);

            GameManager.GetLevel().AddObject(Node);
            return(Node.Get());
        }
        public override void Destroy()
        {
            if (SoundInstance != null && !SoundInstance.IsDisposed)
            {
                SoundInstance.Dispose();
                SoundInstance = null;
            }

            if (UnitCommited)
            {
                UnitCommited = false;
                FactionManager.RemoveUnit(this);
            }

            base.Destroy();

            Dead = true;
            PathFindingManager.Rebuild();
        }
        protected virtual PlayerShip AISearchForPlayers()
        {
            PlayerShip ReturnPlayer = null;
            float      BestDistance = 1000000;

            QuadGrid grid = Parent2DScene.quadGrids.First.Value;

            foreach (Basic2DObject o in grid.Enumerate(getPosition(), new Vector2(BestDistance) * 2))
            {
                if (o.GetType().IsSubclassOf(typeof(PlayerShip)))
                {
                    PlayerShip s = (PlayerShip)o;
                    if (s.GetTeam() == WaveManager.ActiveTeam && !s.Dead && !PathFindingManager.CollisionLine(Position.get(), o.Position.get()))
                    {
                        ReturnPlayer = s;
                    }
                }
            }

            return(ReturnPlayer);
        }
Example #11
0
        public static Vector2 GetSpawnPosition()
        {
            int Counter = 0;

            while (true)
            {
                if (CurrentNode == null)
                {
                    CurrentNode = SpawnList.First;
                }
                else
                {
                    CurrentNode = CurrentNode.Next;
                }

                Counter++;
                if (Counter > 100)
                {
                    break;
                }
                else if (CurrentNode != null &&
                         (PathFindingManager.GetCellValue(CurrentNode.Value.Position.get()) > PathFindingManager.StartingCell - 50 &&
                          PathFindingManager.GetCellValue(CurrentNode.Value.Position.get()) < PathFindingManager.StartingCell - 20) &&
                         PathFindingManager.GetAreaClear(CurrentNode.Value.Position.get()))
                {
                    break;
                }
            }

            if (CurrentNode != null)
            {
                Vector2 p = CurrentNode.Value.Position.get() + CurrentNode.Value.Offset;
                CurrentNode.Value.UpdateOffset(new Vector2(32));
                return(p);
            }
            else
            {
                return(Vector2.Zero);
            }
        }
        public override void Interact(PlayerShip p)
        {
            if (miningPlatform == null && FactionManager.CanBuildMiningPlatform(p.FactionNumber))
            {
                Vector3 P3 = new Vector3(Position.X(), 0, Position.Y());
                for (int i = 0; i < 40; i++)
                {
                    LineParticleSystem.AddParticle(P3, P3 + Rand.V3() * 1000, TeamInfo.GetColor(p.GetTeam()));
                }

                MiningPlatform m = FactionManager.GetMiningPlatform(p.FactionNumber);
                ParentLevel.AddObject(m);
                m.Position.set(Position.get());
                setPlatform(m);

                SoundManager.Play3DSound("PlayerBuildMiningRing",
                                         new Vector3(m.Position.X(), Y, m.Position.Y()), 0.25f, 500, 1);

                if (p.PlacedStartingMineralRock)
                {
                    FactionManager.AddCells(p.FactionNumber, -FactionManager.GetMiningPlatformCost(p.FactionNumber));
                    FactionManager.SetBuildingPlatform(p.FactionNumber, m);
                }
                else
                {
                    FactionManager.GetFaction(p.FactionNumber).MiningPlatformCounter = 0;
                    m.HullToughness *= 2;
                    m.SetAsStarting();
                    p.PlacedStartingMineralRock = true;
                    p.StartingMineralRock       = this;
                }

                p.LastPlacedPlatform.AddFirst(m);
                PathFindingManager.AddMineralRock(m);
            }
            base.Interact(p);
        }
        public virtual Vector2 GetPlacePosition(int FactionNumber)
        {
            float   BestScore    = -500000;
            Vector2 BestPosition = Vector2.Zero;

            float Distance = 1000;
            float JumpSize = 100;

            Vector2 MinPos = new Vector2(10000);
            Vector2 MaxPos = new Vector2(-10000);

            foreach (MiningPlatform m in GameManager.GetLevel().getCurrentScene().Enumerate(typeof(MiningPlatform)))
            {
                if (m.GetTeam() == FactionManager.GetTeam(FactionNumber) && !m.Dead)
                {
                    MinPos = Vector2.Min(MinPos, m.Position.get() - new Vector2(Distance));
                    MaxPos = Vector2.Max(MaxPos, m.Position.get() + new Vector2(Distance));
                }
            }

            Basic2DScene b = (Basic2DScene)GameManager.GetLevel().getCurrentScene();

            MinPos = Vector2.Max(MinPos, b.MinBoundary.get());
            MaxPos = Vector2.Min(MaxPos, b.MaxBoundary.get());

            for (float x = MinPos.X; x < MaxPos.X; x += JumpSize)
            {
                for (float y = MinPos.Y; y < MaxPos.Y; y += JumpSize)
                {
                    if (TestFree(new Vector2(x, y), TurretSize, FactionNumber) &&
                        PathFindingManager.GetCellValue(new Vector2(x, y)) != PathFindingManager.DeadCell)
                    {
                        float score = 5000;

                        if (GetTurretFragility() != 0)
                        {
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, 0, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, 0, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 0, 1, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 0, -1, 3))
                            {
                                score += 100 * GetTurretFragility();
                            }

                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, -1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, -1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), -1, 1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                            if (PathFindingManager.CollisionLine(new Vector2(x, y), 1, 1, 2))
                            {
                                score += 100 * GetTurretFragility();
                            }
                        }

                        foreach (NeutralSpawn spawn in NeutralManager.SpawnList)
                        {
                            if (PathFindingManager.GetCellValue(spawn.Position.get()) > PathFindingManager.StartingCell - 50 &&
                                PathFindingManager.GetCellValue(spawn.Position.get()) < PathFindingManager.StartingCell - 20 &&
                                PathFindingManager.GetAreaClear(spawn.Position.get()))
                            {
                                if (GetTurretFragility() != 0 && PathFindingManager.CollisionLine(new Vector2(x, y), spawn.Position.get()))
                                {
                                    score += 500 * GetTurretFragility();
                                }

                                if (score > BestScore)
                                {
                                    MiningPlatform NearestMiningPlatform = null;
                                    float          NearestDistance       = 10000;

                                    foreach (MiningPlatform m2 in GameManager.GetLevel().getCurrentScene().Enumerate(typeof(MiningPlatform)))
                                    {
                                        if (m2.GetTeam() == FactionManager.GetTeam(FactionNumber) && !m2.Dead)
                                        {
                                            float d = Vector2.Distance(m2.Position.get(), spawn.Position.get());
                                            if (d < NearestDistance)
                                            {
                                                NearestDistance       = d;
                                                NearestMiningPlatform = m2;
                                            }
                                        }
                                    }

                                    score -= Logic.DistanceLineSegmentToPoint(spawn.Position.get(),
                                                                              NearestMiningPlatform.Position.get(), new Vector2(x, y)) * GetTurretAgression();
                                }
                            }
                        }

                        if (score > BestScore)
                        {
                            Basic2DScene Parent2DScene = (Basic2DScene)GameManager.GetLevel().getCurrentScene();
                            QuadGrid     quad          = Parent2DScene.quadGrids.First.Value;

                            foreach (Basic2DObject o in quad.Enumerate(new Vector2(x, y), new Vector2(200)))
                            {
                                if (o.GetType().IsSubclassOf(typeof(UnitBuilding)))
                                {
                                    UnitBuilding s = (UnitBuilding)o;
                                    if (s.GetTeam() == FactionManager.GetTeam(FactionNumber))
                                    {
                                        float d = Vector2.Distance(o.Position.get(), new Vector2(x, y));
                                        if (d < 2000)
                                        {
                                            score -= (2000 - d) * GetBuildingAvoidence();
                                            if (s.GetType().IsSubclassOf(typeof(MiningPlatform)))
                                            {
                                                score -= (2000 - d) * GetBaseAvoidence();
                                            }
                                            else if (s.GetType().IsSubclassOf(typeof(UnitTurret)))
                                            {
                                                UnitTurret t = (UnitTurret)s;
                                                if (t.MyCard != null)
                                                {
                                                    if (t.MyCard.StrongVs.Equals(StrongVs))
                                                    {
                                                        score -= (2000 - d) * GetTurretAvoidence();
                                                    }
                                                }
                                                else
                                                {
                                                    if (StrongVs.Equals("Heavy"))
                                                    {
                                                        score -= (2000 - d) * GetTurretAvoidence();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            if (score > BestScore)
                            {
                                BestScore    = score;
                                BestPosition = new Vector2(x, y);
                            }
                        }
                    }
                }
            }

            return(BestPosition);
        }
Example #14
0
        public void buildAttackGrid()
        {
            if (AttackGrid == null)
            {
                AttackGrid = new int[CellsX.get(), CellsY.get()];
            }

            AttackJobQue.Clear();

            for (int x = 0; x < CellsX.get(); x++)
            {
                for (int y = 0; y < CellsY.get(); y++)
                {
                    AttackGrid[x, y] = NeutralCell;
                }
            }

            MiningPlatform forwardPlatform = PathFindingManager.TraceToMiningPlatform(NeutralManager.GetSpawnPosition(),
                                                                                      WaveManager.ActiveTeam);

            foreach (MiningPlatform r in Parent2DScene.Enumerate(typeof(MiningPlatform)))
            {
                if (!r.Dead && r.GetTeam() == WaveManager.ActiveTeam)
                {
                    Vector2 UpperLeftCorner  = (r.getUpperLeftCorner() - Parent2DScene.MinBoundary.get()) / Divisor;
                    Vector2 LowerRightCorner = (r.getLowerRightCorner() - Parent2DScene.MinBoundary.get()) / Divisor;

                    int MinX = (int)UpperLeftCorner.X;
                    int MinY = (int)UpperLeftCorner.Y;
                    int MaxX = (int)LowerRightCorner.X;
                    int MaxY = (int)LowerRightCorner.Y;

                    for (int x = MinX; x < MaxX; x++)
                    {
                        for (int y = MinY; y < MaxY; y++)
                        {
                            AttackJobQue.Enqueue(x);
                            AttackJobQue.Enqueue(y);
                            AttackJobQue.Enqueue(r == forwardPlatform && WaveManager.CurrentWave > 5 ? StartingCell / 2 : StartingCell);
                        }
                    }
                }
            }

            foreach (UnitTurret u in Parent2DScene.Enumerate(typeof(UnitTurret)))
            {
                if (!u.Dead && u.GetTeam() == WaveManager.ActiveTeam &&
                    ((u.MyCard == null && !NeutralManager.MyPattern.CurrentCard.Type.Equals("Heavy")) ||
                     (u.MyCard != null && !u.MyCard.StrongVs.Equals(NeutralManager.MyPattern.CurrentCard.Type))))
                {
                    Vector2 UpperLeftCorner  = (u.getUpperLeftCorner() - Parent2DScene.MinBoundary.get()) / Divisor;
                    Vector2 LowerRightCorner = (u.getLowerRightCorner() - Parent2DScene.MinBoundary.get()) / Divisor;

                    int MinX = (int)UpperLeftCorner.X;
                    int MinY = (int)UpperLeftCorner.Y;
                    int MaxX = (int)LowerRightCorner.X;
                    int MaxY = (int)LowerRightCorner.Y;

                    for (int x = MinX; x < MaxX; x++)
                    {
                        for (int y = MinY; y < MaxY; y++)
                        {
                            AttackJobQue.Enqueue(x);
                            AttackJobQue.Enqueue(y);
                            AttackJobQue.Enqueue(StartingCell);
                        }
                    }
                }
            }
        }
Example #15
0
 public PathFindingManager()
 {
     self = this;
 }
        private void AIMove(GameTime gameTime)
        {
            MoveChangeTime += gameTime.ElapsedGameTime.Milliseconds;
            if (MoveChangeTime > MaxMoveChangeTime)
            {
                MoveChangeTime -= MaxMoveChangeTime;

                TargetPosition = Position.get();

                if (!DodgesBullets || BulletToDodge == null || BulletToDodge.TimeAlive > BulletToDodge.LifeTime)
                {
                    if (BulletToDodge != null)
                    {
                        BulletToDodge = null;
                    }

                    if (CurrentAttackTarget != null)
                    {
                        float d = Vector2.Distance(CurrentAttackTarget.getPosition(), getPosition());

                        if (!RunningAway)
                        {
                            if (d > MinEngagementDistance)
                            {
                                TargetPosition = CurrentAttackTarget.getPosition();
                            }
                            else if (d < MinEngagementDistance)
                            {
                                TargetPosition = Position.get();
                            }
                        }
                        else
                        {
                            TargetPosition = Position.get() + (Position.get() - CurrentAttackTarget.getPosition());
                        }

                        DisplacedFromPath = true;
                    }
                    else
                    {
                        if (TargetNode == null)
                        {
                            TargetNode        = PathFindingNode.GetBestNode(Position.get());
                            DisplacedFromPath = false;
                        }
                        else
                        {
                            DisplaceTime += gameTime.ElapsedGameTime.Milliseconds;
                            if (DisplaceTime > MaxDisplaceTime)
                            {
                                DisplaceTime     -= MaxDisplaceTime;
                                DisplacedFromPath = true;
                            }

                            if (DisplacedFromPath)
                            {
                                if (PathFindingManager.CollisionLine(Position.get(), TargetNode.Position.get()))
                                {
                                    TargetNode = PathFindingNode.GetBestNode(Position.get());
                                }
                                DisplacedFromPath = false;
                            }
                        }

                        TargetPosition = TargetNode.Position.get();

                        if (TargetNode.GetNext() != null && !PathFindingManager.CollisionLine(Position.get(), TargetNode.GetNext().Position.get()) ||
                            (Vector2.Distance(getPosition(), TargetPosition) < 16))
                        {
                            TargetNode = TargetNode.GetNext();
                        }
                    }
                }
                else
                {
                    Vector2 bPos = BulletToDodge.getPosition();
                    bPos += BulletToDodge.Speed / BulletToDodge.Speed.Length() * Vector2.Distance(bPos, Position.get());

                    TargetPosition = (Position.get() - (bPos - Position.get()));

                    BulletDodgeTime -= gameTime.ElapsedGameTime.Milliseconds;

                    if (BulletDodgeTime < 0)
                    {
                        TargetPosition = CurrentMoveTarget == null ? TargetPosition : CurrentMoveTarget.getPosition();
                        BulletToDodge  = null;
                    }

                    DisplacedFromPath = true;
                }
            }

            if (Vector2.Distance(getPosition(), TargetPosition) > 16)
            {
                Accelerate(gameTime, TargetPosition - getPosition());
            }
            else if (CurrentAttackTarget != null)
            {
                Rotation.set(MathHelper.ToDegrees(Logic.Clerp(Rotation.getAsRadians(), Logic.ToAngle(CurrentAttackTarget.Position.get() - Position.get()), RotationSpeed * gameTime.ElapsedGameTime.Milliseconds * 60.0f / 1000.0f)));
                RotationMatrix = Matrix.CreateFromYawPitchRoll(Rotation.getAsRadians() + RotationOffset.X, RotationOffset.Y, RotationOffset.Z);
            }
        }
        public override void Update2(GameTime gameTime)
        {
            base.Update2(gameTime);
            Position.set(Vector2.Clamp(Position.get(), Parent2DScene.MinBoundary.get(), Parent2DScene.MaxBoundary.get()));

            if (CrystalWall.SortedWalls.ContainsKey(WaveManager.ActiveTeam))
            {
                foreach (CrystalWall n in CrystalWall.SortedWalls[WaveManager.ActiveTeam])
                {
                    if (!n.Dead)
                    {
                        foreach (CrystalWallConnection n2 in n.ConnectedWalls)
                        {
                            if (!n2.wall.Dead)
                            {
                                float MoveAmount = (Size.X() + n.getSize().X * 0.75f) / 2 - Logic.DistanceLineSegmentToPoint(n.Position.get(), n2.wall.Position.get(), Position.get());

                                if (MoveAmount > 0)
                                {
                                    Vector2 MoveVector;

                                    if (!n2.LineIsVertical)
                                    {
                                        if (n2.LineSlope == 0)
                                        {
                                            MoveVector = new Vector2(0, -1);
                                            if (Position.Y() > n2.LineSlope * Position.X() + n2.LineIntercept)
                                            {
                                                MoveAmount = -MoveAmount;
                                            }
                                        }
                                        else
                                        {
                                            MoveVector = new Vector2(1, -1 / n2.LineSlope);
                                            if (!(Position.Y() > n2.LineSlope * Position.X() + n2.LineIntercept ^ n2.LineSlope > 0))
                                            {
                                                MoveAmount = -MoveAmount;
                                            }
                                        }

                                        MoveVector.Normalize();
                                    }
                                    else
                                    {
                                        MoveVector = new Vector2(Position.X() > n.Position.X() ? 1 : -1, 0);
                                    }

                                    Position.set(Position.get() + MoveVector * MoveAmount);


                                    float d1 = Vector2.Distance(Position.get(), n.Position.get());
                                    float d2 = 0;
                                    if (!PathFindingManager.CollisionLine(Position.get(), n.Position.get()))
                                    {
                                        Vector2.Distance(Position.get(), n2.wall.Position.get());
                                    }

                                    CurrentAttackTarget = d1 > d2 ? n : n2.wall;
                                    AngerTime           = MaxAngerTime;
                                }
                            }
                        }
                    }
                }
            }
        }