예제 #1
0
        public HelpState(EntityFactory factory)
        {
            Factory     = factory;
            MainAtlas   = Vrax.Game.AssetCache.Get <Atlas>("Atlas.json");
            DefaultFont = Vrax.Game.AssetCache.Get <Font>("DefaultFont.fnt");

            HelpFont = Vrax.Game.AssetCache.Get <Font>("HelpFont.fnt");
            if (HelpFont == null)
            {
                HelpFont = Vrax.Game.AssetCache.LoadFont("HelpFont.fnt");
            }

            Display = new DisplayContainer()
            {
                Parent = Vrax.Game.Display
            };

            CreateBaseUI();

            // Create pages
            CreateControlsPage();
            CreateUIHelpPage();
            CreateTransformPage();
            CreateAboutPage();

            Display.Add(Pages[0]);
        }
예제 #2
0
        private void CreateUIHelpPage()
        {
            var page = new DisplayContainer();

            Pages.Add(page);

            float y = 40;
            float x = Screen.Width * 0.3f;

            var helpTexture = Vrax.Game.AssetCache.Get <Texture>("uihelp.png");

            if (helpTexture == null)
            {
                helpTexture = Vrax.Game.AssetCache.LoadTexture("uihelp.png");
            }

            var img = new Image(helpTexture)
            {
                Parent   = page,
                Position = new Point(Screen.Half.Width, y),
                Anchor   = new Distance(0.5f, 0)
            };

            y += img.Size.Y + 30;

            var tf = new Textfield(HelpFont, "Objective: Kill enemies to advance your Wave Level. Different enemies spawn on different waves. The higher the wave level, the harder and much worse your life will be.")
            {
                Parent   = page,
                MaxWidth = 600,
                Position = new Point(Screen.Width * 0.2f, y)
            };
        }
예제 #3
0
        void DisplayViews()
        {
            var defaultView = new DisplayContainer();

            Primary   = defaultView;
            Secondary = defaultView;
            Tertiary  = defaultView;

            foreach (var View in AllViews)
            {
                switch (View.DisplayIndex)
                {
                case 1:
                    Primary = View;
                    break;

                case 2:
                    Secondary = View;
                    break;

                case 3:
                    Tertiary = View;
                    break;

                default:
                    Primary = View;
                    break;
                }
            }
        }
예제 #4
0
        private void CreateControlsPage()
        {
            var page = new DisplayContainer();

            Pages.Add(page);

            float y = 40;
            float x = Screen.Width * 0.3f;

            var tf = new Textfield(HelpFont, "Controls")
            {
                Parent   = page,
                Position = new Point(Screen.Half.Width, y),
                Anchor   = new Distance(0.5f, 0),
                Scale    = new Distance(1.5f, 1.5f),
                Align    = TextAlign.Center
            };

            y += tf.TextSize.Height + 20;

            tf = new Textfield(HelpFont, "Movement: WASD or Arrow keys")
            {
                Parent   = page,
                Position = new Point(x, y)
            };
            y += tf.TextSize.Height + 10;

            tf = new Textfield(HelpFont, "M: Turn off music")
            {
                Parent   = page,
                Position = new Point(x, y)
            };
            y += tf.TextSize.Height + 10;

            tf = new Textfield(HelpFont, "Prev Ship: Q")
            {
                Parent   = page,
                Position = new Point(x, y)
            };
            y += tf.TextSize.Height + 10;

            tf = new Textfield(HelpFont, "Next Ship: E")
            {
                Parent   = page,
                Position = new Point(x, y)
            };
            y += tf.TextSize.Height + 10;

            tf = new Textfield(HelpFont, "Fire: Spacebar or Left Mouse Button")
            {
                Parent   = page,
                Position = new Point(x, y)
            };
            y += tf.TextSize.Height + 10;
        }
예제 #5
0
        private void CreateAboutPage()
        {
            var page = new DisplayContainer();

            Pages.Add(page);

            var tf = new Textfield(HelpFont, "This game was made completely in 48 hours by Mark Troyer on Dec 1-3, 2017 for the Ludum Dare 40 Compo. I had fun making it and I hope you enjoy playing it!")
            {
                Parent   = page,
                Position = Screen.Half,
                Anchor   = Distance.Center,
                MaxWidth = (int)(Screen.Width * 0.8f)
            };
        }
예제 #6
0
        private void CreateTransformPage()
        {
            var page = new DisplayContainer();

            Pages.Add(page);

            float x = Screen.Half.Width;
            float y = 30;

            new Image(TryLoad("helptransform0.png"))
            {
                Parent   = page,
                Position = new Point(x, y),
                Anchor   = new Distance(0.5f, 0)
            };
            y += 200;

            new Image(TryLoad("helptransform1.png"))
            {
                Parent   = page,
                Position = new Point(x, y),
                Anchor   = new Distance(0.5f, 0)
            };
        }
