IEnumerator StartCastingFireBalls() { isThrowingFireBalls = true; anim.SetBool("CastBombs", true); while (target && isThrowingFireBalls) { for (int i = 0; i < amountOfFireBalls; i++) { float randomX = Random.Range(transform.position.x - 3f, transform.position.x + 3f); float randomY = Random.Range(transform.position.y - 3f, transform.position.y + 3f); Vector3 randomFireBallPos = new Vector3(randomX, randomY, 0f); GameObject fbp = Instantiate(castingFireBallParticles, randomFireBallPos, transform.rotation) as GameObject; fbp.transform.SetParent(skills); StartCoroutine(ThrowFireBalls(fbp.transform.position)); yield return(new WaitForSeconds(timeBetweenFireBallSpawn)); } isThrowingFireBalls = false; } lastFaze = currentFaze; anim.SetBool("CastBombs", false); currentFaze = Faze.Idle; }
IEnumerator StartCastingBombs() { isCastingBombs = true; anim.SetBool("CastBombs", true); while (target && isCastingBombs) { for (int i = 0; i < amountOfBombs; i++) { float randomX = Random.Range(target.position.x - 3f, target.position.x + 3f); float randomY = Random.Range(target.position.y - 3f, target.position.y + 3f); Vector3 randomBombsPosition = new Vector3(randomX, randomY, 0f); GameObject castedBomb = Instantiate(Boom, randomBombsPosition, new Quaternion(0, 0, 0, 0)) as GameObject; castedBomb.transform.SetParent(skills); StartCoroutine(PlayBoomSound(castedBomb)); yield return(new WaitForSeconds(timeBetweenBombSpawn)); } isCastingBombs = false; } lastFaze = currentFaze; anim.SetBool("CastBombs", false); currentFaze = Faze.Idle; }
IEnumerator Rest() { isResting = true; yield return(new WaitForSeconds(timeToNextFaze)); if (lastFaze == Faze.FireBalls) { currentFaze = Faze.Bombs; } else if (lastFaze == Faze.Bombs) { currentFaze = Faze.FireBalls; } isResting = false; }
void Start() { skills = transform.Find("Skills"); anim = GetComponent <Animator>(); currentFaze = Faze.Idle; randomFaze = Random.Range(0, 2); if (randomFaze == 0) { currentFaze = Faze.FireBalls; } else { currentFaze = Faze.Bombs; } body = transform.Find("Body"); }