Ejemplo n.º 1
0
 public void PlayFootStep()
 {
     AkSoundEngine.PostEvent("Steps_E", this.gameObject);
 }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     AkSoundEngine.PostEvent("Rat_Hit", gameObject);
 }
Ejemplo n.º 3
0
    public void ChangeScene()
    {
        if (SceneManager.GetActiveScene().name == "Gameplay")
        {
            Destroy(GameManager.Get().gameObject);
            Destroy(WaveSystem.Get().gameObject);
            Destroy(TurretSpawner.Get().gameObject);
            Destroy(Highscore.Get().gameObject);
            Destroy(MilestoneManager.Get().gameObject);

            UpgradeSystem upgrades = UpgradeSystem.Get();

            if (upgrades)
            {
                upgrades.CleanList();
            }

            AkSoundEngine.StopAll();
        }
        else if (SceneManager.GetActiveScene().name == "Upgrade Screen")
        {
            AkSoundEngine.StopAll();
        }

        if (sceneName == "Upgrade Screen")
        {
            AkSoundEngine.StopAll();

            UpgradeSystem upgrades = UpgradeSystem.Get();

            if (upgrades)
            {
                upgrades.CleanList();
            }

            int goToTutorial = PlayerPrefs.GetInt("isFirstTimePlaying", 1);

            if (goToTutorial == 1)
            {
                SceneManager.LoadScene("Tutorial");
            }
            else if (goToTutorial == 0)
            {
                SceneManager.LoadScene(sceneName);
            }
        }
        else if (sceneName == "Gameplay")
        {
            AkSoundEngine.StopAll();
            UpgradeSystem upgrades = UpgradeSystem.Get();

            if (upgrades)
            {
                upgrades.CleanList();
            }

            int goToTutorial = PlayerPrefs.GetInt("isFirstTimePlaying", 1);

            if (goToTutorial == 1)
            {
                SceneManager.LoadScene("Tutorial");
            }
            else if (goToTutorial == 0)
            {
                LoaderManager.Get().LoadScene(sceneName);
                UILoadingScreen.Get().SetVisible(true);
            }
        }
        else
        {
            SceneManager.LoadScene(sceneName);
        }

        Time.timeScale = 1;
    }
Ejemplo n.º 4
0
 public void CleanUp()
 {
     AkSoundEngine.UnloadBank(__soundBank, (System.IntPtr)__bankID);
 }
Ejemplo n.º 5
0
 public void PlayBoth(string name)
 {
     AkSoundEngine.PostEvent(name + "_J1", gameObject);
     AkSoundEngine.PostEvent(name + "_J2", gameObject);
 }
Ejemplo n.º 6
0
 /*
  * Initialize attack and decay times
  */
 void Start()
 {
     AkSoundEngine.SetRTPCValue(attack, 0.0f);
     AkSoundEngine.SetRTPCValue(decay, 100.0f);
 }
Ejemplo n.º 7
0
     // Start is called before the first frame update
     void Start()
     
 {
             AkSoundEngine.RegisterGameObj(gameObject);
         
 }
Ejemplo n.º 8
0
 public void PlayEnter()
 {
     AkSoundEngine.PostEvent(enterEv, gameObject);
 }
Ejemplo n.º 9
0
 public void PlayExit()
 {
     AkSoundEngine.PostEvent(exitEv, gameObject);
 }
Ejemplo n.º 10
0
 public void PlayClick()
 {
     AkSoundEngine.PostEvent(clickEv, gameObject);
 }
Ejemplo n.º 11
0
 public void PlayHover()
 {
     AkSoundEngine.PostEvent(hoverEv, gameObject);
 }
Ejemplo n.º 12
0
 protected override void DoEffect(PlayerController user)
 {
     if (user.HasPickupID(289))
     {
         if (UnityEngine.Random.value > .25f)
         {
             GoodEffectActive = true;
             AkSoundEngine.PostEvent("Play_WPN_radgun_noice_01", base.gameObject);
             if (user.HasPickupID(Gungeon.Game.Items["nn:lump_of_space_metal"].PickupObjectId) || user.HasPickupID(Gungeon.Game.Items["nn:loose_change"].PickupObjectId) || user.HasPickupID(214) || user.HasPickupID(272) || user.HasPickupID(614) || user.HasPickupID(397))
             {
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
             }
             StartGoodEffect(user);
             StartCoroutine(ItemBuilder.HandleDuration(this, duration, user, EndGoodEffect));
             //ETGModConsole.Log("Lucky Coin has given you the positive effect, and thinks you have the Seven Leaf Clover");
         }
         else
         {
             BadEffectActive = true;
             AkSoundEngine.PostEvent("Play_WPN_radgun_wack_01", base.gameObject);
             StartBadEffect(user);
             StartCoroutine(ItemBuilder.HandleDuration(this, duration, user, EndBadEffect));
             //ETGModConsole.Log("Lucky Coin has given you the negative effect, and thinks you have the Seven Leaf Clover");
         }
     }
     else
     {
         if (UnityEngine.Random.value < .5f)
         {
             GoodEffectActive = true;
             AkSoundEngine.PostEvent("Play_WPN_radgun_noice_01", base.gameObject);
             if (user.HasPickupID(Gungeon.Game.Items["nn:lump_of_space_metal"].PickupObjectId) || user.HasPickupID(Gungeon.Game.Items["nn:loose_change"].PickupObjectId) || user.HasPickupID(214) || user.HasPickupID(272) || user.HasPickupID(614) || user.HasPickupID(397))
             {
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
                 LootEngine.SpawnItem(PickupObjectDatabase.GetById(68).gameObject, user.specRigidbody.UnitCenter, Vector2.zero, 1f, false, true, false);
             }
             StartGoodEffect(user);
             StartCoroutine(ItemBuilder.HandleDuration(this, duration, user, EndGoodEffect));
             //ETGModConsole.Log("Lucky Coin has given you the positive effect.");
         }
         else
         {
             BadEffectActive = true;
             AkSoundEngine.PostEvent("Play_WPN_radgun_wack_01", base.gameObject);
             StartBadEffect(user);
             StartCoroutine(ItemBuilder.HandleDuration(this, duration, user, EndBadEffect));
             //ETGModConsole.Log("Lucky Coin has given you the negative effect.");
         }
     }
 }
Ejemplo n.º 13
0
    public void Initialize()
    {
        if (ms_Instance != null)
        {
            //Don't init twice
            //Check if there are 2 objects with this script.  If yes, remove this component.
            if (ms_Instance != this)
            {
                UnityEngine.Object.DestroyImmediate(this.gameObject);
            }
            return;
        }

        Debug.Log("WwiseUnity: Initialize sound engine ...");

        //Use default properties for most SoundEngine subsystem.
        //The game programmer should modify these when needed.  See the Wwise SDK documentation for the initialization.
        //These settings may very well change for each target platform.
        AkMemSettings memSettings = new AkMemSettings();

        memSettings.uMaxNumPools = 20;

        AkDeviceSettings deviceSettings = new AkDeviceSettings();

        AkSoundEngine.GetDefaultDeviceSettings(deviceSettings);

        AkStreamMgrSettings streamingSettings = new AkStreamMgrSettings();

        streamingSettings.uMemorySize = (uint)streamingPoolSize * 1024;

        AkInitSettings initSettings = new AkInitSettings();

        AkSoundEngine.GetDefaultInitSettings(initSettings);
        initSettings.uDefaultPoolSize = (uint)defaultPoolSize * 1024;

        AkPlatformInitSettings platformSettings = new AkPlatformInitSettings();

        AkSoundEngine.GetDefaultPlatformInitSettings(platformSettings);
        platformSettings.uLEngineDefaultPoolSize           = (uint)lowerPoolSize * 1024;
        platformSettings.fLEngineDefaultPoolRatioThreshold = memoryCutoffThreshold;

        AkMusicSettings musicSettings = new AkMusicSettings();

        AkSoundEngine.GetDefaultMusicSettings(musicSettings);

// Unity 5 only, UNity 4 doesn't provide a way to access the product name at runtime.
#if UNITY_5
#if UNITY_EDITOR
        AkSoundEngine.SetGameName(Application.productName + " (Editor)");
#else
        AkSoundEngine.SetGameName(Application.productName);
#endif
#endif

        AKRESULT result = AkSoundEngine.Init(memSettings, streamingSettings, deviceSettings, initSettings, platformSettings, musicSettings, (uint)preparePoolSize * 1024);
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort.");
            return; //AkSoundEngine.Init should have logged more details.
        }

        ms_Instance = this;

        string basePathToSet = AkBasePathGetter.GetValidBasePath();
        if (string.IsNullOrEmpty(basePathToSet))
        {
            return;
        }

        result = AkSoundEngine.SetBasePath(basePathToSet);
        if (result != AKRESULT.AK_Success)
        {
            return;
        }

        AkSoundEngine.SetCurrentLanguage(language);

        result = AkCallbackManager.Init();
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine.");
            AkSoundEngine.Term();
            ms_Instance = null;
            return;
        }

        AkBankManager.Reset();

        Debug.Log("WwiseUnity: Sound engine initialized.");

        //The sound engine should not be destroyed once it is initialized.
        DontDestroyOnLoad(this);

#if UNITY_EDITOR
        //Redirect Wwise error messages into Unity console.
        AkCallbackManager.SetMonitoringCallback(ErrorLevel.ErrorLevel_All, CopyMonitoringInConsole);
#endif

        //Load the init bank right away.  Errors will be logged automatically.
        uint BankID;
        result = AkSoundEngine.LoadBank("Init.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + result.ToString());
        }

#if UNITY_EDITOR
        EditorApplication.playmodeStateChanged += OnEditorPlaymodeStateChanged;
#endif
    }
Ejemplo n.º 14
0
 public void PlayIdle()
 {
     AkSoundEngine.PostEvent("Enemy_Idle", this.gameObject);
 }
