public void CharacterClick() { this.GetComponent <Animation>().Play("Talk"); for (int i = 0; i < GameEngine.Instance.snapRandomChat.Length; i++) { GameEngine.Instance.snapRandomChat[i].SetActive(false); } if (this.gameObject.tag == "Strawberry") { if (GameEngine.isCreatStrawberryKing) { if (Vector3.Distance(GameEngine.Instance.sCrownPrefab0.transform.position, targetGameObject.transform.position) > 3f && Vector3.Distance(GameEngine.Instance.sCrownPrefab0.transform.position, targetGameObject.transform.position) < 10f) { int index = RandFunction.RandSelect(new List <int>() { 13, 14, 15 }); GameEngine.Instance.snapRandomChat[0].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (GameObject.FindGameObjectsWithTag("Wolf").Length > 0) { for (int i = 0; i < GameObject.FindGameObjectsWithTag("Wolf").Length; i++) { if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Wolf")[i].transform.position, targetGameObject.transform.position) > 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) < 20f) { int index = RandFunction.RandSelect(new List <int>() { 4, 5, 6, 7, 8, 9 }); GameEngine.Instance.snapRandomChat[0].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Wolf")[i].transform.position, targetGameObject.transform.position) < 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) > 3f) { int index = RandFunction.RandSelect(new List <int>() { 10, 11, 12 }); GameEngine.Instance.snapRandomChat[0].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else { int index = RandFunction.RandSelect(new List <int>() { 0, 1, 2, 3 }); GameEngine.Instance.snapRandomChat[0].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } } } else { int index = RandFunction.RandSelect(new List <int>() { 0, 1, 2, 3 }); GameEngine.Instance.snapRandomChat[0].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[0].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } } } else if (this.gameObject.tag == "Corn") { if (GameEngine.isFindeCornCrown) { if (Vector3.Distance(GameEngine.Instance.cCrownPrefab0.transform.position, targetGameObject.transform.position) > 3f && Vector3.Distance(GameEngine.Instance.cCrownPrefab0.transform.position, targetGameObject.transform.position) < 10f) { int index = RandFunction.RandSelect(new List <int>() { 29, 30, 31 }); GameEngine.Instance.snapRandomChat[1].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (GameObject.FindGameObjectsWithTag("Cloud").Length > 0) { for (int i = 0; i < GameObject.FindGameObjectsWithTag("Cloud").Length; i++) { if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Cloud")[i].transform.position, targetGameObject.transform.position) > 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) < 20f) { int index = RandFunction.RandSelect(new List <int>() { 20, 21, 22, 23, 24, 25 }); GameEngine.Instance.snapRandomChat[1].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Cloud")[i].transform.position, targetGameObject.transform.position) < 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) > 3f) { int index = RandFunction.RandSelect(new List <int>() { 26, 27, 28 }); GameEngine.Instance.snapRandomChat[1].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else { int index = RandFunction.RandSelect(new List <int>() { 16, 17, 18, 19 }); GameEngine.Instance.snapRandomChat[1].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } } } else { int index = RandFunction.RandSelect(new List <int>() { 16, 17, 18, 19 }); GameEngine.Instance.snapRandomChat[1].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[1].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } } } else if (this.gameObject.tag == "Pumkin") { if (GameEngine.isFindPumkinCrown) { if (Vector3.Distance(GameEngine.Instance.pCrownPrefab0.transform.position, targetGameObject.transform.position) > 3f && Vector3.Distance(GameEngine.Instance.pCrownPrefab0.transform.position, targetGameObject.transform.position) < 10f) { int index = RandFunction.RandSelect(new List <int>() { 45, 46, 47 }); GameEngine.Instance.snapRandomChat[2].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (GameObject.FindGameObjectsWithTag("Witch").Length > 0) { for (int i = 0; i < GameObject.FindGameObjectsWithTag("Witch").Length; i++) { if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Witch")[i].transform.position, targetGameObject.transform.position) > 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) < 20f) { int index = RandFunction.RandSelect(new List <int>() { 36, 37, 38, 39, 40, 41 }); GameEngine.Instance.snapRandomChat[2].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else if (Vector3.Distance(GameObject.FindGameObjectsWithTag("Witch")[i].transform.position, targetGameObject.transform.position) < 10f && Vector3.Distance(this.gameObject.transform.position, targetGameObject.transform.position) > 3f) { int index = RandFunction.RandSelect(new List <int>() { 42, 43, 44 }); GameEngine.Instance.snapRandomChat[2].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } else { int index = RandFunction.RandSelect(new List <int>() { 32, 33, 34, 35 }); GameEngine.Instance.snapRandomChat[2].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } break; } } } else { int index = RandFunction.RandSelect(new List <int>() { 32, 33, 34, 35 }); GameEngine.Instance.snapRandomChat[2].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[2].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } } } }
public void Hit() { if (isAttack && !isDie) { HitCount++; isHit = true; this.GetComponent <Animation>().Play("Hit"); HealthBarHandler.Instance.SetHealthBarValue(1f - 0.1f * HitCount); } else if (isEnemyFollowDialog && !isDie) { if (this.gameObject.tag == "Wolf") { int index = RandFunction.RandSelect(new List <int>() { 48, 49, 50 }); GameEngine.Instance.snapRandomChat[3].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[3].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[3].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (this.gameObject.tag == "Cloud") { int index = RandFunction.RandSelect(new List <int>() { 54, 55, 56 }); GameEngine.Instance.snapRandomChat[4].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[4].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[4].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (this.gameObject.tag == "Witch") { int index = RandFunction.RandSelect(new List <int>() { 60, 61 }); GameEngine.Instance.snapRandomChat[5].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[5].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[5].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } } if (HitCount == 10 && !isDie) { this.GetComponent <Animation>().Play("Die"); isDie = true; isEnemyNearbyDialog = false; isEnemyFollowDialog = false; isEnemyDieDialog = true; GameEngine.Instance.healthBar.enabled = false; for (int i = 0; i < GameEngine.Instance.snapRandomChat.Length; i++) { GameEngine.Instance.snapRandomChat[i].SetActive(false); } if (this.gameObject.tag == "Wolf") { int index = RandFunction.RandSelect(new List <int>() { 51, 52, 53 }); GameEngine.Instance.snapRandomChat[3].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[3].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[3].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (this.gameObject.tag == "Cloud") { int index = RandFunction.RandSelect(new List <int>() { 57, 58, 59 }); GameEngine.Instance.snapRandomChat[4].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[4].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[4].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } else if (this.gameObject.tag == "Witch") { int index = RandFunction.RandSelect(new List <int>() { 62, 63, 64 }); GameEngine.Instance.snapRandomChat[5].SetActive(true); GameEngine.isType = true; if (SplashScene.gameplayLang == "english") { GameEngine.Instance.snapRandomChat[5].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogE[index]; } else if (SplashScene.gameplayLang == "french") { GameEngine.Instance.snapRandomChat[5].GetComponentsInChildren <Text>()[0].text = Strings.randomDialogF[index]; } } if (this.gameObject.tag == "Wolf") { GameEngine.Instance.wolfAvatar.SetActive(true); } else if (this.gameObject.tag == "Cloud") { GameEngine.Instance.cloudAvatar.SetActive(true); } else if (this.gameObject.tag == "Witch") { GameEngine.Instance.witchAvatar.SetActive(true); } GameEngine.Instance.killedEnemyCount++; GameEngine.Instance.killedEnemyCountText.text = "" + GameEngine.Instance.killedEnemyCount; } }