// Use this for initialization void Start() { manager = FindObjectOfType <TOManager>(); grid = FindObjectOfType <Grid>(); //GameObject tempEvok = Instantiate(Evoker, grid.getGrid[0, 2].worldPosition + new Vector3(0,1.5f,0), transform.rotation); //grid.getGrid[0, 2].unitStanding = tempEvok; GameObject tempBatt = Instantiate(BattleMage, grid.getGrid[0, 1].worldPosition, Quaternion.Euler(0, 90f, 0)); grid.getGrid[0, 1].unitStanding = tempBatt; /* * GameObject tempWhite = Instantiate(WhiteMage, grid.getGrid[0, 0].worldPosition, transform.rotation); * grid.getGrid[0, 0].unitStanding = tempWhite; */ for (int i = 0; i < Level[levelInt].spawns.Count; i++) { switch (Level[levelInt].spawns[i].enemyType) { case Unit.unitType.SLIME: SpawnUnit(Slime, i); break; case Unit.unitType.SKELETON: SpawnUnit(Skeleton, i); break; case Unit.unitType.DARK_RIFT: SpawnUnit(DarkRift, i); break; case Unit.unitType.ABYSSAL_EYE: SpawnUnit(AbyssalEye, i); break; case Unit.unitType.HAND_OF_CHAOS: SpawnUnit(HandofChaos, i); break; } } manager.Initialise(false); }
// Update is called once per frame void Update() { if (hp <= 0) { hp = 0; if (!dieCheck) { Grid grid = FindObjectOfType <Grid>(); dieCheck = true; grid.NodeFromWorldPoint(transform.position).unitStanding = null; } if (GetComponent <Animator>() != null) { Animator anim = this.GetComponent <Animator>(); if (anim.parameters.Any(x => x.name == "Faint")) { anim.SetBool("Faint", true); if (anim.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1 && transform.CompareTag("Player")) { TOManager toManager = FindObjectOfType <TOManager>(); Destroy(toManager); timer += Time.deltaTime; if (timer >= 1.5f) { //SceneManager.LoadScene("LoseScene"); //overlayCanvas = GameObject.FindGameObjectWithTag("Canvas").GetComponent<Canvas>(); nonOverlayCanvas = overlayCanvas.GetComponent <EquipmentDrop>().GetNonOverlayCanvas(); failUI = nonOverlayCanvas.transform.GetChild(4).gameObject; overlayCanvas.gameObject.SetActive(false); nonOverlayCanvas.gameObject.SetActive(true); failUI.SetActive(true); ResultCameraZoom.ResultZoomIn(); anim.Play("BM_Defeat"); } } else { if (anim.GetCurrentAnimatorStateInfo(0).IsName("Dead")) { /*if (this.gameObject.CompareTag("Enemy")) * { * SoundManager.Instance.PlaySound("EnemyHit", SoundManager.AUDIO_SOURCE.OTHER); * }*/ Destroy(this.gameObject); } } } else { if (type == unitType.HAND_OF_CHAOS) { anim.SetTrigger("HandOfChaos_Dead"); } if (this.gameObject.CompareTag("Enemy")) { SoundManager.Instance.PlaySound("EnemyHit", SoundManager.AUDIO_SOURCE.OTHER); } Destroy(this.gameObject); } } else { /*if (this.gameObject.CompareTag("Enemy")) * { * SoundManager.Instance.PlaySound("EnemyHit", SoundManager.AUDIO_SOURCE.OTHER); * }*/ Destroy(this.gameObject); } } }