Esempio n. 1
0
    /// <summary>
    /// Called on script construction
    /// </summary>
	void Awake()
	{        
		m_SlicedSprite = GetComponent<SlicedSprite>();
        m_RigidBody = m_SlicedSprite.GetComponent<Rigidbody2D>();
        m_Material = m_SlicedSprite.GetComponent<Renderer>().material;
		m_InitialColor = m_Material.color;
	}
Esempio n. 2
0
 //construct
 //set color fade
 void Awake()
 {
     m_SlicedSprite = GetComponent <SlicedSprite>();
     m_RigidBody    = m_SlicedSprite.GetComponent <Rigidbody2D>();
     m_Material     = m_SlicedSprite.GetComponent <Renderer>().material;
     m_InitialColor = m_Material.color;
 }
Esempio n. 3
0
 // Called on script construction
 private void Awake()
 {
     _slicedSprite = GetComponent <SlicedSprite>();
     _rigidBody    = _slicedSprite.GetComponent <Rigidbody2D>();
     _material     = _slicedSprite.GetComponent <Renderer>().material;
     _initialColor = _material.color;
     tag           = "Destroy";
 }
Esempio n. 4
0
    //check state
    //covert the fade
    //set fade timer
    void Update()
    {
        if (!m_WaitUntilStationary || m_RigidBody.velocity.sqrMagnitude < (m_StationaryVelocity * m_StationaryVelocity))
        {
            m_Timer += Time.deltaTime;

            if (m_FadeTime > 0)
            {
                Color newColor = m_InitialColor;
                newColor.a = 1.0f - Mathf.Clamp01((m_Timer - m_FadeDelay) / m_FadeTime);
                m_SlicedSprite.GetComponent <Renderer>().material.color = newColor;
            }

            if ((m_Timer - m_FadeDelay) >= m_FadeTime)
            {
                Destroy(this.gameObject);
            }
        }
    }
Esempio n. 5
0
        // Update this instance
        private void Update()
        {
            if (!WaitUntilStationary || _rigidBody.velocity.sqrMagnitude < StationaryVelocity * StationaryVelocity)
            {
                _timer += Time.deltaTime;

                if (FadeTime > 0)
                {
                    var newColor = _initialColor;
                    newColor.a = 1.0f - Mathf.Clamp01((_timer - FadeDelay) / FadeTime);
                    _slicedSprite.GetComponent <Renderer>().material.color = newColor;
                }

                if (_timer - FadeDelay >= FadeTime)
                {
                    Destroy(gameObject);
                }
            }
        }