Exemplo n.º 1
0
 public UIButton(string label, Rectangle frame, UIButtonStyleSet styles, OnPressDelegate onPress)
 {
     this.label = label;
     this.frame = frame;
     this.styles = styles;
     this.onPress = onPress;
 }
Exemplo n.º 2
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);

            font = Content.Load<SpriteFont>("Arial");
            gridCursor = Content.Load<Texture2D>("cursor");
            highlightSquare = Content.Load<Texture2D>("highlightSquare");
            gameOverTexture = Content.Load<Texture2D>("gameover");
            gameWonTexture = Content.Load<Texture2D>("gamewon");
            upgradeTexture = Content.Load<Texture2D>("upgrade");
            levelDoneTexture = Content.Load<Texture2D>("level_pip_done");
            levelOpenTexture = Content.Load<Texture2D>("level_pip_open");
            levelHoverTexture = Content.Load<Texture2D>("level_pip_hover");
            levelStarDoneTexture = Content.Load<Texture2D>("level_star_done");
            levelStarOpenTexture = Content.Load<Texture2D>("level_star_open");
            levelStarHoverTexture = Content.Load<Texture2D>("level_star_hover");
            selectionCircleTexture = Content.Load<Texture2D>("selection_circle");

            StreamReader configReader = new StreamReader(File.OpenRead("Content/config.json"));
            JSONTable config = JSONTable.parse(configReader.ReadToEnd());

            tooltipBG = new LayeredImage(config.getJSON("tooltipBG"), Content);
            activeCardBG = new LayeredImage(config.getJSON("activeCardBG"), Content);

            ResourceType.load(config.getJSON("resources"), Content);
            MinionType.load(config.getJSON("minions"), Content);
            LevelType.load(config.getJSON("levelTypes"), Content);

            spellBooks = new Dictionary<string, List<Card>>();
            JSONTable spellsTemplate = config.getJSON("spells");
            foreach (string key in spellsTemplate.Keys)
            {
                spellBooks.Add(key, Card.load(spellsTemplate.getArray(key), Content));
            }

            wizardCatalog = new CardCatalog(new Rectangle(0, 5, 128, 600), spellBooks["main"], spellUpgrades);
            dynamicCatalog = new CardCatalog(new Rectangle(800 - 128, 5, 128, 600), spellBooks["rhs"], spellUpgrades);
            catalogs = new CardCatalog[]{ wizardCatalog, dynamicCatalog };

            levelScreen = new LevelScreen(config.getArray("chapters"));

            basicButtonStyle = new UIButtonStyleSet
            (
                new UIButtonStyle(font, Color.Black, new LayeredImage(config.getJSON("button3d"), Content), Color.White),
                new UIButtonStyle(font, Color.Yellow, new LayeredImage(config.getJSON("button3d_hover"), Content), Color.White),
                new UIButtonStyle(font, Color.Yellow, new LayeredImage(config.getJSON("button3d_pressed"), Content), Color.White)
            );
            gameScreenButtons = new List<UIButton>()
            {
                new UIButton("Back To Map", new Rectangle(GraphicsDevice.Viewport.Width - 240, 10, 100, 35), basicButtonStyle, OnPress_BackToMap),
                new UIButton("Cheat: Win", new Rectangle(GraphicsDevice.Viewport.Width - 240, GraphicsDevice.Viewport.Height - 100, 100, 35), basicButtonStyle, OnPress_CheatWin)
            };
            winScreenButtons = new List<UIButton>()
            {
                new UIButton("Next Level", new Rectangle(GraphicsDevice.Viewport.Width/2 - 120, GraphicsDevice.Viewport.Height/2 + 100, 100, 35), basicButtonStyle, OnPress_NextLevel),
                new UIButton("View Map", new Rectangle(GraphicsDevice.Viewport.Width/2 + 20, GraphicsDevice.Viewport.Height/2 + 100, 100, 35), basicButtonStyle, OnPress_BackToMap)
            };
            mapScreenButtons = new List<UIButton>()
            {
                new UIButton("Cheat: All spells", new Rectangle(GraphicsDevice.Viewport.Width - 160, GraphicsDevice.Viewport.Height - 100, 150, 35), basicButtonStyle, OnPress_CheatAllSpells),
                new UIButton("Cheat: All basic", new Rectangle(GraphicsDevice.Viewport.Width - 160, GraphicsDevice.Viewport.Height - 150, 150, 35), basicButtonStyle, OnPress_CheatAllBasic),
                new UIButton("Cheat: Restart", new Rectangle(GraphicsDevice.Viewport.Width - 160, GraphicsDevice.Viewport.Height - 200, 150, 35), basicButtonStyle, OnPress_CheatRestart),
            };
        }