// Update is called once per frame void Update() { if (Time.time >= nextFireballTime) { sfx.PlayEnemyAttack(gameObject.transform.position); nextFireballTime = Time.time + fireballCoolDown; var position = attackPos.position; //position.x = position.x * -1; GameObject spell = Instantiate(fireball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x) * -1, position.y), Quaternion.identity); sfx.PlayFireBallSFX(position); PlayerFireBall spellController = spell.GetComponent <PlayerFireBall>(); spellController.enemy = "Player"; Vector3 spellScale = spell.transform.localScale; spell.transform.localScale = new Vector3(spellScale.x * Mathf.Sign(gameObject.transform.localScale.x) * -1, spellScale.y, spellScale.z); } }
// Update is called once per frame void Update() { if (Time.time >= nextIceballTime) { sfx.PlayEnemyAttack(gameObject.transform.position); nextIceballTime = Time.time + iceballCoolDown; var position = attackPos.position; //position.x = position.x * -1; GameObject spell = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity); PlayerIce spell1Controller = spell.GetComponent <PlayerIce>(); spell1Controller.enemy = "Player"; spell1Controller.damage = iceDamege; GameObject spell2 = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity); PlayerIce spell2Controller = spell2.GetComponent <PlayerIce>(); spell2Controller.enemy = "Player"; spell2Controller.damage = iceDamege; GameObject spell3 = Instantiate(iceball, new Vector2(position.x + 2 * Mathf.Sign(gameObject.transform.localScale.x), position.y), Quaternion.identity); PlayerIce spell3Controller = spell3.GetComponent <PlayerIce>(); spell3Controller.enemy = "Player"; spell3Controller.damage = iceDamege; if (Mathf.Sign(transform.localScale.x) > 0) { spell.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180); spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 + iceAngle); spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 180 - iceAngle); } else { spell2.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, iceAngle); spell3.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, 360 - iceAngle); } Vector3 spellScale = spell.transform.localScale; spell.transform.localScale = new Vector3(spellScale.x * Mathf.Sign(gameObject.transform.localScale.x), spellScale.y, spellScale.z); } }
IEnumerator cambiarEstado(float seconds) { yield return(new WaitForSeconds(seconds)); //Cambiar de posicion int position = (int)Random.Range(1, 3.99f); switch (position) { case 1: positionA(); break; case 2: positionB(); break; case 3: positionC(); break; } updateLocalScale(); // Tipo de escudo //shield: // 1: fire // 2: ice // 3: wind shield = (int)Random.Range(1, 3.99f); switch (shield) { case 1: fireShield(); break; case 2: iceShield(); break; case 3: windShield(); break; default: idleShield(); break; } // Tipo de ataque int attack = (int)Random.Range(1, 3.99f); switch (attack) { case 1: iceAttackHorizaontal(); sfx.PlayEnemyAttack(gameObject.transform.position); break; case 2: iceAttackVertical(); sfx.PlayEnemyAttack(gameObject.transform.position); break; case 3: fireAttack(); sfx.PlayEnemyAttack(gameObject.transform.position); break; } //Debug.Log("ataque: "+ attack) StartCoroutine(cambiarEstado(3)); }