Ejemplo n.º 15
0
 private void PlayJumpSound()
 {
     AkSoundEngine.PostEvent("Jump", gameObject);
 }
Ejemplo n.º 16
0
 void Start()
 {
     AkSoundEngine.PostEvent("Play_music", gameObject);
 }
Ejemplo n.º 17
0
        public override void Bind(Entity entity, Main main, bool creating = false)
        {
            Main.Config settings  = main.Settings;
            Transform   transform = entity.GetOrCreate <Transform>("Transform");

            entity.CannotSuspend = true;

            PlayerFactory.Instance = entity;

            this.SetMain(entity, main);

            FPSInput input = new FPSInput();

            input.EnabledWhenPaused = false;
            entity.Add("Input", input);

            Updater parkour = entity.Create <Updater>();
            Updater jumper  = entity.Create <Updater>();

            Player player = entity.GetOrCreate <Player>("Player");

            AnimatedModel firstPersonModel = entity.GetOrCreate <AnimatedModel>("FirstPersonModel");

            firstPersonModel.MapContent            = false;
            firstPersonModel.Serialize             = false;
            firstPersonModel.Filename.Value        = "Models\\joan-firstperson";
            firstPersonModel.CullBoundingBox.Value = false;

            AnimatedModel model = entity.GetOrCreate <AnimatedModel>("Model");

            model.MapContent            = false;
            model.Serialize             = false;
            model.Filename.Value        = "Models\\joan";
            model.CullBoundingBox.Value = false;

            AnimationController anim      = entity.GetOrCreate <AnimationController>("AnimationController");
            RotationController  rotation  = entity.GetOrCreate <RotationController>("Rotation");
            BlockPredictor      predictor = entity.GetOrCreate <BlockPredictor>("BlockPredictor");
            Jump          jump            = entity.GetOrCreate <Jump>("Jump");
            RollKickSlide rollKickSlide   = entity.GetOrCreate <RollKickSlide>("RollKickSlide");
            Vault         vault           = entity.GetOrCreate <Vault>("Vault");
            WallRun       wallRun         = entity.GetOrCreate <WallRun>("WallRun");
            VoxelTools    voxelTools      = entity.GetOrCreate <VoxelTools>("VoxelTools");
            Footsteps     footsteps       = entity.GetOrCreate <Footsteps>("Footsteps");
            FallDamage    fallDamage      = entity.GetOrCreate <FallDamage>("FallDamage");
            FPSCamera     fpsCamera       = entity.GetOrCreate <FPSCamera>("FPSCamera");

            fpsCamera.Enabled.Value = false;
            Rumble           rumble        = entity.GetOrCreate <Rumble>("Rumble");
            CameraController cameraControl = entity.GetOrCreate <CameraController>("CameraControl");

            Property <Vector3> floor = new Property <Vector3>();

            transform.Add(new Binding <Vector3>(floor, () => transform.Position + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height));
            Sound.AttachTracker(entity, floor);

            predictor.Add(new Binding <Vector3>(predictor.FootPosition, floor));
            predictor.Add(new Binding <Vector3>(predictor.LinearVelocity, player.Character.LinearVelocity));
            predictor.Add(new Binding <float>(predictor.Rotation, rotation.Rotation));
            predictor.Add(new Binding <float>(predictor.MaxSpeed, player.Character.MaxSpeed));
            predictor.Add(new Binding <float>(predictor.JumpSpeed, player.Character.JumpSpeed));
            predictor.Add(new Binding <bool>(predictor.IsSupported, player.Character.IsSupported));

            jump.Add(new Binding <bool>(jump.Crouched, player.Character.Crouched));
            jump.Add(new TwoWayBinding <bool>(player.Character.IsSupported, jump.IsSupported));
            jump.Add(new TwoWayBinding <bool>(player.Character.HasTraction, jump.HasTraction));
            jump.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, jump.LinearVelocity));
            jump.Add(new TwoWayBinding <BEPUphysics.Entities.Entity>(jump.SupportEntity, player.Character.SupportEntity));
            jump.Add(new TwoWayBinding <Vector3>(jump.SupportVelocity, player.Character.SupportVelocity));
            jump.Add(new Binding <Vector2>(jump.AbsoluteMovementDirection, player.Character.MovementDirection));
            jump.Add(new Binding <WallRun.State>(jump.WallRunState, wallRun.CurrentState));
            jump.Add(new Binding <float>(jump.Rotation, rotation.Rotation));
            jump.Add(new Binding <Vector3>(jump.Position, transform.Position));
            jump.Add(new Binding <Vector3>(jump.FloorPosition, floor));
            jump.Add(new Binding <float>(jump.MaxSpeed, player.Character.MaxSpeed));
            jump.Add(new Binding <float>(jump.JumpSpeed, player.Character.JumpSpeed));
            jump.Add(new Binding <float>(jump.Mass, player.Character.Mass));
            jump.Add(new Binding <float>(jump.LastRollKickEnded, rollKickSlide.LastRollKickEnded));
            jump.Add(new Binding <Voxel>(jump.WallRunMap, wallRun.WallRunVoxel));
            jump.Add(new Binding <Direction>(jump.WallDirection, wallRun.WallDirection));
            jump.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(jump.WalkedOn, footsteps.WalkedOn));
            jump.Add(new CommandBinding(jump.DeactivateWallRun, (Action)wallRun.Deactivate));
            jump.Add(new CommandBinding <float>(jump.FallDamage, fallDamage.ApplyJump));
            jump.Predictor = predictor;
            jump.Bind(model);
            jump.Add(new TwoWayBinding <Voxel>(wallRun.LastWallRunMap, jump.LastWallRunMap));
            jump.Add(new TwoWayBinding <Direction>(wallRun.LastWallDirection, jump.LastWallDirection));
            jump.Add(new TwoWayBinding <bool>(rollKickSlide.CanKick, jump.CanKick));
            jump.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, jump.LastSupportedSpeed));

            wallRun.Add(new Binding <bool>(wallRun.IsSwimming, player.Character.IsSwimming));
            wallRun.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, wallRun.LinearVelocity));
            wallRun.Add(new TwoWayBinding <Vector3>(transform.Position, wallRun.Position));
            wallRun.Add(new TwoWayBinding <bool>(player.Character.IsSupported, wallRun.IsSupported));
            wallRun.Add(new CommandBinding(wallRun.LockRotation, (Action)rotation.Lock));
            wallRun.Add(new CommandBinding <float>(wallRun.UpdateLockedRotation, rotation.UpdateLockedRotation));
            vault.Add(new CommandBinding(wallRun.Vault, delegate() { vault.Go(true); }));
            wallRun.Predictor = predictor;
            wallRun.Add(new Binding <float>(wallRun.Height, player.Character.Height));
            wallRun.Add(new Binding <float>(wallRun.JumpSpeed, player.Character.JumpSpeed));
            wallRun.Add(new Binding <float>(wallRun.MaxSpeed, player.Character.MaxSpeed));
            wallRun.Add(new TwoWayBinding <float>(rotation.Rotation, wallRun.Rotation));
            wallRun.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, wallRun.AllowUncrouch));
            wallRun.Add(new TwoWayBinding <bool>(player.Character.HasTraction, wallRun.HasTraction));
            wallRun.Add(new Binding <float>(wallRun.LastWallJump, jump.LastWallJump));
            wallRun.Add(new Binding <float>(player.Character.LastSupportedSpeed, wallRun.LastSupportedSpeed));
            player.Add(new Binding <WallRun.State>(player.Character.WallRunState, wallRun.CurrentState));

            input.Bind(rollKickSlide.RollKickButton, settings.RollKick);
            rollKickSlide.Add(new Binding <bool>(rollKickSlide.EnableCrouch, player.EnableCrouch));
            rollKickSlide.Add(new Binding <float>(rollKickSlide.Rotation, rotation.Rotation));
            rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSwimming, player.Character.IsSwimming));
            rollKickSlide.Add(new Binding <bool>(rollKickSlide.IsSupported, player.Character.IsSupported));
            rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.FloorPosition, floor));
            rollKickSlide.Add(new Binding <float>(rollKickSlide.Height, player.Character.Height));
            rollKickSlide.Add(new Binding <float>(rollKickSlide.MaxSpeed, player.Character.MaxSpeed));
            rollKickSlide.Add(new Binding <float>(rollKickSlide.JumpSpeed, player.Character.JumpSpeed));
            rollKickSlide.Add(new Binding <Vector3>(rollKickSlide.SupportVelocity, player.Character.SupportVelocity));
            rollKickSlide.Add(new TwoWayBinding <bool>(wallRun.EnableEnhancedWallRun, rollKickSlide.EnableEnhancedRollSlide));
            rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, rollKickSlide.AllowUncrouch));
            rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.Crouched, rollKickSlide.Crouched));
            rollKickSlide.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, rollKickSlide.EnableWalking));
            rollKickSlide.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, rollKickSlide.LinearVelocity));
            rollKickSlide.Add(new TwoWayBinding <Vector3>(transform.Position, rollKickSlide.Position));
            rollKickSlide.Predictor = predictor;
            rollKickSlide.Bind(model);
            rollKickSlide.VoxelTools = voxelTools;
            rollKickSlide.Add(new CommandBinding(rollKickSlide.DeactivateWallRun, (Action)wallRun.Deactivate));
            rollKickSlide.Add(new CommandBinding(rollKickSlide.Footstep, footsteps.Footstep));
            rollKickSlide.Add(new CommandBinding(rollKickSlide.LockRotation, (Action)rotation.Lock));
            SoundKiller.Add(entity, AK.EVENTS.STOP_PLAYER_SLIDE_LOOP);

            vault.Add(new Binding <Vector3>(vault.Position, transform.Position));
            vault.Add(new Binding <Vector3>(vault.FloorPosition, floor));
            vault.Add(new Binding <float>(vault.MaxSpeed, player.Character.MaxSpeed));
            vault.Add(new Binding <WallRun.State>(vault.WallRunState, wallRun.CurrentState));
            vault.Add(new CommandBinding(vault.LockRotation, (Action)rotation.Lock));
            vault.Add(new CommandBinding(vault.DeactivateWallRun, (Action)wallRun.Deactivate));
            vault.Add(new TwoWayBinding <float>(player.Character.LastSupportedSpeed, vault.LastSupportedSpeed));
            vault.Add(new CommandBinding <float>(vault.FallDamage, fallDamage.Apply));
            vault.Bind(model);
            vault.Predictor = predictor;
            vault.Add(new TwoWayBinding <float>(rotation.Rotation, vault.Rotation));
            vault.Add(new TwoWayBinding <bool>(player.Character.IsSupported, vault.IsSupported));
            vault.Add(new TwoWayBinding <bool>(player.Character.HasTraction, vault.HasTraction));
            vault.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, vault.LinearVelocity));
            vault.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, vault.EnableWalking));
            vault.Add(new TwoWayBinding <bool>(player.Character.AllowUncrouch, vault.AllowUncrouch));
            vault.Add(new TwoWayBinding <bool>(player.Character.Crouched, vault.Crouched));
            vault.Add(new Binding <float>(vault.Radius, player.Character.Radius));

            rotation.Add(new TwoWayBinding <Vector2>(rotation.Mouse, input.Mouse));
            rotation.Add(new Binding <bool>(rotation.Rolling, rollKickSlide.Rolling));
            rotation.Add(new Binding <bool>(rotation.Kicking, rollKickSlide.Kicking));
            rotation.Add(new Binding <Vault.State>(rotation.VaultState, vault.CurrentState));
            rotation.Add(new Binding <WallRun.State>(rotation.WallRunState, wallRun.CurrentState));

            voxelTools.Add(new Binding <float>(voxelTools.Height, player.Character.Height));
            voxelTools.Add(new Binding <float>(voxelTools.SupportHeight, player.Character.SupportHeight));
            voxelTools.Add(new Binding <Vector3>(voxelTools.Position, transform.Position));

            anim.Add(new Binding <bool>(anim.IsSupported, player.Character.IsSupported));
            anim.Add(new Binding <WallRun.State>(anim.WallRunState, wallRun.CurrentState));
            anim.Add(new Binding <bool>(anim.EnableWalking, player.Character.EnableWalking));
            anim.Add(new Binding <bool>(anim.Crouched, player.Character.Crouched));
            anim.Add(new Binding <Vector3>(anim.LinearVelocity, player.Character.LinearVelocity));
            anim.Add(new Binding <Vector2>(anim.Movement, input.Movement));
            anim.Add(new Binding <Vector2>(anim.Mouse, input.Mouse));
            anim.Add(new Binding <float>(anim.Rotation, rotation.Rotation));
            anim.Add(new Binding <Voxel>(anim.WallRunMap, wallRun.WallRunVoxel));
            anim.Add(new Binding <Direction>(anim.WallDirection, wallRun.WallDirection));
            anim.Add(new Binding <bool>(anim.IsSwimming, player.Character.IsSwimming));
            anim.Add(new Binding <bool>(anim.Kicking, rollKickSlide.Kicking));
            anim.Add(new Binding <Vector3>(anim.SupportVelocity, player.Character.SupportVelocity));
            anim.Add
            (
                new Binding <bool>
                (
                    anim.EnableLean,
                    () => player.Character.EnableWalking.Value && player.Character.IsSupported.Value && input.Movement.Value.Y > 0.5f,
                    player.Character.EnableWalking, player.Character.IsSupported, input.Movement
                )
            );
            anim.Bind(model);

            // Camera control
            model.UpdateWorldTransforms();

            cameraControl.Add(new Binding <Vector2>(cameraControl.Mouse, input.Mouse));
            cameraControl.Add(new Binding <float>(cameraControl.Lean, x => x * (float)Math.PI * 0.05f, anim.Lean));
            cameraControl.Add(new Binding <Vector3>(cameraControl.LinearVelocity, player.Character.LinearVelocity));
            cameraControl.Add(new Binding <float>(cameraControl.MaxSpeed, player.Character.MaxSpeed));
            cameraControl.Add(new Binding <Matrix>(cameraControl.CameraBone, model.GetBoneTransform("Camera")));
            cameraControl.Add(new Binding <Matrix>(cameraControl.HeadBone, model.GetBoneTransform("ORG-head")));
            cameraControl.Add(new Binding <Matrix>(cameraControl.ModelTransform, model.Transform));
            cameraControl.Add(new Binding <float>(cameraControl.BaseCameraShakeAmount, () => MathHelper.Clamp((player.Character.LinearVelocity.Value.Length() - (player.Character.MaxSpeed * 2.5f)) / (player.Character.MaxSpeed * 4.0f), 0, 1), player.Character.LinearVelocity, player.Character.MaxSpeed));
            cameraControl.Offset = model.GetBoneTransform("Camera").Value.Translation - model.GetBoneTransform("ORG-head").Value.Translation;

            float heightOffset = 0.1f;

