Ejemplo n.º 1
0
        public override void Update(GameTime gameTime)
        {
            if (components.Count == 0)
            {
                foodLabel  = new Components.Label("100", new Rectangle(1150, 666, 120, 32), this, Color.White, TextureManager.fontRegular30);
                scoreLabel = new Components.Label("0", new Rectangle(0, 680, 1280, 40), this, Color.White, TextureManager.fontRegular30);
                components.Add(new Models.PauseButton(new Rectangle(1215, 20, 45, 45), TextureManager.uiSpriteSheet, new Rectangle(240, 4, 45, 45), new Rectangle(240, 4, 45, 45), Color.White, this, "II", TextureManager.fontRegular30, Color.Black));
                components.Add(new Components.Image(new Rectangle(1110, 658, 32, 42), TextureManager.uiSpriteSheet, new Rectangle(305, 5, 32, 42), Color.White, this));
                components.Add(new Components.Label("Room " + GameplayManager.self.currLevelNumber, new Rectangle(20, 20, 200, 40), this, Color.White, TextureManager.fontRegular30));
                components.Add(new Components.Label("SCORE", new Rectangle(0, 670, 1280, 20), this, Color.White, TextureManager.fontRegular12));
                components.Add(scoreLabel);
                components.Add(foodLabel);
            }

            foodLabel.text = ((int)GameplayManager.self.CurrLevel.player.hp).ToString();
            foodLabel.Realign();

            scoreLabel.text = GameplayManager.self.score.ToString();
            scoreLabel.Realign();

            foreach (Component component in components)
            {
                component.Update(gameTime);
            }
        }
        public void MergeIntoTest()
        {
            StyleDefn target = CreatePDFStyleBase();
            StyleDefn style  = CreateAlternateStyle();

            //
            // label with matching class name - should be merged
            //

            Scryber.Components.Label lbl = new Components.Label();
            lbl.StyleClass = "sea";
            lbl.ID         = "mylabel";
            ComponentState state = ComponentState.Down;

            target.MergeInto(style, lbl, state);
            style.Flatten();                                                               //must flatten the style after a merge

            Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10);              // part of style
            Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Aqua);       // should have been replaced by targets color
            Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern); //from the target - not replaced by the change of color
            Assert.IsTrue(style.IsValueDefined(StyleKeys.BorderColorKey));
            Assert.AreEqual(style.Border.Width, (Scryber.Drawing.PDFUnit) 4);              //from the target - not originally in style
            Assert.AreEqual(style.Border.Color, Scryber.Drawing.PDFColors.Blue);           //from the target - not originally in style

            //No style class so should not be merged.

            target = CreatePDFStyleBase();
            style  = CreateAlternateStyle();

            lbl    = new Components.Label();
            lbl.ID = "mylabel";
            target.MergeInto(style, lbl, state);
            Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10);
            Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow);
            Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern);
            Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey));

            //Different ID so should not be merged.

            target = CreatePDFStyleBase();
            style  = CreateAlternateStyle();

            lbl            = new Components.Label();
            lbl.StyleClass = "sea";
            lbl.ID         = "anotherlabel";
            target.MergeInto(style, lbl, state);
            Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10);
            Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow);
            Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern);
            Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey));

            // different type

            Components.Image img = new Components.Image();
            img.StyleClass = "sea";
            img.ID         = "mylabel";
            target.MergeInto(style, img, state);
            Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10);
            Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow);
            Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern);
            Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey));
        }