示例#1
0
        public override void Update(GameTime gameTime)
        {
            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                SystemCore.ScreenManager.AddAndSetActive(new MainMenuScreen());
            }

            float currentHeight = cameraObject.Transform.AbsoluteTransform.Translation.Y;

            cameraObject.Transform.Translate(new Vector3(0, input.ScrollDelta / 10f, 0));

            float cameraSpeed = 1f;

            if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Up))
            {
                cameraObject.Transform.Translate(new Vector3(0, 0, cameraSpeed));
            }
            if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Down))
            {
                cameraObject.Transform.Translate(new Vector3(0, 0, -cameraSpeed));
            }
            if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left))
            {
                cameraObject.Transform.Translate(new Vector3(-cameraSpeed, 0, 0));
            }
            if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))
            {
                cameraObject.Transform.Translate(new Vector3(cameraSpeed, 0, 0));
            }


            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.Space))
            {
                floodFiller.Step();
            }

            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.Enter))
            {
                floodFiller.pause = !floodFiller.pause;
            }

            if (input.MouseLeftPress())
            {
                Plane p   = new Plane(Vector3.Down, 0);
                Ray   ray = input.GetProjectedMouseRay();
                float?result;
                ray.Intersects(ref p, out result);
                if (result.HasValue)
                {
                    mouseLeftPoint = ray.Position + ray.Direction * result.Value;
                    FindPath();
                }
            }
            if (input.MouseRightPress())
            {
                Plane p   = new Plane(Vector3.Down, 0);
                Ray   ray = input.GetProjectedMouseRay();
                float?result;
                ray.Intersects(ref p, out result);
                if (result.HasValue)
                {
                    mouseRightPoint = ray.Position + ray.Direction * result.Value;
                    FindPath();
                }
            }


            floodFiller.Update();



            //apiHandler.MovePlayerForward(10);

            if (connectToServer)
            {
                TimeSpan timeSincePlayerUpdate    = DateTime.Now - timeOfLastPlayerUpdate;
                TimeSpan timeSinceWorldUpdate     = DateTime.Now - timeOfLastWorldUpdate;
                TimeSpan timeSinceHitVectorUpdate = DateTime.Now - timeOfLastHitVectorUpdate;

                if (timeSincePlayerUpdate.TotalMilliseconds > playerUpdateFrequency)
                {
                    timeOfLastPlayerUpdate = DateTime.Now;
                    apiHandler.RequestPlayerDetails();
                }

                if (timeSinceWorldUpdate.TotalMilliseconds > worldUpdateFrequency)
                {
                    timeOfLastWorldUpdate = DateTime.Now;
                    apiHandler.RequestAllWorldDetails();
                }

                if (timeSinceHitVectorUpdate.TotalMilliseconds > hitVectorUpdateFrequency)
                {
                    RequestHitVectorData();
                }

                apiHandler.Update();

                HandleResponses();
            }

            base.Update(gameTime);
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                SystemCore.ScreenManager.AddAndSetActive(new MainMenuScreen());
            }

            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.O))
            {
                heading -= 10;
                playerObj.GetComponent <DoomMovementComponent>().TurnRightToHeading(heading);
            }
            if (input.KeyPress(Microsoft.Xna.Framework.Input.Keys.P))
            {
                heading += 10;
                playerObj.GetComponent <DoomMovementComponent>().TurnRightToHeading(heading);
            }

            if (heading > 360)
            {
                heading = 0;
            }
            if (heading < 0)
            {
                heading = 360;
            }

            if (input.MouseLeftPress())
            {
                //PathToMousePoint();
            }


            UpdateCamera();

            if (!mapHandler.FloodFillComplete)
            {
                mapHandler.FloodFillStep();
            }

            if (mapHandler.FloodFillComplete && playerObj.GetComponent <DoomMovementComponent>().path == null && !doNothing)
            {
                playerObj.GetComponent <DoomMovementComponent>().PathToPoint(mapHandler.LevelEnd);
                endOfLevelSeeking = true;
            }

            //check if we can see anything. If so, path to it.
            if (!doNothing)
            {
                if (collectItems)
                {
                    PickUpObjects();
                }
            }


            apiHandler.Update();


            if (playerObj != null)
            {
                DebugText.Write(playerObj.Transform.AbsoluteTransform.Translation.ToString());
            }


            base.Update(gameTime);
        }