Example #1
0
        public override void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
        {
            if (!Enabled)
            {
                currentState = "disabled";
                return;
            }

            if (inputState.IsMouseInRectangle(Bounds))
            {
                //2-按下,1-经过
                currentState = inputState.IsMouseLeftButtonPressed(Bounds) ? "pressed" : "hover";

                //松开按键时立刻引发事件
                if (inputState.IsNewMouseLeftButtonReleased(Bounds))
                {
                    if (OnClick != null) OnClick(this);
                }
            }
            else
            {
                //通常
                currentState = "normal";
            }

            base.HandleInput(inputState, isTopMost, screenManager);
        }
Example #2
0
 public virtual void Update(GameTime gameTime, ScreenManager screenManager)
 {
     foreach (var texture in textures.Where(texture => texture.Value != null))
     {
         texture.Value.Update(gameTime);
     }
 }
Example #3
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
        {
            if (!Enabled) return;

            spriteBatch.Begin();

            foreach (FallingElement element in fallingElements)
            {
                spriteBatch.Draw(
                    Textures[element.TextureIndex.ToString()].CurrentFrame,
                    element.CurrentPostion,
                    null,
                    Color.White,
                    element.CurrentAngle,
                    new Vector2(
                        Textures[element.TextureIndex.ToString()].CurrentFrame.Width / 2,
                        Textures[element.TextureIndex.ToString()].CurrentFrame.Height / 2),
                    element.Scale,
                    SpriteEffects.None,
                    0f);
            }

            spriteBatch.End();

            base.Draw(gameTime, spriteBatch, screenManager);
        }
Example #4
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
        {
            spriteBatch.Begin();

            if (Enabled)
                spriteBatch.Draw(
                    Textures[currentState] != null
                        ? Textures[currentState].CurrentFrame
                        : Textures["hover"] != null
                              ? Textures["hover"].CurrentFrame
                              : Textures["normal"].CurrentFrame,
                    Bounds,
                    Color.White);
            else
                spriteBatch.Draw(
                    Textures["disabled"] != null
                        ? Textures["disabled"].CurrentFrame
                        : Textures["normal"].CurrentFrame,
                    Bounds,
                    Color.White);

            spriteBatch.End();

            base.Draw(gameTime, spriteBatch, screenManager);
        }
Example #5
0
        public EAGSS()
        {
            IsMouseVisible = true;

            graphics = new GraphicsDeviceManager(this)
                           {
                               PreferredBackBufferWidth = GameSettings.WindowWidth,
                               PreferredBackBufferHeight = GameSettings.WindowHeight,
                           };

            Components.Add(new DebugScreen(this) {DrawOrder = 65535});

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            screenManager.AddScreen(new TestScreen());
        }
Example #6
0
        public override void Update(GameTime gameTime, ScreenManager screenManager)
        {
            if (!Enabled) return;

            //control finished!
            if (status == TransitionStatus.Dead)
            {
                //call OnFinish event
                if (OnFinish != null)
                    OnFinish(this);

                return;
            }

            if (status == TransitionStatus.Dead) return;
            if (status == TransitionStatus.NotShown) status = TransitionStatus.TransitioningIn;

            //now this.status must among [FadingIn, Shown, FadingOut]
            switch (status)
            {
                case TransitionStatus.TransitioningIn:
                    if (!UpdateTransition(gameTime, transitionOnTime, 1))
                    {
                        status = TransitionStatus.Shown;
                    }
                    break;

                case TransitionStatus.Shown:
                    alreadyShownTime += gameTime.ElapsedGameTime;
                    if (stopTime != TimeSpan.Zero && alreadyShownTime > stopTime)
                    {
                        // clear alreadyShownTime for next texture
                        alreadyShownTime = TimeSpan.Zero;
                        status = TransitionStatus.TransitioningOut;
                    }
                    break;

                case TransitionStatus.TransitioningOut:
                    if (!UpdateTransition(gameTime, transitionOffTime, -1))
                    {
                        Textures.Remove(Textures.ElementAt(0).Key);

                        // do we reach the end?
                        status = Textures.Count == 0
                                     ? TransitionStatus.Dead
                                     : TransitionStatus.TransitioningIn;
                    }
                    break;

                default:
                    throw new ArgumentException("Transition status error.");
            }

            base.Update(gameTime, screenManager);
        }
Example #7
0
 public override void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
     base.LoadContent(content, screenManager);
 }
