Exemplo n.º 1
0
        public static LivingUnit NearedTarget(Game game, World world, Wizard self)
        {
            StrategyStorage.nearedTargets.Clear();
            StrategyStorage.nearedTargets = ActiveUnits(world);

            LivingUnit player         = null;
            LivingUnit target         = null;
            double     playerDistance = double.MaxValue;
            double     minDistance    = double.MaxValue;

            foreach (var neardTarget in StrategyStorage.nearedTargets)
            {
                double distance = self.GetDistanceTo(neardTarget);

                if (neardTarget.Faction == StrategyStorage.badGuyFaction)
                {
                    if (neardTarget is Wizard && distance < self.CastRange && distance < playerDistance)
                    {
                        playerDistance = distance;
                        player         = neardTarget;
                    }

                    if (distance < minDistance)
                    {
                        minDistance = distance;
                        target      = neardTarget;
                    }
                }
            }

            return(player != null ? player : target);
        }
Exemplo n.º 2
0
        public static LivingUnit CollizedObject(Wizard self, World world)
        {
            StrategyStorage.nearedStaticObject.Clear();
            StrategyStorage.nearedStaticObject = ActiveUnits(world);
            StrategyStorage.nearedStaticObject.AddRange(world.Trees);

            LivingUnit collizedObject      = null;
            LivingUnit collizedTree        = null;
            double     minDistanceToTree   = double.MaxValue;
            double     minDistanceToObject = double.MaxValue;

            foreach (var neardTarget in StrategyStorage.nearedStaticObject)
            {
                double distance = self.GetDistanceTo(neardTarget) - neardTarget.Radius - self.Radius;
                if (neardTarget.Id != StrategyStorage.myId && distance < self.Radius)
                {
                    if (neardTarget is Tree && distance < minDistanceToTree)
                    {
                        minDistanceToTree = distance;
                        collizedTree      = neardTarget;
                    }
                    else if (distance < minDistanceToObject)
                    {
                        minDistanceToObject = distance;
                        collizedObject      = neardTarget;
                    }
                }
            }

            return(collizedTree != null ? collizedTree : collizedObject);
        }
Exemplo n.º 3
0
 public static void Tick(Game game, World world, Wizard self)
 {
     myId          = self.Id;
     prevLife      = self.Life;
     target        = null;
     currentSpeed  = 0;
     currentTurn   = 0;
     currentStrafe = 0;
     needRun       = false;
     StrategyStorage.collisionObject = null;
     StrategyStorage.target          = null;
 }
Exemplo n.º 4
0
 public static void Init(Game game, World world, Wizard self)
 {
     myId          = self.Id;
     waitTimer     = game.TickCount / TIMEOUTDELUMETER;
     safeDistance  = self.CastRange / DISTANCEDELUMETER;
     halfLife      = self.MaxLife / 2;
     visionRange   = self.VisionRange / 2;
     spawnPointX   = self.X;
     spawnPointY   = self.Y;
     mainBase      = StrategyHelper.MainBase(world, self);
     prevLife      = self.Life;
     positionTop   = self.Y < (world.Height / 2);
     badGuyFaction = self.Faction == Faction.Academy ? Faction.Renegades : Faction.Academy;
 }
Exemplo n.º 5
0
        public virtual void CheckNeedAttack(Game game, World world, Wizard self, Move move)
        {
            if (StrategyStorage.target != null)
            {
                double distance = self.GetDistanceTo(StrategyStorage.target);
                if (distance <= self.CastRange)
                {
                    double angle = self.GetAngleTo(StrategyStorage.target);
                    if (Math.Abs(angle) < (game.StaffSector / 2.0D))
                    {
                        if (distance < (game.StaffRange - StrategyStorage.target.Radius))
                        {
                            move.Action = ActionType.Staff;
                            StrategyHelper.Log("\tStaff attack");
                        }
                        else
                        {
                            LivingUnit blockUnit = StrategyHelper.CheckBlockAttack(world, self);
                            if (blockUnit != null)
                            {
                                StrategyStorage.currentStrafe = (Math.Round(self.GetAngleTo(blockUnit)) >= 0 ? -1 : 1) * game.WizardStrafeSpeed;
                            }
                            else
                            {
                                StrategyStorage.currentStrafe = (random.Next(2) > 0 ? 1 : -1) * game.WizardStrafeSpeed;
                            }

                            move.Action          = ActionType.MagicMissile;
                            move.CastAngle       = angle;
                            move.MinCastDistance = distance - StrategyStorage.target.Radius + game.MagicMissileRadius;
                            StrategyHelper.Log("\tMagic attack");
                        }
                    }
                }
            }
        }