示例#1
0
        public void execute(GameEvent gameEvent)
        {
            QuantumModel model   = gameEvent.model;
            General      general = model.FindGeneralByTeam(team);

            double angle = -10;

            if (gameEvent.isButtonPressed(upButton) && gameEvent.isButtonPressed(rightButton))
            {
                angle = -Math.PI / 4;
            }
            else if (gameEvent.isButtonPressed(downButton) && gameEvent.isButtonPressed(rightButton))
            {
                angle = Math.PI / 4;
            }
            else if (gameEvent.isButtonPressed(downButton) && gameEvent.isButtonPressed(leftButton))
            {
                angle = 3 * Math.PI / 4;
            }
            else if (gameEvent.isButtonPressed(leftButton) && gameEvent.isButtonPressed(upButton))
            {
                angle = -(3 * Math.PI / 4);
            }
            else if (gameEvent.isButtonPressed(upButton))
            {
                angle = -Math.PI / 2;
            }
            else if (gameEvent.isButtonPressed(rightButton))
            {
                angle = 0;
            }
            else if (gameEvent.isButtonPressed(downButton))
            {
                angle = Math.PI / 2;
            }
            else if (gameEvent.isButtonPressed(leftButton))
            {
                angle = -Math.PI;
            }

            if (angle != -10)
            {
                Vector newVelocity = new Vector(Math.Cos(angle) * gameEvent.model.speedConstant,
                                                Math.Sin(angle) * gameEvent.model.speedConstant);



                general.Velocity = Vector.Add(Vector.Multiply(0.75, general.Velocity),
                                              Vector.Multiply(0.25, newVelocity));
                general.PrevSpeed = general.Velocity;
            }
            else
            {
                general.Velocity = new Vector(0, 0);
            }


            general.Position = new Vector(general.Position.X + (general.Velocity.X * gameEvent.deltaTime),
                                          general.Position.Y + (general.Velocity.Y * gameEvent.deltaTime));
        }
示例#2
0
        public void execute(GameEvent gameEvent)
        {
            QuantumModel model          = gameEvent.model;
            double       cloudRadius    = model.cloudRadius;
            General      general        = model.FindGeneralByTeam(team);
            Vector       targetPosition = gameEvent.mousePosition;


            if (gameEvent.isButtonPressed(orderButton))
            {
                giveOrderToDrones(gameEvent, model, general, targetPosition, cloudRadius);
            }

            if (gameEvent.isButtonPressed(recruiteKey))
            {
                recruiteDrones(gameEvent, model, general, cloudRadius);
            }
        }
        public void execute(GameEvent gameEvent)
        {
            QuantumModel model = gameEvent.model;

            foreach (Outpost outpost in model.Outposts)
            {
                if (outpost.Team == Team.neutral)
                {
                    continue;
                }

                int newDronesToRespawn = (int)((gameEvent.deltaTime + outpost.respawnTimerAccumulator) / model.milsPerDronRespawn);
                outpost.respawnTimerAccumulator += gameEvent.deltaTime - newDronesToRespawn * model.milsPerDronRespawn;

                if (newDronesToRespawn == 0)
                {
                    continue;
                }

                General general = model.FindGeneralByTeam(outpost.Team);

                int currrentAmountDronesOnOutpost = countDronesOnOutpost(outpost, general, model.cloudRadius);

                if (currrentAmountDronesOnOutpost > model.maxRespawnAmount)
                {
                    continue;
                }

                int amountToRespawn = Math.Min(model.maxRespawnAmount - currrentAmountDronesOnOutpost, newDronesToRespawn);

                for (int i = 0; i < amountToRespawn; i++)
                {
                    Drone drone = new Drone();

                    drone.Order         = DroneOrder.MoveToOutpost;
                    drone.TargetOutpost = outpost.id;
                    drone.Position      = new Vector(outpost.Position.X + random.NextDouble(), outpost.Position.Y + random.NextDouble());
                    //drone.Position = new Vector(outpost.Position.X, outpost.Position.Y);

                    general.AddDrone(drone);
                }
            }
        }