Exemplo n.º 1
0
        public Drone createDrone(QuantumModel model, General general, Vector position)
        {
            Drone drone = new Drone();

            drone.Position = position;

            drone.Order = DroneOrder.MoveToGeneral;

            general.AddDrone(drone);

            return(drone);
        }
        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);
                }
            }
        }