Exemplo n.º 1
0
        /// <summary>
        /// Game Loop in Unit
        /// </summary>
        public override void Update()
        {
            // Observation

            bool globalAttack = TeamPlay && Team.ArchersAttack > 2 * Team.ArchersTarget.Life;

            SearchTargetNotFlying();

            bool canMove = !IsDead() && !DumpCantFly;

            // Affectations terrain

            double speed = 0;
            double range = 0;

            if (!DumpCantFly)
            {
                FieldEffects(Location, Target.Location, Speed, Range, out speed, out range);
            }

            // Action

            if (canMove)
            {
                if (InRange(range))
                {
                    SetMouvementZero();
                    if (_coolDown == 0)
                    {
                        BoulderAttack(48, Target);
                    }
                    else
                    {
                        _coolDown--;
                    }
                }
                else
                {
                    Mouvement = Vector.Move(speed, Direction);
                    Vector NewLocation = Vector.Add(Mouvement, Location);

                    if (!Arena.Collision(this, NewLocation, speed))
                    {
                        Location = NewLocation;
                    }
                }

                SpecialEffect();
            }
            else if (!IsDead())
            {
                SetMouvementZero();
                DumpFlyAway();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Game Loop in Unit
        /// </summary>
        public override void Update()
        {
            // Observation

            SearchTarget();

            bool canMove = !IsDead() && DumpCantFly == false;

            bool willBurn = new Random().NextDouble() < 0.5;

            // Affectations terrain

            double speed = 0;
            double range = 0;

            if (!DumpCantFly)
            {
                FieldEffects(Location, Target.Location, Speed, Range, out speed, out range);
            }

            // Action

            if (canMove)
            {
                if (InRange(range))
                {
                    SetMouvementZero();
                    if (willBurn)
                    {
                        Arena.GiveDamage(Target, Strength);
                    }
                    else
                    {
                        Arena.GiveFire(Target, 2);
                    }
                }
                else
                {
                    Mouvement = Vector.Move(speed, Direction);
                    Vector NewLocation = Vector.Add(Mouvement, Location);

                    if (!Arena.Collision(this, NewLocation, speed))
                    {
                        Location = NewLocation;
                    }
                }

                SpecialEffect();
            }
            else if (!IsDead())
            {
                SetMouvementZero();
                DumpFlyAway();
            }
        }
Exemplo n.º 3
0
        public bool MissObstacle(Vector vector, double speed, bool isOriginalXGood, bool isOriginalYGood)
        {
            bool DoesCollide = false;

            bool isXSmallest = Vector.Orientation(vector, Location);

            Vector NewLocation;

            if (isXSmallest)
            {
                if (isOriginalXGood)
                {
                    _location.X += 1;

                    NewLocation = Vector.Add(Vector.Move(speed, Direction), Location);

                    DoesCollide = Arena.Collision(this, NewLocation, speed, true, isOriginalYGood);

                    if (!DoesCollide)
                    {
                        Location = NewLocation;
                    }
                }
                else
                {
                    _location.X -= 1;

                    NewLocation = Vector.Add(Vector.Move(speed, Direction), Location);

                    DoesCollide = Arena.Collision(this, NewLocation, speed, true, isOriginalYGood);

                    if (!DoesCollide)
                    {
                        Location = NewLocation;
                    }
                }
            }
            else
            {
                if (isOriginalYGood)
                {
                    _location.X += 1;

                    NewLocation = Vector.Add(Vector.Move(speed, Direction), Location);

                    DoesCollide = Arena.Collision(this, NewLocation, speed, isOriginalXGood, true);

                    if (!DoesCollide)
                    {
                        Location = NewLocation;
                    }
                }
                else
                {
                    _location.X -= 1;

                    NewLocation = Vector.Add(Vector.Move(speed, Direction), Location);

                    DoesCollide = Arena.Collision(this, NewLocation, speed, isOriginalXGood, true);

                    if (!DoesCollide)
                    {
                        Location = NewLocation;
                    }
                }
            }

            return(DoesCollide);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Game Loop in Unit
        /// </summary>
        public override void Update()
        {
            // Observation

            bool globalAttack = TeamPlay && Team.GoblinsAttack > 2 * Team.GoblinsTarget.Life;

            Unit finalTarget = null;

            SearchTargetNotFlying();

            if (globalAttack)
            {
                finalTarget = Team.GoblinsTarget;
                NewDirection(finalTarget);
            }
            else
            {
                finalTarget = Target;
            }

            bool canMove = !IsDead() && DumpCantFly == false;

            bool runAway = finalTarget != null && finalTarget.Life > Life && Life < 5 && !GoblinsAlone();

            // Affectations terrain

            double speed = 0;
            double range = 0;

            if (!DumpCantFly)
            {
                FieldEffects(Location, finalTarget.Location, Speed, Range, out speed, out range);
            }

            // Action

            if (canMove)
            {
                if (runAway && !TeamPlay)
                {
                    Mouvement = Vector.MoveAndRunAway(Speed, Direction);
                    Vector NewLocation = Vector.Add(Mouvement, Location);
                    NewLocation.Limit(-Arena.Height, Arena.Height);

                    if (!Arena.Collision(this, NewLocation, speed))
                    {
                        Location = NewLocation;
                    }
                }
                else
                {
                    if (InRange(range))
                    {
                        SetMouvementZero();
                        Arena.GiveDamage(finalTarget, Strength);
                    }
                    else
                    {
                        Mouvement = Vector.Move(speed, Direction);
                        Vector NewLocation = Vector.Add(Mouvement, Location);

                        if (!Arena.Collision(this, NewLocation, speed))
                        {
                            Location = NewLocation;
                        }
                    }
                }

                SpecialEffect();
            }
            else if (!IsDead())
            {
                SetMouvementZero();
                DumpFlyAway();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Game Loop in Unit
        /// </summary>
        public override void Update()
        {
            // Observation

            SearchTargetNotFlying();

            bool canMove = !IsDead() && DumpCantFly == false;

            double currentLife = Life;

            bool coldDownDown = PastedLife - currentLife > 5 && ColdDown == 0;

            //Affectations terrain

            double speed = 0;
            double range = 0;

            if (!DumpCantFly)
            {
                FieldEffects(Location, Target.Location, Speed, Range, out speed, out range);
            }

            // Action

            if (canMove)
            {
                if (coldDownDown)
                {
                    BoostArmor();
                    _coldDown = 3;
                }
                if (InRange(range))
                {
                    SetMouvementZero();
                    Arena.GiveDamage(Target, Strength);
                }
                else
                {
                    Mouvement = Vector.Move(speed, Direction);
                    Vector NewLocation = Vector.Add(Mouvement, Location);

                    if (!Arena.Collision(this, NewLocation, speed))
                    {
                        Location = NewLocation;
                    }
                }

                SpecialEffect();
            }
            else if (!IsDead())
            {
                SetMouvementZero();
                DumpFlyAway();
            }
            if (ColdDown > 0)
            {
                _coldDown--;
                if (ColdDown == 2)
                {
                    UnboostArmor();
                }
            }
        }