/// <summary> /// On init we grab our WeaponAim /// </summary> protected virtual void Initialization() { _weaponAim = this.gameObject.GetComponent <WeaponAim>(); _weapon = this.gameObject.GetComponent <Weapon>(); if (_weaponAim == null) { Debug.LogWarning(this.name + " : the WeaponAutoAim on this object requires that you add either a WeaponAim2D or WeaponAim3D component to your weapon."); return; } _originalAimControl = _weaponAim.AimControl; _originalRotationMode = _weaponAim.RotationMode; _character = _weapon.Owner; _contactFilter = new ContactFilter2D(); _contactFilter.SetLayerMask(TargetsMask); _contactFilter.useLayerMask = true; _contactFilter.useDepth = false; _contactFilter.useNormalAngle = false; _contactFilter.useOutsideDepth = false; _contactFilter.useOutsideNormalAngle = false; _contactFilter.useTriggers = false; _detectionColliders = new List <Collider2D>(); _initialized = true; FirstTargetFoundFeedback?.Initialization(this.gameObject); NewTargetFoundFeedback?.Initialization(this.gameObject); NoMoreTargetsFeedback?.Initialization(this.gameObject); if (AimMarkerPrefab != null) { _aimMarker = Instantiate(AimMarkerPrefab); _aimMarker.name = this.gameObject.name + "_AimMarker"; _aimMarker.Disable(); } }
/// <summary> /// On init we grab our WeaponAim /// </summary> protected virtual void Initialization() { _weaponAim = this.gameObject.GetComponent <WeaponAim>(); _weapon = this.gameObject.GetComponent <Weapon>(); if (_weaponAim == null) { Debug.LogWarning(this.name + " : the WeaponAutoAim on this object requires that you add either a WeaponAim2D or WeaponAim3D component to your weapon."); return; } _originalAimControl = _weaponAim.AimControl; _originalRotationMode = _weaponAim.RotationMode; _originalMoveCameraTarget = _weaponAim.MoveCameraTargetTowardsReticle; }
/// <summary> /// Sets the dash properties, triggers the dash, and resets everything afterwards /// </summary> /// <returns></returns> protected virtual IEnumerator DashSequence() { _dashInProgress = true; // we set our dash's properties _characterDash3D.DashDistance = DashDistance; _characterDash3D.DashCurve = DashCurve; _characterDash3D.DashDuration = DashDuration; _characterDash3D.DashDirection = this.transform.forward; // we turn off input detection _character.LinkedInputManager.InputDetectionActive = false; // we force rotation on the model if (_characterOrientation3D != null) { _rotationMode = _characterOrientation3D.RotationMode; _characterOrientation3D.RotationMode = CharacterOrientation3D.RotationModes.MovementDirection; _characterOrientation3D.ForcedRotation = true; _characterOrientation3D.ForcedRotationDirection = ((this.transform.position + this.transform.forward * 10) - this.transform.position).normalized; } // we force rotation on the weapon if (_characterHandleWeapon != null) { if (_characterHandleWeapon.CurrentWeapon != null) { _weaponAim3D = _characterHandleWeapon.CurrentWeapon.gameObject.MMGetComponentNoAlloc <WeaponAim3D>(); if (_weaponAim3D != null) { _weaponAimControl = _weaponAim3D.AimControl; _weaponAim3D.AimControl = WeaponAim.AimControls.Script; _weaponAim3D.SetCurrentAim(((this.transform.position + this.transform.forward * 10) - this.transform.position).normalized); } } } // we disable obstacle collisions CoverObstacleCollider.enabled = false; // we turn triggers off SetColliderTrigger(false); foreach (DashZone3D dashZone in ExitDashZones) { dashZone.SetColliderTrigger(false); } // we start dashing _characterDash3D.DashStart(); // we wait for the duration of the dash yield return(_dashWaitForSeconds); // we put everything back as it was _character.LinkedInputManager.InputDetectionActive = true; if (_characterOrientation3D != null) { _characterOrientation3D.ForcedRotation = false; _characterOrientation3D.RotationMode = _rotationMode; } if (_weaponAim3D != null) { _weaponAim3D.AimControl = _weaponAimControl; } CoverObstacleCollider.enabled = true; // we wait to turn the triggers back on again yield return(_triggerResetForSeconds); // we turn our triggers back on SetColliderTrigger(true); foreach (DashZone3D dashZone in ExitDashZones) { dashZone.SetColliderTrigger(true); } _dashInProgress = false; }