예제 #1
0
        /// <summary>
        /// Set everything required for a new round
        /// </summary>
        private void InitializeRound()
        {
            round++;

            // Clear lists
            projectiles.Clear();
            robots.Clear();
            //hud.Clear();
            hud.AddMessage("New Round: " + round, true);
            foreach (KeyValuePair <string, int> score in scoreKeeper.GetAllScores())
            {
                hud.AddMessage(String.Format("Team {0} has {1,3} Point{2}", score.Key, score.Value, score.Value != 1 ? "s" : ""));
            }

            // Get all game objects from manager
            Collection <GameObjectRobot> gameObjectRobots = Program.Tournament.RobotManager.CreateGameObjects(Program.Tournament);

            foreach (GameObjectRobot gorobot in gameObjectRobots)
            {
                // Set position to free map area
                map.PlaceRobot(gorobot);
                // Set round values after positioning the object so positions are correct for notification event
                gorobot.SetRoundValues(Program.Tournament.Rules);
                // create world object and load model
                WorldObjectRobot worldObject = new WorldObjectRobot(gorobot);
                worldObject.Load(Content);
                // Assign all event handler
                ((GameObjectRobot)worldObject.GameObject).HandleRobotEvents += RobotCore_HandleRobotEvents;
                worldObject.Update(0);
                // Add robot to the list
                robots.Add(worldObject);
            }

            // Place camera and select nothing
            cameraTargetIndex = -1;
            camera            = new Vector2(cameraScreen.X / 2 - (map.MapWidth + 1) / 2 * map.MapScale,
                                            cameraScreen.Y / 2 - (map.MapHeight + 1) / 2 * map.MapScale);

            if (round == 1)
            {
                hud.StatusMessage = String.Format("Ready...\n\nRound {0} of {1}", round, Program.Tournament.Rules.Rounds);
            }
            else
            {
                hud.StatusMessage = String.Format("{0}\n\nRound {1} of {2}", hud.StatusMessage, round, Program.Tournament.Rules.Rounds);
            }
        }