Ejemplo n.º 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth = WINDOW_WIDTH;
            graphics.PreferredBackBufferHeight = WINDOW_HEIGHT;
            graphics.ApplyChanges();

            //Creates the graph
            graph = new Graph(WINDOW_WIDTH / graphSize, WINDOW_HEIGHT / graphSize);
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            agent = new AIAgent(this, graph.GetNode(new Vector2(0, 0)), graph, goldMines, Color.Blue);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(0, WINDOW_HEIGHT - 1)), graph, goldMines, Color.Green);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(WINDOW_WIDTH - 1, 0)), graph, goldMines, Color.White);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(WINDOW_WIDTH - 1, WINDOW_HEIGHT - 1)), graph, goldMines, Color.Red);
            agents.Add(agent);
            Components.Add(agent);

            GiveAgentsEnemies();

            IsMouseVisible = true;
            base.Initialize();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            graphics.PreferredBackBufferWidth  = WINDOW_WIDTH;
            graphics.PreferredBackBufferHeight = WINDOW_HEIGHT;
            graphics.ApplyChanges();

            //Creates the graph
            graph = new Graph(WINDOW_WIDTH / graphSize, WINDOW_HEIGHT / graphSize);
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            goldMines.Add(new GoldMine(this, graph.GetNode(new Vector2(random.Next(0 + graphSize * 3, WINDOW_WIDTH - graphSize * 3), random.Next(0 + graphSize * 3, WINDOW_HEIGHT - graphSize * 3))), graph, null));
            Components.Add(goldMines.Last());
            agent = new AIAgent(this, graph.GetNode(new Vector2(0, 0)), graph, goldMines, Color.Blue);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(0, WINDOW_HEIGHT - 1)), graph, goldMines, Color.Green);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(WINDOW_WIDTH - 1, 0)), graph, goldMines, Color.White);
            agents.Add(agent);
            Components.Add(agent);
            agent = new AIAgent(this, graph.GetNode(new Vector2(WINDOW_WIDTH - 1, WINDOW_HEIGHT - 1)), graph, goldMines, Color.Red);
            agents.Add(agent);
            Components.Add(agent);

            GiveAgentsEnemies();

            IsMouseVisible = true;
            base.Initialize();
        }