예제 #7
0
        public MenuState(EntityFactory factory)
        {
            Factory = factory;

            Display = new DisplayContainer()
            {
                Parent = Vrax.Game.Display
            };

            var assetCache   = Vrax.Game.AssetCache;
            var titleTexture = assetCache.Get <Texture>("Title.png");

            TitleImage = new Image(titleTexture)
            {
                Parent   = Display,
                Anchor   = new Distance(0.5f, 0),
                Position = new Point(Screen.Half.Width, 30)
            };
            AnimateTitle();

            var font        = assetCache.Get <Font>("DefaultFont.fnt");
            var menuOptions = new List <(string label, Action callback)>()
            {
                ("Play", OnPlayPressed),
                ("Toggle Music", OnToggleMusic),
                ("Help", OnHelpPressed),
            };

            var textColor = Color.FromRGB(0xbbbbbb);

            int y = 180;

            for (int i = 0; i < menuOptions.Count; i++)
            {
                var tf = new Textfield(font, menuOptions[i].label)
                {
                    Parent   = Display,
                    Position = new Point(Screen.Half.Width - 90, y + (i * 60)),
                    Color    = textColor
                };

                var button = new TextButton(
                    new TextButton.State()
                {
                    Scale = 1f,
                    Color = textColor
                },
                    new TextButton.State()
                {
                    Scale = 1f,
                    Color = Color.White
                },
                    new TextButton.State()
                {
                    Scale = 0.95f,
                    Color = textColor
                });

                button.ClickEvent += menuOptions[i].callback;
                tf.Attach(button);
            }

            new Textfield(font, "Ludum Dare 40 \"The more you have, the worse it is.\"")
            {
                Parent   = Display,
                Scale    = new Distance(0.5f, 0.5f),
                Position = Screen,
                Anchor   = Distance.One,
                Align    = TextAlign.Right
            };
        }
예제 #8
0
        private void CreateUI()
        {
            UILayer = new DisplayContainer()
            {
                Parent = Display
            };

            var title = new Textfield(DefaultFont, "Begin!")
            {
                Parent   = UILayer,
                Position = new Point(Screen.Half.Width, -50),
                Anchor   = Distance.Center
            };

            Vrax.Game.Animator.AddSequence(new[]
            {
                title.MoveTo(new Point(Screen.Half.Width, Screen.Half.Height * 0.4f), 800, Ease.BounceOut),
                new DelayTween(1500),
                title.MoveRelative(new Distance(-Screen.Width, 0), 1500, Ease.CubicOut),
                new ActionTween(() => title.Parent = null)
            });

            HealthFrame     = MainAtlas.GetFrame("health.png");
            HealthOffset    = new Distance(DefaultFont.GetTextWidth("HP:") + 12, 9);
            TransformFrame  = MainAtlas.GetFrame("transform.png");
            TransformOffset = new Distance(DefaultFont.GetTextWidth("TX:") + 12, 35);

            MeterHolder = new Image(MainAtlas.GetFrame("meterholder.png"))
            {
                Parent    = UILayer,
                FixedSize = new Size(171, 40),
                Position  = new Point((Screen.Width - 171) * 0.5f, Screen.Height - 50)
            };
            Meter = new Image(MainAtlas.GetFrame("meter.png"))
            {
                Parent    = UILayer,
                Position  = MeterHolder.Position + new Distance(5, 5),
                FixedSize = new Size(0, MeterHeight)
            };
            KillCounterTextfield = new Textfield(DefaultFont, "0")
            {
                Parent   = UILayer,
                Position = new Point(Screen.Half.Width, MeterHolder.Position.Y + 5),
                Color    = Color.Black,
                Align    = TextAlign.Center,
                Anchor   = new Distance(0.5f, 0)
            };
            Spawner.KillCountChanged += OnKillCountChanged;

            var counterHolder = new Image(MainAtlas.GetFrame("meterholder.png"))
            {
                Parent    = UILayer,
                FixedSize = new Size(45, 40),
                Position  = MeterHolder.Position - new Distance(55, 0)
            };

            LevelCounterTextfield = new Textfield(DefaultFont, "0")
            {
                Parent   = UILayer,
                Position = counterHolder.Position + new Distance(22, 5),
                Color    = Color.Black,
                Align    = TextAlign.Center,
                Anchor   = new Distance(0.5f, 0)
            };

            // Shield counter
            ShieldImage = new Image(MainAtlas.GetFrame("shieldicon.png"))
            {
                Parent   = UILayer,
                Position = MeterHolder.Position + new Distance(MeterWidth + 40, 20),
                Anchor   = Distance.Center,
                Color    = Color.None
            };

            ShieldCounter = new Textfield(DefaultFont, "0")
            {
                Parent   = UILayer,
                Position = ShieldImage.Position,
                Anchor   = Distance.Center,
                Scale    = new Distance(0.5f, 0.5f),
                Color    = Color.None
            };
        }
예제 #9
0
 public McJackJump(DisplayContainer parent) : this()
 {
     this.parent = parent;
 }
예제 #10
0
 public McDemo_TouchAndTween(DisplayContainer parent) : this()
 {
     this.parent = parent;
 }
예제 #11
0
 public McDemo_Animation(DisplayContainer parent) : this()
 {
     this.parent = parent;
 }
예제 #12
0
 public McLight(DisplayContainer parent) : this()
 {
     this.parent = parent;
 }
예제 #13
0
 public McJackRunGo(DisplayContainer parent) : this()
 {
     this.parent = parent;
 }