/* ~~~~~~~~~~~~~~~~~~~~~~~~~~ Slot State Handlers ~~~~~~~~~~~~~~~~~~~~~~~~~~ */ public void SetSlotMachineState(SlotMachineState slotState) { switch (SlotState) { case SlotMachineState.AT_REST: if (slotState != SlotMachineState.START_SPINNING) { throw new ArgumentException(string.Format(SLOT_STATE_ERROR_MSG, SlotState, slotState, SlotMachineState.START_SPINNING)); } break; case SlotMachineState.START_SPINNING: if (slotState != SlotMachineState.SPINNING) { throw new ArgumentException(string.Format(SLOT_STATE_ERROR_MSG, SlotState, slotState, SlotMachineState.SPINNING)); } break; case SlotMachineState.SPINNING: if (slotState != SlotMachineState.STOP_SPINNING) { throw new ArgumentException(string.Format(SLOT_STATE_ERROR_MSG, SlotState, slotState, SlotMachineState.STOP_SPINNING)); } break; case SlotMachineState.STOP_SPINNING: if (slotState != SlotMachineState.AT_REST) { throw new ArgumentException(string.Format(SLOT_STATE_ERROR_MSG, SlotState, slotState, SlotMachineState.AT_REST)); } break; } SlotState = slotState; }
void Start() { State = MainGameState.PRE_LAUNCH; SlotState = SlotMachineState.AT_REST; EventManager eventMgr = EventManager.Instance; eventMgr.RegisterListener <BuyPuckEvent>(OnBuyPuck); eventMgr.RegisterListener <PuckAimingEvent>(OnPuckAiming); eventMgr.RegisterListener <PuckLaunchEvent>(OnPuckLaunch); eventMgr.RegisterListener <KillPuckEvent>(OnPuckDeath); eventMgr.RegisterListener <PuckScoreEvent>(OnPuckScore); eventMgr.RegisterListener <PauseGameEvent>(OnGamePause); eventMgr.RegisterListener <UnpauseGameEvent>(OnGameUnpause); eventMgr.RegisterListener <GameOverEvent>(OnGameOver); }
void Update() { animationCounter -= Time.deltaTime; switch (state) { // wait for player to touch lever default: case SlotMachineState.idle: if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("Fire1")) { state = SlotMachineState.spinning; animationCounter = animationLength; lever.Press(); SoundManager.i.PlayOnce("Spinning"); // hide slots playerSlot.gameObject.SetActive(false); arenaSlot.gameObject.SetActive(false); enemySlot.gameObject.SetActive(false); } return; // spinspinspinspiiin case SlotMachineState.spinning: // rotate cylinders bigCylinder.transform.Rotate(Vector3.up * spinningSpeed * Time.deltaTime); smallCylinder.transform.Rotate(Vector3.up * spinningSpeed * Time.deltaTime); float slotTime = animationLength / 3f; if (animationCounter <= slotTime * 0 && !enemySlot.gameObject.activeSelf) { PickEnemyModifier(); state = SlotMachineState.done; animationCounter = waitAfterRoll; SoundManager.i.StopPlaying("Spinning"); } else if (animationCounter <= slotTime * 1 && !arenaSlot.gameObject.activeSelf) { PickArenaModifier(); } else if (animationCounter <= slotTime * 2 && !playerSlot.gameObject.activeSelf) { PickPlayerModifier(); } break; // wait after results roll case SlotMachineState.done: if (animationCounter <= 0f) { state = SlotMachineState.end; } break; // set modifiers and start game case SlotMachineState.end: print(GameManager.playerModifier.health); print(this.playerModifier.health); GameManager.playerModifier.MergeModifier(this.playerModifier); GameManager.arenaModifier.MergeModifier(this.arenaModifier); GameManager.enemyModifier.MergeModifier(this.enemyModifier); print(GameManager.playerModifier.health); GameManager.instance.ToArenaScene(); break; } }
void Start() { slotMachineState = GameObject.Find("RealMachineState").GetComponent<SlotMachineState>(); // リールをセットアップ Setup4thReelTexture(); ZZ.setThreadSpeed(20); InitializeCasinoData(); LoadPlayData(); StartCoroutine(MainLoop()); }