#if VR
            if (main.VR)
            {
                heightOffset = 0.4f;
            }
#endif
            cameraControl.Offset += new Vector3(0, heightOffset, 0);

            rumble.Add(new Binding <float>(rumble.CameraShake, cameraControl.TotalCameraShake));
            rumble.Add(new CommandBinding <float>(fallDamage.Rumble, rumble.Go));
            rumble.Add(new CommandBinding <float>(player.Rumble, rumble.Go));
            rumble.Add(new CommandBinding <float>(rollKickSlide.Rumble, rumble.Go));

            firstPersonModel.Add(new Binding <bool>(firstPersonModel.Enabled, x => !x, cameraControl.ThirdPerson));

            model.Add(new ChangeBinding <bool>(cameraControl.ThirdPerson, delegate(bool old, bool value)
            {
                if (value && !old)
                {
                    model.UnsupportedTechniques.Remove(Technique.Clip);
                    model.UnsupportedTechniques.Remove(Technique.Render);
                }
                else if (old && !value)
                {
                    model.UnsupportedTechniques.Add(Technique.Clip);
                    model.UnsupportedTechniques.Add(Technique.Render);
                }
            }));

            Lemma.Console.Console.AddConCommand(new Console.ConCommand("third_person", "Toggle third-person view (WARNING: EXPERIMENTAL)", delegate(Console.ConCommand.ArgCollection args)
            {
                cameraControl.ThirdPerson.Value = !cameraControl.ThirdPerson;
            }));
            entity.Add(new CommandBinding(entity.Delete, delegate()
            {
                Lemma.Console.Console.RemoveConCommand("third_person");
            }));

            // When rotation is locked, we want to make sure the player can't turn their head
            // 180 degrees from the direction they're facing

#if VR
            if (main.VR)
            {
                input.MaxY.Value = input.MinY.Value = 0;
            }
            else
