Ejemplo n.º 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()
        {
            // TODO: Add your initialization logic here

            gameState       = GameState.Menu;
            gameStateNumber = true;

            input           = new Input();
            toast           = new MessageHandler(width, height);
            networkMessages = new MessageHandler(width, height);
            userName        = new TextInput(new Rectangle((width / 2) - 100, (height / 2) - 10, 200, 20));
            lobbyName       = new TextInput(new Rectangle(100, 200, 200, 20));
            chatBox         = new TextInput(new Rectangle(100, height - 40, 600, 20));
            network         = new Network();
            chatlog         = new List <string>();
            lobbyList       = new List <Gui>();

            // Action bar objects
            actionButtons = new List <Button>();
            actionButtons.Add(new Button(new Rectangle(5, height - ACTIONBUTTONOFFSET_X, 60, 60), "10", "Basic ranged tower, medium damage, medium firing speed, medium ammunition speed, single target. 100 gold - 50% return", Keys.D1, 1));
            actionButtons.Add(new Button(new Rectangle(5 + ACTIONBUTTONOFFSET_X, height - ACTIONBUTTONOFFSET_X, 60, 60), "20", "Fast ranged tower, low damage, high firing speed, fast ammunition speed, single target. 200 gold - 50% return", Keys.D2, 3));
            actionButtons.Add(new Button(new Rectangle(width - (ACTIONBUTTONOFFSET_X * 2), height - ACTIONBUTTONOFFSET_X, 60, 60), "3", "Deletes a tower, 50% gold return for normal towers, 100% for walls.", Keys.D, 5));
            actionButtons.Add(new Button(new Rectangle(width - ACTIONBUTTONOFFSET_X, height - ACTIONBUTTONOFFSET_X, 60, 60), "0", "Starts a new wave.", Keys.N, 6));
            actionButtons.Add(new Button(new Rectangle(width - (ACTIONBUTTONOFFSET_X * 3), height - ACTIONBUTTONOFFSET_X, 60, 60), "1", "Place a blocking tower. 5 gold - 100% return.", Keys.D3, 15));

            // Upgrade tower button
            upgradeTowerButton = new Button(new Rectangle(0, 0, 60, 60), "upgradetower", "Upgrade the tower?", Keys.D9, 15);

            Gui.SetScreenSize(width, height);
            topbar            = new Gui(new Rectangle(0, 0, width, 24));
            actionbar         = new Gui(new Rectangle(0, (height - 70), width, 70));
            Button.GameHeight = height;
            Button.GameWidth  = width;

            // Menu objects
            menuButtons = new List <Button>();
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X, 400, 70), "13", "Start a new game.", Keys.D1, 7));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + 75, 400, 70), "14", "Multiplayer.", Keys.D2, 8));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 2), 400, 70), "15", "Check the game controls.", Keys.D3, 9));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 3), 400, 70), "17", "Save the game.", Keys.D4, 13));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 4), 400, 70), "16", "Exit the game.", Keys.D5, 10));

            // Multiplayer buttons
            multiplayerButtons = new List <Button>();
            multiplayerButtons.Add(new Button(new Rectangle(300, 200, 20, 20), "createlobby;", "Create lobby.", Keys.D1, 14));

            // join lobby buttons
            joinLobbyButtons = new List <Button>();

            // Map object
            map        = new Map();
            pathfinder = new Pathfinder(map);
            pathview   = new PathView();

            // Enemy objects
            Unit.SetPathfinder(pathfinder, map);
            Unit.LoadPath();
            waveHandler   = new WaveHandler(enemies);
            pathview.Path = Unit.Path;

            ContentHolder.Initialize();

            // Player object
            player      = new Player(5, 1000, ref map, ref toast, ref waveHandler);
            player.Wave = waveHandler.WaveNumber;

            storageHandler = new StorageHandler();

            base.Initialize();
        }
