void Awake() { cam = Camera.main; canvGroup = GetComponent <CanvasGroup>(); gameObject.SetActive(false); obj = GetComponentInParent <objectScript>(); wordScript = GetComponentInChildren <genWord>(); }
public void rightAnswer(objectScript choice) { currentScore = choice.getScore(); board.setScoreBoard(currentScore); destroyedObj = destroyedObj + 1; level = level + 1; loadNewLevel(); }
public void Inside() { objectScript objTemp = (objectScript)FindObjectOfType(typeof(objectScript)); if (objTemp != null) { objTemp.Inside(); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.GetComponent <objectScript>() != null) { canInteract = true; interactingObject = collision.gameObject.GetComponent <objectScript>(); interactingObject.overlayText.enabled = true; //interactingObject.Overlay(); maybe this will be useful sometime } }
public void wrongAnswer(objectScript choice) { counter = choice.getCounter(); //print("choice: " + choice); //print("obj counter: " + choice.getCounter()); if (counter > 0) { currentScore = choice.decScore(); counter = choice.decCounter(); print("currentScore: " + currentScore); print("counter: " + choice.getCounter()); } }
// Update is called once per frame void Update() { if (GvrViewer.Instance.Triggered)// || Input.GetMouseButtonDown(0)) { RaycastHit hit; bool u = Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity);//, 1 << 8); Collider tempHolder = hit.collider; if (u) { //print("Raycast hit: " + tempHolder); /*TempHolder here gets the Objects collider, therefor searching for a component in Parent works. * Searching for a Child component will therefor not work since the objects collider doesn't have components * underneath itself, it's the object itself that holds the collider that has the children components. * We also check if our tempHolder has a parent since as of this moment, the object is root in the hierachy. * This might change when we add more objects. */ objectScript rayCast = tempHolder.GetComponentInParent <objectScript>(); //This functions checks if the object is initiated and then does something with the choice you picked. if ((rayCast.getFade() == 0) && (rayCast.getClick() == 1) && (tempHolder.transform.parent != null)) { canvasScript canvScript = tempHolder.gameObject.GetComponentInParent <canvasScript>(); answer = tempHolder.GetComponentInChildren <Text>().text.ToString(); //print("tempHolder: " + answer.ToString()); //print("racCast " + rayCast.getAnswer().ToString()); if (answer == rayCast.getAnswer()) { canvScript.pickChoice(tempHolder); playScript.rightAnswer(rayCast); //fades everything. rayCast.setFade(); } else { canvScript.pickChoice(tempHolder); playScript.wrongAnswer(rayCast); } } //This function initiates the model choices and sets them to initiated so you can't initiate them again. else if (rayCast.getInstantiate() == 0) { model = tempHolder.GetComponent <objectScript>(); model.click(); model.setInstantiate(); } } } }
void OnZoomStart(Vector3 _pos1, Vector3 _pos2) { targetScript = (objectScript)FindObjectOfType(typeof(objectScript)); dist = (_pos1 - _pos2).magnitude; }