public void setSelection(GameObject block, int lev) { if (States.selectedLevel == lev) { GamePhaseController.showLoading(); GameStorage.getInstance().loadLevel(lev); } if (States.selectedLevel != lev) { if (lev % 2 == 0) { ((UnityEngine.UI.Image)((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[0]).overrideSprite = ((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState.pressedSprite; ((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[0]).spriteState = selectedState; } if (lev % 2 == 1) { ((UnityEngine.UI.Image)((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).gameObject.GetComponentsInChildren <UnityEngine.UI.Image>()[0]).overrideSprite = ((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).spriteState.pressedSprite; ((UnityEngine.UI.Button)block.GetComponentsInChildren <UnityEngine.UI.Button>()[1]).spriteState = selectedState; } descriptionPanel.GetComponentsInChildren <UnityEngine.UI.Text>()[0].text = ((Templates.LevelInfo)Templates.getInstance().getLevel((int)States.currentCampaign.levels[lev])).levelName; descriptionPanel.GetComponentsInChildren <UnityEngine.UI.Text>()[1].text = ((Templates.LevelInfo)Templates.getInstance().getLevel((int)States.currentCampaign.levels[lev])).description; States.selectedLevel = lev; start_but.SetActive(true); } }
public void ChangeState(GameStates newState) { bool isCurrentState = (GameState == newState); if (!isCurrentState) { // send new state to server. Only change state in Unity app once server responds SocketIO.ChangeGameState(GameStateToSocketMessageString(newState), response => { // check for error in the response var responseJSON = JSONObject.Parse(response); if (responseJSON["error"] != null) { Debug.LogError("Server error when changing game state: " + responseJSON["error"]); return; } // get any carry-over data from the current state controller and delete the controller JSONObject betweenStateControllerData = null; if (currentStateController != null) { betweenStateControllerData = currentStateController.ReturnDataForNextGamePhase(); Destroy(currentStateController.gameObject); } // instantiate a new state controller and pass it the carry-over data GamePhaseController newStateController = InstantiateControllerForState(newState); currentStateController = newStateController; currentStateController.UseCarryOverData(betweenStateControllerData); GameState = newState; }); } }
public void nextButtonCallback() { States.retries = 0; GamePhaseController.showLoading(); pausePanel.SetActive(false); States.selectedLevel++; GameStorage.getInstance().loadLevel(States.selectedLevel); }
public void mainButtonCallback() { States.retries = 0; mainPanel.SetActive(false); pausePanel.SetActive(false); GamePhaseController.showLoading(); UnityEngine.SceneManagement.SceneManager.LoadScene(0, UnityEngine.SceneManagement.LoadSceneMode.Single); States.inPauseMenu = false; }
public void restartButtonCallback() { States.retries++; mainPanel.SetActive(false); pausePanel.SetActive(false); GamePhaseController.showLoading(); GameStorage.getInstance().loadLevel(States.selectedLevel); States.inPauseMenu = false; }
public void checkZalpButtonState() { bool res = false; foreach (FriendlySpaceship obj in friendlySpaceships) { if (obj.haveAbilRocketsOrThorpeds()) { res = true; break; } } GamePhaseController.setZalpButtonActive(res); }
public void loadLevel() { GamePhaseController.showLoading(); GameStorage.getInstance().loadLevel(States.selectedLevel); }
void Start() { instance = this; //Debug.Log("initialized"); }
void Start() { instance=this; //Debug.Log("initialized"); }