private IEnumerator Throw(Vector3 targetPos, EnWp_Bomb bombType, float angle = 70f) { switch (curAnim) { default: anim.Play("ThrowStand"); break; case "Jump": anim.Play("ThrowJump"); break; case "JumpB": anim.Play("ThrowJumpB"); break; case "JumpF": anim.Play("ThrowJumpF"); break; } GameObject bomb = Instantiate(bombType.gameObject); bomb.transform.position = transform.position + transform.up * 6f; Vector3 velocity = Helper.LaunchVelocity(bomb.transform.position, targetPos, angle, 1000); bomb.GetComponent <Rigidbody2D>().velocity = velocity; yield return(new WaitForSeconds(0.1f)); anim.Play(curAnim); }
private IEnumerator Behavior() { while (true) { yield return(null); int roll = Random.Range(0, 9); float cooldown = 0.0f; LookAtPlayer(); switch (roll) { case 0: case 1: case 2: case 3: yield return(Jump(96)); StartCoroutine(Throw(GameManager.playerPosition, bombClassic, 60)); while (!isGrounded) { yield return(null); } body.velocity = Vector2.zero; AnimPlay("Stand"); break; case 4: case 5: StartCoroutine(Jump(0, 60)); cooldown = 0.0f; while (body.velocity.y > 0.0f || !isGrounded) { cooldown -= Time.deltaTime; if (cooldown <= 0.0f) { EnWp_Bomb bomb = Random.Range(0, 2) == 0 ? bombCross : bombX; StartCoroutine(Throw(GameManager.playerPosition + Vector3.right * Random.Range(-32, 32), bomb)); cooldown = 0.25f; } yield return(null); } body.velocity = Vector2.zero; AnimPlay("Stand"); break; case 6: StartCoroutine(Jump(-64, 82)); cooldown = 0.0f; while (body.velocity.y > 0.0f || !isGrounded) { cooldown -= Time.deltaTime; if (cooldown <= 0.0f) { StartCoroutine(Throw(GameManager.playerPosition + Vector3.right * Random.Range(-96, 96), bombRubber)); cooldown = 0.5f; } yield return(null); } body.velocity = Vector2.zero; AnimPlay("Stand"); yield return(new WaitForSeconds(0.5f)); break; case 7: for (int i = 0; i < 6; i++) { yield return(Throw(transform.position + transform.up * 16f, bombClassic)); health += 0.5f; aud.PlaySound(healSound, true); } break; case 8: yield return(new WaitForSeconds(0.5f)); yield return(Throw(GameManager.playerPosition, bombFlower, 70)); yield return(Jump(0, 80f)); while (!isGrounded) { yield return(null); } body.velocity = Vector2.zero; break; } yield return(new WaitForSeconds(1.0f)); } }