Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //Debug.Log(coolDownCounter);
        if (isfire)
        {
            //check time between attacks
            if (coolDownCounter > 0)
            {
                coolDownCounter -= Time.deltaTime;
            }
            else
            {
                //check time between two shots
                if (ShotTimeCounter > 0)
                {
                    ShotTimeCounter -= Time.deltaTime;
                }
                else
                {
                    //Debug.Log(ShotTimeCounter);
                    ShotTimeCounter = TimeBtwShots;
                    firecount++;

                    foreach (Transform t in fire_pos)
                    {
                        bulletLogic new_bullet = pool.Spawn(t.position, Quaternion.Euler(90, 0, 0)).GetComponent <bulletLogic>();
                        if (shotSound != null)
                        {
                            shotSound.Play();
                        }
                        //Debug.Log(new_bullet.name);
                        new_bullet.fromEnemy = true;
                        new_bullet.setSpeed(BulletSpeed);
                        new_bullet.setDir(t.forward);
                        //new_CannoBall.dir = m_player.transform.position - fire_pos.transform.position;
                        //Debug.Log(new_CannoBall.dir);
                    }
                    if (firecount >= max_firecount)
                    {
                        firecount       = 0;
                        coolDownCounter = coolDownTime;

                        //need to deactivate game objects and put them back into the pool
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void useMachineGun()
    {
        //check time between attacks
        if (shooting_counter <= shooting_interval)
        {
            shooting_counter += Time.deltaTime;
        }
        else
        {
            //check time between two shots
            if (ShotTimeCounter <= TimeBtwShots)
            {
                ShotTimeCounter += Time.deltaTime;
            }
            else
            {
                //Debug.Log(ShotTimeCounter);
                ShotTimeCounter = 0;
                fireCount++;

                foreach (Transform t in Fire_pos)
                {
                    bulletLogic new_bullet = Instantiate(bullet, t.position, Quaternion.Euler(90, 0, 0));
                    new_bullet.fromEnemy = false;
                    new_bullet.setSpeed(BulletSpeed);
                    new_bullet.setDir(t.forward);
                }
                if (fireCount >= fireCountMax)
                {
                    fireCount        = 0;
                    shooting_counter = 0;
                    //need to deactivate game objects and put them back into the pool
                }
            }
        }
    }