Ejemplo n.º 1
0
        // c'tor
        public ModalDisplay(OnPress OnContinue, OnPress OnBack, OnPress OnExitTutorial)
        {
            this.OnContinue     = OnContinue;
            this.OnBack         = OnBack;
            this.OnExitTutorial = OnExitTutorial;

            // We're rendering the text into a 1024x768 rt and then composing that with
            // the background elements into another 1024x768 rt.  This is then scaled
            // and rendered onto the backbuffer.
            camera            = new PerspectiveUICamera();
            camera.Resolution = new Point(1024, 768);

            {
                GetTexture getTexture = delegate() { return(ButtonTextures.AButton); };
                continueButton = new Button(Strings.Localize("tutorial.continue"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.BButton); };
                backButton = new Button(Strings.Localize("tutorial.back"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.XButton); };
                exitTutorialButton = new Button(Strings.Localize("tutorial.exitTutorial"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
        }   // end of c'tor
        // c'tor
        public ModularMessageDialog(
            string text,
            ButtonHandler handlerA, string labelA,
            ButtonHandler handlerB, string labelB,
            ButtonHandler handlerX, string labelX,
            ButtonHandler handlerY, string labelY)
        {
            SetText(text);

            commandMap.name += text;

            this.handlerA = handlerA;
            this.handlerB = handlerB;
            this.handlerX = handlerX;
            this.handlerY = handlerY;

            this.labelA = labelA;
            this.labelB = labelB;
            this.labelX = labelX;
            this.labelY = labelY;

            if (handlerA != null)
            {
                Debug.Assert(labelA != null, "If you have a button handler you must have a label for it.");
            }
            if (handlerB != null)
            {
                Debug.Assert(labelB != null, "If you have a button handler you must have a label for it.");
            }
            if (handlerX != null)
            {
                Debug.Assert(labelX != null, "If you have a button handler you must have a label for it.");
            }
            if (handlerY != null)
            {
                Debug.Assert(labelY != null, "If you have a button handler you must have a label for it.");
            }


            if (labelA != null)
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.AButton); };
                aButton = new Button(labelA, Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            if (labelB != null)
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.BButton); };
                bButton = new Button(labelB, Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            if (labelX != null)
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.XButton); };
                xButton = new Button(labelX, Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            if (labelY != null)
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.YButton); };
                yButton = new Button(labelY, Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
        }   // end of c'tor
