private void OnCollisionEnter(Collision collision) { if (PlayerSkillManager.Singleton.SkillInUse == SkillInUse.Jump && IsBeingThrown) { if (collision.gameObject.CompareTag("Ground")) { Quaternion rotation = transform.rotation; _playerAnimator.SetBool("jumping", false); TargetRigidbody.MoveRotation(rotation); IsBeingThrown = false; _playerMovement.Disabled = false; if (!PlayerSkillManager.Singleton.InfiniteSkill) { RemainingUsage--; } _remainingUsageText.text = RemainingUsage.ToString(); if (RemainingUsage == 0) { _iconImage.color = Color.grey; } IsFinished = true; PlayerSkillManager.Singleton.SkillInUse = SkillInUse.None; } } }
public void ActionBoth(Dagger other) { if (TargetRigidbody != null && other.TargetRigidbody == TargetRigidbody) { if (TargetRigidbody.tag == "Enemy") { TargetRigidbody.GetComponentInParent <Guard>().Explode(); } var retractionForce = (Vector3.up + transform.forward * -1f).normalized * RETRACT_PULL_FORCE; TargetRigidbody.AddForce(retractionForce, ForceMode.Impulse); } Action(); }
IEnumerator Fire() { var ray = camera.ScreenPointToRay(Mouse.current.position.ReadValue()); RaycastHit hit; if (!Physics.Raycast(ray, out hit, RANGE, mask) || Vector3.Distance(hit.point, transform.position) <= PICKUP_RADIUS) { State = DaggerState.Holstered; yield break; } State = DaggerState.Firing; transform.parent = null; target = hit.point; rope.enabled = true; interceptTrigger.enabled = true; audio.PlayOneShot(sounds.fire); while (interceptTrigger.enabled && !MoveToTarget(target, TRAVEL_SPEED)) { rotationParent.Rotate(Vector3.forward, TRAVEL_ROTATION * Time.deltaTime, Space.Self); yield return(null); } State = DaggerState.Embedded; interceptTrigger.enabled = false; if (TargetRigidbody == null) { TargetRigidbody = hit.rigidbody; } if (TargetRigidbody && TargetRigidbody.tag == "Enemy") { TargetRigidbody.GetComponentInParent <Guard>().Die(); } embedDistance = Vector3.Distance(originalParent.position, target) + EMBED_EXTRA_SLACK_DISTANCE; }