public void setCurrentState( StateMachine state ) { SFXManager.instance.playSingleSFX(openSFX, context.GetComponent<AudioSource>()); if(current_state != null) { current_state.onExitState(); } state.onEnterState(this); current_state = state; }
public void setState( StateMachine next ) { if( currentState != next ){ next.onEnterState( currentState ); }else{ } currentState = next; }
private IEnumerator init() { yield return new WaitForSeconds (0.2f); lightDownTurn = 20; boardManager.init(); currentLevel++; if (player == null) { player = Instantiate (playerPrefab, boardManager.getRandomRoomScript ().getEntry (), Quaternion.identity) as GameObject; GameObject.Find("HP").GetComponentInChildren<LifeText>().setTarget(player); } else { player.transform.position = boardManager.getRandomRoomScript ().getEntry (); } ((PlayerTurnState)playerTurn).setPlayer(player); Camera.main.GetComponent<CameraController>().setTarget(player.transform); for( int i = 0; i < 3; i++ ){ enemies[i] = Instantiate (enemyPrefab, boardManager.getRandomRoomScript ().getEntry (), Quaternion.identity) as GameObject; } ((EnemyTurnState)enemyTurn).setEnemy(enemies); currentState = playerTurn; currentState.onEnterState( enemyTurn ); inti_ready = true; yield return new WaitForSeconds (0.2f); Messenger.Invoke("light fadeIn"); yield return null; }