Example #1
0
        /*####################################################################*/
        /*                           Initialization                           */
        /*####################################################################*/
        public Gui(Game game, Skin defaultSkin, Text defaultText,
            IEnumerable<Tuple<string, Skin>> skins = null, 
            IEnumerable<Tuple<string, Text>> textRenderers = null)
        {
            InitDom();

            NewState = OldState = new MouseState();

            InputManager = new InputManager(Dom);
            RenderManager = new RenderManager(game.GraphicsDevice);

            SetDefaultSettings(game, defaultSkin, defaultText);

            if (skins != null) {
                foreach (var skin in skins) {
                    AddSkin(skin.Item1, skin.Item2);
                }
            }

            if (textRenderers != null) {
                foreach (var textRenderer in textRenderers) {
                    AddText(textRenderer.Item1, textRenderer.Item2);
                }
            }
        }
Example #2
0
        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},
                }
            };
        }
Example #4
0
        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)

                }
            };
        }
Example #5
0
 public static void Init(SpriteBatch spb, Game1 game)
 {
     try
     {
         var skin = new Skin(game.GreyImageMap, game.GreyMap);
         Stream stream1 = new FileStream("./titlebackground.png", FileMode.Open);
         StreamReader streader = new StreamReader(stream1);
         spb.Draw(Texture2D.FromStream(spb.GraphicsDevice, stream1), new Microsoft.Xna.Framework.Rectangle(0, 0, 1280, 720), Microsoft.Xna.Framework.Color.White);
         // Close the reader before the stream to ensure a safe & successful closure.
         streader.Close();
         stream1.Close();
         Font_Def = Game1.Font1;
         txtBxPos = new Vector2(5, 10);
         textedit = new UI.Elements.UITextBox();
         Ruminate.GUI.Content.TextBox usernamebox = new Ruminate.GUI.Content.TextBox(100, (short)50);
         usernamebox.Active = true;
         new Ruminate.GUI.Content.CheckBox(10, 215, "Check Box");
     }
     catch { }
 }
Example #6
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            Texture2D GreyImageMap = Content.Load<Texture2D>(@"GUI\ImageMap");
            string GreyMap = File.OpenText(@"Content\GUI\Map.txt").ReadToEnd();
            Font = Content.Load<SpriteFont>(@"Minecraftia");

            DefaultSkin = new Skin(GreyImageMap, GreyMap);
            DefaultText = new Text(Font, Color.White);
        }
Example #7
0
        private void SetDefaultSettings(Game.Game1 game, Skin defaultSkin, Text defaultText)
        {
            DefaultScrollSpeed = 3;
            DefaultWheelSpeed = 6;

            SelectionColor = new Texture2D(game.GraphicsDevice, 1, 1);
            HighlightingColor = Color.LightSkyBlue * 0.3f;

            AddSkin("Default", defaultSkin);
            DefaultSkin = "Default";

            AddText("Default", defaultText);
            DefaultText = "Default";
        }
Example #8
0
 public void AddSkin(string name, Skin skin)
 {
     RenderManager.AddSkin(name, skin);
 }
Example #9
0
        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)
                                                                                                }
                                                                                            }
                                                                                        }
                                                                                    }
                                                                                }
                                                                            }
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
        }
Example #10
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
        }
