public static bool IssueRequest(GameObject gameObject) { var data = new RequestSingleShotMessageData(); gameObject.SendMessage(MessageName, data, SendMessageOptions.DontRequireReceiver); return(!data.StopShooting); }
void OnRequestSingleShot(RequestSingleShotMessageData data) { /* TODO: implement. This handler can set data.StopShooting = true when * shooter is out of ammo. Return from method without triggering SingleShotTrigger * when shooting must be stopped. */ animator.SetTrigger(AnimatorNames.SingleShotTrigger); }
private void ProcessShooting() { if (!IsShooting || !enabled) { return; } float frameEndTimestamp = Time.fixedTime + Time.fixedDeltaTime; if (float.IsNegativeInfinity(nextShotTimestamp)) { nextShotTimestamp = Time.fixedTime; } bool shootingAllowed = true; for ( ; NumShotsProduced < NumShotsToProduce && nextShotTimestamp < frameEndTimestamp && shootingAllowed; NumShotsProduced++, nextShotTimestamp += delayBetweenShots ) { shootingAllowed = RequestSingleShotMessageData.IssueRequest(gameObject); if (shootingAllowed) { if (soundPlayer != null) { soundPlayer.PlayVariation(ShotSounds); } SendMessage(OnPerformSingleShotMessageName, SendMessageOptions.DontRequireReceiver); } } if (!shootingAllowed || NumShotsProduced >= NumShotsToProduce) { StopShooting(); } }