public static void LoadListFromFile(string filename, Game1 game) { objectList = LevelLoader.Load(filename, game); objectWithinZoneList = new List<IGameObject>(); currentGame = game; currentGame.gameState.StateBackgroundTheme(); }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { using (Game1 game = new Game1()) { game.Run(); } }
public override void Init(Game1 game) { Color = Color.White; var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.Black); //Simply subscribe to the events demonstrated below _gui = new Gui(game, skin, text); _gui.CharEntered += CharEntered; _gui.KeyDown += KeyDown; _gui.KeyUp += KeyUp; _gui.MouseDoubleClick += MouseDoubleClick; _gui.MouseDown += MouseDown; _gui.MouseHover += MouseHover; _gui.MouseUp += MouseUp; _gui.MouseWheel += MouseWheel; _gui.AddWidget(_hasMouse = new Label(100, 10 + 30 * 0, "Test1")); _gui.AddWidget(_charEntered = new Label(100, 10 + 30 * 1, "Test2")); _gui.AddWidget(_keyDown = new Label(100, 10 + 30 * 2, "Test3")); _gui.AddWidget(_keyUp = new Label(100, 10 + 30 * 3, "Test3")); _gui.AddWidget(_doubleClick = new Label(100, 10 + 30 * 4, "Test4")); _gui.AddWidget(_mouseDown = new Label(100, 10 + 30 * 5, "Test5")); _gui.AddWidget(_mouseHover = new Label(100, 10 + 30 * 6, "Test6")); _gui.AddWidget(_mouseUp = new Label(100, 10 + 30 * 7, "Test7")); _gui.AddWidget(_mouseWheel = new Label(100, 10 + 30 * 8, "Test7")); }
public override void Init(Game1 game) { Color = Color.White; var beaker = game.Content.Load<Texture2D>("beaker"); var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.Black); var testSkin = new Skin(game.TestImageMap, game.TestMap); var testText = new Text(game.TestSpriteFont, Color.Black); var testSkins = new[] { new Tuple<string, Skin>("testSkin", testSkin) }; var testTexts = new[] { new Tuple<string, Text>("testText", testText) }; _gui = new Gui(game, skin, text, testSkins, testTexts) { Widgets = new Widget[] { //By default the Button is as wide as the width of the label plus the edge of the button graphic new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 0), "Start Game", buttonEvent: delegate(Widget widget) { buttonPressed = 1; }) { Skin = "testSkin", Text = "testText" }, new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 1), "Options", buttonEvent: delegate(Widget widget) { buttonPressed = 2; }) { Skin = "testSkin", Text = "testText" }, new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 2), "Instructions", buttonEvent: delegate(Widget widget) { buttonPressed = 3; }) { Skin = "testSkin", Text = "testText" }, new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 3), "Credits", buttonEvent: delegate(Widget widget) { buttonPressed = 4; }) { Skin = "testSkin", Text = "testText" }, new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 4), "Exit", buttonEvent: delegate(Widget widget) { buttonPressed = 5; }) { Skin = "testSkin", Text = "testText" }, new Button(10, BUTTON_DISPLACEMENT_Y + (40 * 5), "Back", buttonEvent: delegate(Widget widget) { buttonPressed = 6; }) { Skin = "testSkin", Text = "testText", Visible = false }, new Label(LABEL_DISPLACEMENT_X, LABEL_DISPLACEMENT_Y + (40 * 0), "Time"){Visible = false}, new Label(LABEL_DISPLACEMENT_X, LABEL_DISPLACEMENT_Y + (40 * 1), "Rounds"){Visible = false}, new Label(LABEL_DISPLACEMENT_X, LABEL_DISPLACEMENT_Y + (40 * 2), "Players"){Visible = false}, new SingleLineTextBox(TEXTBOX_DISPLACEMENT_X, TEXTBOX_DISPLACEMENT_Y + (40 * 0), TEXTBOX_WIDTH, TEXTBOX_HEIGHT){Visible = false}, new SingleLineTextBox(TEXTBOX_DISPLACEMENT_X, TEXTBOX_DISPLACEMENT_Y + (40 * 1), TEXTBOX_WIDTH, TEXTBOX_HEIGHT){Visible = false}, new SingleLineTextBox(TEXTBOX_DISPLACEMENT_X, TEXTBOX_DISPLACEMENT_Y + (40 * 2), TEXTBOX_WIDTH, TEXTBOX_HEIGHT){Visible = false}, } }; }
public override void Init(Game1 game) { Color = Color.White; var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.Black); var testSkin = new Skin(game.TestImageMap, game.TestMap); var testText = new Text(game.TestSpriteFont, Color.Black); var testSkins = new[] { new Tuple<string, Skin>("testSkin", testSkin) }; var testTexts = new[] { new Tuple<string, Text>("testText", testText) }; _gui = new Gui(game, skin, text, testSkins, testTexts) { Widgets = new Widget[] { new Button(10, 10 + (40 * 0), "Button"), new Button(10, 10 + (40 * 1), "Skin") { Skin = "testSkin", Text = "testText" }, new Button(10, 10 + (40 * 2), "Change Label", buttonEvent: delegate(Widget widget) { ((Button)widget).Label = _label.Value; }), _label = new SingleLineTextBox(220, 10 + (40 * 2), 100, 10), new Button(10, 10 + (40 * 4), "TextPadding = 25", 25), new Button(10, 10 + (40 * 5), "TextPadding = 25") { TextPadding = 25 }, new Button(10, 10 + (40 * 6), "Change TextPadding", buttonEvent: delegate(Widget widget) { int value; if (int.TryParse(_padding.Value, out value)) { ((Button)widget).TextPadding = value; } }), _padding = new SingleLineTextBox(220, 10 + (40 * 6), 100, 10), new Button(10, 10 + (40 * 8), 200, "Width = 200"), new Button(10, 10 + (40 * 9), "Width = 200") { Width = 200 }, new Button(10, 10 + (40 * 10), "Change Width", buttonEvent: delegate(Widget widget) { int value; if (int.TryParse(_width.Value, out value)) { ((Button)widget).Width = value; } }), _width = new SingleLineTextBox(220, 10 + (40 * 10), 100, 10) } }; }
public Client(Game1 theGame) { game = theGame; NetPeerConfiguration config = new NetPeerConfiguration("gamajama"); config.AutoFlushSendQueue = false; config.AcceptIncomingConnections = true; config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse); config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest); config.EnableMessageType(NetIncomingMessageType.StatusChanged); config.EnableMessageType(NetIncomingMessageType.ErrorMessage); config.EnableMessageType(NetIncomingMessageType.DebugMessage); config.EnableMessageType(NetIncomingMessageType.VerboseDebugMessage); config.EnableMessageType(NetIncomingMessageType.Data); s_client = new NetClient(config); s_client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage)); s_client.Start(); s_client.DiscoverLocalPeers(14240); NetOutgoingMessage hail = s_client.CreateMessage("This is the hail message"); //s_client.Connect(theGame.hostIP, 14240, hail); }
public override void Init(Game1 game) { Color = Color.White; _beaker = game.Content.Load<Texture2D>("beaker"); var skin = new Skin(game.GreyImageMap, game.GreyMap); var text = new Text(game.GreySpriteFont, Color.LightGray); _gui = new Gui(game, skin, text) { Widgets = new Widget[] { new ScrollBars { Children = new Widget[] { new Panel(10, 10, 1000, 1000) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new Button(10, 10, "Test 1"), new Button(10, 50, "Test 2"), new Button(10, 90, "Test 3"), new Button(10, 130, "Test 4"), new Button(10, 170, "Test 5"), new Button(10, 210, "Test 6"), new Button(10, 250, "Test 7"), new Button(10, 290, "Test 8"), new Button(10, 330, "Test 9"), new Button(10, 370, "Test 10"), new Button(10, 410, "Test 11"), new Button(10, 450, "Test 12"), new Button(10, 490, "Test 13"), new Button(10, 530, "Test 14"), new Button(10, 570, "Test 15"), new Button(10, 610, "Test 16"), new Panel(100, 10, 200, 200) { Children = new Widget[] { new Button(10, 10, "Test 1"), new Button(10, 50, "Test 2"), new Button(10, 90, "Test 3") } }, new Panel(100, 230, 400, 400) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new Button(10, 10, "Test 1"), new Button(10, 50, "Test 2"), new Button(10, 90, "Test 3"), new Button(10, 130, "Test 4"), new Button(10, 170, "Test 5"), new Button(10, 210, "Test 6"), new Button(10, 250, "Test 7"), new Button(10, 290, "Test 8"), new Button(10, 330, "Test 9"), new Button(10, 370, "Test 10"), new Button(10, 410, "Test 11"), new Button(10, 450, "Test 12"), new Button(10, 490, "Test 13"), new Button(10, 530, "Test 14"), new Button(10, 570, "Test 15"), new Button(10, 610, "Test 16"), new Panel(100, 10, 600, 600) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new Button(10, 10, "Button"), new ToggleButton(10, 50, "Toggle Button"), new Panel(10, 90, 120, 120), new CheckBox(10, 215, "Check Box"), new RadioButton(10, 255, "GRP", "Radio 1"), new RadioButton(10, 285, "GRP", "Radio 2"), new RadioButton(10, 315, "GRP", "Radio 3"), new Label(10, 340, "Research"), new Label(10, 365, _beaker, "Research"), new Panel(140, 90, 220, 220) { Children = new Widget[] { new TextBox(2, 600) } }, new Panel(370, 70, 220, 220) { Children = new Widget[] { new ScrollBars { Children = new Widget[] { new CheckBox(10, 10, "Button"), new CheckBox(210, 10, "Button"), new CheckBox(10, 210, "Button"), new CheckBox(210, 210, "Button"), new Panel(10, 230, 300, 300) { Children = new Widget[] { new TextBox(2, 300) } } } } } } } } } } } } } } } } } } } } } }; }
public abstract void Init(Game1 game);
public FireBallSpawner(Game1 game) { this.game = game; }
private static List<IGameObject> CreateNewGameObjects(List<string[]> objectList, Game1 game) { List<IGameObject> gameObjects = new List<IGameObject>(); Vector2 location = new Vector2(0,0); objectList.RemoveAt(0); foreach(string[] line in objectList) { foreach(string objectName in line) { IGameObject gameObject = null; IGameObject objectsItem = null; if (objectName.Equals("Mario")) gameObject = new MarioInstance(game); if (objectName.Equals("InvisiMario")) gameObject = new InvisiMario(game); if (objectName.Equals("PacMario")) gameObject = new PacMario(game); else if (objectName.Equals("Coin")) gameObject = new Coin(false, game); else if (objectName.Equals("PacNormCoin")) gameObject = new PacMarioNormalCoin(false, game); else if (objectName.Equals("PacMarioCoin")) gameObject = new PacMarioCoin(false, game); else if (objectName.Equals("Flower")) gameObject = new Flower(false, game); else if (objectName.Equals("GreenMush")) gameObject = new GreenMushroom(false, game); else if (objectName.Equals("RedMush")) gameObject = new RedMushroom(false, game); else if (objectName.Equals("Star")) gameObject = new Star(false, game); else if (objectName.Equals("Koopa")) gameObject = new GreenKoopa(game); else if (objectName.Equals("Goomba")) gameObject = new Goomba(game); else if (objectName.Equals("Boo1")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[0]); else if (objectName.Equals("Boo2")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[1]); else if (objectName.Equals("Boo3")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[2]); else if (objectName.Equals("Boo4")) gameObject = new Boo(game, IEnemyObjectConstants.BOO_START_LOCATIONS[3]); else if (objectName.Equals("Castle")) gameObject = new Castle(game); else if (objectName.Equals("FlagPole")) gameObject = new FlagPole(game); else if (objectName.Equals("FlagPoleBarrier")) gameObject = new InvisibleFlagPoleBarrier(game); else if (objectName.Equals("SolidBlock")) gameObject = new Block(Block.Type.SolidBlock, false, game); else if (objectName.Equals("HBlockWall")) gameObject = new Block(Block.Type.HorizontalBlockWall, false, game); else if (objectName.Equals("VBlockWall")) gameObject = new Block(Block.Type.VerticalBlockWall, false, game); else if (objectName.Equals("InvisCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.HiddenBlock, false, game); } else if (objectName.Equals("InvisGreenMushBlock")) { objectsItem = new GreenMushroom(true, game); gameObject = new Block(Block.Type.HiddenBlock, false, game); } else if (objectName.Equals("QuestionCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("BrickCoinBlock")) { objectsItem = new Coin(true, game); gameObject = new Block(Block.Type.BrickBlock, false, game); } else if (objectName.Equals("QuestionRedMushBlock")) { objectsItem = new RedMushroom(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionGreenMushBlock")) { objectsItem = new GreenMushroom(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionFlowerBlock")) { objectsItem = new Flower(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("QuestionStarBlock")) { objectsItem = new Star(true, game); gameObject = new Block(Block.Type.QuestionBlock, false, game); } else if (objectName.Equals("BrickStarBlock")) { objectsItem = new Star(true, game); gameObject = new Block(Block.Type.BrickBlock, false, game); } else if (objectName.Equals("BrickBlock")) gameObject = new Block(Block.Type.BrickBlock, false, game); else if (objectName.Equals("UndergroundBrickBlock")) gameObject = new Block(Block.Type.BrickBlock, true, game); else if (objectName.Equals("BreakingBlock")) gameObject = new Block(Block.Type.BreakingBlock, false, game); else if (objectName.Equals("UndergroundBreakingBlock")) gameObject = new Block(Block.Type.BreakingBlock, true, game); else if (objectName.Equals("EnemyUpBlock")) gameObject = new Block(Block.Type.EnemyUpBlock, true, game); else if (objectName.Equals("EnemyDownBlock")) gameObject = new Block(Block.Type.EnemyDownBlock, true, game); else if (objectName.Equals("EnemyRightBlock")) gameObject = new Block(Block.Type.EnemyRightBlock, true, game); else if (objectName.Equals("EnemyLeftBlock")) gameObject = new Block(Block.Type.EnemyLeftBlock, true, game); else if (objectName.Equals("TeleportBlock")) gameObject = new Block(Block.Type.TeleportBlock, false, game); else if (objectName.Equals("Pipe")) gameObject = new Pipe(game); else if (objectName.Equals("DoublePipe")) gameObject = new DoublePipe(game); else if (objectName.Equals("TriplePipe")) gameObject = new TriplePipe(game); else if (objectName.Equals("SidePipe")) gameObject = new SidePipe(game); else if (objectName.Equals("VerticalPipe")) gameObject = new VerticalPipe(game); else if (objectName.StartsWith("TripleWarpPipe")) { string[] parsedName = objectName.Split('-'); float x = Int32.Parse(parsedName[1]); float y = Int32.Parse(parsedName[2]); gameObject = new TriplePipe(new Vector2(x, y), game); } else if (objectName.StartsWith("TripleGameStatePipe")) { string[] parsedName = objectName.Split('-'); IGameState gameState = createNewGameState(parsedName[1], game); gameObject = new TriplePipe(gameState, game); } else if (objectName.StartsWith("SideWarpPipe")) { string[] parsedName = objectName.Split('-'); float x = Int32.Parse(parsedName[1]); float y = Int32.Parse(parsedName[2]); gameObject = new SidePipe(new Vector2(x, y), game); } else if (objectName.Equals("BigHill")) gameObject = new BigHill(game); else if (objectName.Equals("Bush")) gameObject = new SingleBush(game); else if (objectName.Equals("Cloud")) gameObject = new SingleCloud(game); else if (objectName.Equals("SmHill")) gameObject = new SmallHill(game); else if (objectName.Equals("TripleBush")) gameObject = new TripleBush(game); else if (objectName.Equals("TripleCloud")) gameObject = new TripleCloud(game); else if (objectName.Equals("Buckeye")) gameObject = new BuckeyePlayer(game); else if (objectName.Equals("Wolverine")) gameObject = new WolverineEnemy(game); else if (objectName.Equals("JmpWolverine")) gameObject = new JumpingWolverineEnemy(game); else if (objectName.Equals("WolverineChuck")) gameObject = new WolverineChuck(game); else if (objectName.Equals("ThwWolverine")) gameObject = new ThrowingWolverineEnemy(game); else if (objectName.Equals("BuckeyeGrass")) gameObject = new GrassTile(game); else if (objectName.Equals("BuckeyeGround")) gameObject = new GroundTile(game); else if (objectName.Equals("BuckeyeStone")) gameObject = new StoneTile(game); else if (objectName.Equals("StoneWall")) gameObject = new GiantVerticalStoneWall(game); else if (objectName.Equals("Paddle")) gameObject = new Paddle(game); else if (objectName.Equals("PaddleBall")) gameObject = new PaddleBall(game); else if (objectName.Equals("ElevatorU")) gameObject = new Elevator(true, game); else if (objectName.Equals("ElevatorD")) gameObject = new Elevator(false, game); else if (objectName.Equals("Endblock")) gameObject = new Endblock(game); if (objectsItem != null) { objectsItem.VectorCoordinates = location + new Vector2(0, -objectsItem.Sprite.SpriteDimensions.Y); gameObjects.Add(objectsItem); } if(gameObject != null){ gameObject.VectorCoordinates = location + new Vector2(0, -gameObject.Sprite.SpriteDimensions.Y + 16); if (gameObject is IFlagPole) gameObject.VectorCoordinates += new Vector2(0,16); gameObjects.Add(gameObject); } location.X += 16; } location.Y += 16; location.X = 0; } for(int index = 0; index < gameObjects.Count; index++) { if (gameObjects[index] is IMario) { IGameObject mario = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Add(mario); break; } } for (int index = 0; index < gameObjects.Count; index++) { if (gameObjects[index] is IScenery) { IGameObject scenery = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Insert(0, scenery); } } for (int index = gameObjects.Count - 1; index > 0; index--) { if (gameObjects[index] is IPipe) { IGameObject pipe = gameObjects[index]; gameObjects.RemoveAt(index); gameObjects.Add(pipe); } } return gameObjects; }
public static List<IGameObject> Load(string filename, Game1 game) { string directory = game.Content.RootDirectory + "\\Levels\\" + filename + ".csv"; List<string[]> objectList = ParseFile(GetFileContents(directory)); return CreateNewGameObjects(objectList, game); }
public static IGameState createNewGameState(string text, Game1 game) { IGameState gameState = null; if(text.Equals("ProjectBuckeyeGameState")) { gameState = new ProjectBuckeyeGameState(game); } else if (text.Equals("PacMarioGameState")) { gameState = new PacMarioGameState(game); } else if (text.Equals("MarioBrickBreakerGameState")) { gameState = new MarioBrickBreakerGameState(game); } else if (text.Equals("LemmingGameState")) { gameState = new LemmingGameState(game); } return gameState; }