Exemplo n.º 1
0
        private void InitUiArchetypes()
        {
            Texture2D       texture         = Textures["bStart"];
            Integer2        dimensions      = new Integer2(texture.Width, texture.Height);
            Transform2D     transform2D     = new Transform2D(Vector2.Zero, 0, Vector2.One, Vector2.Zero, dimensions);
            UITextureObject uiTextureObject = new UITextureObject("texture", ActorType.UITextureObject,
                                                                  StatusType.Drawn | StatusType.Update, transform2D, Color.White, 0.6f,
                                                                  SpriteEffects.None, texture, new Rectangle(0, 0, texture.Width, texture.Height));

            string text = "";

            dimensions  = new Integer2(Fonts["Arial"].MeasureString(text));
            transform2D = new Transform2D(Vector2.Zero, 0, Vector2.One, Vector2.Zero, dimensions);
            UITextObject uiTextObject = new UITextObject("text", ActorType.UIText, StatusType.Drawn | StatusType.Update,
                                                         transform2D, Color.Black, 0.1f,
                                                         SpriteEffects.None, text, Fonts["Arial"]);

            text       = "";
            texture    = Textures["bStart"];
            dimensions = new Integer2(texture.Width, texture.Height);
            Vector2 origin = new Vector2(texture.Width / 2f, texture.Height / 2f);

            transform2D = new Transform2D(Vector2.Zero, 0, Vector2.One, origin, dimensions);
            UIButtonObject uiButtonObject = new UIButtonObject("button", ActorType.UIButtonObject,
                                                               StatusType.Update | StatusType.Drawn, transform2D, Color.White, 0.5f,
                                                               SpriteEffects.None, texture, new Rectangle(0, 0, texture.Width, texture.Height), text, Fonts["Arial"],
                                                               Vector2.One, GameConstants.colorGold, Vector2.Zero);

            uiButtonObject.ControllerList.Add(new UiScaleLerpController("USC", ControllerType.Ui, mouseManager,
                                                                        new TrigonometricParameters(0.05f, 0.1f, 180)));

            UiArchetypes.Add("button", uiButtonObject);
            UiArchetypes.Add("texture", uiTextureObject);
            UiArchetypes.Add("text", uiTextObject);
        }
Exemplo n.º 2
0
 public UiOptionsEvent(EventCategoryType eventCategoryType, IActor parent, Texture2D textureEasy,
                       Texture2D textureHard) : base(eventCategoryType, parent)
 {
     uiButtonObject   = parent as UIButtonObject;
     this.textureEasy = textureEasy;
     this.textureHard = textureHard;
     EventManager.RegisterListener <OptionsEventInfo>(HandleEvent);
 }
Exemplo n.º 3
0
        private void HandleClickedButton(GameTime gameTime, UIButtonObject uIButtonObject)
        {
            //benefit of switch vs if...else is that code will jump to correct switch case directly
            switch (uIButtonObject.ID)
            {
            case "play":
                EventDispatcher.Publish(new EventData(EventCategoryType.Menu, EventActionType.OnPlay, null));
                break;

            case "controls":
                this.SetScene("controls");
                break;

            case "exit":
                this.Game.Exit();
                break;

            default:
                break;
            }
        }
Exemplo n.º 4
0
        private void HandleClickedButton(GameTime gameTime, UIButtonObject uIButtonObject)
        {
            //benefit of switch vs if...else is that code will jump to correct switch case directly
            switch (uIButtonObject.ID)
            {
            case "play":
                SetScene("levelselect");
                break;

            case "level1":
                EventDispatcher.Publish(new EventData(EventCategoryType.GameState, EventActionType.OnStart, new[] { "Level 1" }));
                break;

            case "level2":
                EventDispatcher.Publish(new EventData(EventCategoryType.GameState, EventActionType.OnStart, new[] { "Level 2" }));
                break;

            case "resume":
                EventDispatcher.Publish(new EventData(EventCategoryType.Menu, EventActionType.OnPlay, null));
                break;

            case "controls":
                this.SetScene("controls");
                break;

            case "exit":
                Game.Exit();
                break;

            case "tomenu":
                SetScene("main");
                EventDispatcher.Publish(new EventData(EventCategoryType.GameState, EventActionType.OnLeaveGame, null));
                break;

            case "restart":
                EventDispatcher.Publish(new EventData(EventCategoryType.GameState, EventActionType.OnRestart, null));
                break;
            }
        }