Example #11
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);
            // TODO: use this.Content to load your game content here
            shipTexture = Content.Load<Texture2D>("ship1");
            energyBar = Content.Load<Texture2D>("energyBar");
            healthBar = Content.Load<Texture2D>("healthBar");
            playerShip = new Ship(shipTexture, new Vector2(50, 50));
            font = Content.Load<SpriteFont>("Calibri");

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

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

            gui.AddText("error", new Text(font, Color.Red));
            gui.AddText("password", new Text(font, Color.TransparentBlack));
            gui.AddText("empty", new Text(font, Color.LightSlateGray));
        }
        public void Initialize(Game1 game)
        {
            var skin = new Skin(game.GreyImageMap, game.GreyMap);
            var text = new TextRenderer(game.GreySpriteFont, Color.White);
            const int margin = 10;
            const int buttonHeight = 40;

            int i = -1;

            gui = new Gui(game, skin, text)
            {
                Widgets = new Widget[] {
                    useToonButton = new ToggleButton(margin, margin + (buttonHeight * ++i), "Use Toon") {
                        IsToggled = true
                    },
                    drawOutlineButton = new ToggleButton(margin, margin + (buttonHeight * ++i), "Draw Outline") {
                        IsToggled = true
                    },
                    useXToon = new ToggleButton(margin, margin + (buttonHeight * ++i), "Use X-Toon") {
                        IsToggled = false
                    },
                    secondDimension = new ComboBox(margin + 100, margin + (buttonHeight * i), 150, "Second Dimension", CardinalDirection.South,
                        new List<ComboBox.DropDownItem>() {
                            new ComboBox.DropDownItem("Distance"),
                            new ComboBox.DropDownItem("Angle")
                        }),
                    useTextureButton = new ToggleButton(margin, margin + (buttonHeight * ++i), "Use Textures") {
                        IsToggled = true
                    },
                    edgeWidth = new Slider(margin, margin + (buttonHeight * ++i), 150, delegate(Widget slider) {
                        edgeWidthLabel.Value = "Edge Width = " + (((Slider)slider).Value * maxEdgeWidth);
                    }) {
                        Value = 1 / maxEdgeWidth
                    },
                    edgeWidthLabel = new Label(margin, margin + (buttonHeight * ++i), "Edge Width = 1.0"),
                    edgeIntensity = new Slider(margin, margin + (buttonHeight * ++i), 150, delegate(Widget slider) {
                        edgeIntensityLabel.Value = "Edge Intensity = " + (((Slider)slider).Value * maxEdgeIntensity);
                    }) {
                        Value = 1 / maxEdgeIntensity
                    },
                    edgeIntensityLabel = new Label(margin, margin + (buttonHeight * ++i), "Edge Intensity = 1.0"),
                    detailAdjustment = new Slider(margin, margin + (buttonHeight * ++i), 150, delegate(Widget slider) {
                        detailAdjustmentLabel.Value = "Detail Adjustment = " + (((Slider)slider).Value * maxDetail);
                    }) {
                       Value = 1 / maxDetail
                    },
                    detailAdjustmentLabel = new Label(margin, margin + (buttonHeight * ++i), "Detail Adjustment = 1.0"),
                    useLightDirections = new ToggleButton(margin, margin + (buttonHeight * ++i), "Use Light Directions"),
                    lightAttentuation = new Slider(margin, margin + (buttonHeight * ++i), 150, delegate(Widget slider) {
                        lightAttenuationLabel.Value = "Light attenuation = " + (((Slider)slider).Value * maxAttenuation);
                    }) {
                        Value = 1200 / maxAttenuation
                    },
                    lightAttenuationLabel = new Label(margin, margin + (buttonHeight * ++i), "Light attentuation = 1200.0"),
                    disableLighting = new ToggleButton(margin, margin + (buttonHeight * ++i), "Disable lighting")
                }
            };
        }
