Example #1
0
        private void HandleDown()
        {
            // If it's already ending, do nothing else.
            if (m_IsEnding)
            {
                return;
            }

            // Otherwise this is ending the target's lifetime.
            m_IsEnding = true;

            // Turn off the visual and physical aspects.
            m_Renderer.enabled = false;
            m_Collider.enabled = false;

            // Play the clip of the target being hit.
            m_Audio.clip = m_DestroyClip;
            m_Audio.Play();

            // Add to the player's score.
            SessionData.AddScore(m_Score);

            // Instantiate the shattered target prefab in place of this target.
            GameObject destroyedTarget = Instantiate(m_DestroyPrefab, transform.position, transform.rotation) as GameObject;

            // Destroy the shattered target after it's time out duration.
            Destroy(destroyedTarget, m_DestroyTimeOutDuration);

            // Tell subscribers that this target is ready to be removed.
            if (OnRemove != null)
            {
                OnRemove(this);
            }
        }
        private IEnumerator MissTarget()
        {
            // Wait for the target to disappear naturally.
            yield return(new WaitForSeconds(m_TimeOutDuration));

            // If by this point it's already ending, do nothing else.
            if (m_IsEnding)
            {
                yield break;
            }

            // Otherwise this is ending the target's lifetime.
            m_IsEnding = true;

            // Turn off the visual and physical aspects.
            m_Renderer.enabled = false;
            m_Collider.enabled = false;

            // Play the clip of the target being missed.
            m_Audio.clip = m_MissedClip;
            m_Audio.Play();

            // Add to the player's score.
            SessionData.AddScore(-1);

            // Wait for the clip to finish.
            yield return(new WaitForSeconds(m_MissedClip.length));

            // Tell subscribers that this target is ready to be removed.
            if (OnRemove != null)
            {
                OnRemove(this);
            }
        }
Example #3
0
        //  This is called by ShootingGalleryGun.cs
        public void ReceiveHit(int scoreMultiplier, int distance)
        {
            int        score    = (m_Score + DistanceToScoreBonus(distance)) * scoreMultiplier;
            GameObject scorePop = (GameObject)Instantiate(scorePopPrefab, transform.position, Quaternion.identity);

            scorePop.GetComponent <ScorePop>().UpdateScoreDisplay(score);

            // Add to the player's score.
            SessionData.AddScore(score);

            if (health > 1)
            {
                ShrinkAndDecrementHealth();
                m_Score += 1;
                return;
            }

            TriggerRespawn();

            // If it's already ending, do nothing else.
            if (m_IsEnding)
            {
                return;
            }

            // Otherwise this is ending the target's lifetime.
            m_IsEnding = true;

            // Turn off the visual and physical aspects.
            foreach (Renderer m_Renderer in m_Renderers)
            {
                m_Renderer.enabled = false;
            }
            m_Collider.enabled = false;

            // Play the clip of the target being hit.
            m_Audio.clip = m_DestroyClip;
            m_Audio.Play();

            // Instantiate the shattered target prefab in place of this target.
            GameObject destroyedTarget = Instantiate(m_DestroyPrefab, transform.position, transform.rotation) as GameObject;

            // Destroy the shattered target after it's time out duration.
            Destroy(destroyedTarget, m_DestroyTimeOutDuration);

            // Tell subscribers that this target is ready to be removed.
            if (OnRemove != null)
            {
                OnRemove(this);
            }
        }
Example #4
0
    private IEnumerator OnHit()
    {
        if (isEnding)
        {
            yield break;
        }
        mRenderer.enabled = false;
        mCollider.enabled = false;
        audioSource.clip  = destroyClip;
        audioSource.Play();
        SessionData.AddScore(score);
        GameObject destroyedTarget = Instantiate <GameObject>(destroyPrefab, transform.position, transform.rotation);

        Destroy(destroyedTarget, destroyTimeOutDuration);
        yield return(new WaitForSeconds(destroyClip.length));

        if (OnRemove != null)
        {
            OnRemove(this);
        }
    }
Example #5
0
        private void HandleDown()
        {
            if (m_isEnding || !m_shootingGalleryController.IsPlaying)
            {
                return;
            }

            m_isEnding         = true;
            m_renderer.enabled = false;
            if (m_collider)
            {
                m_collider.enabled = false;
            }

            if (m_audio)
            {
                m_audio.Play();
            }
            if (m_particleExplosion)
            {
                m_particleExplosion.transform.parent = null;
                m_particleExplosion.StartEffect();
            }
            if (m_particleScore)
            {
                Vector3 parentPos = m_particleScore.transform.parent.position;
                if (m_gainPoints)
                {
                    m_particleScore.transform.position = new Vector3(parentPos.x, parentPos.y + 12, parentPos.z);
                }
                else
                {
                    m_particleScore.transform.position = new Vector3(parentPos.x, parentPos.y, parentPos.z);
                }

                m_particleScore.transform.parent = null;
                m_particleScore.transform.LookAt(m_camInputManager.CurrentCamera.transform);
                m_particleScore.transform.Rotate(0, 180, 0);

                if (m_gainPoints)
                {
                    PKFxManager.Sampler textAttr = m_particleScore.GetSampler("Text");
                    int score = m_score * SessionData.Multiplicateur;
                    textAttr.m_Text = score.ToString();
                }
                m_particleScore.StartEffect();
            }

            if (m_light)
            {
                m_light.enabled = false;
            }
            if (m_gainPoints)
            {
                SessionData.AddScore(m_score);
            }

            if (m_hasVoronoi)
            {
                GameObject destroyedTarget = Instantiate(m_destroyPrefab, transform.position, transform.rotation) as GameObject;
                Destroy(destroyedTarget, m_destroyTimeOutDuration);
            }
            if (OnRemove != null)
            {
                OnRemove(this);
            }
        }