#endif
            input.Add(new Binding <float>(input.MaxY, () => rotation.Locked ? (float)Math.PI * 0.3f : (float)Math.PI * 0.4f, rotation.Locked));

            input.Add(new Binding <float>(input.MinX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * -0.4f) : 0.0f, rotation.Rotation, rotation.Locked));
            input.Add(new Binding <float>(input.MaxX, () => rotation.Locked ? rotation.Rotation + ((float)Math.PI * 0.4f) : 0.0f, rotation.Rotation, rotation.Locked));
            input.Add(new NotifyBinding(delegate() { input.Mouse.Changed(); }, rotation.Locked));             // Make sure the rotation locking takes effect even if the player doesn't move the mouse

            // Setup rendering properties

            model.Materials = firstPersonModel.Materials = new Model.Material[3];

            // Hoodie and shoes
            model.Materials[0] = new Model.Material
            {
                SpecularIntensity = 0.0f,
                SpecularPower     = 1.0f,
            };

            // Hands
            model.Materials[1] = new Model.Material
            {
                SpecularIntensity = 0.3f,
                SpecularPower     = 2.0f,
            };

            // Pants and skin
            model.Materials[2] = new Model.Material
            {
                SpecularIntensity = 0.5f,
                SpecularPower     = 20.0f,
            };

            firstPersonModel.Bind(model);

            // Third person model only gets rendered for shadows. No regular rendering or reflections.
            model.UnsupportedTechniques.Add(Technique.Clip);
            model.UnsupportedTechniques.Add(Technique.Render);

            // First-person model only used for regular rendering. No shadows or reflections.
            firstPersonModel.UnsupportedTechniques.Add(Technique.Shadow);
            firstPersonModel.UnsupportedTechniques.Add(Technique.Clip);

            // Build UI
            UIRenderer ui = new UIRenderer();
            ui.DrawOrder.Value   = -1;
            ui.EnabledWhenPaused = true;
            ui.EnabledInEditMode = false;
            entity.Add("UI", ui);

            input.Add(new Binding <float>(input.MouseSensitivity, settings.MouseSensitivity));
            input.Add(new Binding <bool>(input.InvertMouseX, settings.InvertMouseX));
            input.Add(new Binding <bool>(input.InvertMouseY, settings.InvertMouseY));
            input.Add(new Binding <PCInput.PCInputBinding>(input.LeftKey, settings.Left));
            input.Add(new Binding <PCInput.PCInputBinding>(input.RightKey, settings.Right));
            input.Add(new Binding <PCInput.PCInputBinding>(input.BackwardKey, settings.Backward));
            input.Add(new Binding <PCInput.PCInputBinding>(input.ForwardKey, settings.Forward));

            model.StartClip("Idle", 0, true, AnimatedModel.DefaultBlendTime);

            // Set up AI agent
            Agent agent = entity.GetOrCreate <Agent>();
            agent.Add(new TwoWayBinding <float>(player.Health, agent.Health));
            agent.Add(new Binding <Vector3>(agent.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height * -0.5f, 0), transform.Position, player.Character.Height));
            agent.Add(new Binding <bool>(agent.Loud, () => player.Character.MovementDirection.Value.LengthSquared() > 0 && !player.Character.Crouched, player.Character.Crouched));

            // Blocks
            BlockCloud blockCloud = entity.GetOrCreate <BlockCloud>("BlockCloud");
            blockCloud.Scale.Value = 0.5f;
            blockCloud.Add(new Binding <Vector3>(blockCloud.Position, () => transform.Position.Value + new Vector3(0, player.Character.Height * 0.5f + player.Character.LinearVelocity.Value.Y, 0), transform.Position, player.Character.Height, player.Character.LinearVelocity));
            blockCloud.Blocks.ItemAdded += delegate(int index, Entity.Handle block)
            {
                Entity e = block.Target;
                if (e != null)
                {
                    e.Serialize = false;
                    PhysicsBlock.CancelPlayerCollisions(e.Get <PhysicsBlock>());
                }
            };
            predictor.Add(new Binding <Voxel.t>(predictor.BlockType, blockCloud.Type));

            PointLight blockLight = entity.Create <PointLight>();
            blockLight.Add(new Binding <Vector3>(blockLight.Position, blockCloud.AveragePosition));
            blockLight.Add(new Binding <bool, int>(blockLight.Enabled, x => x > 0, blockCloud.Blocks.Length));
            blockLight.Attenuation.Value = 30.0f;
            blockLight.Add(new Binding <Vector3, Voxel.t>(blockLight.Color, delegate(Voxel.t t)
            {
                switch (t)
                {
                case Voxel.t.GlowBlue:
                    return(new Vector3(0.7f, 0.7f, 0.9f));

                case Voxel.t.GlowYellow:
                    return(new Vector3(0.9f, 0.9f, 0.7f));

                default:
                    return(new Vector3(0.8f, 0.8f, 0.8f));
                }
            }, blockCloud.Type));

            blockLight.Add(new ChangeBinding <bool>(blockLight.Enabled, delegate(bool old, bool value)
            {
                if (!old && value)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_MAGIC_CUBE_LOOP, entity);
                }
                else if (old && !value)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.STOP_MAGIC_CUBE_LOOP, entity);
                }
            }));
            if (blockLight.Enabled)
            {
                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_MAGIC_CUBE_LOOP, entity);
            }

            // Death
            entity.Add(new CommandBinding(player.Die, blockCloud.Clear));
            entity.Add(new CommandBinding(player.Die, delegate()
            {
                Session.Recorder.Event(main, "Die");
                if (agent.Killed || Agent.Query(transform.Position, 0.0f, 10.0f, x => x != agent) != null)
                {
                    Session.Recorder.Event(main, "Killed");
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_DEATH, entity);
                    main.Spawner.RespawnDistance = Spawner.KilledRespawnDistance;
                    main.Spawner.RespawnInterval = Spawner.KilledRespawnInterval;
                }
                entity.Add(new Animation(new Animation.Execute(entity.Delete)));
            }));

            player.EnabledInEditMode = false;

            player.Add(new TwoWayBinding <Matrix>(transform.Matrix, player.Character.Transform));

            model.Add(new Binding <Matrix>(model.Transform, delegate()
            {
                const float leanAmount = (float)Math.PI * 0.1f;
                return(Matrix.CreateTranslation(0, (player.Character.Height * -0.5f) - player.Character.SupportHeight, 0) * Matrix.CreateRotationZ(anim.Lean * leanAmount) * Matrix.CreateRotationY(rotation.Rotation) * transform.Matrix);
            }, transform.Matrix, rotation.Rotation, player.Character.Height, player.Character.SupportHeight, anim.Lean));

            firstPersonModel.Add(new Binding <Matrix>(firstPersonModel.Transform, model.Transform));
            firstPersonModel.Add(new Binding <Vector3>(firstPersonModel.Scale, model.Scale));

            WallRun.State[] footstepWallrunStates = new[]
            {
                WallRun.State.Left,
                WallRun.State.Right,
                WallRun.State.Straight,
                WallRun.State.None,
            };
            footsteps.Add(new Binding <bool>(footsteps.SoundEnabled, () => !player.Character.Crouched && footstepWallrunStates.Contains(wallRun.CurrentState) || (player.Character.IsSupported && player.Character.EnableWalking), player.Character.IsSupported, player.Character.EnableWalking, wallRun.CurrentState, player.Character.Crouched));
            footsteps.Add(new Binding <Vector3>(footsteps.Position, transform.Position));
            footsteps.Add(new Binding <float>(footsteps.Rotation, rotation.Rotation));
            footsteps.Add(new Binding <float>(footsteps.CharacterHeight, player.Character.Height));
            footsteps.Add(new Binding <float>(footsteps.SupportHeight, player.Character.SupportHeight));
            footsteps.Add(new Binding <bool>(footsteps.IsSupported, player.Character.IsSupported));
            footsteps.Add(new Binding <bool>(footsteps.IsSwimming, player.Character.IsSwimming));
            footsteps.Add(new CommandBinding <float>(footsteps.Damage, agent.Damage));
            footsteps.Add(new CommandBinding <Voxel, Voxel.Coord, Direction>(wallRun.WalkedOn, footsteps.WalkedOn));
            model.Trigger("Run", 0.16f, footsteps.Footstep);
            model.Trigger("Run", 0.58f, footsteps.Footstep);
            model.Trigger("WallRunLeft", 0.16f, footsteps.Footstep);
            model.Trigger("WallRunLeft", 0.58f, footsteps.Footstep);
            model.Trigger("WallRunRight", 0.16f, footsteps.Footstep);
            model.Trigger("WallRunRight", 0.58f, footsteps.Footstep);
            model.Trigger("WallRunStraight", 0.16f, footsteps.Footstep);
            model.Trigger("WallRunStraight", 0.58f, footsteps.Footstep);
            model.Trigger("TurnLeft", 0.15f, footsteps.Footstep);
            model.Trigger("TurnRight", 0.15f, footsteps.Footstep);
            model.Trigger("TopOut", 1.0f, new Command
            {
                Action = delegate()
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_GRUNT, entity);
                }
            });

            main.UI.IsMouseVisible.Value = false;

            SkinnedModel.Clip sprintAnimation = model["Sprint"], runAnimation = model["Run"];

            // Movement binding
            player.Add(new Binding <Vector2>(player.Character.MovementDirection, delegate()
            {
                Vector2 movement = input.Movement;
                if (movement.LengthSquared() == 0.0f)
                {
                    return(Vector2.Zero);
                }

                Matrix matrix = Matrix.CreateRotationY(rotation.Rotation);

                Vector2 forwardDir = new Vector2(matrix.Forward.X, matrix.Forward.Z);
                Vector2 rightDir   = new Vector2(matrix.Right.X, matrix.Right.Z);
                return(-(forwardDir * movement.Y) - (rightDir * movement.X));
            }, input.Movement, rotation.Rotation));

            player.Character.Crouched.Value      = true;
            player.Character.AllowUncrouch.Value = true;

            // Fall damage
            fallDamage.Add(new Binding <bool>(fallDamage.IsSupported, player.Character.IsSupported));
            fallDamage.Add(new TwoWayBinding <Vector3>(player.Character.LinearVelocity, fallDamage.LinearVelocity));
            fallDamage.Add(new TwoWayBinding <float>(player.Health, fallDamage.Health));
            fallDamage.Add(new CommandBinding <BEPUphysics.BroadPhaseEntries.Collidable, ContactCollection>(player.Character.Collided, fallDamage.Collided));
            fallDamage.Add(new TwoWayBinding <bool>(player.Character.EnableWalking, fallDamage.EnableWalking));
            fallDamage.Add(new TwoWayBinding <bool>(player.EnableMoves, fallDamage.EnableMoves));
            fallDamage.Add(new TwoWayBinding <bool>(fallDamage.Landing, rotation.Landing));
            fallDamage.Add(new CommandBinding(fallDamage.LockRotation, (Action)rotation.Lock));
            fallDamage.Add(new CommandBinding <float>(fallDamage.PhysicsDamage, agent.Damage));
            fallDamage.Bind(model);

            // Swim up
            input.Bind(player.Character.SwimUp, settings.Jump);

            float parkourTime = 0;
            float jumpTime = 0;
            jumper.Action = delegate(float dt)
            {
                if (player.EnableMoves && player.Character.EnableWalking &&
                    vault.CurrentState.Value == Vault.State.None &&
                    !rollKickSlide.Rolling && !rollKickSlide.Kicking &&
                    jumpTime < Player.SlowmoTime)
                {
                    if (jump.Go())
                    {
                        parkour.Enabled.Value = false;
                        jumper.Enabled.Value  = false;
                    }
                    jumpTime += dt;
                }
                else
                {
                    jumper.Enabled.Value = false;
                }
            };
            jumper.Add(new CommandBinding(jumper.Enable, delegate() { jumpTime = 0; }));
            jumper.Enabled.Value = false;
            entity.Add(jumper);

            // Jumping
            input.Bind(settings.Jump, PCInput.InputState.Down, delegate()
            {
                jumper.Enabled.Value = true;
            });

            input.Bind(settings.Jump, PCInput.InputState.Up, delegate()
            {
                jumper.Enabled.Value = false;
            });

            // Wall-run, vault, predictive
            parkour.Action = delegate(float dt)
            {
                if (player.EnableMoves &&
                    player.Character.EnableWalking &&
                    !(player.Character.Crouched && player.Character.IsSupported) &&
                    vault.CurrentState.Value == Vault.State.None &&
                    !rollKickSlide.Kicking &&
                    !rollKickSlide.Rolling &&
                    wallRun.CurrentState.Value == WallRun.State.None &&
                    parkourTime < Player.SlowmoTime)
                {
                    bool didSomething = false;

                    bool parkourBeganThisFrame = parkourTime == 0;
                    if (predictor.PossibilityCount > 0)
                    {
                        // In slow motion, prefer left and right wall-running
                        if (!(didSomething = wallRun.Activate(WallRun.State.Left, parkourBeganThisFrame)))
                        {
                            if (!(didSomething = wallRun.Activate(WallRun.State.Right, parkourBeganThisFrame)))
                            {
                                if (!(didSomething = vault.Go(parkourBeganThisFrame)))
                                {
                                    didSomething = wallRun.Activate(WallRun.State.Straight, parkourBeganThisFrame);
                                }
                            }
                        }
                    }
                    else
                    {
                        // In normal mode, prefer straight wall-running
                        if (!(didSomething = vault.Go(parkourBeganThisFrame)))
                        {
                            if (!(didSomething = wallRun.Activate(WallRun.State.Straight, parkourBeganThisFrame)))
                            {
                                if (!(didSomething = wallRun.Activate(WallRun.State.Left, parkourBeganThisFrame)))
                                {
                                    didSomething = wallRun.Activate(WallRun.State.Right, parkourBeganThisFrame);
                                }
                            }
                        }
                    }

                    if (didSomething)
                    {
                        jumper.Enabled.Value    = false;
                        player.SlowMotion.Value = false;
                        parkour.Enabled.Value   = false;
                    }
                    else if (parkourBeganThisFrame && player.Character.LinearVelocity.Value.Y > FallDamage.RollingDeathVelocity)
                    {
                        if (blockCloud.Blocks.Length > 0)
                        {
                            player.SlowMotion.Value = true;
                            predictor.ClearPossibilities();
                            predictor.PredictPlatforms();
                            predictor.PredictWalls();
                        }
                        else if (player.EnableSlowMotion)
                        {
                            player.SlowMotion.Value = true;
                        }
                    }

                    parkourTime += dt;
                }
                else
                {
                    parkour.Enabled.Value = false;
                }
            };
            parkour.Add(new CommandBinding(parkour.Enable, delegate()
            {
                parkourTime = 0;
            }));
            entity.Add(parkour);
            parkour.Enabled.Value = false;

            input.Bind(settings.Parkour, PCInput.InputState.Down, delegate()
            {
                parkour.Enabled.Value = true;
            });

            input.Bind(settings.Parkour, PCInput.InputState.Up, delegate()
            {
                parkour.Enabled.Value = false;
                wallRun.Deactivate();
                if (player.SlowMotion)
                {
                    player.SlowMotion.Value = false;
                }
            });

            input.Bind(settings.RollKick, PCInput.InputState.Down, delegate()
            {
                if (player.EnableMoves && player.Character.EnableWalking)
                {
                    rollKickSlide.Go();
                    parkour.Enabled.Value = false;
                    jumper.Enabled.Value  = false;
                }
            });

            input.Bind(settings.RollKick, PCInput.InputState.Up, delegate()
            {
                if (!rollKickSlide.Rolling && !rollKickSlide.Kicking)
                {
                    player.Character.AllowUncrouch.Value = true;
                }
            });

            // Special ability

            /*
             * input.Bind(settings.SpecialAbility, PCInput.InputState.Down, delegate()
             * {
             *      Voxel.GlobalRaycastResult hit = Voxel.GlobalRaycast(main.Camera.Position, main.Camera.Forward, main.Camera.FarPlaneDistance, null);
             *      if (hit.Voxel != null && hit.Voxel.GetType() != typeof(DynamicVoxel))
             *      {
             *              VoxelRip.Go(hit.Voxel, hit.Coordinate.Value, 7, delegate(List<DynamicVoxel> results)
             *              {
             *                      foreach (DynamicVoxel v in results)
             *                      {
             *                              v.IsAffectedByGravity.Value = false;
             *                              v.LinearVelocity.Value = hit.Voxel.GetAbsoluteVector(hit.Normal.GetVector()) * 7.0f
             + new Vector3((float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f, (float)this.random.NextDouble() * 2.0f - 1.0f);
             +                      }
             +              });
             +      }
             + });
             */

            // Player data bindings

            entity.Add(new PostInitialization(delegate()
            {
                Entity dataEntity     = PlayerDataFactory.Instance;
                PlayerData playerData = dataEntity.Get <PlayerData>();

                // HACK. Overwriting the property rather than binding the two together. Oh well.
                // This is because I haven't written a two-way list binding.
                footsteps.RespawnLocations = playerData.RespawnLocations;

                // Bind player data properties
                entity.Add(new TwoWayBinding <float>(WorldFactory.Instance.Get <World>().CameraShakeAmount, cameraControl.CameraShakeAmount));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableRoll, rollKickSlide.EnableRoll));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableCrouch, player.EnableCrouch));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableKick, rollKickSlide.EnableKick));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRun, wallRun.EnableWallRun));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableWallRunHorizontal, wallRun.EnableWallRunHorizontal));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableEnhancedWallRun, wallRun.EnableEnhancedWallRun));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableMoves, player.EnableMoves));
                entity.Add(new TwoWayBinding <float>(playerData.MaxSpeed, player.Character.MaxSpeed));
                entity.Add(new Binding <bool>(fallDamage.PhoneOrNoteActive, () => playerData.PhoneActive || playerData.NoteActive, playerData.PhoneActive, playerData.NoteActive));

                if (playerData.CloudType.Value == Voxel.t.Empty)                 // This makes everything work if we spawn next to a power block socket
                {
                    entity.Add(new TwoWayBinding <Voxel.t>(blockCloud.Type, playerData.CloudType));
                }
                else
                {
                    entity.Add(new TwoWayBinding <Voxel.t>(playerData.CloudType, blockCloud.Type));
                }

                entity.Add(new TwoWayBinding <bool>(playerData.ThirdPerson, cameraControl.ThirdPerson));
                entity.Add(new TwoWayBinding <bool>(playerData.EnableSlowMotion, player.EnableSlowMotion));

                Phone phone = dataEntity.GetOrCreate <Phone>("Phone");

                entity.Add
                (
                    new Binding <bool>
                    (
                        phone.CanReceiveMessages,
                        () => player.Character.IsSupported && !player.Character.IsSwimming && !player.Character.Crouched,
                        player.Character.IsSupported,
                        player.Character.IsSwimming,
                        player.Character.Crouched
                    )
                );

                PhoneNote.Attach(main, entity, player, model, input, phone, player.Character.EnableWalking, playerData.PhoneActive, playerData.NoteActive);

                PlayerUI.Attach(main, entity, ui, player.Health, rotation.Rotation, playerData.NoteActive, playerData.PhoneActive);
            }));

            fpsCamera.Add(new Binding <Vector2>(fpsCamera.Mouse, input.Mouse));
            fpsCamera.Add(new Binding <Vector2>(fpsCamera.Movement, input.Movement));
            input.Bind(fpsCamera.SpeedMode, settings.Parkour);
            input.Bind(fpsCamera.Up, settings.Jump);
            fpsCamera.Add(new Binding <bool>(fpsCamera.Down, input.GetKey(Keys.LeftControl)));
            Lemma.Console.Console.AddConCommand(new ConCommand("noclip", "Toggle free camera mode", delegate(ConCommand.ArgCollection args)
            {
                bool freeCameraMode            = !fpsCamera.Enabled;
                fpsCamera.Enabled.Value        = freeCameraMode;
                cameraControl.Enabled.Value    = !freeCameraMode;
                firstPersonModel.Enabled.Value = !freeCameraMode;
                model.Enabled.Value            = !freeCameraMode;
                ui.Enabled.Value = !freeCameraMode;
                player.Character.EnableWalking.Value      = !freeCameraMode;
                player.EnableMoves.Value                  = !freeCameraMode;
                player.Character.Body.IsAffectedByGravity = !freeCameraMode;
                if (freeCameraMode)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.STOP_PLAYER_BREATHING_SOFT, entity);
                }
                else
                {
                    transform.Position.Value = main.Camera.Position;
                }
            }));

            entity.Add(new CommandBinding(entity.Delete, delegate()
            {
                Lemma.Console.Console.RemoveConCommand("noclip");
                if (fpsCamera.Enabled)                 // Movement is disabled. Re-enable it.
                {
                    player.Character.EnableWalking.Value = true;
                    player.EnableMoves.Value             = true;
                }
                PlayerFactory.Instance = null;
            }));
        }
