Ejemplo n.º 1
0
    void flipDirection()
    {
        facingRight = !facingRight;
        transform.Rotate(0, 180, 0);


        //Fix Children Health bar and RecruitMenu
        int index = this.transform.childCount;

        for (int i = 0; i < index; ++i)
        {
            Transform   t  = this.transform.GetChild(i);
            ScaleKeeper sk = t.GetComponent <ScaleKeeper>();
            if (sk)
            {
                Vector3 _properScale = sk.getScale();

                if (facingRight)
                {
                    _properScale = new Vector3(-_properScale.x, _properScale.y, _properScale.z);
                }

                t.localScale = _properScale;
            }
        }
    }
Ejemplo n.º 2
0
    private void FlipDirection()
    {
        // Switch the way the player is labeled as facing.
        m_FacingRight = !m_FacingRight;

        // Multiply the player's x local scale by -1.
        Vector3 theScale = transform.localScale;

        theScale.x          *= -1;
        transform.localScale = theScale;

        //Fix Children HealthBar
        int index = this.transform.childCount;

        for (int i = 0; i < index; ++i)
        {
            Transform   t  = this.transform.GetChild(i);
            ScaleKeeper sk = t.GetComponent <ScaleKeeper>();
            if (sk)
            {
                Vector3 _properScale = sk.getScale();

                if (!m_FacingRight)
                {
                    _properScale = new Vector3(-_properScale.x, _properScale.y, _properScale.z);
                }

                t.localScale = _properScale;
            }
        }
    }