Ejemplo n.º 3
0
        /// <summary>
        /// Takes the direction and moves the Entity to the tile according to the direction.
        /// Checks if the game is paused and if the Entity is able to move.
        /// Asks if there is a neighbor tile next to the Entity in the current direction.
        /// Asks if something is in that tile.
        /// Depending what is in that tile, returns true (to not move) or false (to move).
        /// Moving the Entity saves it in that tile and saves null in its place.
        /// </summary>
        /// <param name="pDirection"></param>
        /// <returns></returns>
        ///
        public bool Move(Direction pDirection)
        {
            Tile neighborTile = thisTile.GetNeighbour(pDirection);

            if (neighborTile == null)
            {
                return(false);
            }
            else if (neighborTile.GetEntity() == null)
            {
                neighborTile.SaveEntity(this);
                thisTile.SaveEntity(null);
                thisTile = neighborTile;
                _level.DrawEntities();
                return(true);
            }
            else if (neighborTile.GetEntity() is Pillar && IsEnemy == false)
            {
                if (((Pillar)neighborTile.GetEntity()).Move(pDirection))
                {
                    neighborTile.SaveEntity(this);
                    thisTile.SaveEntity(null);
                    _level.DrawEntities();
                    thisTile = neighborTile;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (neighborTile.GetEntity() is Player && IsEnemy == true)
            {
                _timer.Stop();
                thisTile.GetEntity().Move(Direction.None);
                GetTexture.Dispose();
                if (MessageBox.Show("You got hit by the enemy! Restart?", "Angry Chicken", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    _game.Restart();
                }
                else
                {
                    Application.Exit();
                }
                return(true);
            }
            else if (neighborTile.GetEntity() is Enemy)
            {
                return(false);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 4
0
        public Button(string label, Color color, GetTexture getTexture, UI2D.Shared.GetFont Font)
        {
            this.label       = label;
            this.color       = color;
            this.renderColor = color;
            this.getTexture  = getTexture;
            this.Font        = Font;
            this.state       = ButtonState.Released;

            this.box         = new AABB2D();
            this.labelOffset = new Vector2();
        }
Ejemplo n.º 5
0
        public ItemScroller(Vector2 pos, Vector2 size, Color baseColor, GetTexture getTexture,
                            UI2D.Shared.GetFont Font)
        {
            this.scrollItems      = new List <ScrollContainer>();
            this.color_bg         = baseColor.ToVector4();
            this.renderColor      = baseColor.ToVector4();
            this.getTexture       = getTexture;
            this.Font             = Font;
            this.state            = ButtonState.Released;
            this.FixedSize        = size;
            this.relativePosition = pos;

            GraphicsDevice device = BokuGame.bokuGame.GraphicsDevice;

            this.originalDeviceViewport = device.Viewport;

            // Since we're rendering to a 1280*720 rendertarget.
            this.uiCamera.Resolution = new Point(1280, 720);
        }
Ejemplo n.º 6
0
        }   // end of HandleTouchInput()

        #endregion

        public void LoadContent(bool immediate)
        {
            whiteTile      = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\LoadLevel\WhiteTile");
            whiteTop       = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\WhiteTop");
            whiteBottom    = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\WhiteBottom");
            blackHighlight = BokuGame.Load <Texture2D>(BokuGame.Settings.MediaPath + @"Textures\GridElements\BlackHighlight");

            {
                GetTexture getTexture = delegate { return(ButtonTextures.BButton); };
                cancelButton = new Button(Strings.Localize("textDialog.cancel"), Color.White, getTexture,
                                          UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate { return(ButtonTextures.AButton); };
                okButton = new Button(Strings.Localize("textDialog.ok"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }

            BokuGame.Load(textLineEditor, immediate);
        }   // end of LoadContent()
        public MicrobitPatternEditor()
        {
            // Create a blob of common parameters.
            UIGridElement.ParamBlob blob = new UIGridElement.ParamBlob();
            blob.width            = 512.0f / 96.0f;    // 5.33333
            blob.height           = blob.width / 5.0f; // 1.06667
            blob.edgeSize         = 0.06f;
            blob.Font             = UI2D.Shared.GetGameFont24Bold;
            blob.textColor        = Color.White;
            blob.dropShadowColor  = Color.Black;
            blob.useDropShadow    = true;
            blob.invertDropShadow = false;
            blob.unselectedColor  = new Color(new Vector3(4, 100, 90) / 255.0f);
            blob.selectedColor    = new Color(new Vector3(5, 180, 160) / 255.0f);
            blob.normalMapName    = @"Slant0Smoothed5NormalMap";
            blob.justify          = UIGridModularCheckboxElement.Justification.Left;

            brightnessSlider                   = new UIGridModularIntegerSliderElement(blob, Strings.Localize("microbitPatternEditor.brightness"));
            brightnessSlider.Position          = new Vector3(1.06667f, 1.01f, 0);
            brightnessSlider.MinValue          = 0;
            brightnessSlider.MaxValue          = 255;
            brightnessSlider.IncrementByAmount = 1;
            brightnessSlider.FastScrollScalar  = 10;
            brightnessSlider.UseRightStick     = true;
            brightnessSlider.OnChange          = delegate(int brightness) { pattern.Brightness = brightness; };
            brightnessSlider.SetHelpOverlay    = false;

            durationSlider                       = new UIGridModularFloatSliderElement(blob, Strings.Localize("microbitPatternEditor.duration"));
            durationSlider.Position              = new Vector3(1.06667f, 0.0f, 0);
            durationSlider.MinValue              = 0.0f;
            durationSlider.MaxValue              = 5.0f;
            durationSlider.IncrementByAmount     = 0.1f;
            durationSlider.CurrentValueImmediate = 0.1f;
            durationSlider.UseRightStick         = true;
            durationSlider.OnChange              = delegate(float duration) { pattern.Duration = duration; };
            durationSlider.SetHelpOverlay        = false;

            blob.width             = 2.06777f;
            blob.height            = blob.width;
            ledGrid                = new UIGrid2DLEDArrayElement(blob);
            ledGrid.Position       = new Vector3(-2.58f, 0.51f, 0);
            ledGrid.SetHelpOverlay = false;

            blob.width         = brightnessSlider.Width + ledGrid.Width - 0.04f;
            blob.height        = brightnessSlider.Height * 0.75f;
            bar                = new UIGrid2DButtonBarElement(blob);
            bar.Position       = new Vector3(0.055f, -0.875f, 0);
            bar.SetHelpOverlay = false;

            camera = new PerspectiveUICamera();

            leftStickPosition            = new Vector2(-3.9f, 0.5f);
            rightStickPositionBrightness = new Vector2(4.0f, 1.0f);
            rightStickPositionDuration   = new Vector2(4.0f, 0.0f);
            rightStickPosition           = rightStickPositionBrightness;

            // Buttons
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.BButton); };
                cancelButton = new Button(Strings.Localize("saveLevelDialog.cancel"), labelColor, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.AButton); };
                saveButton = new Button(Strings.Localize("saveLevelDialog.save"), labelColor, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.YButton); };
                toggleLEDButton = new Button(Strings.Localize("microbitPatternEditor.toggleLED"), labelColor, getTexture, UI2D.Shared.GetGameFont20);
            }
        }   // end of c'tor