コード例 #1
0
    private IEnumerator VulcanChargingFire(GunCoreCharging playerGunCoreCharging, int vulcanLevel, float chargingPercent)
    {
        int   bulletCount      = (int)(vulcanLevel * 17.0f * chargingPercent / 100.0f);
        float leftStartDegree  = Random.Range(-3.0f * bulletCount / 2, -3.0f);
        float rightStartDegree = Random.Range(3.0f, 3.0f * bulletCount / 2);

        for (int i = 0; i < bulletCount; i++)
        {
            Instantiate(m_VulcanBullet, m_FireTransforms[0].position, Quaternion.Euler(0, 0, leftStartDegree + 3.0f * i));
            Instantiate(m_VulcanBullet, m_FireTransforms[0].position, Quaternion.Euler(0, 0, rightStartDegree - 3.0f * i));
            yield return(new WaitForSeconds(0.1f));
        }

        playerGunCoreCharging.SetIsChargingFiring(false);

        yield return(null);
    }
コード例 #2
0
    private void VariableInit()
    {
        m_PlayerManager = ManagerPool.GetInstance().GetManager <PlayerManager>();

        //쿨탐 초기화
        m_PlayerGun = m_PlayerManager.GetPlayerGun();
        m_PlayerGun.SetCurrentBulletFiringTime(0.0f);


        GunCoreCharging charging = m_PlayerGun.GetCore <GunCoreCharging>();

        if (charging != null)
        {
            charging.SetIsChargingFull(false);
            charging.SetIsChargingFiring(false);
            charging.SetIsCharging(false);
            charging.SetChargingTime(0.0f);
        }
    }
コード例 #3
0
    private void FireVulcanBullet()
    {
        GunVulcan       vulcanGun             = m_PlayerManager.GetPlayerGun() as GunVulcan;
        GunCoreCharging playerGunCoreCharging = vulcanGun.GetCore <GunCoreCharging>();

        if (vulcanGun is null)
        {
            throw new NullReferenceException("vulcanGun 오브젝트가 null입니다.");
        }

        //if (vulcanGun.GetPowerLevel() == 1)
        //{
        //    if (playerGunCoreCharging.IsCharging() == false && playerGunCoreCharging.IsChargingFiring() == false)
        //        Instantiate(m_VulcanBullet, m_FireTransforms[0].position, m_FireTransforms[0].rotation);
        //    else
        //    {
        //        float chargedPercent = playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime() * 100;


        //        playerGunCoreCharging.SetChargingTime(0.0f);
        //        playerGunCoreCharging.SetIsChargingFull(false);
        //        playerGunCoreCharging.SetIsCharging(false);
        //        playerGunCoreCharging.SetIsChargingFiring(true); //밑에 두면안된다. bulletCount가 0일 경우에 바로 m_IsChargingFiring값이 false로 되버리기 때문에 그 이후 true로 바껴버리면 담에 발사가 안됨

        //        StartCoroutine(VulcanChargingFire(playerGunCoreCharging, vulcanGun.GetPowerLevel(), chargedPercent));
        //    }
        //}


        if (playerGunCoreCharging.IsCharging() == false && playerGunCoreCharging.IsChargingFiring() == false)
        {
            if (vulcanGun.GetPowerLevel() == 1)
            {
                Instantiate(m_VulcanBullet, m_FireTransforms[0].position, m_FireTransforms[0].rotation);
            }
            else if (vulcanGun.GetPowerLevel() == 2)
            {
                Instantiate(m_VulcanBullet, m_FireTransforms[1].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[2].position, m_FireTransforms[0].rotation);
            }
            else if (vulcanGun.GetPowerLevel() == 3)
            {
                Instantiate(m_VulcanBullet, m_FireTransforms[0].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[1].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[2].position, m_FireTransforms[0].rotation);
            }
            else if (vulcanGun.GetPowerLevel() == 4)
            {
                Instantiate(m_VulcanBullet, m_FireTransforms[1].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[2].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[3].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[4].position, m_FireTransforms[0].rotation);
            }
            else if (vulcanGun.GetPowerLevel() == 5)
            {
                Instantiate(m_VulcanBullet, m_FireTransforms[0].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[1].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[2].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[3].position, m_FireTransforms[0].rotation);
                Instantiate(m_VulcanBullet, m_FireTransforms[4].position, m_FireTransforms[0].rotation);
            }
        }
        else
        {
            float chargedPercent = playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime() * 100;


            playerGunCoreCharging.SetChargingTime(0.0f);
            playerGunCoreCharging.SetIsChargingFull(false);
            playerGunCoreCharging.SetIsCharging(false);
            playerGunCoreCharging.SetIsChargingFiring(true); //밑에 두면안된다. bulletCount가 0일 경우에 바로 m_IsChargingFiring값이 false로 되버리기 때문에 그 이후 true로 바껴버리면 담에 발사가 안됨

            StartCoroutine(VulcanChargingFire(playerGunCoreCharging, vulcanGun.GetPowerLevel(), chargedPercent));
        }
        vulcanGun.SetCurrentBulletFiringTime(0.0f);
        vulcanGun.SetFireEnabled(false);
    }