private void Start() { config = GetComponent <Player_Config>(); controllerAnimation = GetComponent <Player_AnimationController>(); SelectWeaponModel(selectedWeapon); config.humanAnimator.SetLayerWeight(1, 0f); }
IEnumerator StabCooldownTimer(Player_AnimationController controllerAnimation) { config.humanAnimator.SetLayerWeight(1, 1f); isFighting = true; controllerAnimation.TriggerStab(); config.firstAudioSource.clip = config.knifeClip; if (!config.firstAudioSource.isPlaying && !playedClip) { config.firstAudioSource.Play(); playedClip = true; } //controller.StopMoving = true; punchCooldownOn = true; yield return(new WaitForSeconds(punchTimer)); config.firstAudioSource.Stop(); punchCooldownOn = false; //controller.StopMoving = false; controllerAnimation.ResetTriggerStab(); isFighting = false; playedClip = false; }
private void Start() { //movement controller controllerWalker = GetComponent <AdvancedWalkerController>(); controllerAnimation = GetComponent <Player_AnimationController>(); controllerRagdoll = GetComponent <Player_RagdollController>(); config = GetComponent <Player_Config>(); hud = GetComponent <Player_Hud>(); playerHealth = GetComponent <Player_Health>(); lineRenderGrab = gameObject.GetComponent <LineRenderer>(); lineRenderGrab.SetPositions(new Vector3[] { Vector3.zero, Vector3.zero }); lineRenderGrab.startColor = Color.white; lineRenderGrab.endColor = Color.white; lineRenderGrab.startWidth = 0.002f; lineRenderGrab.endWidth = 0.002f; //stamina config.runStamina = config.staminaLevel; //hud StartCoroutine("UpdateHUD"); }
IEnumerator ShootCooldownTimer(Player_AnimationController controllerAnimation) { config.humanAnimator.SetLayerWeight(1, 1f); isFighting = true; controllerAnimation.TriggerShoot(); config.firstAudioSource.clip = config.shootClip; if (!config.firstAudioSource.isPlaying && !playedClip) { config.firstAudioSource.Play(); playedClip = true; } config.cameraShake.shakeDuration = 0.05f; //controller.StopMoving = true; punchCooldownOn = true; yield return(new WaitForSeconds(pistolShotTimer)); config.firstAudioSource.Stop(); punchCooldownOn = false; //controller.StopMoving = false; controllerAnimation.ResetTriggerShoot(); isFighting = false; playedClip = false; }
public void FightingControls(Player_Config config, Player_AnimationController controllerAnimation) { if (!config.canAttack) { return; } if (Input.GetMouseButtonDown(1)) { //so we can punch and move after animation is done if (isFighting) { return; } //Make sure no other coroutines are playing StopAllCoroutines(); //Weapon selection switch (selectedWeapon) { case Weapon.Fists: hitDistance = 1.7f; hitDamage = 20f; StartCoroutine(PunchCooldownTimer(controllerAnimation)); break; case Weapon.Knife: hitDistance = 1.7f; hitDamage = 33; StartCoroutine(StabCooldownTimer(controllerAnimation)); break; case Weapon.Pistol: hitDistance = 22f; hitDamage = 75f; StartCoroutine(ShootCooldownTimer(controllerAnimation)); break; } //Action Ray ray = Camera.allCameras[0].ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, hitDistance, ~playerCapsuleLayermask)) { if (hit.transform.tag == "PlayerRagdoll") { Debug.Log("Punched " + hit.collider.gameObject.name + " On other player!"); //damage and kill the player PhotonView pvOther = hit.transform.root.gameObject.GetComponent <PhotonView>(); if (pvOther == null) { Debug.LogError("OTHER PLAYER DOESNT HAVE PHOTONVIEW?!"); } pvOther.RPC("Damage", RpcTarget.AllBufferedViaServer, pvOther.ViewID, DamageMultiplier(hit.collider.gameObject.name, hitDamage)); //pvOther.RPC("KillImmediately", RpcTarget.AllBufferedViaServer, pvOther.ViewID, 15f, hit.point); } //transfer ownership if available (punching obj) PhotonView otherPv = hit.transform.gameObject.GetComponent <PhotonView>(); if (otherPv != null && !otherPv.IsMine) { otherPv.TransferOwnership(PhotonNetwork.LocalPlayer); } //hit a draggable/door or something, apply force StartCoroutine(PunchDelay(0.25f, hit)); } } }