void Update() { if (shruikenColddownCount > 0) { shruikenColddownCount -= Time.deltaTime; return; } if (input.ShootDown) { Vector2 direction = input.ShootDirection; direction.y *= -1f; if (direction == Vector2.zero) { direction = physic.Direction == 1? Vector2.right: Vector2.left; } Vector2 shootSpeed = direction * shruikenSpeed; if ((shootSpeed.x > 0 && physic.Velocity.x > 0) || (shootSpeed.x < 0 && physic.Velocity.x < 0)) { shootSpeed.x += physic.Velocity.x; } if ((shootSpeed.y > 0 && physic.Velocity.y > 0) || (shootSpeed.y < 0 && physic.Velocity.y < 0)) { shootSpeed.y += physic.Velocity.y; } direction.Normalize(); Shruiken.Spawn( transform.position + (Vector3)direction, shootSpeed); shruikenColddownCount = shruikenColddown; } }
IEnumerator BounceOut() { yield return(new WaitForSeconds(0.2f)); Shruiken.PutBack(this); }
private static void PutBack(Shruiken shruiken) { shruikens.Add(shruiken); shruiken.gameObject.SetActive(false); }