Ejemplo n.º 18
0
 public void LoadGame()
 {
     StartCoroutine(LoadScene(GameScene));
     //SceneManager.LoadScene(GameScene);
     AkSoundEngine.StopAll();
 }
Ejemplo n.º 19
0
    void Awake()
    {
        if (ms_Instance != null)
        {
            //Don't init twice
            //Check if there are 2 objects with this script.  If yes, remove this component.
            if (ms_Instance != this)
            {
                UnityEngine.Object.DestroyImmediate(this.gameObject);
            }
            return;
        }

        Debug.Log("WwiseUnity: Initialize sound engine ...");

        //Use default properties for most SoundEngine subsystem.
        //The game programmer should modify these when needed.  See the Wwise SDK documentation for the initialization.
        //These settings may very well change for each target platform.
        AkMemSettings memSettings = new AkMemSettings();

        memSettings.uMaxNumPools = 20;

        AkDeviceSettings deviceSettings = new AkDeviceSettings();

        AkSoundEngine.GetDefaultDeviceSettings(deviceSettings);

        AkStreamMgrSettings streamingSettings = new AkStreamMgrSettings();

        streamingSettings.uMemorySize = (uint)streamingPoolSize * 1024;

        AkInitSettings initSettings = new AkInitSettings();

        AkSoundEngine.GetDefaultInitSettings(initSettings);
        initSettings.uDefaultPoolSize = (uint)defaultPoolSize * 1024;

        AkPlatformInitSettings platformSettings = new AkPlatformInitSettings();

        AkSoundEngine.GetDefaultPlatformInitSettings(platformSettings);
        platformSettings.uLEngineDefaultPoolSize           = (uint)lowerPoolSize * 1024;
        platformSettings.fLEngineDefaultPoolRatioThreshold = memoryCutoffThreshold;

        AkMusicSettings musicSettings = new AkMusicSettings();

        AkSoundEngine.GetDefaultMusicSettings(musicSettings);

        AKRESULT result = AkSoundEngine.Init(memSettings, streamingSettings, deviceSettings, initSettings, platformSettings, musicSettings);

        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort.");
            return; //AkSoundEngine.Init should have logged more details.
        }

        ms_Instance = this;

        AkBankPathUtil.UsePlatformSpecificPath();
        string platformBasePath = AkBankPathUtil.GetPlatformBasePath();

