private IEnumerator createCannonProjectile(GameObject playerGO, int fishDelta) { Vector3 shotTarget = playerGO.GetComponentInChildren <FishBucketCannonTarget>().gameObject.transform.position; int projectileCount = 1; AssetRequest <GameObject> request; if (fishDelta > 0) { request = Content.LoadAsync(cannonProjectileContentKey_Fish); projectileCount = fishDelta; } else { request = Content.LoadAsync(cannonProjectileContentKey_Squid); } yield return(request); for (int i = 0; i < projectileCount; i++) { GameObject gameObject = UnityEngine.Object.Instantiate(request.Asset, base.transform); FishBucketCannonProjectile component = gameObject.GetComponent <FishBucketCannonProjectile>(); component.SetTrajectory(ShotOrigin.transform.position, shotTarget, CannonShotTimeInSeconds + UnityEngine.Random.Range(0f - CannonShotTimeRandomOffsetInSeconds, CannonShotTimeRandomOffsetInSeconds)); if (i == 0) { currentShot = component; FishBucketCannonProjectile fishBucketCannonProjectile = currentShot; fishBucketCannonProjectile.ShotCompleteAction = (Action)Delegate.Combine(fishBucketCannonProjectile.ShotCompleteAction, new Action(onShotComplete)); } } }
private void OnDestroy() { CoroutineRunner.StopAllForOwner(this); if (currentShot != null) { FishBucketCannonProjectile fishBucketCannonProjectile = currentShot; fishBucketCannonProjectile.ShotCompleteAction = (Action)Delegate.Remove(fishBucketCannonProjectile.ShotCompleteAction, new Action(onShotComplete)); } }
private void onShotComplete() { FishBucketCannonProjectile fishBucketCannonProjectile = currentShot; fishBucketCannonProjectile.ShotCompleteAction = (Action)Delegate.Remove(fishBucketCannonProjectile.ShotCompleteAction, new Action(onShotComplete)); if (ShotCompleteAction != null) { ShotCompleteAction(currentShotTargetPlayerId, currentShotTarget, currentShotDelta); } currentShot = null; }