using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; //Contact Katinka at ka.m.kalkman@gmail.com, if there are any questions //edited by: Luciano class MenuButton : SpriteGameObject { string button; public MenuButton(GameWorld gameWorld, string assetname, int layer, string id = "") : base(gameWorld, assetname, layer, id = "") { button = assetname; Reset(); } public override void Reset() { base.Reset(); switch (button) { case "Sprites/Single": position = new Vector2(280, 90); velocity = new Vector2(2, 0); position += GlobalPosition; break; case "Sprites/Host": position = new Vector2(280, 140 + sprite.Height); velocity = new Vector2(-3, 0); position += GlobalPosition; break; case "Sprites/Join": position = new Vector2(280, 190 + 2 * sprite.Height); velocity = new Vector2(1, 0); position += GlobalPosition; break; default: position = Vector2.Zero; break; } } public override void HandleInput(InputHelper inputHelper, GameWorld gameWorld) { if (inputHelper.MouseBoundingRectangle.Intersects(this.BoundingRectangle) && inputHelper.MouseLeftButtonPressed()) { GameModeHandler gmHandler = gameWorld.Find("gmHandler") as GameModeHandler; switch (button) { case "Sprites/Single": gmHandler.CurrentGameMode = GameModeHandler.GameMode.Single; Duck duck = gameWorld.Find("Duck") as Duck; duck.Reset2(gameWorld); Player player = gameWorld.Find("Cursor") as Player; player.Reset(); break; case "Sprites/Host": SpriteGameObject waiting = gameWorld.Find("waiting") as SpriteGameObject; if (waiting != null) waiting.Visible = true; gmHandler.CurrentGameMode = GameModeHandler.GameMode.Host; break; case "Sprites/Join": gmHandler.CurrentGameMode = GameModeHandler.GameMode.IP; break; default: gmHandler.CurrentGameMode = GameModeHandler.GameMode.Menu; break; } } } }