Exemple #1
0
    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;
        }
    }
Exemple #2
0
    IEnumerator BounceOut()
    {
        yield return(new WaitForSeconds(0.2f));

        Shruiken.PutBack(this);
    }
Exemple #3
0
 private static void PutBack(Shruiken shruiken)
 {
     shruikens.Add(shruiken);
     shruiken.gameObject.SetActive(false);
 }