Ejemplo n.º 1
0
 public AIAgent(Game game, Node location, Graph graph, List<GoldMine> goldMines, Color renderColor)
     : base(game)
 {
     this.renderColor = renderColor;
     Base myBase = new Base((Game1)game, location, graph, this);
     game.Components.Add(myBase);
     units = new Units();
     buildings = new Buildings();
     buildings.GetBase = myBase;
     buildings.GetGoldMines = goldMines;
     goldText = new TextRepresentation(game, new Vector2(buildings.GetBase.Position.X, buildings.GetBase.Position.Y + 8));
     Game.Components.Add(goldText);
     this.goldMines = goldMines;
     foreach (GoldMine mine in goldMines)
     {
         if (Vector2.Distance(mine.Position, buildings.GetBase.Position) < distanceToNearestGoldMine)
         {
             distanceToNearestGoldMine = Vector2.Distance(mine.Position, buildings.GetBase.Position);
             buildings.NearestGoldMine = mine;
         }
     }
 }
Ejemplo n.º 2
0
        public AIAgent(Game game, Node location, Graph graph, List <GoldMine> goldMines, Color renderColor)
            : base(game)
        {
            this.renderColor = renderColor;
            Base myBase = new Base((Game1)game, location, graph, this);

            game.Components.Add(myBase);
            units                  = new Units();
            buildings              = new Buildings();
            buildings.GetBase      = myBase;
            buildings.GetGoldMines = goldMines;
            goldText               = new TextRepresentation(game, new Vector2(buildings.GetBase.Position.X, buildings.GetBase.Position.Y + 8));
            Game.Components.Add(goldText);
            this.goldMines = goldMines;
            foreach (GoldMine mine in goldMines)
            {
                if (Vector2.Distance(mine.Position, buildings.GetBase.Position) < distanceToNearestGoldMine)
                {
                    distanceToNearestGoldMine = Vector2.Distance(mine.Position, buildings.GetBase.Position);
                    buildings.NearestGoldMine = mine;
                }
            }
        }