// Note: Android low-level IO uses relative path to "assets" folder of the apk as SoundBank folder.
// Unity uses full paths for general path checks. We thus don't use DirectoryInfo.Exists to test
// our SoundBank folder for Android.
#if !UNITY_ANDROID && !UNITY_METRO && !UNITY_PSP2
        if (!AkBankPathUtil.Exists(platformBasePath))
        {
            string errorMsg = string.Format("WwiseUnity: Failed to find soundbank folder: {0}. Abort.", platformBasePath);
            Debug.LogError(errorMsg);
            ms_Instance = null;
            return;
        }
#endif // #if !UNITY_ANDROID

        AkSoundEngine.SetBasePath(platformBasePath);
        AkSoundEngine.SetCurrentLanguage(language);

        result = AkCallbackManager.Init();
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine.");
            AkSoundEngine.Term();
            ms_Instance = null;
            return;
        }

        AkBankManager.Reset();

        Debug.Log("WwiseUnity: Sound engine initialized.");

        //The sound engine should not be destroyed once it is initialized.
        DontDestroyOnLoad(this);

#if UNITY_EDITOR
        //Redirect Wwise error messages into Unity console.
        AkCallbackManager.SetMonitoringCallback(ErrorLevel.ErrorLevel_All, CopyMonitoringInConsole);
#endif

        //Load the init bank right away.  Errors will be logged automatically.
        uint BankID;
#if UNITY_ANDROID && !UNITY_METRO && AK_LOAD_BANK_IN_MEMORY
        result = AkInMemBankLoader.LoadNonLocalizedBank("Init.bnk");
#else
        result = AkSoundEngine.LoadBank("Init.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);
#endif // #if UNITY_ANDROID && !UNITY_METRO && AK_ANDROID_BANK_IN_OBB
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + result.ToString());
        }
    }
Ejemplo n.º 20
0
    public void Init(AkInitializer akInitializer)
    {
#if UNITY_EDITOR
        string[] arguments = Environment.GetCommandLineArgs();
        if (Array.IndexOf(arguments, "-nographics") >= 0 && Array.IndexOf(arguments, "-wwiseEnableWithNoGraphics") < 0)
        {
            return;
        }
#endif

        engineLogging = akInitializer.engineLogging;

        AkLogger.Instance.Init();

        AKRESULT result;
        uint     BankID;
        if (AkSoundEngine.IsInitialized())
        {
#if UNITY_EDITOR
            if (Application.isPlaying || BuildPipeline.isBuildingPlayer)
            {
                AkSoundEngine.ClearBanks();
                AkBankManager.Reset();

                result = AkSoundEngine.LoadBank("Init.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);
                if (result != AKRESULT.AK_Success)
                {
                    Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + result.ToString());
                }
            }

            result = AkCallbackManager.Init(akInitializer.callbackManagerBufferSize * 1024);
            if (result != AKRESULT.AK_Success)
            {
                Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine.");
                AkSoundEngine.Term();
                return;
            }

            EditorApplication.update += LateUpdate;
#endif
            return;
        }

#if UNITY_EDITOR
        if (BuildPipeline.isBuildingPlayer)
        {
            return;
        }
#endif

        Debug.Log("WwiseUnity: Initialize sound engine ...");
        basePath = akInitializer.basePath;
        language = akInitializer.language;

        //Use default properties for most SoundEngine subsystem.
        //The game programmer should modify these when needed.  See the Wwise SDK documentation for the initialization.
        //These settings may very well change for each target platform.
        AkMemSettings memSettings = new AkMemSettings();
        memSettings.uMaxNumPools = 20;

        AkDeviceSettings deviceSettings = new AkDeviceSettings();
        AkSoundEngine.GetDefaultDeviceSettings(deviceSettings);

        AkStreamMgrSettings streamingSettings = new AkStreamMgrSettings();
        streamingSettings.uMemorySize = (uint)akInitializer.streamingPoolSize * 1024;

        AkInitSettings initSettings = new AkInitSettings();
        AkSoundEngine.GetDefaultInitSettings(initSettings);
        initSettings.uDefaultPoolSize      = (uint)akInitializer.defaultPoolSize * 1024;
        initSettings.uMonitorPoolSize      = (uint)akInitializer.monitorPoolSize * 1024;
        initSettings.uMonitorQueuePoolSize = (uint)akInitializer.monitorQueuePoolSize * 1024;
#if (!UNITY_ANDROID && !UNITY_WSA) || UNITY_EDITOR // Exclude WSA. It only needs the name of the DLL, and no path.
        initSettings.szPluginDLLPath = System.IO.Path.Combine(Application.dataPath, "Plugins" + System.IO.Path.DirectorySeparatorChar);
#endif

        AkPlatformInitSettings platformSettings = new AkPlatformInitSettings();
        AkSoundEngine.GetDefaultPlatformInitSettings(platformSettings);
        platformSettings.uLEngineDefaultPoolSize           = (uint)akInitializer.lowerPoolSize * 1024;
        platformSettings.fLEngineDefaultPoolRatioThreshold = akInitializer.memoryCutoffThreshold;

        AkMusicSettings musicSettings = new AkMusicSettings();
        AkSoundEngine.GetDefaultMusicSettings(musicSettings);

        AkSpatialAudioInitSettings spatialAudioSettings = new AkSpatialAudioInitSettings();
        spatialAudioSettings.uPoolSize = (uint)akInitializer.spatialAudioPoolSize * 1024;
        spatialAudioSettings.uMaxSoundPropagationDepth = akInitializer.maxSoundPropagationDepth;
        spatialAudioSettings.uDiffractionFlags         = (uint)akInitializer.diffractionFlags;

#if UNITY_EDITOR
        AkSoundEngine.SetGameName(Application.productName + " (Editor)");
#else
        AkSoundEngine.SetGameName(Application.productName);
#endif

        result = AkSoundEngine.Init(memSettings, streamingSettings, deviceSettings, initSettings, platformSettings, musicSettings, spatialAudioSettings, (uint)akInitializer.preparePoolSize * 1024);

        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize the sound engine. Abort.");
            AkSoundEngine.Term();
            return;             //AkSoundEngine.Init should have logged more details.
        }

        string basePathToSet = AkBasePathGetter.GetSoundbankBasePath();
        if (string.IsNullOrEmpty(basePathToSet))
        {
            Debug.LogError("WwiseUnity: Couldn't find soundbanks base path. Terminate sound engine.");
            AkSoundEngine.Term();
            return;
        }

        result = AkSoundEngine.SetBasePath(basePathToSet);
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to set soundbanks base path. Terminate sound engine.");
            AkSoundEngine.Term();
            return;
        }

#if !UNITY_SWITCH
        // Calling Application.persistentDataPath crashes Switch
        string decodedBankFullPath = GetDecodedBankFullPath();
        // AkSoundEngine.SetDecodedBankPath creates the folders for writing to (if they don't exist)
        AkSoundEngine.SetDecodedBankPath(decodedBankFullPath);
#endif

        AkSoundEngine.SetCurrentLanguage(language);

#if !UNITY_SWITCH
        // Calling Application.persistentDataPath crashes Switch
        // AkSoundEngine.AddBasePath is currently only implemented for iOS and Android; No-op for all other platforms.
        AkSoundEngine.AddBasePath(Application.persistentDataPath + System.IO.Path.DirectorySeparatorChar);
        // Adding decoded bank path last to ensure that it is the first one used when writing decoded banks.
        AkSoundEngine.AddBasePath(decodedBankFullPath);
#endif

        result = AkCallbackManager.Init(akInitializer.callbackManagerBufferSize * 1024);
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed to initialize Callback Manager. Terminate sound engine.");
            AkSoundEngine.Term();
            return;
        }

        AkBankManager.Reset();

        Debug.Log("WwiseUnity: Sound engine initialized.");

        //Load the init bank right away.  Errors will be logged automatically.
        result = AkSoundEngine.LoadBank("Init.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);
        if (result != AKRESULT.AK_Success)
        {
            Debug.LogError("WwiseUnity: Failed load Init.bnk with result: " + result.ToString());
        }

#if UNITY_EDITOR
#if UNITY_2017_2_OR_NEWER
        EditorApplication.pauseStateChanged += OnPauseStateChanged;
#else
        EditorApplication.playmodeStateChanged += OnEditorPlaymodeStateChanged;
#endif
        EditorApplication.update += LateUpdate;
#endif
    }
Ejemplo n.º 21
0
 public void LoadUp(string s)
 {
     __soundBank = s;
     AkSoundEngine.LoadBank(__soundBank, AkSoundEngine.AK_DEFAULT_POOL_ID, out __bankID);
 }