Ejemplo n.º 2
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()
        {
            // TODO: Add your initialization logic here

            gameState = GameState.Menu;
            gameStateNumber = true;

            input = new Input();
            toast = new MessageHandler(width, height);
            networkMessages = new MessageHandler(width, height);
            userName = new TextInput(new Rectangle((width / 2) - 100, (height / 2) - 10, 200, 20));
            lobbyName = new TextInput(new Rectangle(100, 200, 200, 20));
            chatBox = new TextInput(new Rectangle(100, height - 40, 600, 20));
            network = new Network();
            chatlog = new List<string>();
            lobbyList = new List<Gui>();

            // Action bar objects
            actionButtons = new List<Button>();
            actionButtons.Add(new Button(new Rectangle(5, height - ACTIONBUTTONOFFSET_X, 60, 60), "10", "Basic ranged tower, medium damage, medium firing speed, medium ammunition speed, single target. 100 gold - 50% return", Keys.D1, 1));
            actionButtons.Add(new Button(new Rectangle(5 + ACTIONBUTTONOFFSET_X, height - ACTIONBUTTONOFFSET_X, 60, 60), "20", "Fast ranged tower, low damage, high firing speed, fast ammunition speed, single target. 200 gold - 50% return", Keys.D2, 3));
            actionButtons.Add(new Button(new Rectangle(width - (ACTIONBUTTONOFFSET_X * 2), height - ACTIONBUTTONOFFSET_X, 60, 60), "3", "Deletes a tower, 50% gold return for normal towers, 100% for walls.", Keys.D, 5));
            actionButtons.Add(new Button(new Rectangle(width - ACTIONBUTTONOFFSET_X, height - ACTIONBUTTONOFFSET_X, 60, 60), "0", "Starts a new wave.", Keys.N, 6));
            actionButtons.Add(new Button(new Rectangle(width - (ACTIONBUTTONOFFSET_X * 3), height - ACTIONBUTTONOFFSET_X, 60, 60), "1", "Place a blocking tower. 5 gold - 100% return.", Keys.D3, 15));

            // Upgrade tower button
            upgradeTowerButton = new Button(new Rectangle(0, 0, 60, 60), "upgradetower", "Upgrade the tower?", Keys.D9, 15);

            Gui.SetScreenSize(width, height);
            topbar = new Gui(new Rectangle(0, 0, width, 24));
            actionbar = new Gui(new Rectangle(0, (height - 70), width, 70));
            Button.GameHeight = height;
            Button.GameWidth = width;

            // Menu objects
            menuButtons = new List<Button>();
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X, 400, 70), "13", "Start a new game.", Keys.D1, 7));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + 75, 400, 70), "14", "Multiplayer.", Keys.D2, 8));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 2), 400, 70), "15", "Check the game controls.", Keys.D3, 9));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 3), 400, 70), "17", "Save the game.", Keys.D4, 13));
            menuButtons.Add(new Button(new Rectangle(width / 2 - MENUBUTTONOFFSET_X, MENUBUTTONOFFSET_X + (75 * 4), 400, 70), "16", "Exit the game.", Keys.D5, 10));

            // Multiplayer buttons
            multiplayerButtons = new List<Button>();
            multiplayerButtons.Add(new Button(new Rectangle(300, 200, 20, 20), "createlobby;", "Create lobby.", Keys.D1, 14));

            // join lobby buttons
            joinLobbyButtons = new List<Button>();

            // Map object
            map = new Map();
            pathfinder = new Pathfinder(map);
            pathview = new PathView();

            // Enemy objects
            Unit.SetPathfinder(pathfinder, map);
            Unit.LoadPath();
            waveHandler = new WaveHandler(enemies);
            pathview.Path = Unit.Path;

            ContentHolder.Initialize();

            // Player object
            player = new Player(5, 1000, ref map, ref toast, ref waveHandler);
            player.Wave = waveHandler.WaveNumber;

            storageHandler = new StorageHandler();

            base.Initialize();
        }