private void SetSpeed() { if (!Inventory.HasAxe) { //Checks if the player is crouched, if it is set the speed to the set crouched speed if (Crouched) { Speed = CrouchSpeedValue; SoundSender.SendSound(CrouchSoundLevel, MovingMode.mM_Crouched); } //Check if the player is pressing the shift button and want's to run else if (IsRunning && !Crouched) { //Sets the speed to the set running speed Speed = RunSpeedValue; SoundSender.SendSound(RunSoundLevel, MovingMode.mM_Walk); } else if (!IsRunning && !Crouched) { //Otherwise set the speed to the walking speed Speed = WalkSpeedValue; SoundSender.SendSound(WalkSoundLevel, MovingMode.mM_Walk); } } else { Speed = 3f; } }
// Update is called once per frame void Update() { if (Input.GetKey(KeyCode.Mouse1) && transform.parent) { IsRinging = true; gameObject.AddComponent <Rigidbody>(); transform.parent = null; } if (transform.parent == null) { if (TimerBeforestart > 0) { TimerBeforestart -= Time.deltaTime; } else if (TimerBeforestart <= 0 && TimeWhenringing > 0) { StartRinging(); SoundSender.SendSound(Sound, MovingMode.mM_Null); TimeWhenringing -= Time.deltaTime; } else if (TimeWhenringing <= 0) { StopRinging(); } } }
// Update is called once per frame void Update() { if (CanOpen) { if (IsLocked) { if (!DoorKey) { if (Input.GetKeyDown(KeyCode.E)) { HandleShake.Play(); PlayerInv.SetMessageText("Door locked, key needed.", false); } } if (DoorKey) { if (Input.GetKeyDown(KeyCode.E)) { OpenDoor.Play(); if (IsSprayed) { SoundSender.SendSound(0, MovingMode.mM_Null); } else { CreakingDoor.Play(); SoundSender.SendSound(SoundLevel, MovingMode.mM_Null); } CanOpen = false; IsLocked = false; if (!Pressed) { Pressed = true; _animate.SetBool("open", !_animate.GetBool("open")); PlayerInv.SetMessageText("", false); } } } } else { if (Input.GetKeyDown(KeyCode.E)) { OpenDoor.Play(); if (IsSprayed) { SoundSender.SendSound(0, MovingMode.mM_Null); } else { CreakingDoor.Play(); SoundSender.SendSound(SoundLevel, MovingMode.mM_Null); } IsLocked = false; CanOpen = false; if (!Pressed) { Pressed = true; _animate.SetBool("open", !_animate.GetBool("open")); PlayerInv.SetMessageText("", false); } } } } }