Exemplo n.º 1
0
    IEnumerator FireByDelay(int i, float delay)
    {
        if (StaticData.IsSoundOn() && fireShootSource)
        {
            fireShootSource.Play();
        }
        yield return(new WaitForSeconds(delay));

        PlayerFire fire = GetFires();

        //If its null we will spawn and add to the pool list
        if (fire == null)
        {
            if (GameManager.instance.isPowerUp2X)
            {
                fire = Instantiate(bullet2XPrefab);
                fires2X.Add(fire);
            }
            else
            {
                fire = Instantiate(bulletPrefab);
                fires.Add(fire);
            }
        }
        fire.transform.position = firePoint[i].transform.position + firePoint[i].transform.forward * firePointOffset.z;
        fire.transform.rotation = firePoint[i].transform.rotation;

        fire.gameObject.SetActive(true);
        fire.Fire(fireSpeed);
    }
Exemplo n.º 2
0
 void HandleFire()
 {
     //We will compare the last fire time with current time to give delay in bullet spawn
     if (Time.time >= lastFireTime + delayBetweenFire)
     {
         //Setting last fire time to current time
         lastFireTime = Time.time;
         for (int i = 0; i < firePoint.Count; i++)
         {
             //Getting Fire Prefab from Pool list
             PlayerFire fire = GetFires();
             //If its null we will spawn and add to the pool list
             if (fire == null)
             {
                 fire = Instantiate(bulletPrefab);
                 fires.Add(fire);
             }
             fire.transform.position = firePoint[i].transform.position;
             fire.transform.rotation = firePoint[i].transform.rotation;
             fire.gameObject.SetActive(true);
             //Calling fire function to add force
             fire.SetDroneProperty(bulletDelayToLookTarget, rotationSpeedForBullet);
             fire.Fire(fireSpeed);
         }
     }
 }
Exemplo n.º 3
0
    IEnumerator FireByDelay(int i, float delay)
    {
        yield return(new WaitForSeconds(delay));

        PlayerFire fire = GetFires();

        //If fire is null we will spawn  from prefab
        if (fire == null)
        {
            fire = Instantiate(bulletPrefab);
            fires.Add(fire);
        }
        fire.transform.position = firePoint[i].transform.position + firePoint[i].transform.forward * firePointOffset.z;
        if (fireToPlayer && cannon == null)
        {
            firePoint[i].transform.LookAt(GameManager.instance.player.transform);
        }
        fire.transform.rotation = firePoint[i].transform.rotation;
        fire.gameObject.SetActive(true);
        fire.Fire(fireSpeed);
    }
 void Update()
 {
     if ((grounded || !secJump) && Input.GetKeyDown(KeyCode.Space))
     {
         anim.SetBool("Ground", false);
         GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, 0);
         GetComponent <Rigidbody2D>().AddForce(new Vector2(0, jumpForce));
         if (!grounded)
         {
             secJump = true;
         }
     }
     if (Input.GetKeyDown(KeyCode.LeftShift))
     {
         PlayerFire shot = this.gameObject.GetComponent <PlayerFire>();
         if (shot != null)
         {
             shot.Fire();
         }
     }
     //if (grounded && Input.GetKeyDown(KeyCode.DownArrow)) {
     //anim.SetBool("Slide", true);
     //}
 }