예제 #1
0
        public override void Update(GameTime gameTime, TeeEngine engine)
        {
            Hero          player        = (Hero)engine.GetEntity("Player");
            KeyboardState keyboardState = Keyboard.GetState();

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.S, this, true) &&
                Entity.IntersectsWith(this, null, player, "Shadow", gameTime))
            {
                if (CurrentDrawableState != "Open")
                {
                    Random random = new Random();

                    CurrentDrawableState = "Open";
                    Drawables.ResetState("Open", gameTime);

                    for (int i = 0; i < 10; i++)
                    {
                        Coin coin = new Coin(this.Pos.X, this.Pos.Y, 100, (CoinType)random.Next(3));
                        coin.Pos.X += (float)((random.NextDouble() - 0.5) * 100);
                        coin.Pos.Y += (float)((random.NextDouble() - 0.5) * 100);

                        engine.AddEntity(coin);
                    }
                }
            }
        }
예제 #2
0
        void MapEntrance_MapZoneHit(MapZone sender, Entity entity, TeeEngine engine, GameTime gameTime)
        {
            if (KeyboardExtensions.GetKeyDownState(Keyboard.GetState(), ACTIVATE_KEY, engine, true) &&
                entity == engine.GetEntity("Player"))
            {
                MapEventArgs mapArgs = new MapEventArgs();
                mapArgs.SetProperty("Target", Target);

                engine.ClearEntities();
                engine.LoadMap(Destination, mapArgs);
            }
        }
예제 #3
0
        protected override void Update(GameTime gameTime)
        {
            // F1 = Show/Hide Bounding Boxes
            // F2 = Show/Hide Debug Info
            // F3 = Enable/Disable LightShader
            // F4 = Change Current SamplerState
            // F5 = Show/Hide Tile Grid
            // F6 = Show/Hide Quad Tree
            // F7 = Show Performance Diagnostics
            // F8 = Show Entity Debug Info
            // F10 = Toggle Fullscreen Mode
            // F11 = Show/Hide Player Helmet
            // F12 = Disable Player Collision Detection

            KeyboardState keyboardState = Keyboard.GetState();

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F1, this, true))
            {
                Engine.DrawingOptions.ShowBoundingBoxes = !Engine.DrawingOptions.ShowBoundingBoxes;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F2, this, true))
            {
                showDebugInfo = !showDebugInfo;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F3, this, true))
            {
                LightShader.Enabled = !LightShader.Enabled;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F4, this, true))
            {
                CurrentSampler = SamplerStates[++SamplerIndex % SamplerStates.Length];
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F5, this, true))
            {
                Engine.DrawingOptions.ShowTileGrid = !Engine.DrawingOptions.ShowTileGrid;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F6, this, true))
            {
                Engine.DrawingOptions.ShowColliderDebugInfo = !Engine.DrawingOptions.ShowColliderDebugInfo;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F7, this, true))
            {
                showDiagnostics = !showDiagnostics;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F8, this, true))
            {
                Engine.DrawingOptions.ShowEntityDebugInfo = !Engine.DrawingOptions.ShowEntityDebugInfo;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F10, this, true))
            {
                Engine.DrawingOptions.ShowDrawableComponents = !Engine.DrawingOptions.ShowDrawableComponents;
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F11, this, true))
            {
                helmetVisible = !helmetVisible;
                //CurrentPlayer.Drawables.SetGroupProperty("Head", "Visible", helmetVisible);
                if (helmetVisible)
                {
                    CurrentPlayer.Drawables.SetGroupProperty("Head", "Offset", Vector2.Zero);
                }
                else
                {
                    CurrentPlayer.Drawables.SetGroupProperty("Head", "Offset", new Vector2(0, -40));
                }
            }

            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.F12, this, true))
            {
                CurrentPlayer.CollisionDetection = !CurrentPlayer.CollisionDetection;
            }

            // INCREASE ZOOM LEVEL
            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.OemPlus, this, true))
            {
                Zoom += 0.1f;
            }

            // DECREASE ZOOM LEVEL
            if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.OemMinus, this, true))
            {
                Zoom -= 0.1f;
            }

            base.Update(gameTime);
        }
예제 #4
0
        public override void Update(GameTime gameTime, TeeEngine engine)
        {
            KeyboardState keyboardState = Keyboard.GetState();

            Vector2 movement = Vector2.Zero;
            float   prevX    = Pos.X;
            float   prevY    = Pos.Y;

            Tile  prevTile          = engine.Map.GetPxTopMostTile(Pos.X, Pos.Y);
            float moveSpeedModifier = prevTile.GetProperty <float>("MoveSpeed", 1.0f);

            // ATTACK KEY.
            if (keyboardState.IsKeyDown(Keys.A))
            {
                bool reset = !CurrentDrawableState.StartsWith("Slash");
                CurrentDrawableState = "Slash_" + Direction;

                if (reset)
                {
                    Drawables.ResetState(CurrentDrawableState, gameTime);
                }
            }
            else
            {
                // MOVEMENT BASED KEYBOARD EVENTS.
                if (keyboardState.IsKeyDown(Keys.Up))
                {
                    CurrentDrawableState = "Walk_Up";
                    Direction            = Direction.Up;

                    movement.Y--;
                }
                if (keyboardState.IsKeyDown(Keys.Down))
                {
                    CurrentDrawableState = "Walk_Down";
                    Direction            = Direction.Down;

                    movement.Y++;
                }
                if (keyboardState.IsKeyDown(Keys.Left))
                {
                    CurrentDrawableState = "Walk_Left";
                    Direction            = Direction.Left;

                    movement.X--;
                }
                if (keyboardState.IsKeyDown(Keys.Right))
                {
                    CurrentDrawableState = "Walk_Right";
                    Direction            = Direction.Right;

                    movement.X++;
                }

                if (KeyboardExtensions.GetKeyDownState(keyboardState, Keys.T, this, true))
                {
                    if (IsEquiped(ItemRepository.GameItems["RobeShirt"]))
                    {
                        Equip(ItemRepository.GameItems["PlateChest"]);
                    }
                    else
                    {
                        Equip(ItemRepository.GameItems["RobeShirt"]);
                    }
                }

                // Set animation to idle of no movements where made.
                if (movement.Length() == 0)
                {
                    CurrentDrawableState = "Idle_" + Direction;
                }
                else
                {
                    movement.Normalize();
                    Pos += movement * MOVEMENT_SPEED * moveSpeedModifier;
                }

                LightSource.Pos = this.Pos;
            }

            base.Update(gameTime, engine);
        }