Ejemplo n.º 1
0
        public static AionLevelViewerImpl CreateLevelViewer(GraphicsDevice GraphicsDevice,
                                                            IServiceProvider serviceProvider, string aionRoot, string level)
        {
            var result = new AionLevelViewerImpl(GraphicsDevice, serviceProvider);

            result.m_contentLoader.LoadLevelData(aionRoot, level);
            // todo: fix hack - m_astarLoader should be a subobject of whatever manages the NavMeshSet...
            result.m_astarLoader = new AstarVertexBufferGenerator(GraphicsDevice, result.m_contentLoader.GetCompiledNavMeshSet());
            return(result);
        }
Ejemplo n.º 2
0
        public static AionLevelViewerImpl CreateCgfViewer(GraphicsDevice GraphicsDevice,
                                                          IServiceProvider serviceProvider, CgfLoader cgf)
        {
            var result = new AionLevelViewerImpl(GraphicsDevice, serviceProvider);

            result.camera.StepSpeed   = 1;
            result.camera.UpDownSpeed = 1;
            result.m_contentLoader.LoadCgf(cgf);
            //result.doorHackCgf = cgf;
            return(result);
        }
Ejemplo n.º 3
0
        public static void HandleInput(AionLevelViewerImpl game, bool isActive, GameTime gameTime, Camera camera, ref Matrix view)
        {
            if (!isActive)
            {
                s_wasPreviouslyActive = false;
                s_mouseDown           = false;
                return;
            }

            var kb = Keyboard.GetState();

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || kb.IsKeyDown(Keys.Escape))
            {
                game.InvokeOnExitRequest();
            }

            float speedMult = 0.04f;

            if (kb.IsKeyDown(Keys.LeftShift) || kb.IsKeyDown(Keys.RightShift))
            {
                speedMult = 0.7f;
            }

            if (kb.IsKeyDown(Keys.W))
            {
                camera.Forward(speedMult);
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.S))
            {
                camera.Forward(-speedMult);
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.A))
            {
                camera.Right(speedMult);
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.D))
            {
                camera.Right(-speedMult);
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.Q))
            {
                camera.Turn(-MathHelper.ToRadians(2.5f));
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.E))
            {
                camera.Turn(MathHelper.ToRadians(2.5f));
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.R))
            {
                camera.MoveUp(speedMult);
                camera.ApplyToView(ref view);
            }
            if (kb.IsKeyDown(Keys.F))
            {
                camera.MoveUp(-speedMult);
                camera.ApplyToView(ref view);
            }

            if (kb.IsKeyDown(Keys.T))
            {
                game.SetAstarTargetPoint();
            }
            if (kb.IsKeyDown(Keys.Y))
            {
                game.SetAstarStartPoint();
            }

            // toggles
            if (s_ksw1.IsDown(ref kb))
            {
                game.ShowTerrain ^= true;
            }
            if (s_ksw2.IsDown(ref kb))
            {
                game.ShowMesh ^= true;
            }
            if (s_ksw3.IsDown(ref kb))
            {
                game.ShowCollision ^= true;
            }
            if (s_ksw4.IsDown(ref kb))
            {
                game.ShowOriginLines ^= true;
            }
            if (s_ksw5.IsDown(ref kb))
            {
                game.ShowFloorLines ^= true;
            }
            if (s_ksw6.IsDown(ref kb))
            {
                game.ShowNames ^= true;
            }
            if (s_ksw7.IsDown(ref kb))
            {
                game.DoorMode = (game.DoorMode + 1) % 3; // hide doors, show state 1, show state 2
            }
            if (s_wasPreviouslyActive)
            {
                var ms = Mouse.GetState();
                if (ms.LeftButton == ButtonState.Pressed)
                {
                    if (!s_mouseDown)
                    {
                        s_mouseDown   = true;
                        s_mouseStartX = ms.X;
                        s_mouseStartY = ms.Y;

                        game.InvokeOnChangeMouseVisibilityRequest(false);
                    }
                    else
                    {
                        int dx = s_mouseStartX - ms.X;
                        int dy = s_mouseStartY - ms.Y;

                        if (dx != 0 || dy != 0)
                        {
                            if (dx != 0)
                            {
                                camera.Turn(MathHelper.ToRadians(-dx) / 4f);
                            }
                            if (dy != 0)
                            {
                                camera.Pitch(MathHelper.ToRadians(dy) / 4f);
                            }

                            camera.ApplyToView(ref view);

                            Mouse.SetPosition(s_mouseStartX, s_mouseStartY);
                        }
                    }
                }
                else if (s_mouseDown)
                {
                    s_mouseDown = false;
                    game.InvokeOnChangeMouseVisibilityRequest(true);
                }
            }
            s_wasPreviouslyActive = true;
        }