Example #13
0
 /*####################################################################*/
 /*                          Skin Management                           */
 /*####################################################################*/
 internal void AddSkin(string name, Skin skin)
 {
     Skins.Add(name, skin);
 }
        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, 10 + (40 * 0), "Button") { Skin = "testSkin", Text = "testText" },
                    new Button(10, 10 + (40 * 1), "Wide Button"),
                    new Button(10, 10 + (40 * 2), "T"),
                    new Button(10, 10 + (40 * 3), 120, "Width 120"),
                    //Button will resized to fit if the specified width is smaller than the width of the text
                    new Button(10, 10 + (40 * 4), 20, "Width 20"),
                    //The optional padding argument causes the button to be as wide as the label + (padding * 2)
                    new Button(10, 10 + (40 * 5), "5 Padding", 5),
                    new Button(10, 10 + (40 * 6), "10 Padding", 10),

                    //The ToggleButton behaves similarly to the Button but toggles between being
                    //pressed or released each time its clicked.
                    new ToggleButton(150, 10 + (40 * 0), "Button"),
                    new ToggleButton(150, 10 + (40 * 1), "Wide Button"),
                    new ToggleButton(150, 10 + (40 * 2), "T"),
                    new ToggleButton(150, 10 + (40 * 3), 120, "Width 120"),
                    new ToggleButton(150, 10 + (40 * 4), 20, "Width 20"),
                    new ToggleButton(150, 10 + (40 * 5), "5 Padding", 5),
                    new ToggleButton(150, 10 + (40 * 6), "10 Padding", 10),

                    //Standard old checkbox
                    new CheckBox(300, 10, "Check Box"),

                    //Standard old radio button
                    //Only one radio buttons in the same group can have a value of true
                    new RadioButton(300, 40, "GRP", "Group GRP"),
                    new RadioButton(300, 70, "GRP", "Group GRP"),
                    new RadioButton(300, 100, "GRP", "Group GRP"),

                    //Slider allowing anologue selection. Value is the percent selected between 0 and 1 inclusive.
                    _slider = new Slider(300, 130, 200, delegate(Widget slider) {
                        _sliderLabel.Value = "Value = " + ((Slider)slider).Value;
                    }),
                    _sliderLabel = new Label(300, 160, "Value = 0"),

                    _singleLineTextBox = new SingleLineTextBox(300, 180, 100, 10),
                    new Button(410, 177, 100, "Change", delegate {
                        var result = 0.0f;
                        if (float.TryParse(_singleLineTextBox.Value, out result)) {
                            _slider.Value = result;
                        }
                    }),

                    //Combo box allowing that expands to allow the user to select one of the items in the DropDownItem List.
                    new ComboBox(300, 210, "Pick a Color", 2, CardinalDirection.North, new List<ComboBox.DropDownItem> { //The padding argument behaves the same as for the Button
                        new ComboBox.DropDownItem("Violet", null, delegate { Color = Color.Violet; }),
                        new ComboBox.DropDownItem("Tomato", null, delegate { Color = Color.Tomato; }),
                        new ComboBox.DropDownItem("YellowGreen", null, delegate { Color = Color.YellowGreen; }),
                        new ComboBox.DropDownItem("LightSkyBlue", null, delegate { Color = Color.LightSkyBlue; })
                    }),
                    new ComboBox(300, 250, 131, "Holder Text", CardinalDirection.South, new List<ComboBox.DropDownItem> {
                        new ComboBox.DropDownItem("Test 1"),
                        new ComboBox.DropDownItem("Test 2"),
                        new ComboBox.DropDownItem("Test 3"),
                        new ComboBox.DropDownItem("Test 4"),
                        new ComboBox.DropDownItem("Test 5")
                    }),

                    //For labels with icons the label is centered in the height of the icon
                    new Label(450, 10, "Research"),
                    new Label(450, 40, beaker, "Research"),
                    new Label(450, 70, beaker, "Research", 4), //Use the optional field for padding

                    //ScrollBars no longer have borders so nest them in panels if you need them.
                    //Panels have a min size of twice the renderers border width.
                    new Panel(10, 300, 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")
                                }
                            }
                        }
                    },

                    //TextBoxs no longer have borders so nest them in panels if you need them.
                    new Panel(240, 300, 400, 400) {
                        Children = new Widget[] {
                            new TextBox(2, 800) { Value = "This is a textbox!" }
                        }
                    },

                    new SingleLineTextBox(10, 525, 120, 10), //Basic Test
                    new SingleLineTextBox(10, 550, 120, 10) { Value = "0123456789" }, //Test with default value
                    new SingleLineTextBox(10, 575, 120, 10) { Value = "0123456789", Text = "testText" } //Test with specified font
                }
            };
        }
