Exemple #1
0
        public override void Load()
        {
            CrosshairTex = Engine.Load <Texture>("/content/textures/gui/crosshair_default.png");
            UtilityGun UtilGun = new UtilityGun();

            Console.WriteLine("Loading map");
            Engine.Map = BSPMap.LoadMap("/content/maps/lt_test.bsp");
            Engine.Map.InitPhysics();
            Console.WriteLine("Done!");

            PlayerSpawn[] SpawnPositions = Engine.Map.GetEntities <PlayerSpawn>().ToArray();
            PlayerEnt = new Player();
            PlayerEnt.SetPosition((PlySpawnPos = SpawnPositions.Random().SpawnPosition) + new Vector3(0, 100, 0));
            PlayerEnt.Camera.LookAt(Vector3.Zero);

            PlayerEnt.SetPosition(new Vector3(-285.1535f, -964.8776f, 229.2883f));

            Engine.Map.SpawnEntity(UtilGun);
            Engine.Map.SpawnEntity(PlayerEnt);
            PlayerEnt.WeaponPickUp(UtilGun);

            /*foreach (var L in Engine.Map.GetLights())
             *      Engine.Map.RemoveEntity(L);*/

            LightEmitter = Engine.Map.GetEntities <EntPhysics>().Skip(5).First();
            Light        = new DynamicLight(Vector3.Zero, Color.Red);
            Engine.Map.SpawnEntity(Light);


            EntStatic TestEntity = new EntStatic(new libTechModel(Obj.Load("content/models/cube.obj"), Engine.GetMaterial(FogMaterial.Name)));

            TestEntity.Model.Scale = new Vector3(120);             // 20
            //DragonEnt.Model.Position = new Vector3(0, -1120, 0);
            TestEntity.Model.Position = new Vector3(0, -1000, 0);
            Engine.Map.SpawnEntity(TestEntity);

            /*
             * EntStatic TestEntity2 = new EntStatic(new libTechModel(TestEntity.Model));
             * TestEntity2.Model.Position = new Vector3(240, -1000, 0);
             * Engine.Map.SpawnEntity(TestEntity2);
             * //*/

            PlayerEnt.Camera.LookAt(TestEntity.Position);



            Engine.Camera3D.MouseMovement = true;
            Engine.Window.CaptureCursor   = true;

            Engine.Window.OnMouseMoveDelta += (Wnd, X, Y) => {
                PlayerEnt.MouseMove(new Vector2(-X, -Y));
            };

            Engine.Window.OnKey += (Wnd, Key, Scancode, Pressed, Repeat, Mods) => {
                PlayerEnt.OnKey(Key, Pressed, Mods);
                if (Key == Key.Escape && Pressed)
                {
                    Engine.Exit();
                }

                if (Key == Key.F5 && Pressed)
                {
                    RenderDoc.CaptureFrame();
                }

                if (Key == Key.F6 && Pressed)
                {
                    if (!Debugger.IsAttached)
                    {
                        Debugger.Launch();
                    }
                }
            };
        }