private void Update() { if (m_PlayerGun == null) { return; } if (m_PlayerManager.IsPlayerLoaded() == false) { return; } if (m_PlayerManager.IsInteractable() == false) { return; } if (m_PlayerManager.IsUltimatable() == false) { return; } GunCoreCharging gunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>(); if (Input.GetKeyDown(KeyCode.LeftAlt) && m_PlayerGun.IsUltimateEnabled()) { if (m_PlayerManager.GetPlayerGun()?.IsUltimateEnabled() == false) { return; } if (m_PlayerManager.GetPlayerUltimateCount() <= 0) { return; } if (GameObject.FindGameObjectsWithTag("PlayerUltimate")?.Length >= 1) { return; } if (gunCoreCharging == null) { FireUltimate(); } else { if (gunCoreCharging.IsChargingFiring() == false && gunCoreCharging.IsCharging() == false) { FireUltimate(); } } } }
private void OnDestroy() { if (m_PlayerGun == null) { return; } GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>(); if (playerGunCoreCharging.IsCharging() == true) { ParticleFactory.GetInstance().DeleteParticle(this); } }
void Update() { if (m_PlayerGun == null) { return; } if (m_PlayerManager.IsPlayerLoaded() == false) { return; } if (m_PlayerManager.IsInteractable() == false) { return; } if (m_PlayerManager.IsShootable() == false) { return; } m_PlayerGun.SetCurrentBulletFiringTime(m_PlayerGun.GetCurrentBulletFiringTime() + Time.deltaTime); if (m_PlayerGun.GetCurrentBulletFiringTime() >= m_PlayerGun.GetBulletFiringDelay()) { m_PlayerGun.SetFireEnabled(true); } bool hasGunChargingCore = m_PlayerGun.HasCore <GunCoreCharging>(); if (Input.GetKeyDown(KeyCode.LeftControl)) { m_CurrentRecognizingPressedTime += Time.deltaTime; if (m_PlayerGun.IsFireEnabled()) { if (hasGunChargingCore == false) { FireBullet(); } else { GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>(); if (m_CurrentRecognizingPressedTime < m_MaxRecognizingPressedTime) { FireBullet(); } } } } else if (Input.GetKey(KeyCode.LeftControl)) { m_CurrentRecognizingPressedTime += Time.deltaTime; if (m_PlayerGun.IsFireEnabled()) { if (hasGunChargingCore == false) { FireBullet(); } else { if (m_CurrentRecognizingPressedTime < m_MaxRecognizingPressedTime) { FireBullet(); } else { GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>(); if (playerGunCoreCharging.IsCharging() == false) { if (playerGunCoreCharging.IsChargingFiring() == false) { playerGunCoreCharging.SetIsCharging(true); ParticleFactory.GetInstance().CreatePermanentParticle <ParticleCharging>(this, m_FireTransforms[(int)MainFireTransformPosition.Top].transform).Play(); } } else { if (playerGunCoreCharging.IsChargingFiring() == false) { playerGunCoreCharging.SetChargingTime(playerGunCoreCharging.GetChargingTime() + Time.deltaTime); m_PointLight.intensity = 20.0f * playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime();; m_PointLight.range = 20.0f * playerGunCoreCharging.GetChargingTime() / playerGunCoreCharging.GetMaxCharingTime();; //차징 게이지가 모두 찬 경우 차징풀 상태로 바꾼다. if (playerGunCoreCharging.GetChargingTime() >= playerGunCoreCharging.GetMaxCharingTime()) { playerGunCoreCharging.SetIsChargingFull(true); } //차징이 다된 경우 파티클을 더이상 재생하지 않는다. if (playerGunCoreCharging.IsChargingFull() && ParticleFactory.GetInstance().IsPlaying <ParticleCharging>(this) == true) { ParticleFactory.GetInstance().DeleteParticle(this); } } } } } } } else if (Input.GetKeyUp(KeyCode.LeftControl)) { if (hasGunChargingCore == false) { FireBullet(); } else { GunCoreCharging playerGunCoreCharging = m_PlayerGun.GetCore <GunCoreCharging>(); ParticleFactory.GetInstance().DeleteParticle(this); if (playerGunCoreCharging.IsCharging() == true) { FireBullet(); } } m_CurrentRecognizingPressedTime = 0.0f; m_PointLight.intensity = 0.0f; m_PointLight.range = 0.0f; } }
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); }