Example #15
0
        /// <summary>
        /// Ładowanie graficznych kontentów i ogolnie wszstkich
        /// </summary>
        protected override void LoadContent()
        {
            GreyImageMap = Game.Content.Load<Texture2D>("ImageMap");
                GreyMap = File.OpenText(Game.Content.RootDirectory + @"\Map.txt").ReadToEnd();
                GreySpriteFont = Game.Content.Load<SpriteFont>("font");

                var skin = new Skin(GreyImageMap, GreyMap);
                //var text = new Text(GreySpriteFont, Color.LightGray);

                TextRenderer text = new Ruminate.GUI.Framework.TextRenderer(GreySpriteFont, Color.White);
                PanelHeader = new Ruminate.GUI.Framework.Text(GreySpriteFont, Color.White);

                TextBox login = new TextBox(16, 16);
                TextBox haslo = new TextBox(8, 8);

                myGui = new Gui(this.Game, skin, text);
                myGui.AddWidget(login);

                spriteBatch = new SpriteBatch(this.GraphicsDevice);
                // ladowanie fontu z assetow
                //contentFont = Game.Content.Load<SpriteFont>("font");

                komunikat = "Zarejestruj swoje konto, aby grac";

                Vector2 wymiarKom = GreySpriteFont.MeasureString(komunikat);
                wspNaSrodek = new Vector2((GraphicsDevice.Viewport.TitleSafeArea.Width - wymiarKom.X) / 2, (GraphicsDevice.Viewport.TitleSafeArea.Height - wymiarKom.Y) / 2);

                base.LoadContent();
        }
Example #16
0
        public void Init()
        {
            greyImageMap = game.Content.Load<Texture2D>(@"GreySkin\ImageMap");
            greyMap = File.OpenText(@"Content\GreySkin\Map.txt").ReadToEnd();
            greySpriteFont = game.Content.Load<SpriteFont>(@"GreySkin\Texture");
            testImageMap = game.Content.Load<Texture2D>(@"TestSkin\ImageMap");
            testMap = File.OpenText(@"Content\TestSkin\Map.txt").ReadToEnd();
            testSpriteFont = game.Content.Load<SpriteFont>(@"TestSkin\Font");

            var skin = new Skin(this.greyImageMap, this.greyMap);
            var text = new Text(this.greySpriteFont, Color.White);

            var testSkin = new Skin(this.testImageMap, this.testMap);
            var testText = new Text(this.testSpriteFont, Color.White);

            var testSkins = new[] { new Tuple<string, Skin>("testSkin", testSkin) };
            var testTexts = new[] { new Tuple<string, Text>("testText", testText) };

            Button clearButton = new Button(0, 5, "Clear Drawing", 5, delegate { game.resetDrawing(); });

            comboBox = new ComboBox(755, 5, 200, "Choose Style", CardinalDirection.South, new List<ComboBox.DropDownItem>{
                new ComboBox.DropDownItem("No Style", null, null),
                new ComboBox.DropDownItem("Color Style", null, null),
                new ComboBox.DropDownItem("Test Style", null, null),
                new ComboBox.DropDownItem("Greek Style", null, null),
                new ComboBox.DropDownItem("ZigZag Style", null,null)
            });

            slider = new Slider(980, 10, 150, delegate{
                sliderLabel.Value = "" + Math.Round(((Slider)slider).Value * 99 + 1, 2);
            });
            sliderLabel = new Label(1122, 12, "1");
            slider.Value = 0.3f;

            slider2 = new Slider(1170, 10, 150, delegate
            {
                sliderLabel2.Value = "" + Math.Round(((Slider)slider2).Value * 39 + 1, 2);
            });
            sliderLabel2 = new Label(1312, 12, "1");
            slider2.Value = 0.3f;

            drawToggleButton = new ToggleButton(200, 5, "Moving Mode", 5);
            polyToggleButton = new ToggleButton(325, 5, "Drawing Poly", 5);
            newHoleToggleButton = new ToggleButton(445, 5, "Current Hole", 10);
            removeHoleButton = new Button(575, 5, "Remove Sel. Hole", 5);
            removeHoleButton.ClickEvent += delegate { game.removeSelectedHole(); };

            //drawToggleButton.OnToggle += delegate { polyToggleButton.IsToggled = false; };
            //polyToggleButton.OnToggle += delegate { drawToggleButton.IsToggled = false; };

            gui = new Gui(game, skin, text, testSkins, testTexts)
            {
                Widgets = new Widget[] { clearButton, drawToggleButton, polyToggleButton, newHoleToggleButton, removeHoleButton, comboBox, slider, sliderLabel, slider2, sliderLabel2 }
            };
        }