コード例 #1
0
ファイル: GameplayLoop.cs プロジェクト: LaserYGD/Zeldo-CSharp
        public override void Initialize()
        {
            CollisionSystem system = new CollisionSystemSAP();

            system.UseTriangleMeshNormal = true;

            // TODO: Should damping factors be left in their default states? (they were changed while adding kinematic bodies)
            world         = new World(system);
            world.Gravity = new JVector(0, -PhysicsConstants.Gravity, 0);
            world.SetDampingFactors(1, 1);
            world.Events.ContactCreated += OnContact;

            space = new Space();
            scene = new Scene
            {
                Camera = camera,
                Canvas = canvas,
                Space  = space,
                World  = world
            };

            var stats = new StatisticsDisplay();

            stats.Anchor    = Alignments.Left | Alignments.Top;
            stats.Offset    = new ivec2(10);
            stats.IsVisible = false;

            canvas.Clear();
            canvas.Load("Canvas.json");
            canvas.Add(stats);
            //canvas.Add(new RopeTester());

            spawnHelper = new SpawnHelper(scene);

            // TODO: Load settings from a file.
            ControlSettings settings = new ControlSettings();

            settings.MouseSensitivity = 50;

            // TODO: Set player position from a save slot.
            PlayerCharacter player = new PlayerCharacter(settings);

            player.Equip(new Sword(player));
            player.Unlock(PlayerSkills.Grab);
            player.Unlock(PlayerSkills.Jump);
            player.Unlock(PlayerSkills.DoubleJump);
            player.Unlock(PlayerSkills.WallJump);
            //player.Unlock(PlayerSkills.Ascend);
            player.Unlock(PlayerSkills.Block);
            player.Unlock(PlayerSkills.Parry);

            player.Equip(new Sword(player));

            // TODO: Load fragments from a save slot.
            scene.Add(player);

            var fragment = scene.LoadFragment("Demo.json");

            //var fragment = scene.LoadFragment("Windmill.json");
            player.Position = fragment.Origin + fragment.Spawn;

            CreateDebugCubes();

            camera.Attach(new FollowView(camera, player, settings));

            // TODO: Initialize renderer settings from a configuration file (based on user settings).
            // TODO: Set light color and direction based on time of day and weather.
            var renderer = scene.Renderer;

            renderer.Light.Direction = Utilities.Normalize(new vec3(-2, -0.75f, 2));

            renderTargetUsers3D.Add(renderer);

            // Create visualizers.
            spaceVisualizer            = new SpaceVisualizer(camera, space);
            jitterVisualizer           = new JitterVisualizer(camera, world);
            jitterVisualizer.IsEnabled = true;

            MessageSystem.Subscribe(this, CoreMessageTypes.Keyboard, (messageType, data, dt) =>
            {
                ProcessKeyboard((KeyboardData)data);
            });
        }
コード例 #2
0
ファイル: SpaceVisualizer.cs プロジェクト: dag10/HoloDrink
 // Functions
 private void Awake()
 {
     Instance = this;
 }
コード例 #3
0
 // Functions
 private void Awake()
 {
     Instance = this;
 }