/* ~~~~~~~~~~~~~~~~~~~~ Unity Event Handlers ~~~~~~~~~~~~~~~~~~~~ */ public void OnPowerUpAcquisition(PowerUpAcquiredEvent powerUpAcquiredEvent) { if (powerUpAcquiredEvent.activationType == PowerUpActivationType.IMMEDIATE) { ActivatePowerUp(powerUpAcquiredEvent.powerUp); } else { Debug.Log("Enqueuing newly acquired PowerUp."); storedPowerUps.Enqueue(powerUpAcquiredEvent.powerUp); storedPowerUpWidget.UpdateStoredPowerUpIcons(storedPowerUps); } }
void Awake() { if (powerUpIconsByGuid == null || powerUpIconsByGuid.Count == 0) { throw new InvalidOperationException("There must be at least one Sprite in powerUpIcons."); } if (costPerPwrUp == 0f) { costPerPwrUp = DEFAULT_COST_PER_PWR_UP; } Cash = 0f; IsRandomizingPowerUps = false; pwrUpAcquiredEvent = new PowerUpAcquiredEvent(); }
void Awake() { Id = Guid.NewGuid(); pwrUpAcquiredEvent = EventManager.Instance.GetOrAddEventWithPayload(new PowerUpAcquiredEvent()); pwrUpExpiredEvent = EventManager.Instance.GetOrAddEventWithPayload(new PowerUpExpiredEvent()); if (puckVelModifier == 0f) { puckVelModifier = DEFAULT_PUCK_VEL_MOD; } if (maxPegBreaks == 0) { maxPegBreaks = DEFAULT_MAX_PEG_BREAKS; } }
void Awake() { Id = Guid.NewGuid(); pwrUpAcquiredEvent = EventManager.Instance.GetOrAddEventWithPayload(new PowerUpAcquiredEvent()); pwrUpExpiredEvent = EventManager.Instance.GetOrAddEventWithPayload(new PowerUpExpiredEvent()); if (puckBounceMod == 0f) { puckBounceMod = DEFAULT_PUCK_BOUNCE_MOD; } if (pwrUpDuration == 0f) { pwrUpDuration = DEFAULT_PWR_UP_DURATION; } }
void Update() { switch (gameState.SlotState) { case SlotMachineState.AT_REST: break; case SlotMachineState.START_SPINNING: MoveSlotReel(UP, reelTransitionSpeed); if (slotMachineSlots.ElementAt(0).HasMovedPassedY(UP, visibleReelYBounds.y)) { gameState.SetSlotMachineState(SlotMachineState.SPINNING); reelRotationsCount = 0; slotShiftCount = 0; // TODO: Add "blur" effect } break; case SlotMachineState.SPINNING: MoveSlotReel(DOWN, reelSpinSpeed); HandleSlotLooping(); if (reelRotationsCount == fullRotationsToComplete) { gameState.SetSlotMachineState(SlotMachineState.STOP_SPINNING); // TODO: Remove "blur" effect } break; case SlotMachineState.STOP_SPINNING: MoveSlotReel(UP, reelTransitionSpeed); if (slotMachineSlots.ElementAt(0).HasMovedPassedY(DOWN, visibleReelYBounds.x)) { gameState.SetSlotMachineState(SlotMachineState.AT_REST); // Notify listeners that a PowerUp has been acquired. PowerUpAcquiredEvent powerUpAcquiredEvent = new PowerUpAcquiredEvent() { powerUp = winningPowerUp, activationType = PowerUpActivationType.MANUAL }; EventManager.Instance.NotifyListeners(powerUpAcquiredEvent); } break; } }