示例#1
0
        public virtual void CheckCollision(Game game, World world, Wizard self, Move move)
        {
            if (StrategyStorage.collisionObject != null)
            {
                /* Если мы "воткнулись", но не можем разрушить, пытаемся обойти */
                if (StrategyStorage.collisionObject is Tree)
                {
                    if (self.GetDistanceTo(StrategyStorage.collisionObject) < (game.StaffRange - StrategyStorage.collisionObject.Radius))
                    {
                        move.Action = ActionType.Staff;
                    }
                    else
                    {
                        move.Action    = ActionType.MagicMissile;
                        move.CastAngle = self.GetAngleTo(StrategyStorage.collisionObject);
                    }

                    StrategyHelper.Log("\tCollise with tree");
                }
                else if (StrategyStorage.collisionObject is Building)
                {
                    double angle = Math.Round(self.GetAngleTo(StrategyStorage.collisionObject));
                    StrategyStorage.currentStrafe = (angle >= 0 ? -1 : 1) * game.WizardStrafeSpeed;
                    StrategyHelper.Log("\tCollise with build");
                }
                else
                {
                    double angle = Math.Round(self.GetAngleTo(StrategyStorage.collisionObject));
                    StrategyStorage.currentStrafe = (angle >= 0 ? -1 : 1) * game.WizardStrafeSpeed;
                    //StrategyStorage.currentTurn = (random.Next(2) > 0 ? 2 : -1) * self.GetAngleTo(StrategyStorage.collisionObject);
                    StrategyHelper.Log("\tCollise with other unit");
                }
            }
        }
示例#2
0
        public static IStrategyState GetState(World world, Wizard self)
        {
            /* Основная логика игры */
            StrategyStates strategyState = StrategyStates.Game;

            if (self.Life == 0)
            {
                /* Жизней 0 - мертв */
                strategyState = StrategyStates.None;
            }
            else if (StrategyStorage.prepareTick < StrategyStorage.waitTimer)
            {
                strategyState = StrategyStates.Prepare;
            }
            else if (StrategyStorage.prevLife == 0 && self.Life > 0)
            {
                StrategyHelper.Log(String.Format("RESPAWN, tick {0}", world.TickIndex));
                int enemyCount = StrategyHelper.CountEnemyInCastRange(world, self);

                StrategyStorage.priorityLane = null;
                strategyState = enemyCount == 0 ? StrategyStates.Prepare : StrategyStates.Game;

                StrategyHelper.Log(String.Format("\tEnemyCount: {0}, work strategy: {1}", Enum.GetName(typeof(StrategyStates), strategyState)));
            }

            StrategyHelper.Log(String.Format("strategy {0}, tick: {1}", Enum.GetName(typeof(StrategyStates), strategyState).ToUpper(), world.TickIndex));

            return(StrategyStateManager.strategyStates[strategyState]);
        }
示例#3
0
        public override void Run(Game game, World world, Wizard self, Move move)
        {
            StrategyStorage.prepareTick++;

            if (StrategyStorage.priorityLane == null)
            {
                switch (random.Next(3))
                {
                case 0:
                    StrategyStorage.waitTimer    = game.TickCount / 15;
                    StrategyStorage.priorityLane = LaneType.Bottom;
                    break;

                case 1:
                    StrategyStorage.waitTimer    = game.TickCount / 30;
                    StrategyStorage.priorityLane = LaneType.Middle;
                    break;

                case 2:
                default:
                    StrategyStorage.waitTimer    = game.TickCount / 15;
                    StrategyStorage.priorityLane = LaneType.Top;
                    break;
                }

                // TODO: Пока ходим только по миду
                //StrategyStorage.priorityLane = LaneType.Middle;

                StrategyHelper.Log(String.Format("\tChosen line: {0}", StrategyStorage.priorityLane));
            }
            else
            {
                if (StrategyStorage.priorityLane == LaneType.Bottom)
                {
                    StrategyStorage.currentTurn = self.GetAngleTo(StrategyStorage.positionTop ? 0 : world.Width, self.Y);
                }
                else if (StrategyStorage.priorityLane == LaneType.Middle)
                {
                    StrategyStorage.currentTurn = self.GetAngleTo(StrategyStorage.mainBase.Y, StrategyStorage.mainBase.X);
                }
                else if (StrategyStorage.priorityLane == LaneType.Top)
                {
                    StrategyStorage.currentTurn = self.GetAngleTo(self.X, StrategyStorage.positionTop ? world.Height : 0);
                }
            }

            this.InitSpeed(game, world, self, move, 0.7);
            this.CheckCollision(game, world, self, move);
        }
示例#4
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");
                        }
                    }
                }
            }
        }