// PUBLIC METHODS: ------------------------------------------------------------------------ public bool StartChargedShot(CharacterShooter shooter) { if (!this.CanStartChargedShoot(shooter)) { return(false); } shooter.chargeShotStartTime = Time.time; shooter.isChargingShot = true; if (this.actionsOnStartCharge) { ShootData shootData = this.GetShootData(shooter); GameObject actionsInstance = Instantiate( this.actionsOnStartCharge.gameObject, shootData.originWeapon, Quaternion.FromToRotation( Vector3.up, shootData.destination - shootData.originWeapon ) ); actionsInstance.hideFlags = HideFlags.HideInHierarchy; Actions actions = actionsInstance.GetComponent <Actions>(); if (actions) { actions.Execute(shooter.gameObject, null); } } if (this.aimingMode == AimType.Trajectory) { if (shooter.trajectoryRenderer) { Destroy(shooter.trajectoryRenderer.gameObject); } this.trajectory.layerMask = this.layerMask; this.trajectory.maxDistance = this.distance; this.trajectory.shooter = shooter; Transform parent = (shooter.muzzle != null ? shooter.muzzle.transform : shooter.transform ); shooter.trajectoryRenderer = TrajectoryRenderer.Create(this.trajectory, parent); } shooter.eventChargedShotStart.Invoke(shooter.currentWeapon, this); return(true); }
// PUBLIC STATIC METHODS: --------------------------------------------------------- public static TrajectoryRenderer Create(Trajectory trajectory, Transform parent) { GameObject instance = new GameObject("ArcLineRenderer"); TrajectoryRenderer arc = instance.AddComponent <TrajectoryRenderer>(); arc.transform.parent = parent; arc.transform.localPosition = Vector3.zero; arc.transform.localRotation = Quaternion.identity; arc.transform.localScale = Vector3.one; arc.trajectory = trajectory; arc.SetupTrajectory(arc.trajectory); return(arc); }
private TrajectoryRenderer.TrajectoryResult GetTrajectoryResult(CharacterShooter shooter) { TrajectoryRenderer.Trajectory data = this.trajectory; data.layerMask = this.layerMask; data.maxDistance = this.distance; data.shooter = shooter; Transform origin = (shooter.muzzle != null ? shooter.muzzle.transform : shooter.transform ); return(TrajectoryRenderer.GetTrajectory( origin, data, shooter.GetCharge() )); }