Ejemplo n.º 22
0
        public void InstantiatePossibility(Possibility block)
        {
            block.Model.Delete.Execute();
            List <Possibility> mapList = possibilities[block.Map];

            mapList.Remove(block);
            if (mapList.Count == 0)
            {
                possibilities.Remove(block.Map);
            }

            bool regenerate = block.Map.Empty(block.StartCoord.CoordinatesBetween(block.EndCoord), false, false);

            foreach (Voxel.Coord c in block.StartCoord.CoordinatesBetween(block.EndCoord))
            {
                Vector3 absolutePos   = block.Map.GetAbsolutePosition(c);
                bool    foundConflict = false;
                foreach (Voxel m2 in Voxel.ActivePhysicsVoxels)
                {
                    if (m2 != block.Map && m2[absolutePos].ID != 0)
                    {
                        foundConflict = true;
                        break;
                    }
                }
                if (!foundConflict)
                {
                    regenerate |= block.Map.Fill(c, Voxel.States.Blue);
                }
            }

            if (regenerate)
            {
                block.Map.Regenerate();
                const float prePrime = 2.0f;
                // Front and back faces
                for (int x = block.StartCoord.X; x < block.EndCoord.X; x++)
                {
                    for (int y = block.StartCoord.Y; y < block.EndCoord.Y; y++)
                    {
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(x, y, block.EndCoord.Z - 1), Vector3.Zero, -1.0f, prePrime);
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(x, y, block.StartCoord.Z), Vector3.Zero, -1.0f, prePrime);
                    }
                }

                // Left and right faces
                for (int z = block.StartCoord.Z; z < block.EndCoord.Z; z++)
                {
                    for (int y = block.StartCoord.Y; y < block.EndCoord.Y; y++)
                    {
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(block.StartCoord.X, y, z), Vector3.Zero, -1.0f, prePrime);
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(block.EndCoord.X - 1, y, z), Vector3.Zero, -1.0f, prePrime);
                    }
                }

                // Top and bottom faces
                for (int z = block.StartCoord.Z; z < block.EndCoord.Z; z++)
                {
                    for (int x = block.StartCoord.X; x < block.EndCoord.X; x++)
                    {
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(x, block.StartCoord.Y, z), Vector3.Zero, -1.0f, prePrime);
                        particleSystem.AddParticle(block.Map.GetAbsolutePosition(x, block.EndCoord.Y - 1, z), Vector3.Zero, -1.0f, prePrime);
                    }
                }

                AkSoundEngine.PostEvent(AK.EVENTS.PLAY_MAGIC_CUBE_STINGER, this.Entity);
            }
        }
Ejemplo n.º 23
0
        public void Update(float dt)
        {
            Vector2 mouse = this.Mouse;

            Vector3 relativeVelocity           = this.LinearVelocity.Value - this.SupportVelocity.Value;
            Vector3 horizontalRelativeVelocity = relativeVelocity;

            horizontalRelativeVelocity.Y = 0;
            float horizontalSpeed = horizontalRelativeVelocity.Length();

            if (this.WallRunState == WallRun.State.None)
            {
                this.model.Stop
                (
                    "WallRunLeft",
                    "WallRunRight",
                    "WallRunStraight",
                    "WallSlideDown",
                    "WallSlideReverse"
                );

                if (this.IsSupported)
                {
                    this.model.Stop
                    (
                        "Jump",
                        "Jump02",
                        "Jump03",
                        "JumpLeft",
                        "JumpBackward",
                        "JumpRight",
                        "Fall",
                        "Swim",
                        "SwimForward"
                    );

                    Vector2 dir   = this.Movement;
                    float   angle = (float)Math.Atan2(dir.Y, dir.X);
                    if (angle < 0.0f)
                    {
                        angle += (float)Math.PI * 2.0f;
                    }

                    string movementAnimation;

                    if (this.EnableWalking)
                    {
                        if (this.Crouched)
                        {
                            if (dir.LengthSquared() == 0.0f)
                            {
                                movementAnimation = "CrouchIdle";
                            }
                            else
                            {
                                movementAnimation = AnimationController.crouchDirections[(int)Math.Round(angle / ((float)Math.PI * 0.25f)) % 8];
                            }
                        }
                        else
                        {
                            if (dir.LengthSquared() == 0.0f)
                            {
                                movementAnimation = "Idle";
                            }
                            else
                            {
                                movementAnimation = AnimationController.directions[(int)Math.Round(angle / ((float)Math.PI * 0.25f)) % 8];
                            }
                        }
                    }
                    else
                    {
                        if (this.Crouched)
                        {
                            movementAnimation = "CrouchIdle";
                        }
                        else
                        {
                            movementAnimation = "Idle";
                        }
                    }

                    foreach (KeyValuePair <string, AnimationInfo> animation in this.Crouched ? crouchMovementAnimations : movementAnimations)
                    {
                        if (animation.Key != "Idle" && animation.Key != "CrouchIdle")
                        {
                            this.model[animation.Key].Speed = Math.Min(horizontalSpeed * (this.Crouched ? animationSpeedCoefficientCrouched : animationSpeedCoefficient), maxAnimationSpeed);
                        }
                        this.model[animation.Key].TargetStrength = animation.Key == movementAnimation ? 1.0f : animation.Value.DefaultStrength;
                    }

                    bool nowIdling = false;
                    if (movementAnimation == "Run")
                    {
                        this.sprintAnimation.TargetStrength = MathHelper.Clamp((horizontalSpeed - sprintThreshold) / sprintRange, 0.0f, 1.0f);
                        this.runAnimation.TargetStrength    = Math.Min(MathHelper.Clamp(horizontalSpeed / sprintThreshold, 0.0f, 1.0f), 1.0f - this.sprintAnimation.TargetStrength);
                    }
                    else if (movementAnimation != "Idle" && movementAnimation != "CrouchIdle")
                    {
                        this.model[movementAnimation].TargetStrength = MathHelper.Clamp(this.Crouched ? horizontalSpeed / 2.0f : horizontalSpeed / sprintThreshold, 0.0f, 1.0f);
                    }
                    else if (movementAnimation == "Idle")
                    {
                        nowIdling = true;
                    }

                    if (nowIdling)
                    {
                        if (this.idling)
                        {
                            // We're already idling. Blend to new idle rotation if necessary
                            if (this.idleRotationBlend < 1.0f)
                            {
                                this.idleRotationBlend += dt / idleRotationBlendTime;
                                if (this.idleRotationBlend >= 1.0f)
                                {
                                    this.idleRotation = this.Rotation;                                     // We're done blending
                                }
                            }
                            else
                            {
                                float rotationDiff = this.Rotation - this.idleRotation.ClosestAngle(this.Rotation);
                                if (Math.Abs(rotationDiff) > Math.PI * 0.25)
                                {
                                    this.idleRotationBlend = 0.0f;                                     // Start blending to new rotation
                                    this.model.StartClip(rotationDiff > 0.0f ? "TurnLeft" : "TurnRight", 1);
                                }
                            }
                        }
                        else                         // We just started idling. Save the current rotation.
                        {
                            this.idleRotation = this.Rotation;
                        }
                    }
                    else
                    {
                        if (this.idling)                         // We're just now coming out of idle state
                        {
                            if (this.idleRotationBlend > 1.0f)
                            {
                                this.idleRotationBlend = 0.0f;
                            }
                        }
                    }
                    this.idling = nowIdling;

                    if (!this.model.IsPlaying(movementAnimation))
                    {
                        foreach (string anim in this.Crouched ? movementAnimations.Keys : crouchMovementAnimations.Keys)
                        {
                            this.model.Stop(anim);
                        }
                        Dictionary <string, AnimationInfo> animations = this.Crouched ? crouchMovementAnimations : movementAnimations;
                        TimeSpan currentTime = TimeSpan.FromSeconds(this.random.NextDouble() * this.model[animations.Keys.First()].Duration.TotalSeconds);
                        foreach (KeyValuePair <string, AnimationInfo> animation in animations)
                        {
                            this.model.StartClip(animation.Key, animation.Value.Priority, true, AnimatedModel.DefaultBlendTime);
                            SkinnedModel.Clip clip = this.model[animation.Key];
                            clip.CurrentTime = currentTime;
                            clip.Strength    = animation.Value.DefaultStrength;
                        }
                    }
                }
                else
                {
                    this.idling = false;
                    foreach (string anim in movementAnimations.Keys)
                    {
                        this.model.Stop(anim);
                    }
                    foreach (string anim in crouchMovementAnimations.Keys)
                    {
                        this.model.Stop(anim);
                    }

                    if (this.IsSwimming)
                    {
                        this.model.Stop("Fall");
                        if (this.Movement.Value.Y > 0.25f)
                        {
                            this.model.Stop("Swim");
                            if (!this.model.IsPlaying("SwimForward"))
                            {
                                this.model.StartClip("SwimForward", 0, true, AnimatedModel.DefaultBlendTime);
                                SkinnedModel.Clip clip = this.model["SwimForward"];
                                clip.CurrentTime = TimeSpan.FromSeconds(this.random.NextDouble() * clip.Duration.TotalSeconds);
                            }
                        }
                        else
                        {
                            this.model.Stop("SwimForward");
                            if (!this.model.IsPlaying("Swim"))
                            {
                                this.model.StartClip("Swim", 0, true, AnimatedModel.DefaultBlendTime);
                                SkinnedModel.Clip clip = this.model["Swim"];
                                clip.CurrentTime = TimeSpan.FromSeconds(this.random.NextDouble() * clip.Duration.TotalSeconds);
                            }
                        }
                    }
                    else
                    {
                        this.model.Stop("SwimForward");
                        if (!this.model.IsPlaying("Fall"))
                        {
                            this.model.StartClip("Fall", 0, true, AnimatedModel.DefaultBlendTime);
                            this.fallAnimation.CurrentTime = TimeSpan.FromSeconds(random.NextDouble() * this.fallAnimation.Duration.TotalSeconds);
                        }
                    }

                    this.fallAnimation.Speed = MathHelper.Clamp(this.LinearVelocity.Value.Length() * (1.0f / 20.0f), 0, 2);
                }
            }
            else
            {
                this.idling = false;
                this.model.Stop
                (
                    "Jump",
                    "Jump02",
                    "Jump03",
                    "JumpLeft",
                    "JumpBackward",
                    "JumpRight",
                    "Fall"
                );
                foreach (string anim in movementAnimations.Keys)
                {
                    this.model.Stop(anim);
                }

                string wallRunAnimation;
                switch (this.WallRunState.Value)
                {
                case WallRun.State.Straight:
                    wallRunAnimation = "WallRunStraight";
                    break;

                case WallRun.State.Down:
                    wallRunAnimation = "WallSlideDown";
                    break;

                case WallRun.State.Left:
                    wallRunAnimation = "WallRunLeft";
                    break;

                case WallRun.State.Right:
                    wallRunAnimation = "WallRunRight";
                    break;

                default:
                    wallRunAnimation = null;
                    break;
                }
                if (!this.model.IsPlaying(wallRunAnimation))
                {
                    this.model.Stop
                    (
                        "WallRunStraight",
                        "WallSlideDown",
                        "WallRunLeft",
                        "WallRunRight",
                        "WallSlideReverse"
                    );
                    this.model.StartClip(wallRunAnimation, 1, true);
                }

                if (wallRunAnimation != null)
                {
                    Vector3 wallNormal     = this.WallRunMap.Value.GetAbsoluteVector(this.WallDirection.Value.GetVector());
                    float   animationSpeed = (relativeVelocity - wallNormal * Vector3.Dot(relativeVelocity, wallNormal)).Length();
                    this.model[wallRunAnimation].Speed = Math.Min(maxAnimationSpeedWallRun, animationSpeed * animationSpeedCoefficientWallRun);
                }
            }

            // Rotate head to match mouse
            this.relativeHeadBone.Value *= Matrix.CreateRotationX(mouse.Y * 0.6f);
            this.model.UpdateWorldTransforms();

            float l = 0.0f;

            if (this.EnableLean)
            {
                l = horizontalSpeed * (this.lastRotation.ClosestAngle(this.Rotation) - this.Rotation) * (1.0f / 60.0f) / dt;
            }
            this.lastRotation = this.Rotation;
            this.Lean.Value  += (l - this.Lean) * 20.0f * dt;

            const float timeScale = 5.0f;
            const float softBreathingThresholdPercentage = 0.75f;
            float       newBreathing;

            if (!this.Crouched && this.Movement.Value.LengthSquared() > 0.0f && horizontalSpeed > Character.DefaultMaxSpeed * 0.75f)
            {
                newBreathing = Math.Min(this.breathing + (dt / timeScale), 1.0f);
                if (this.breathing < softBreathingThresholdPercentage && newBreathing > softBreathingThresholdPercentage)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.PLAY_PLAYER_BREATHING_SOFT, this.Entity);
                    newBreathing = 1.0f;
                }
            }
            else
            {
                newBreathing = Math.Max(0, this.breathing - dt / timeScale);
                if (this.breathing > softBreathingThresholdPercentage && newBreathing < softBreathingThresholdPercentage)
                {
                    AkSoundEngine.PostEvent(AK.EVENTS.STOP_PLAYER_BREATHING_SOFT, this.Entity);
                    newBreathing = 0.0f;
                }
            }
            this.breathing = newBreathing;
            AkSoundEngine.SetRTPCValue(AK.GAME_PARAMETERS.SFX_PLAYER_SLIDE, MathHelper.Clamp(relativeVelocity.Length() / 8.0f, 0.0f, 1.0f) * (this.Kicking ? 1.0f : 0.25f));
        }
