public bool HandleInput(ITMPlayer player)
 {
     if (InputManager.IsKeyReleasedNew(player.PlayerIndex, Keys.K))
     {
         if (cam == null)
         {
             cam = player.CreateCamera(player);
         }
         else
         {
             player.RemoveCamera(player, cam);
             cam = null;
         }
         return(true);
     }
     return(false);
 }
Example #2
0
        public void Update(ITMPlayer player)
        {
            particleElapsed += Services.ElapsedTime;
            if (particleElapsed > 1)
            {
                //var data = new ParticleData()
                //{
                //    Duration = 8000,
                //    Gravity = 1,
                //    Size = new Vector4(0.2f, 0.2f, 0.2f, 1f),
                //    StartColor = Color.White,
                //    EndColor = Color.White,
                //    VelocityType = ScriptCoordType.Absolute,
                //    Velocity = player.ViewDirection * 10
                //};
                //game.AddParticle(player.EyePosition, ref data);
                particleElapsed = 0;
            }

            if (InputManager.IsKeyReleasedNew(player.PlayerIndex, Keys.K))
            {
                if (cam == null)
                {
                    cam = player.CreateCamera(player);
                }
                else
                {
                    player.RemoveCamera(player, cam);
                    cam = null;
                }
            }

            if (cam != null)
            {
                var vd = Vector3.Normalize(new Vector3(player.ViewDirection.X, 0, player.ViewDirection.Z));
                cam.Position      = player.EyePosition - vd * 5 + new Vector3(0, 1, 0);
                cam.ViewDirection = vd;
                cam.UpdateMatrices();
            }
        }