Exemplo n.º 1
0
    // Spawns a projectile from the pool, setting it's new direction based on the character's direction (WeaponOwner)
    private void SpawnProjectile(Vector2 spawnPosition)
    {
        // Get Object from the pool
        GameObject projectilePooled = Pooler.GetObjectFromPool();

        projectilePooled.transform.position = spawnPosition;
        projectilePooled.SetActive(true);

        // Get reference to the projectile
        Projectile_lsy projectile = projectilePooled.GetComponent <Projectile_lsy>();

        projectile.EnableProjectile();

        // Spread
        randomProjectileSpread.z = Random.Range(-projectileSpread.z, projectileSpread.z);
        Quaternion spread = Quaternion.Euler(randomProjectileSpread);

        // Set direction and rotation
        Vector2 newDirection = new Vector2();

        if (WeaponOwner.GetComponent <CharacterFlip_lsy>().flipMode == CharacterFlip_lsy.FlipMode.MovementDirection)
        {
            newDirection = spread * transform.right;
        }
        else if (WeaponOwner.GetComponent <CharacterFlip_lsy>().flipMode == CharacterFlip_lsy.FlipMode.WeaponDirection)
        {
            newDirection = WeaponOwner.GetComponent <CharacterFlip_lsy>().FacingRight ? spread * transform.right : spread * transform.right * -1;
        }
        projectile.SetDirection(newDirection, transform.rotation, WeaponOwner.GetComponent <CharacterFlip_lsy>().FacingRight);

        CanShoot = false;
    }
Exemplo n.º 2
0
 private void Start()
 {
     projectile     = GetComponent <Projectile_lsy>();
     bossProjectile = GetComponent <BossProjectile_lsy>();
 }