Example #1
0
        public void execute(GameEvent gameEvent)
        {
            if (gameEvent.graphics == null)
            {
                return;
            }

            gameEvent.graphics.DrawImage(background, 0, 0, (float)gameEvent.model.mapWidth,
                                         (float)gameEvent.model.mapHeight);

            drawOutposts(gameEvent);

            List <General>      generals    = gameEvent.model.Generals;
            GeneralsDronesCache dronesCache = gameEvent.game.smallCache;

            foreach (General general in generals)
            {
                drawGeneral(gameEvent, general);
            }

            foreach (General general in generals)
            {
                drawDrone(gameEvent, general, dronesCache.getTeamCache(general.Team));
            }

            drawBeam(gameEvent);
        }
Example #2
0
        public void execute(GameEvent gameEvent)
        {
            QuantumModel        model        = gameEvent.model;
            GeneralsDronesCache dronesCached = gameEvent.game.largeCache;

            double maxFightDistance = 150;

            foreach (General general in model.Generals)
            {
                List <Team> enemyTeams = new List <Team>();

                int beamSizeLimit = 1000;

                foreach (General enemyGeneral in model.Generals)
                {
                    if (general.Team == enemyGeneral.Team)
                    {
                        continue;
                    }

                    enemyTeams.Add(enemyGeneral.Team);
                }

                foreach (Drone drone in general.Drones)
                {
                    Vector fightDistanceCorner = new Vector(maxFightDistance, maxFightDistance);

                    dronesCached.findDrones(enemyTeams, Vector.Subtract(drone.Position, fightDistanceCorner),
                                            Vector.Add(drone.Position, fightDistanceCorner),
                                            droneList => {
                        foreach (Drone enemyDrone in droneList)
                        {
                            if (Vector.Subtract(enemyDrone.Position, drone.Position).Length > maxFightDistance)
                            {
                                continue;
                            }

                            enemyDrone.Health--;

                            if (beamSizeLimit-- > 0)
                            {
                                model.Beams.Add(new Beam(drone.Position, enemyDrone.Position, general.Team));
                            }

                            break;
                        }
                    });
                }
            }


            foreach (General general in gameEvent.model.Generals)
            {
                general.Drones.RemoveAll(p => p.Health <= 0);
            }
        }