void Start() { agent = GetComponent <NavMeshAgent>(); agent.speed = speed; anim = GetComponent <Animator>(); target = FindObjectOfType <Player>().transform; health = GetComponent <IHealth>(); sedat = GetComponent <SedatPoint>(); audioSource = GetComponent <AudioSource>(); ws = FindObjectOfType <WaveSystem>(); GetInfo(); if (health.HealthPoint <= 0) { isDied = true; health.OnDead(); anim.Play("Died"); anim.SetBool("isIdling", true); anim.SetBool("isRunning", false); anim.SetBool("isDead", false); anim.Play("Died"); } else if (sedat.SedatPoints <= 0) { isDied = true; anim.Play("Died"); anim.SetBool("isIdling", true); anim.SetBool("isRunning", false); anim.SetBool("isDead", false); anim.Play("Died"); } }
void Update() { IHealth health = GetComponent <IHealth>(); ISedat sedat = GetComponent <ISedat>(); if ((health.HealthPoint <= 0 || sedat.SedatPoints <= 0) && !gathered) { ShowUI(GetComponent <EnemyStats>().textPrefab); } }
private void Update() { if (SaveManager.instance.firstTimeEvent[0] && id == 0) { IInventoryItem item = inventory.FindKeyItem("Med R. Keycard"); if (item != null) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(true); } //Invoke("StartCon2", 0.2f); SaveManager.instance.firstTimeEvent[0] = false; } else { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[1] && id == 1) { bool condition = false; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <Health>().HealthPoint <= 0) { condition = true; } else { condition = false; break; } } if (condition) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(true); } SaveManager.instance.firstTimeEvent[1] = false; } else { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[2] && id == 2) { bool conditionA = false; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <Health>().HealthPoint <= 0) { conditionA = true; } else { conditionA = false; break; } } bool conditionB = false; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <SedatPoint>().SedatPoints <= 0) { conditionB = true; } else { conditionB = false; break; } } if (conditionA) { cargo.SetActive(true); for (int i = 0; i < ammo9mm.Length; i++) { if (ammo9mm[i] != null) { int index = ammo9mm[i].GetComponent <IInventoryItem>().Id; if (!SaveManager.instance.collected[index]) { ammo9mm[i].SetActive(true); } } } for (int i = 0; i < meds.Length; i++) { if (meds[i] != null) { int index = meds[i].GetComponent <IInventoryItem>().Id; SaveManager.instance.collected[index] = true; } } for (int i = 0; i < sedat.Length; i++) { if (sedat[i] != null) { int index = sedat[i].GetComponent <IInventoryItem>().Id; if (!SaveManager.instance.collected[index]) { sedat[i].SetActive(false); } } } SaveManager.instance.firstTimeEvent[2] = false; } else if (conditionB) { cargo.SetActive(true); for (int i = 0; i < meds.Length; i++) { if (meds[i] != null) { int index = meds[i].GetComponent <IInventoryItem>().Id; if (!SaveManager.instance.collected[index]) { meds[i].SetActive(true); } } } for (int i = 0; i < sedat.Length; i++) { if (sedat[i] != null) { int index = sedat[i].GetComponent <IInventoryItem>().Id; if (!SaveManager.instance.collected[index]) { sedat[i].SetActive(true); } } } for (int i = 0; i < ammo9mm.Length; i++) { if (ammo9mm[i] != null) { int index = ammo9mm[i].GetComponent <IInventoryItem>().Id; //SaveManager.instance.collected[index] = true; } } SaveManager.instance.firstTimeEvent[2] = false; } else { cargo.SetActive(false); for (int i = 0; i < ammo9mm.Length; i++) { ammo9mm[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[4] && id == 4) { if (!conditionDoor[0].GetComponent <Door>().needKey) { StartCon2(); SaveManager.instance.firstTimeEvent[4] = false; } } if (SaveManager.instance.firstTimeEvent[8] && id == 8) { IInventoryItem item = inventory.FindKeyItem("Syringe Tricera DNA"); if (item != null) { StartCon5(); SaveManager.instance.firstTimeEvent[8] = false; } } if (SaveManager.instance.firstTimeEvent[9] && id == 9) { if (conditionDoor[0].GetComponent <Door>().isOpened) { StartCon6(); SaveManager.instance.firstTimeEvent[9] = false; } } if (SaveManager.instance.firstTimeEvent[10] && id == 10) { IInventoryItem item = inventory.FindKeyItem("Syringe Stego DNA"); if (item != null) { StartCon7(); SaveManager.instance.firstTimeEvent[10] = false; } } if (SaveManager.instance.firstTimeEvent[11] && id == 11) { if (conditionDoor[0].GetComponent <Door>().isOpened) { StartCon8(); SaveManager.instance.firstTimeEvent[11] = false; } } if (SaveManager.instance.firstTimeEvent[12] && id == 12) { IInventoryItem item = inventory.FindKeyItem("Syringe Brachio DNA"); if (item != null) { StartCon9(); FindObjectOfType <SoundManager>().PlayForest(); FindObjectOfType <SwampSound>().gameObject.SetActive(false); SaveManager.instance.firstTimeEvent[12] = false; } } if (SaveManager.instance.firstTimeEvent[13] && id == 13) { for (int i = 0; i < conditionDino.Length; i++) { IHealth conDino = conditionDino[i].GetComponent <IHealth>(); if (conDino.HealthPoint < conDino.MaxHealthPoint) { for (int j = 0; j < spawnDino.Length; j++) { spawnDino[j].SetActive(true); } SaveManager.instance.firstTimeEvent[13] = false; break; } else { for (int j = 0; j < spawnDino.Length; j++) { spawnDino[j].SetActive(false); } } } } if (SaveManager.instance.firstTimeEvent[14] && id == 14) { bool conditionA = false; for (int i = 0; i < conditionDino.Length; i++) { IHealth conDino = conditionDino[i].GetComponent <IHealth>(); if (conDino.HealthPoint <= 0) { conditionA = true; SaveManager.instance.firstTimeEvent[14] = false; break; } } bool conditionB = false; for (int i = 0; i < conditionDino.Length; i++) { ISedat conDino = conditionDino[i].GetComponent <ISedat>(); if (conDino.SedatPoints <= 0) { conditionB = true; SaveManager.instance.firstTimeEvent[14] = false; break; } } if (conditionA) { if (!SaveManager.instance.firstTimeEvent[7] || !SaveManager.instance.firstTimeEvent[14]) { Kentro[] kentro = FindObjectsOfType <Kentro>(); for (int i = 0; i < kentro.Length; i++) { kentro[i].isHit = true; } for (int j = 0; j < spawnDino.Length; j++) { spawnDino[j].SetActive(true); //spawnDino[j].transform.position = new Vector3(340, 1, 190); } for (int i = 0; i < conditionDinoB.Length; i++) { conditionDinoB[i].SetActive(false); } for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(true); } cargo.SetActive(true); } } else if (conditionB) { if (SaveManager.instance.firstTimeEvent[14]) { for (int j = 0; j < meds.Length; j++) { meds[j].SetActive(false); } } else { for (int j = 0; j < meds.Length; j++) { meds[j].SetActive(true); } } cargo.SetActive(true); } else { if (SaveManager.instance.firstTimeEvent[7] && SaveManager.instance.firstTimeEvent[14]) { for (int j = 0; j < spawnDino.Length; j++) { spawnDino[j].SetActive(false); } } for (int j = 0; j < meds.Length; j++) { meds[j].SetActive(false); } for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } cargo.SetActive(false); } } if (SaveManager.instance.firstTimeEvent[15] && id == 15) { bool conditionA = false; if (conditionDino[0].GetComponent <Health>().HealthPoint <= 0) { conditionA = true; } else { conditionA = false; } bool conditionB = false; if (conditionDino[0].GetComponent <SedatPoint>().SedatPoints <= 0) { conditionB = true; } else { conditionB = false; } if (conditionA) { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(true); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } cargo.SetActive(true); SaveManager.instance.firstTimeEvent[15] = false; } else if (conditionB) { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(true); } cargo.SetActive(true); SaveManager.instance.firstTimeEvent[15] = false; } else { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } cargo.SetActive(false); } } if (SaveManager.instance.firstTimeEvent[16] && id == 16) { bool[] conditionA = new bool[2]; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <IHealth>().HealthPoint <= 0) { conditionA[i] = true; } } if (conditionA[0] && conditionA[1]) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(true); } for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(true); } SaveManager.instance.firstTimeEvent[16] = false; } if (SaveManager.instance.firstTimeEvent[16]) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(false); } for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[17] && id == 17) { bool[] conditionA = new bool[2]; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <IHealth>().HealthPoint <= 0) { conditionA[i] = true; } } if (conditionA[0] && conditionA[1]) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(true); } SaveManager.instance.firstTimeEvent[17] = false; } if (SaveManager.instance.firstTimeEvent[17]) { for (int i = 0; i < spawnDino.Length; i++) { spawnDino[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[18] && id == 18) { bool conditionA = false; bool[] conA1 = new bool[3]; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <IHealth>().HealthPoint <= 0) { conA1[i] = true; } } for (int i = 0; i < conditionDinoB.Length; i++) { if (conditionDinoB[i].GetComponent <IHealth>().HealthPoint <= 0) { conA1[2] = true; break; } } if (conA1[0] && conA1[1] && conA1[2]) { conditionA = true; } bool conditionB = false; bool[] conB = new bool[3]; for (int i = 0; i < conditionDino.Length; i++) { if (conditionDino[i].GetComponent <ISedat>().SedatPoints <= 0) { conB[i] = true; } } for (int i = 0; i < conditionDinoB.Length; i++) { if (conditionDinoB[i].GetComponent <ISedat>().SedatPoints <= 0) { conB[2] = true; break; } } if (conB[0] && conB[1] && conB[2]) { conditionB = true; } if (conditionA) { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(true); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } SaveManager.instance.firstTimeEvent[18] = false; } else if (conditionB) { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(true); } SaveManager.instance.firstTimeEvent[18] = false; } else { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } } } if (SaveManager.instance.firstTimeEvent[19] && id == 19) { bool conditionA = false; if (conditionDino[0].GetComponent <IHealth>().HealthPoint <= 0) { conditionA = true; } bool conditionB = false; if (conditionDino[0].GetComponent <ISedat>().SedatPoints <= 0) { conditionB = true; } if (conditionA) { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(true); } SaveManager.instance.firstTimeEvent[19] = false; } else if (conditionB) { for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(true); } SaveManager.instance.firstTimeEvent[19] = false; } else { for (int i = 0; i < spawnItems.Length; i++) { spawnItems[i].SetActive(false); } for (int i = 0; i < meds.Length; i++) { meds[i].SetActive(false); } } } }