Пример #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //gui.AddWidget(panel1);

            // load all needed textures here

            #region textures
            shipTexture         = Content.Load <Texture2D>("ship01");
            enemyShipTexture1   = Content.Load <Texture2D>("ship02Flipped");
            enemyShipTexture2   = Content.Load <Texture2D>("ship03Flipped");
            energyBar           = Content.Load <Texture2D>("energyBar");
            healthBarFull       = Content.Load <Texture2D>("healthBarFull");
            healthBarMed        = Content.Load <Texture2D>("healthBarMed");
            healthBarLow        = Content.Load <Texture2D>("healthBarLow");
            shieldBubble        = Content.Load <Texture2D>("shieldBubble");
            gridSprite          = Content.Load <Texture2D>("Grid");
            gridHighlightSprite = Content.Load <Texture2D>("GridNotWalkable");
            energyBarSprite     = Content.Load <Texture2D>("energyBar");
            roomSprite          = Content.Load <Texture2D>("Room2x2");
            roomHighlightSprite = Content.Load <Texture2D>("Room2x2");
            pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            pixel.SetData(new[] { Color.Green });
            crewNoAnimate          = Content.Load <Texture2D>("crewNoAnimate");
            starTexture            = Content.Load <Texture2D>("starNode");
            overworldCursorTexture = Content.Load <Texture2D>("overworldCursor");
            starGreyedTexture      = Content.Load <Texture2D>("starNodeGreyed");


            #endregion


            #region player ship construction

            //Vector2 playerShipStartPosition = new Vector2(50,50);

            gridWidth  = shipTexture.Bounds.Width / 32;
            gridHeight = shipTexture.Bounds.Height / 32;
            shipGrid   = new int[gridWidth, gridHeight];
            // initialize the player's ship

            // TODO: initialize all objects for a ship outside of the ship itself
            // pass in the UIDs of the grids, rooms, and weapons attributed with this ship

            // grid creation for the player ship
            for (int i = 0; i < shipTexture.Bounds.Width / 32; i++)
            {
                // in each column, iterate over the ship sprite's height
                for (int j = 0; j < shipTexture.Bounds.Height / 32; j++)
                {
                    // create a new grid object for i,j
                    //shipGrid[i, j] = new Grid(gridTexture, highlightTexture, new Vector2(i * 32 + position.X, j * 32 + position.Y), new Vector2(i, j));
                    Grid toAdd = new Grid(gridSprite, gridHighlightSprite,
                                          new Vector2(i * 32 + playerShipStartPosition.X, j * 32 + playerShipStartPosition.Y),
                                          new Vector2(i, j));

                    int UID = GridManager.AddEntity(toAdd);
                    gridUIDs.Add(UID);
                    shipGrid[i, j] = UID;
                }
            }

            // create rooms, add them to the manager, pass their UIDs to the ship
            int roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 1, 1, playerShipStartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
            roomUIDs.Add(roomUID);
            roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 3, 2, playerShipStartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
            roomUIDs.Add(roomUID);

            bool[] roomTypes = new bool[11];

            for (int i = 0; i < 11; i++)
            {
                roomTypes[i] = false;
            }



            int weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
            weaponUIDs.Add(weaponUID);


            weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
            weaponUIDs.Add(weaponUID);

            weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
            weaponUIDs.Add(weaponUID);

            weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
            weaponUIDs.Add(weaponUID);


            weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
            weaponUIDs.Add(weaponUID);

            System.Diagnostics.Debug.WriteLine(weaponUIDs.Count);


            playerShipUID = ShipManager.AddEntity(new Ship(shipTexture, gridSprite, gridHighlightSprite, playerShipStartPosition, roomUIDs, gridUIDs, weaponUIDs, roomTypes, shipGrid, 0));


            foreach (var item in weaponUIDs)
            {
                WeaponToShip[item] = playerShipUID;
            }


            setRoomGridDictionary(playerShipUID);
            setRoomToShipDictionary(playerShipUID, roomUIDs);
            setUnwalkableGrids(playerShipUID);
            filledRoomUIDs = setCrewDictionary(playerShipUID);
            setFilledDict(playerShipUID, filledRoomUIDs);


            //playerShip = new Ship(shipTexture, gridSprite, gridHighlightSprite, new Vector2(50, 50), roomUIDs, gridUIDs, weaponUIDs, roomTypes);



            #endregion



            #region enemy ship construction 1

            /*
             * //Vector2 enemyShipStartPosition = new Vector2(400,50);
             *
             * Vector2 enemyShipStartPosition;
             * enemyShipStartPosition = new Vector2(400, 50);
             *
             * gridUIDs = new List<int>();
             * roomUIDs = new List<int>();
             * weaponUIDs = new List<int>();
             * gridWidth = shipTexture.Bounds.Width / 32;
             * gridHeight = shipTexture.Bounds.Height / 32;
             * shipGrid = new int[gridWidth, gridHeight];
             * // grid creation for the player ship
             * for (int i = 0; i < shipTexture.Bounds.Width / 32; i++)
             * {
             *  // in each column, iterate over the ship sprite's height
             *  for (int j = 0; j < shipTexture.Bounds.Height / 32; j++)
             *  {
             *      // create a new grid object for i,j
             *      //shipGrid[i, j] = new Grid(gridTexture, highlightTexture, new Vector2(i * 32 + position.X, j * 32 + position.Y), new Vector2(i, j));
             *      Grid toAdd = new Grid(gridSprite, gridHighlightSprite,
             *                 new Vector2(i * 32 + enemyShip1StartPosition.X, j * 32 + enemyShip1StartPosition.Y),
             *                 new Vector2(i, j));
             *
             *      int UID = GridManager.AddEntity(toAdd);
             *      gridUIDs.Add(UID);
             *      shipGrid[i, j] = UID;
             *  }
             * }
             *
             * roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 3, 1, enemyShip1StartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
             * roomUIDs.Add(roomUID);
             * roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 3, 4, enemyShip1StartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
             * roomUIDs.Add(roomUID);
             *
             * roomTypes = new bool[11];
             *
             * for (int i = 0; i < 11; i++)
             * {
             *  roomTypes[i] = false;
             * }
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * System.Diagnostics.Debug.WriteLine(weaponUIDs.Count);
             *
             *
             * enemyShipUID1 = ShipManager.AddEntity(new Ship(shipTexture, gridSprite, gridHighlightSprite, playerShipStartPosition, roomUIDs, gridUIDs, weaponUIDs, roomTypes, shipGrid, 0));
             *
             *
             * foreach (var item in weaponUIDs)
             * {
             *  WeaponToShip[item] = enemyShipUID1;
             * }
             *
             *
             * WeaponToShip[weaponUID] = enemyShipUID1;
             * setRoomGridDictionary(enemyShipUID1);
             * setUnwalkableGrids(enemyShipUID1);
             */
            #endregion

            #region enemy ship construction 2

            /*
             * //enemyShipStartPosition = new Vector2(400, 50);
             * gridUIDs = new List<int>();
             * roomUIDs = new List<int>();
             * weaponUIDs = new List<int>();
             * gridWidth = shipTexture.Bounds.Width / 32;
             * gridHeight = shipTexture.Bounds.Height / 32;
             * shipGrid = new int[gridWidth, gridHeight];
             * // grid creation for the player ship
             * for (int i = 0; i < shipTexture.Bounds.Width / 32; i++)
             * {
             *  // in each column, iterate over the ship sprite's height
             *  for (int j = 0; j < shipTexture.Bounds.Height / 32; j++)
             *  {
             *      // create a new grid object for i,j
             *      //shipGrid[i, j] = new Grid(gridTexture, highlightTexture, new Vector2(i * 32 + position.X, j * 32 + position.Y), new Vector2(i, j));
             *      Grid toAdd = new Grid(gridSprite, gridHighlightSprite,
             *                 new Vector2(i * 32 + enemyShip2StartPosition.X, j * 32 + enemyShip2StartPosition.Y),
             *                 new Vector2(i, j));
             *
             *      int UID = GridManager.AddEntity(toAdd);
             *      gridUIDs.Add(UID);
             *      shipGrid[i, j] = UID;
             *  }
             * }
             *
             * roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 3, 1, enemyShip2StartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
             * roomUIDs.Add(roomUID);
             * roomUID = RoomManager.AddEntity(new Room(roomHighlightSprite, roomHighlightSprite, 3, 4, enemyShip2StartPosition, Globals.roomShape.TwoXTwo, Globals.roomType.EMPTY_ROOM, 2, 2));
             * roomUIDs.Add(roomUID);
             *
             * roomTypes = new bool[11];
             *
             * for (int i = 0; i < 11; i++)
             * {
             *  roomTypes[i] = false;
             * }
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * weaponUID = WeaponManager.AddEntity(new Weapon(gridSprite, 0, 0, 10, 500, 3));
             * weaponUIDs.Add(weaponUID);
             *
             * System.Diagnostics.Debug.WriteLine(weaponUIDs.Count);
             *
             *
             * enemyShipUID2 = ShipManager.AddEntity(new Ship(shipTexture, gridSprite, gridHighlightSprite, playerShipStartPosition, roomUIDs, gridUIDs, weaponUIDs, roomTypes, shipGrid, 0));
             *
             *
             * foreach (var item in weaponUIDs)
             * {
             *  WeaponToShip[item] = enemyShipUID2;
             * }
             *
             *
             * WeaponToShip[weaponUID] = enemyShipUID2;
             * setRoomGridDictionary(enemyShipUID2);
             * setUnwalkableGrids(enemyShipUID2);
             */
            #endregion
            // load fonts

            font = Content.Load <SpriteFont>("Calibri");

            // load gui elements

            skin = new Skin(Content.Load <Texture2D>("uiskin"), System.IO.File.ReadAllText("Content/uiskinmap.txt"));

            gui = new Gui(this, skin, new Ruminate.GUI.Framework.Text(font, Color.White));

            // add all text the GUI we may be using here

            gui.AddText("error", new Ruminate.GUI.Framework.Text(font, Color.Red));
            gui.AddText("password", new Ruminate.GUI.Framework.Text(font, Color.TransparentBlack));
            gui.AddText("empty", new Ruminate.GUI.Framework.Text(font, Color.LightSlateGray));


            #region stuff from initialize

            // initialize the state of all input managers
            currentKeyState    = Keyboard.GetState();
            currentMouseState  = Mouse.GetState();
            previousKeyState   = Keyboard.GetState();
            previousMouseState = Mouse.GetState();

            // initialize the game state machine and states

            #region state machine setup
            stateMachine = new StateMachine();

            startMenu = new State {
                Name = "startMenu"
            };
            battle = new State {
                Name = "battle"
            };
            pauseState = new State {
                Name = "pauseState"
            };
            overworld = new State {
                Name = "overworld"
            };
            narrative = new State {
                Name = "narrative"
            };
            introState = new State {
                Name = "introState"
            };


            startMenu.Transitions.Add(battle.Name, battle);
            startMenu.Transitions.Add(overworld.Name, overworld);
            startMenu.Transitions.Add(pauseState.Name, pauseState);
            startMenu.Transitions.Add(introState.Name, introState);


            battle.Transitions.Add(startMenu.Name, startMenu);
            battle.Transitions.Add(overworld.Name, overworld);
            battle.Transitions.Add(pauseState.Name, pauseState);

            pauseState.Transitions.Add(startMenu.Name, startMenu);
            pauseState.Transitions.Add(battle.Name, battle);

            overworld.Transitions.Add(battle.Name, battle);
            overworld.Transitions.Add(narrative.Name, narrative);
            overworld.Transitions.Add(pauseState.Name, pauseState);

            narrative.Transitions.Add(overworld.Name, overworld);
            narrative.Transitions.Add(pauseState.Name, pauseState);

            introState.Transitions.Add(overworld.Name, overworld);

            stateMachine.Start(battle);
            #endregion

            // set up any UI elements here

            #region ui setup


            #endregion

            // set up game objects

            crewMembers = new List <Crew>();

            // set up each game state
            setupStartMenu();
            setupBattle(playerShipUID);
            setupPauseState();
            setupOverworld();

            #endregion
        }
