예제 #1
0
    private void OnShootBulletsParticle(object data)
    {
        HeroController.OnShootRaycastEvent onShoot = (HeroController.OnShootRaycastEvent)data;
        if (onShoot.currentGun.GunType.ToString().Equals("Knife"))
        {
            return;
        }

        randomNegativeZ      = Random.Range(-70, -110);
        randomZ              = Random.Range(+70, +110);
        randomZValueArray[0] = randomZ;
        randomZValueArray[1] = randomNegativeZ;
        randomIndexZArray    = Random.Range(0, 2);

        randomRotateSpeed = Random.Range(-5, 5);
        randomSpeed       = Random.Range(2.3f, 3.2f);

        int          quadIndex = meshParticle.AddPooledQuad(onShoot.lineRendererPosition, 0);
        SingleBullet bullet    = new SingleBullet {
            randomSpeed       = randomSpeed,
            randomRotateSpeed = randomRotateSpeed,
            position          = onShoot.lineRendererPosition,
            direction         = Quaternion.Euler(
                0, 0, randomZValueArray[randomIndexZArray]) * onShoot.heroDirection,
            index        = quadIndex,
            meshParticle = meshParticle,
        };

        bulletsList.Add(bullet);
    }
예제 #2
0
    public override void Fire(Vector3 direction)
    {
        m_fireTime = Time.time;
        SingleBullet bullet = GetSingleBullet();

        bullet.OnBulletDead = ActionOnBulletDead;
        bullet.BulletAwake(m_bulletNode.transform, direction, m_data);
    }
예제 #3
0
    private void ActionOnBulletDead(BulletBase bullet)
    {
        SingleBullet singleBullet = bullet as SingleBullet;

        if (singleBullet != null)
        {
            singleBullet.gameObject.SetActive(false);
            m_bullets.Remove(singleBullet);
            m_cacheBullets.Add(singleBullet);
        }
    }
예제 #4
0
 public SingleBulletLauncher(BulletLauncherDataBase data, GameObject gameObject, BulletBase tempBullet)
     : base(EBulletLauncherType.SingleBullet)
 {
     m_data           = data as SingleBulletLauncherData;
     m_bullets        = new List <SingleBullet>();
     m_cacheBullets   = new List <SingleBullet>();
     m_templateBullet = tempBullet as SingleBullet;
     m_templateBullet.gameObject.SetActive(false);
     m_bulletNode = ObjectCommon.GetChildComponent <Transform>(gameObject, "bullet_node");
     if (m_data == null)
     {
         Debug.LogError("SingleBulletLauncherData parse error!!");
     }
 }
예제 #5
0
    // Shoot() Method - Return a type of Bullet.
    public Bullet Shoot(Player Player)
    {
        Bullet singleBullet = new SingleBullet(Player);
        Bullet doubleBullet = new DoubleBullet(Player);

        if (IsSingleBullet == true)
        {
            return(singleBullet);
        }
        else
        {
            return(doubleBullet);
        }
    }
예제 #6
0
    private SingleBullet GetSingleBullet()
    {
        SingleBullet bullet = null;

        if (m_cacheBullets.Count > 0)
        {
            bullet = m_cacheBullets[0];
            m_cacheBullets.RemoveAt(0);
        }
        else
        {
            bullet = GameObject.Instantiate(m_templateBullet);
            bullet.Init();
        }

        return(bullet);
    }