private void OnCollisionEnter2D(Collision2D collision) { GameObject.Find("Active Menu").GetComponent <menuSwitch>().changeMenu(3); PlayerController playerController = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>(); if (name == "Taco" && !playerController.taco) { return; } //print(GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerDictionary>().playerDict.Count + " " + wordPoolName); List <PlayerDictionary.Word> words = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerDictionary>().playerDict[wordPoolName]; playerController.Stop(true); if (useSpecficWord) { if (specficWord == "Yellow") { wordIndex = 0; } else if (specficWord == "Red") { wordIndex = 1; } else if (specficWord == "Black") { wordIndex = 2; } else if (specficWord == "Hello") { wordIndex = 0; } } else { wordIndex = Random.Range(0, words.Count); } PlayerDictionary.Word word = words[wordIndex]; GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().Write(); GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().expectedWord = word; GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().makeTraceBoxes(); GameObject.Find("TextYet").GetComponent <Text>().text = word.koreanText; GameObject.Find("TopMostText").GetComponent <Text>().text = "\"" + word.translation + "\""; GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>().wordsSeen.Add(word); }
private void Update() { //PlayerController playerController = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); if (Vector2.Distance(transform.position, player.transform.position) > 1.2f) { //transform.position = Vector2.MoveTowards(transform.position, player.transform.position, .05f); float moveHorizontal = Input.GetAxis("Horizontal"); float moveVertical = Input.GetAxis("Vertical"); Vector3 pos = transform.position; Vector3 movement = Vector3.MoveTowards(pos, player.transform.position, speed * Time.deltaTime); //Debug.Log("movement" + movement); Vector3 animate = player.transform.position - pos; animator.SetFloat("Horizontal", animate.x); animator.SetFloat("Vertical", animate.y); animator.SetFloat("Magnitude", movement.magnitude); pos = movement; transform.position = pos; } else if (!playerController.writing) { // wordPoolName = RandomValues(GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerDictionary>().playerDict); List <PlayerDictionary.Word> words = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerDictionary>().playerDict[wordPoolName]; playerController.Stop(true); wordIndex = Random.Range(0, words.Count); PlayerDictionary.Word word = words[wordIndex]; GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().Write(); GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().expectedWord = word; GameObject.FindGameObjectWithTag("GUI").GetComponent <GuiController>().makeTraceBoxes(); GameObject.Find("TextYet").GetComponent <Text>().text = word.koreanText; GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>().wordsSeen.Add(word); GameObject.Find("TopMostText").GetComponent <Text>().text = "\"" + word.translation + "\""; } }