Example #8
0
        public override void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
        {
            if (!Enabled) return;

            if (!canInterrupt) return;
            if (!inputState.IsNewMouseLeftButtonReleased(Bounds)) return;

            // we only handle Mouse1
            if (status == TransitionStatus.TransitioningIn) transitionPosition = 1;
            else if (status == TransitionStatus.Shown) status = TransitionStatus.TransitioningOut;
            else if (status == TransitionStatus.TransitioningOut) transitionPosition = 0;

            base.HandleInput(inputState, isTopMost, screenManager);
        }
Example #9
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
        {
            if (!Enabled) return;

            if (Textures.Count == 0
                || status == TransitionStatus.NotShown
                || status == TransitionStatus.Dead) return;

            spriteBatch.Begin();

            spriteBatch.Draw(
                Textures.ElementAt(0).Value.CurrentFrame, Bounds, Color.White * transitionPosition);

            spriteBatch.End();

            base.Draw(gameTime, spriteBatch, screenManager);
        }
Example #10
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
        {
            spriteBatch.Begin();

            spriteBatch.Draw(Textures["thumb_hover"].CurrentFrame, Bounds, Color.White);

            spriteBatch.Draw(
                hovering ? Textures["thumb_hover"].CurrentFrame : Textures["thumb"].CurrentFrame,
                thumbRectangle, Color.White);

            spriteBatch.End();

            base.Draw(gameTime, spriteBatch, screenManager);
        }
Example #11
0
        public override void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
        {
            hovering = inputState.IsMouseInRectangle(thumbRectangle);

            // 单击
            if (inputState.IsMouseLeftButtonPressed(Bounds) || inputState.IsNewMouseLeftButtonReleased(Bounds))
            {
                if (MoveThumbTo(new Point(inputState.CurrentMouseState.X, inputState.CurrentMouseState.Y)))
                    if (OnDrag != null)
                        OnDrag(this);
            }

            base.HandleInput(inputState, isTopMost, screenManager);
        }
Example #12
0
 public virtual void LoadContent(ContentLoader content, ScreenManager screenManager)
 {
 }
Example #13
0
 public virtual void HandleInput(InputState inputState, bool isTopMost, ScreenManager screenManager)
 {
 }
Example #14
0
 public virtual void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
 {
 }
Example #15
0
        public override void Update(GameTime gameTime, ScreenManager screenManager)
        {
            if (!Enabled) return;

            //update each element
            for (int i = 0; i < fallingElements.Length; i++)
            {
                //do we reach the end?
                if (fallingElements[i].CurrentPostion.Y
                    > Bounds.Height + Textures[fallingElements[i].TextureIndex.ToString()].CurrentFrame.Height)
                {
                    fallingElements[i].CurrentPostion = fallingElements[i].StartPostion;
                    fallingElements[i].CurrentAngle = 0;
                }

                fallingElements[i].CurrentPostion += fallingElements[i].DeltaPostion;
                fallingElements[i].CurrentAngle = (fallingElements[i].CurrentAngle
                                                   + fallingElements[i].DeltaAngle) % (2 * (float)Math.PI);
            }

            base.Update(gameTime, screenManager);
        }
Example #16
0
        public override void Update(GameTime gameTime, ScreenManager screenManager)
        {
            if (!Enabled) return;

            if (Textures["new"] == null) return;

            if (!UpdateTransition(gameTime, transitionTime, 1))
            {
                Textures["current"] = Textures["new"];
                Textures["new"] = null;

                transitionPosition = 0;

                //call OnFinish event
                if (OnFinish != null)
                    OnFinish(this);
            }
        }
Example #17
0
        public override void Draw(GameTime gameTime, SpriteBatch spriteBatch, ScreenManager screenManager)
        {
            if (!Enabled) return;

            spriteBatch.GraphicsDevice.Textures[1] = transitionShader;

            if (Textures["current"] != null)
            {
                spriteBatch.Begin();
                spriteBatch.Draw(Textures["current"].CurrentFrame, Bounds, Color.White);
                spriteBatch.End();
            }
            if (Textures["new"] != null)
            {
                spriteBatch.Begin(0, null, null, null, null, transitionEffect);
                spriteBatch.Draw(Textures["new"].CurrentFrame, Bounds, Color.White * transitionPosition);
                spriteBatch.End();
            }
        }
Example #18
0
 public override void Update(GameTime gameTime, ScreenManager screenManager)
 {
     base.Update(gameTime, screenManager);
 }