public void Z_UpdateAllStats(C_GameUnit.EmptyClass curStats)
    {
        Z_UpdateUnitBars(curStats);

        if ( curStats.GetType() == typeof(C_Hero.CurrentStats) ) {
            C_Hero.CurrentStats stats = (C_Hero.CurrentStats) curStats;
            Z_UpdateEnergy(stats.energy);

            // update only for this player
            if (!_gmClass)
                _gmClass = GameObject.Find("Game Manager").GetComponent<C_GameManager>();
            if (_gmClass.z_thisPlayerGO != _gameObject)
                return;

            _show_attackText.text = "Attack: " + stats.attackPower;
            _show_rangeText.text = "Range: " + stats.attackRange;
            _show_defenseText.text = "Defense: " + stats.defensePercent + "%";
            _show_movementText.text = "Movement: " + stats.movementSpeed;
            Z_UpdateMainBars(stats);
        }
    }
 public bool Z_IsHeroTurn(C_GameUnit unitClass)
 {
     return (unitClass == m_unitOnTurnClass);
 }
    public void Z_NewTurn()
    {
        m_call_NewTurn = true;
        if (m_unitOnTurnClass)
            m_unitOnTurnClass.Z_EndTurn();

        m_unitOnTurnClass = m_unitClassList[m_unitOnTurnIndex];
        m_unitOnTurnClass.Z_StartTurn();

        m_unitOnTurnIndex ++;
        if (m_unitOnTurnIndex == m_unitClassList.Count)
            Z_NewRound();
    }
    public void Z_UpdateUnitBars(C_GameUnit.EmptyClass curStats)
    {
        if (!_hpUnitTex) {
            _hpUnitTex = GameObject.Find(name + " Overhead/HP Bar").GetComponent<GUITexture>();
            m_unitBarSize = GameObject.Find(name + " Overhead/Background").GetComponent<GUITexture>().pixelInset.width;
        }
        if (!_mpUnitTex) {
            GameObject hasMP = GameObject.Find(name + " Overhead/MP Bar");
            if (hasMP)
                _mpUnitTex = hasMP.GetComponent<GUITexture>();
        }

        float hp, maxhp, mp, maxmp;
        hp = maxhp = maxmp = mp = 1f;

        if ( curStats.GetType() == typeof(C_Hero.CurrentStats) ) {
            hp = ((C_Hero.CurrentStats) curStats).HP;
            maxhp = ((C_Hero.CurrentStats) curStats).maxHP;
            mp = ((C_Hero.CurrentStats) curStats).MP;
            maxmp = ((C_Hero.CurrentStats) curStats).maxMP;
        }
        if ( curStats.GetType() == typeof(C_Tower.CurrentStats) ) {
            hp = ((C_Tower.CurrentStats) curStats).HP;
            maxhp = ((C_Tower.CurrentStats) curStats).maxHP;
        }

        int barSize = Mathf.FloorToInt( m_unitBarSize * (hp / maxhp) );
        Rect pix = _hpUnitTex.pixelInset;
        _hpUnitTex.pixelInset = new Rect(pix.x, pix.y, barSize, pix.height);

        if (_mpUnitTex) {
            barSize = Mathf.FloorToInt( m_unitBarSize * (mp / maxmp) );
            pix = _mpUnitTex.pixelInset;
            _mpUnitTex.pixelInset = new Rect(pix.x, pix.y, barSize, pix.height);
        }
    }