// Update is called once per frame void Update() { if (gameState == GameStatesEnum.Ready && breathingStatus.value == enumStatus.Exhale) { gameState = GameStatesEnum.BreathingSet; } // Check for a good breath ending and add to the count if (lastBreathingStatus == enumStatus.Exhale && breathingStatus.value == enumStatus.Inhale) { breathCount += 1; if (lastBreathLength > minGoodTime) { breathGoodCount += 1; } } if (breathCount > maxBreathCount || breathGoodCount > breathsMin) { gameState = GameStatesEnum.RestBetweenSets; // resets the counts for breaths breathCount = 0; breathGoodCount = 0; // increases the set counter setCount += 1; restTimer = 0f; if (setCount > minSetNum) { gameState = GameStatesEnum.FinishSets; } } // If the player should be resting, add a timer onto the system. if (gameState == GameStatesEnum.RestBetweenSets) { restTimer += Time.deltaTime; } // If the resting time is over, ready to play again if (restTimer > minRestTime && gameState == GameStatesEnum.RestBetweenSets) { gameState = GameStatesEnum.Ready; } // Update the last frame lastBreathingStatus = breathingStatus.value; lastBreathLength = breathLength.value; }
private void Awake() { _subscribes = new List <ISubscriber>(); _fallCellsDictionary = new Dictionary <GameObject, Vector2>(); _powersDictionary = new Dictionary <Vector2, PowerUpTypesEnum>(); _spawnedPowerUpDictionary = new Dictionary <Vector3, PowerUpTypesEnum>(); _matchedCellsDictionary = new Dictionary <IList <ICell>, AxisTypesEnum>(); _matchedCellsWithAxisDictionary = new Dictionary <ICell, IDictionary <IList <ICell>, AxisTypesEnum> >(); _gameStateEnum = GameStatesEnum.Ready; }
private void CheckBoard() { _lastSpawnedCell = false; _fallCellsDictionary.Clear(); _matchedCellsDictionary.Clear(); _matchedCellsWithAxisDictionary.Clear(); if (HaveMatches()) { FindMatches(); return; } _gameStateEnum = GameStatesEnum.Ready; }
public void OnEvent(EventTypesEnum eventTypeEnum, object messageData) { switch (eventTypeEnum) { case EventTypesEnum.LMB_Down: _clickA = Camera.main.ScreenToWorldPoint(Input.mousePosition); break; case EventTypesEnum.LMB_Up: _clickB = Camera.main.ScreenToWorldPoint(Input.mousePosition); if (_gameStateEnum == GameStatesEnum.Ready) { if (_clickA.x >= 0 && _clickA.x < _board.Width && _clickA.y >= 0 && _clickA.y < _board.Height && (Mathf.Abs(_clickB.x - _clickA.x) > Strings.SWIPE_SENSITIVITY || Mathf.Abs(_clickB.y - _clickA.y) > Strings.SWIPE_SENSITIVITY)) { MoveDirectionTypesEnum swipeDirection = Helper.FindMoveDirection(_clickA, _clickB); SwipeCells(swipeDirection); } } break; case EventTypesEnum.Swipe: _gameStateEnum = GameStatesEnum.Wait; SetMacroCommand((ICommand[])messageData); ExecuteMacroCommand(); break; case EventTypesEnum.BOARD_collapse: ExecuteMacroCommand(); break; case EventTypesEnum.BOARD_EndDestroyMatchedCells: if (_powersDictionary.Count > 0) { Vector2 pos = _powersDictionary.First().Key; PowerUpTypesEnum powerUpTypeEnum = _powersDictionary.First().Value; List <ICell> cellsList = new List <ICell>(_checkManager.PowerCheck(powerUpTypeEnum, pos)); ICell cell = _board.Cells[(int)pos.x, (int)pos.y]; _matchedCellsDictionary.Add(cellsList, AxisTypesEnum.Undefined); _matchedCellsWithAxisDictionary.Add(cell, _matchedCellsDictionary); _powersDictionary.Remove(_powersDictionary.First()); StartCoroutine(MarkAndDestroy(_matchedCellsWithAxisDictionary)); } else { StartCoroutine(RefillBoard()); } break; case EventTypesEnum.CELL_EndMove: TryCheckSwipedCells((ICell)messageData); break; case EventTypesEnum.CELL_EndMoveBack: ICell cellBack = (ICell)messageData; _board.Cells[cellBack.TargetX, cellBack.TargetY] = cellBack; cellBack.CellStateEnum = CellStatesEnum.Wait; _gameStateEnum = GameStatesEnum.Ready; break; case EventTypesEnum.CELL_Fall: ICell cellFall = (ICell)messageData; cellFall.CellStateEnum = CellStatesEnum.Wait; if (cellFall == _lastFallCell) { CheckBoard(); } break; case EventTypesEnum.CELL_Destroy: string cellTag = (string)messageData; Notify(EventTypesEnum.CELL_Destroy, cellTag); break; case EventTypesEnum.POWER_Use: ArrayList arr = (ArrayList)messageData; PowerUpTypesEnum powerUp = Helper.StringToPowerType(arr[0].ToString()); Vector3 position = (Vector3)arr[1]; _powersDictionary.Add(position, powerUp); break; case EventTypesEnum.TASK_Finished: if (_gameStateEnum != GameStatesEnum.End) { _navigationManager.MasterManager.UpdateManager.IsUpdate = false; _gameStateEnum = GameStatesEnum.End; Notify(EventTypesEnum.TASK_Finished, null); } break; default: Debug.Log("EVENT NOT FOUND"); break; } }
public Game() { field = new FieldStatesEnum[9]; state = GameStatesEnum.WaitFirstPlayer; }
public void ChangeState(GameStatesEnum state) { gameStateMachine.MoveNext(state); gameStateMachine.State.Start(); }