Пример #2
0
        public override void Init(Game1 game)
        {
            Color           = Color.White;
            skin            = new Skin(game.GreyImageMap, game.GreyMap);
            text            = new Text(game.GreySpriteFont, Color.Chartreuse);
            AttributeColour = Color.OrangeRed;
            resizeNeeded    = false;

            Attributes = GameManager.NewPlayer;

            gui = new Gui(game, skin, text);
            gui.AddText("Nixie", new Text(game.Nixie, AttributeColour));

            CharCreatePanel = new Panel(1, 1, game.GraphicsDevice.Viewport.Width / 3, game.GraphicsDevice.Viewport.Height - 10);
            CharCreatePanel.AddWidget(new Label(1, 6, "NAME"));
            NameBox       = new SingleLineTextBox(50, 0, 150, 15);
            NameBox.Value = GameManager.NewPlayerName;

            CharCreatePanel.AddWidget(NameBox);

            AttributePanel     = new Panel(1, 50, CharCreatePanel.Area.Width - 10, 70);
            IndAttributePanels = new Panel[6];

            //strength
            Panel PanelSTR = new Panel(1, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);

            LabelSTRVAL      = new Label(1, 1, Convert.ToString(Attributes.Strength));
            LabelSTRVAL.Text = "Nixie";
            Label LabelSTR = new Label(1, 35, "STR");

            PanelSTR.AddWidget(LabelSTR);
            PanelSTR.AddWidget(LabelSTRVAL);
            IndAttributePanels[0] = PanelSTR;

            //Dex
            Panel PanelDEX = new Panel((AttributePanel.Area.Width / 6) * 1, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);
            Label LabelDEX = new Label(1, 35, "DEX");

            LabelDEXVAL      = new Label(1, 1, Convert.ToString(Attributes.Dexterity));
            LabelDEXVAL.Text = "Nixie";
            PanelDEX.AddWidget(LabelDEX);
            PanelDEX.AddWidget(LabelDEXVAL);
            IndAttributePanels[1] = PanelDEX;

            //Charisma
            Panel PanelCHA = new Panel((AttributePanel.Area.Width / 6) * 2, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);
            Label LabelCHA = new Label(1, 35, "CHA");

            LabelCHAVAL      = new Label(1, 1, Convert.ToString(Attributes.Charisma));
            LabelCHAVAL.Text = "Nixie";
            PanelCHA.AddWidget(LabelCHA);
            PanelCHA.AddWidget(LabelCHAVAL);
            IndAttributePanels[2] = PanelCHA;

            //Intelligence
            Panel PanelINT = new Panel((AttributePanel.Area.Width / 6) * 3, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);
            Label LabelINT = new Label(1, 35, "INT");

            LabelINTVAL      = new Label(1, 1, Convert.ToString(Attributes.Intelligence));
            LabelINTVAL.Text = "Nixie";
            PanelINT.AddWidget(LabelINT);
            PanelINT.AddWidget(LabelINTVAL);
            IndAttributePanels[3] = PanelINT;

            //Constitution
            Panel PanelCON = new Panel((AttributePanel.Area.Width / 6) * 4, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);
            Label LabelCON = new Label(1, 35, "CON");

            LabelCONVAL      = new Label(1, 1, Convert.ToString(Attributes.Constitution));
            LabelCONVAL.Text = "Nixie";
            PanelCON.AddWidget(LabelCON);
            PanelCON.AddWidget(LabelCONVAL);
            IndAttributePanels[4] = PanelCON;

            //Age
            Panel PanelAGE = new Panel(((AttributePanel.Area.Width / 6) * 5) - 5, 1, AttributePanel.Area.Width / 6, AttributePanel.Area.Height - 10);
            Label LabelAGE = new Label(1, 35, "AGE");

            LabelAGEVAL      = new Label(1, 1, Convert.ToString(Attributes.Age));
            LabelAGEVAL.Text = "Nixie";

            PanelAGE.AddWidget(LabelAGE);
            PanelAGE.AddWidget(LabelAGEVAL);
            IndAttributePanels[5] = PanelAGE;

            AttributePanel.AddWidgets(IndAttributePanels);

            CharCreatePanel.AddWidget(AttributePanel);

            //
            Panel[] CharModArray = new Panel[3];

            Panel SpeciesSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325);

            SpeciesSelect.AddWidget(new Label(1, 100, "Select:"));


            Panel ClassSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325);

            ClassSelect.AddWidget(new Button(-5, SpeciesSelect.Area.Height / 2, 10, "<", delegate { SpeciesSelect.Visible = true; ClassSelect.Visible = false; }));
            ClassSelect.Visible = false;

            Panel PerkSelect = new Panel(10, 125, CharCreatePanel.Area.Width - 30, 325);

            PerkSelect.AddWidget(new Button(-10, (SpeciesSelect.Area.Height / 2) - 10, 10, "<", delegate { ClassSelect.Visible = true; PerkSelect.Visible = false; }));
            PerkSelect.Visible = false;

            CharModArray[0] = SpeciesSelect;
            CharModArray[1] = ClassSelect;
            CharModArray[2] = PerkSelect;

            CharCreatePanel.AddWidgets(CharModArray);

            SpeciesSelect.AddWidget(new Button(-5, SpeciesSelect.Area.Height / 2, 10, "<", delegate { }));

            gui.AddWidget(CharCreatePanel);
            Console.WriteLine("Character Creation screen initialised");
        }