public void AddDefaultSmartTerrainEventHandler(GameObject go, PropBehaviour prop, SurfaceBehaviour primarySurface) { var handler = go.AddComponent <DefaultSmartTerrainEventHandler>(); handler.PropTemplate = prop.GetComponent <PropBehaviour>(); handler.SurfaceTemplate = primarySurface.GetComponent <SurfaceBehaviour>(); }
public void StartTerrainGeneration() { mSurfaceBehavour = FindObjectOfType <SurfaceBehaviour>(); mSurfaceBehavour.GetComponent <CustomSmartTerrainTrackableEventHandler>().StartRender(); }
void Update() { //We declare the bool values here because we want them to be set to false, unless the state is correct //This saves us from setting the values to false in each state. bool showDoneButton = false; bool showResetButton = false; switch (appState) { //Detection phase case AppStates.OVERLAY_OUTLINE: instructionsText.text = pointDeviceText; surfaceBehaviour.GetComponent <Renderer>().enabled = false; break; // The animation that is played when the trackable is found for the first time case AppStates.INIT_ANIMATION: appState = AppStates.SCANNING; break; // Scanning phase case AppStates.SCANNING: ShowWireFrame(true); instructionsText.text = pullBackText; showDoneButton = true; break; // When the user taps done. This happens before the game can be played case AppStates.GAME_RENDERING: if ((reconstructionBehaviour != null) && (reconstructionBehaviour.Reconstruction != null)) { ShowWireFrame(false); surfaceBehaviour.GetComponent <Renderer>().enabled = false; imageTarget.ToggleOnStateChange = true; reconstructionBehaviour.Reconstruction.Stop(); OnStartGame.Invoke(); appState = AppStates.GAME_PLAY; } break; //This is where the user can shoot the ball case AppStates.GAME_PLAY: instructionHolder.gameObject.SetActive(false); showResetButton = true; break; //User taps on [RESET] button - Re-loads the level case AppStates.RESET_ALL: //Reloads this scene UnityEngine.SceneManagement.SceneManager.LoadScene(0); appState = AppStates.NONE; break; // Just a placeholder state, to make sure that the previous state runs for just one frame. case AppStates.NONE: break; } if (doneButton != null && showDoneButton != doneButton.enabled) { doneButton.enabled = showDoneButton; doneButton.image.enabled = showDoneButton; doneButton.gameObject.SetActive(showDoneButton); } if (resetButton != null && showResetButton != resetButton.enabled) { resetButton.enabled = showResetButton; resetButton.image.enabled = showResetButton; resetButton.gameObject.SetActive(showResetButton); } }
void Update() { if (Input.GetKeyUp(KeyCode.Escape) || Input.GetKeyUp(KeyCode.JoystickButton0)) { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else Application.Quit(); #endif } bool showOutline = false; bool showDoneButton = false; bool showResetButton = false; switch (mState) { //Detection phase case UIStates.OVERLAY_OUTLINE: instructionsImage.texture = mPointDeviceTexture; mSmartSurface.GetComponent <Renderer>().enabled = false; showOutline = true; break; // Soda can ice animating phase case UIStates.INIT_ANIMATION: mSmartSurface.GetComponent <Renderer>().enabled = false; Ice anim = GameObject.FindObjectOfType <Ice>(); anim.Play(); if (anim.DidFinishAnimation) { mSmartSurface.GetComponent <Renderer>().enabled = mSTTrackableHandler.m_trackablesFound; mState = UIStates.SCANNING; } break; // Scanning phase case UIStates.SCANNING: mSmartSurface.GetComponent <Renderer>().enabled = mSTTrackableHandler.m_trackablesFound; instructionsImage.texture = mPullBackTexture; showDoneButton = true; break; // Icebergs rendering phase - user taps on [DONE] button case UIStates.GAME_RENDERING: if ((mReconstructionBehaviour != null) && (mReconstructionBehaviour.Reconstruction != null)) { mSTEventHandler.ShowPropClones(); mReconstructionBehaviour.Reconstruction.Stop(); mState = UIStates.GAME_PLAY; } break; //Penguin appears and user taps on surface to move the penguin around case UIStates.GAME_PLAY: if (mSTEventHandler.propsCloned && !penguin.DidAppear) { penguin.gameObject.SetActive(true); } if (penguin.DidAppear) { // Update UI messaging instructionsImage.texture = mTapIceTexture; showResetButton = true; } break; //User taps on [RESET] button - Re-loads the level case UIStates.RESET_ALL: // Go back to loading scene int loadingScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex - 1; if (loadingScene < 0) { loadingScene = 0; } UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(loadingScene); mState = UIStates.NONE; break; // Just a placeholder state, to make sure that the previous state runs for just one frame. case UIStates.NONE: break; } if (cylinderOutline != null && showOutline != cylinderOutline.enabled) { cylinderOutline.enabled = showOutline; } if (doneButton != null && showDoneButton != doneButton.enabled) { doneButton.enabled = showDoneButton; doneButton.image.enabled = showDoneButton; doneButton.gameObject.SetActive(showDoneButton); } if (resetButton != null && showResetButton != resetButton.enabled) { resetButton.enabled = showResetButton; resetButton.image.enabled = showResetButton; resetButton.gameObject.SetActive(showResetButton); } }