Esempio n. 1
0
    public void Activate(float a_timerBeforeFail)
    {
        m_isPending = false;
        m_currentProblem.GetActiveState().SetActive(true); // Displays the problems active Mesh.
        if (m_currentProblem.GetPhsyicsObject() != null)
        {
            m_currentProblem.GetPhsyicsObject().ApplyForce(); // Applies the force.
        }
        if (m_currentProblem.GetBreakParticleEffect() != null)
        {
            if (m_currentProblem.GetBreakParticleEffect().Count != 0)
            {
                foreach (ParticleSystem particle in m_currentParticle)
                {
                    particle.Stop();
                    Destroy(particle.gameObject, 2);
                }
                m_currentParticle.Clear();
            }
        }
        if (m_currentProblem.GetWhileBrokenParticle() != null)
        {
            if (m_currentProblem.GetWhileBrokenParticle().Count != 0)
            {
                List <ParticleSystem> particles = m_currentProblem.GetWhileBrokenParticle();
                for (int i = 0; i < m_currentProblem.GetWhileBrokenParticle().Count; i++)
                {
                    ParticleSystem t = Instantiate <ParticleSystem>(particles[i]);
                    t.transform.SetParent(this.transform, false); // EXPERIMENT
                    t.transform.position = t.transform.position + m_particleOffset;
                    t.Play();
                    t.transform.position = this.transform.position;
                    m_currentParticle.Add(t);
                }
            }
        }

        Timer.SoundMangerGet().Play(m_currentProblem.GetSounds(), WhenToPlaySound.Active);


        m_buttonPresses = 0;                  // This sets m_buttonpresses to 0.
        m_inactiveState.SetActive(false);     // Hides the problems inactive Mesh.
        m_timeBeforeFail = a_timerBeforeFail; // Assaigns it a time frame before a life is lost.
        m_ui.Activate();
        if (m_currentProblem.GetProblemIndicator() != null)
        {
            m_indicator = Instantiate(m_currentProblem.GetProblemIndicator());
            m_indicator.Setup(this.gameObject, m_uiPosition);           // Creates the ui element.
        }
        else
        {
            Debug.Log("Problem named " + m_currentProblem.GetName() + " has not been asaigned a ui element. Can be found in problem list of " + this.name);
        }
    }