Ejemplo n.º 24
0
 public override void OnPostFired(PlayerController player, Gun gun)
 {
     this.gun.ammo = this.gun.CurrentOwner.gameObject.GetComponent <NuclearPlayerController>().Shells -= 1;
     AkSoundEngine.PostEvent("Play_WPN_shotgun_shot_01", base.gameObject);
 }
Ejemplo n.º 25
0
 public void Reset()
 {
     AkSoundEngine.StopAll();
     Destroy(enn.gameObject);
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
Ejemplo n.º 26
0
    private void MoveAlertBubble()
    {
        if (Camera.main == null)
        {
            return;
        }

        Vector3 screenPos = Camera.main.WorldToScreenPoint(transform.position);

        screenPos = WorldToScreenPointProjected(Camera.main, transform.position);
        Vector3 playerScreenPos = Camera.main.WorldToScreenPoint(GameController.Instance.Player1.transform.position);

        Vector3 direction = playerScreenPos - screenPos;
        float   angle     = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;

        Vector2 finalScreenPos = new Vector2(screenPos.x, screenPos.y);

        // Clamp to screen
        if (finalScreenPos.x >= Screen.width)
        {
            finalScreenPos.x = Screen.width;
        }
        if (finalScreenPos.x <= 0)
        {
            finalScreenPos.x = 0f;
        }

        if (finalScreenPos.y >= Screen.height)
        {
            finalScreenPos.y = Screen.height;
        }
        if (finalScreenPos.y <= 0)
        {
            finalScreenPos.y = 0f;
        }

        bubbleFrame.position = new Vector3(finalScreenPos.x, finalScreenPos.y, 0);
        bubbleFrame.rotation = Quaternion.Euler(0, 0, angle + 90);


        // Icon display cases
        ///// If close to family
        if (!_requested.Equals(REQUEST_NONE))
        {
            bubbleFrame.gameObject.SetActive(true);

            iconDisplay.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
            // Should we display the item icon ?
            if (_hasShownItem || direction.magnitude < Screen.width / 7f)
            {
                switch (_requested)
                {
                case "Wood_Item":
                    iconDisplay.sprite = woodSprite;
                    if (!_hasShownItem)
                    {
                        AkSoundEngine.PostEvent("Play_WomanNeedsWood", gameObject);
                    }
                    break;

                case "Food_Item":
                    iconDisplay.sprite = foodSprite;
                    if (!_hasShownItem)
                    {
                        AkSoundEngine.PostEvent("Play_WomanNeedsFood", gameObject);
                    }
                    break;

                default:
                    iconDisplay.sprite = alertSprite;
                    break;
                }

                _hasShownItem = true;
            }
            else
            {
                iconDisplay.sprite = alertSprite;
            }
        }
        else
        {
            bubbleFrame.gameObject.SetActive(false);
        }
    }
Ejemplo n.º 27
0
 public override void OnPostFired(PlayerController player, Gun gun)
 {
     gun.PreventNormalFireAudio = true;
     AkSoundEngine.PostEvent("Play_WPN_magnum_shot_01", gameObject);
 }
Ejemplo n.º 28
0
 private void PlayLandingSound()
 {
     AkSoundEngine.PostEvent("Land", gameObject);
     m_NextStep = m_StepCycle + .5f;
 }
 // Update is called once per frame
 void Update()
 {
     AkSoundEngine.SetRTPCValue("SoulMovement", this.gameObject.GetComponent <Rigidbody>().velocity.magnitude);
 }
Ejemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        if (!fadingPanels[0].gameObject.activeInHierarchy && !fadingPanels[1].gameObject.activeInHierarchy)
        {
            if (!MenuPanel.activeInHierarchy && !GameOverPanel.activeInHierarchy &&
                !CreditsPanel.activeInHierarchy && !PausePanel.activeInHierarchy && !WinPanel.activeInHierarchy)
            {
                if (backInput && instructionsPanel.activeInHierarchy)
                {
                    instructionsPanel.SetActive(false);
                    if (firstTime)
                    {
                        Restart(true);
                        firstTime = false;
                    }
                    else
                    {
                        GameManager.ResumeTime();
                    }
                    if (GameManager.Instance.soundOn)
                    {
                        AkSoundEngine.PostEvent("Close_Help", gameObject);
                    }
                }

                if (helpInput)
                {
                    instructionsPanel.SetActive(!instructionsPanel.activeInHierarchy);
                    if (instructionsPanel.activeInHierarchy)
                    {
                        if (GameManager.Instance.soundOn)
                        {
                            AkSoundEngine.PostEvent("Open_Help", gameObject);
                        }
                        GameManager.PauseTime();
                    }
                    else
                    {
                        if (GameManager.Instance.soundOn)
                        {
                            AkSoundEngine.PostEvent("Close_Help", gameObject);
                        }
                        GameManager.ResumeTime();
                    }
                }
                else if (instructionsPanel.activeInHierarchy && backInput)
                {
                    instructionsPanel.SetActive(false);
                }

                if (startInput)
                {
                    PauseGame(true);
                }

                //if (Cursor.visible)
                //{
                //    Cursor.visible = false;
                //    Cursor.lockState = CursorLockMode.Locked;
                //}

                if (!garomoController.GetComponent <PlayerInput>().enabled)
                {
                    garomoController.GetComponent <PlayerInput>().enabled = true;
                }
            }
            else
            {
                if (!Cursor.visible && device != Gamepad.current)
                {
                    //Cursor.visible = true;
                    //Cursor.lockState = CursorLockMode.None;
                }
                garomoController.GetComponent <PlayerInput>().enabled = false;
            }



            for (int i = 0; i < garomoController.life; i++)
            {
                muzzleParts[i].gameObject.SetActive(true);
            }

            for (int i = 0; i < garomoController.life; i++)
            {
                if (i == garomoController.life - 1)
                {
                    muzzleParts[i].sprite = lastMuzzle;
                }
                else
                {
                    if (muzzleParts[i].IsActive())
                    {
                        muzzleParts[i].sprite = muzzlePiece;
                    }
                }
            }

            for (int i = garomoController.life; i < 5; i++)
            {
                muzzleParts[i].gameObject.SetActive(false);
            }
        }
        else
        {
            if (fadingTime > 0)
            {
                Color color = new Color(0, 0, 0, fadingTime / fadingTimeMax);
                actualFading.color = color;
                fadingTime        -= Time.deltaTime;
                if (actualFading.transform.childCount > 0)
                {
                    Image childIm = actualFading.transform.Find("Logo").GetComponent <Image>();
                    Color c       = new Color(1, 1, 1, fadingTime / fadingTimeMax);
                    childIm.color = c;
                }
                if (fadingTime < 0)
                {
                    fadingTime = 0;
                    actualFading.gameObject.SetActive(false);
                    if (actualFading.transform.childCount > 0)
                    {
                        GameManager.PauseTime();
                    }
                }
            }
            else if (actualFading == fadingPanels[0])
            {
                actualFading = fadingPanels[1];
                fadingTime   = 5f;
            }
        }

        helpInput  = false;
        backInput  = false;
        startInput = false;
    }