private GridNode CheckforScopeToMove(TraversalDirection dir, int count) { GridNode node = gridManager.GetRandomPosition(); GridNode n = node; for (int i = 0; i < count; i++) { node = gridManager.GetNextNode(node, dir); if (node.isFilled) { return(null); } } return(n); }
private void ChangeState(GAMESTATE state) { switch (_gameState) { case GAMESTATE.INITILIZE: break; case GAMESTATE.GAMEPLAY: break; case GAMESTATE.PAUSE: if (state == GAMESTATE.GAMEPLAY) { StartCoroutine(StartGame()); } break; case GAMESTATE.GAMEOVER: break; } _gameState = state; switch (state) { case GAMESTATE.INITILIZE: gridManager.Initilize(GridSize); goto default; case GAMESTATE.INITILIZECOMPLETE: fruitObj = gridManager.SetCollectObject(CollectPrefab, PoolManager.GetInstance().GetPoolContainer(false), true, out fruitNode); currentNode = gridManager.GetRandomPosition(10, 10); currentDirection = (TraversalDirection)(Random.Range(1, 4)); SetInitilialPositions(currentNode, currentDirection); if (currentDirection == TraversalDirection.LEFT) { currentDirection = TraversalDirection.RIGHT; } else if (currentDirection == TraversalDirection.RIGHT) { currentDirection = TraversalDirection.LEFT; } else if (currentDirection == TraversalDirection.BOTTOM) { currentDirection = TraversalDirection.TOP; } else if (currentDirection == TraversalDirection.TOP) { currentDirection = TraversalDirection.BOTTOM; } goto default; case GAMESTATE.GAMEPLAY: StartCoroutine(StartGame()); goto default; case GAMESTATE.PAUSE: goto default; case GAMESTATE.GAMEEND: StartCoroutine(ChangeState(GAMESTATE.GAMEOVER, 1.0f)); goto default; case GAMESTATE.GAMEOVER: if (OnGameStateChangeEvent != null) { OnGameStateChangeEvent(_gameState); } SoundManager.AudioPlayEvent(ConstantsList.Sfx_GameOver); Score = _score; break; default: if (OnGameStateChangeEvent != null) { OnGameStateChangeEvent(_gameState); } break; } }