// fonction appelée lorsque l'arme de la tour est activée public override void Shoot() { if (Time.time - timeLastShoot > frequency) { isShooting = true; timeLastShoot = Time.time; if (projectilePoolReady.Count > 0) { go = (GameObject)projectilePoolReady[0]; go.SetActive(true); goRigidBody = go.GetComponent(typeof(Rigidbody)) as Rigidbody; goRigidBody.isKinematic = false; goRigidBody.AddForce(shootFromTransform.transform.forward * force, ForceMode.Impulse); bullet = go.GetComponent(typeof(ProjectileCannon)) as ProjectileCannon; bullet.shooter = shootFromTransform; bullet.target = null; bullet.Shoot(); projectilePoolReady.RemoveAt(0); projectilePoolActive.Add(go); } } else { isShooting = false; } }
void Awake() { _battleRaging = false; _party1 = PlayerPanel.GetComponent <PartyGroup>(); //_party1SuccessSprite = PlayerPanel.GetComponentInChildren<SuccessSprite>(true); //_party1FailSprite = PlayerPanel.GetComponentInChildren<FailSprite>(true); _party2 = BossPanel.GetComponent <PartyGroup>(); //_party2SuccessSprite = BossPanel.GetComponentInChildren<SuccessSprite>(true); //_party2FailSprite = BossPanel.GetComponentInChildren<FailSprite>(true); _timerPanel = TimerPanel.GetComponent <TimerPanel>(); _resolutionPanel = GetComponentInChildren <ResolutionPanel>(true); _theBigButton = GetComponentInChildren <TheBigButton>(true); _buttonNamePanel = GetComponentInChildren <ButtonNamePanel>(true); _getReadyPanel = GetComponentInChildren <AttackGetReadyPanel>(true); _cannon = GetComponentInChildren <ProjectileCannon>(true); _audioSource = GetComponent <AudioSource>(); }
// fonction de mise à jour public void FixedUpdate() { for(int i = 0; i < projectilePoolActive.Count; i++) { go = (GameObject) projectilePoolActive[i]; goRigidBody = go.GetComponent(typeof(Rigidbody)) as Rigidbody; bullet = go.GetComponent(typeof(ProjectileCannon)) as ProjectileCannon; if(bullet.isActive) { if(Time.time - bullet.timeShoot > bullet.timeLife) { bullet.isExpired = true; } if(bullet.isExpired) { bullet.isActive = false; explosionPosition = go.transform.position; goRigidBody.isKinematic = true; go.transform.transform.position = nowhere; projectilePoolActive.RemoveAt(i); projectilePoolReady.Add(go); Explode(explosionPosition); } if(bullet.hasCollided){/*...*/} if(bullet.hasExploded){/*...*/} } } for(int i = 0; i < fxPoolActive.Count; i++) { go = (GameObject) fxPoolActive[i]; fx = go.GetComponent(typeof(FX)) as FX; if(fx.isActive) { if(Time.time - fx.timeShoot > fx.timeLife) { fx.isExpired = true; } if(fx.isExpired) { fx.isActive = false; explosionPosition = nowhere; go.transform.transform.position = explosionPosition; ps = go.GetComponent(typeof(ParticleSystem)) as ParticleSystem; ps.Stop(); go.SetActive(false); fxPoolActive.RemoveAt(i); fxPoolReady.Add(go); } } } }
// fonction appelée lorsque l'arme de la tour est activée public override void Shoot() { if(Time.time - timeLastShoot > frequency) { isShooting = true; timeLastShoot = Time.time; if(projectilePoolReady.Count > 0) { go = (GameObject) projectilePoolReady[0]; go.SetActive(true); goRigidBody = go.GetComponent(typeof(Rigidbody)) as Rigidbody; goRigidBody.isKinematic = false; goRigidBody.AddForce(shootFromTransform.transform.forward * force, ForceMode.Impulse); bullet = go.GetComponent(typeof(ProjectileCannon)) as ProjectileCannon; bullet.shooter = shootFromTransform; bullet.target = null; bullet.Shoot(); projectilePoolReady.RemoveAt(0); projectilePoolActive.Add(go); } } else { isShooting = false; } }
// fonction de mise à jour public void FixedUpdate() { for (int i = 0; i < projectilePoolActive.Count; ++i) { go = (GameObject)projectilePoolActive[i]; goRigidBody = go.GetComponent(typeof(Rigidbody)) as Rigidbody; bullet = go.GetComponent(typeof(ProjectileCannon)) as ProjectileCannon; if (bullet.isActive) { if (Time.time - bullet.timeShoot > bullet.timeLife) { bullet.isExpired = true; } if (bullet.isExpired) { bullet.isActive = false; explosionPosition = go.transform.position; goRigidBody.isKinematic = true; go.transform.transform.position = nowhere; projectilePoolActive.RemoveAt(i); projectilePoolReady.Add(go); Explode(explosionPosition); } if (bullet.hasCollided) /*...*/ } { if (bullet.hasExploded)/*...*/ { } } } for (int i = 0; i < fxPoolActive.Count; ++i) { go = (GameObject)fxPoolActive[i]; fx = go.GetComponent(typeof(FX)) as FX; if (fx.isActive) { if (Time.time - fx.timeShoot > fx.timeLife) { fx.isExpired = true; } if (fx.isExpired) { fx.isActive = false; explosionPosition = nowhere; go.transform.transform.position = explosionPosition; ps = go.GetComponent(typeof(ParticleSystem)) as ParticleSystem; ps.Stop(); go.SetActive(false); fxPoolActive.RemoveAt(i); fxPoolReady.Add(go); } } } }