public void OnClick() { AnimalFactory animalFactory = new AnimalFactory(); AnimalVisitorType animalVisitorType = new AnimalVisitorType(); IOption<Animal> animal = animalFactory.Create(type); string typeName = animal.Visit(animalVisitorType).Substring(animal.Visit(animalVisitorType).IndexOf('.') + 1); game1.animalList.Add(animal); for (int i = 0; i < Enum.GetValues(typeof(Game1.Actions)).Length; i++) { new ActionButton( typeName + " " + game1.animalList.Count + ": " + (Game1.Actions)i, game1.mainButtonImage, game1.buttonLocator.getNewRectangle(), (Game1.Actions)i, game1, animal); } string res; //res = ("Error 02 (from CreateButton.OnClick(...)): Unfinished method. Please call Steve."); res = ("\nCompleted animal creation successfully. New animal type: " + type + "\nNew animal: " + animal.GetType()); //return res; Console.WriteLine(res); }
protected override void LoadContent() { //game content stuff mainFont = Content.Load<SpriteFont>("mainFont"); animalFactory = new AnimalFactory(); spriteBatch = new SpriteBatch(GraphicsDevice); for (int i = 0; i < Enum.GetValues(typeof(Animals)).Length; i++) { new CreateButton("Buy " + Enum.GetValues(typeof(Animals)).GetValue(i), mainButtonImage, buttonLocator.getNewRectangle(), (Animals)i, this); } }