예제 #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();
        }
예제 #2
0
 public Unit(Game game, Graph graph, AIAgent agent, Color renderColor)
     : base(game)
 {
     this.graph = graph;
     this.game = game;
     this.agent = agent;
     this.renderColor = renderColor;
     LoadContent();
 }
예제 #3
0
 public GoldMine(Game game, Node node, Graph graph, AIAgent agent)
     :base (game, node, graph, agent, Color.White)
 {
     spriteName = "goldMine";
     this.node = node;
     this.node.IsBlocked = true;
     this.Position = node.Position * Game1.graphSize;
     this.Position = new Vector2(Position.X + 16, Position.Y + 16);
     resourceRemaining = maxResource;
     goldText = new TextRepresentation(game, Position);
     game.Components.Add(goldText);
 }
예제 #4
0
 public Building(Game game, Node node, Graph graph, AIAgent agent, Color renderColor)
     : base(game)
 {
     this.graph = graph;
     this.renderColor = renderColor;
     this.game = game;
     Position = node.Position * Game1.graphSize;
     Position = new Vector2(Position.X + 16, Position.Y + 16);
     healthText = new TextRepresentation(game, new Vector2(Position.X, Position.Y - 8));
     game.Components.Add(healthText);
     LoadContent();
 }
예제 #5
0
 public Peon(Game game, Vector2 position, Graph graph, AIAgent agent)
     : base(game, graph, agent, agent.RenderColor)
 {
     spriteName = "peon";
     speed = 1f;
     maxSpeed = 1f;
     maxAccel = .07f;
     stopRadius = 2f;
     slowRadius = 5f;
     this.position = position;
     graph.SetNodeBlocked(position);
     goldText = new TextRepresentation(game, position);
     Game.Components.Add(goldText);
 }
예제 #6
0
 public Base(Game1 game, Node node, Graph graph, AIAgent agent)
     :base(game, node, graph, agent, agent.RenderColor)
 {
     buildingType = BuildingType.Base;
     spriteName = "base";
     this.agent = agent;
     this.node = node;
     isOperational = true;
     this.node.IsBlocked = true;
     this.Position = node.Position * Game1.graphSize;
     this.Position = new Vector2(Position.X + 16, Position.Y + 16);
     health = 1000;
     maxHealth = 1000;
 }
예제 #7
0
 public Barracks(Game game, Node node, Graph graph, AIAgent agent)
     :base (game, node, graph, agent, agent.RenderColor)
 {
     buildingType = BuildingType.Barracks;
     spriteName = "barracks";
     this.agent = agent;
     this.node = node;
     isOperational = false;
     this.node.IsBlocked = true;
     timeToCreate = 60000; //60 seconds
     maxHealth = 1500;
     health = 1;
     agent.GoldCount -= 500;
     agent.buildings.UnfinishedBuildings.Add(this);
 }
 public GoldRefinery(Game game, Node node, Graph graph, AIAgent agent)
     : base(game, node, graph, agent, agent.RenderColor)
 {
     buildingType = BuildingType.GoldRefinery;
     spriteName = "goldRefinery";
     this.agent = agent;
     this.node = node;
     this.node.IsBlocked = true;
     this.Position = node.Position * Game1.graphSize;
     this.Position = new Vector2(Position.X + 16, Position.Y + 16);
     agent.buildings.UnfinishedBuildings.Add(this);
     timeToCreate = 45000; //45 seconds
     maxHealth = 1000;
     health = 1;
     agent.GoldCount -= 400;
 }
예제 #9
0
 public Soldier(Game game, Vector2 position, Graph graph, AIAgent agent)
     : base(game, graph, agent, agent.RenderColor)
 {
     spriteName = "Marine";
     maxHealth = 100;
     health = maxHealth;
     speed = 1.5f;
     maxSpeed = 1.5f;
     maxAccel = .07f;
     stopRadius = 2f;
     slowRadius = 5f;
     this.position = position;
     graph.SetNodeBlocked(position);
     healthText = new TextRepresentation(game, position);
     game.Components.Add(healthText);
 }