Beispiel #1
0
    public PlayerInfoVisualizer(Player owner)
    {
        m_owner     = owner;
        m_bWithBall = owner.m_bWithBall;

        m_timerHideName = new GameUtils.Timer4View(4f, OnTimerHideName, 1);

        if (m_resPlayerInfo == null)
        {
            m_resPlayerInfo = ResourceLoadManager.Instance.LoadPrefab("prefab/indicator/playerInfo");
        }

        m_goPlayerInfo = GameObject.Instantiate(m_resPlayerInfo) as GameObject;
        m_uiName       = GameUtils.FindChildRecursive(m_goPlayerInfo.transform, "Name").GetComponentInChildren <UILabel>();
        m_nameFadeAway = m_uiName.GetComponent <UITweener>();
        m_nameFadeAway.SetOnFinished(OnNameFadeAwayFinished);
        m_uiName.fontSize = 25;
        m_uiName.text     = owner.m_name;

        //if( owner.m_team != null )
        //	m_uiName.color = owner.m_team.m_side == Team.Side.eHome ? Color.red : Color.green;

        m_uiPosition            = GameUtils.FindChildRecursive(m_goPlayerInfo.transform, "Position").GetComponentInChildren <UISprite>();
        m_oriPositionPos        = m_uiPosition.transform.localPosition;
        m_uiPosition.spriteName = owner.m_position.ToString();
        OnNameFadeAwayFinished();

        GameUtils.SetLayerRecursive(m_goPlayerInfo.transform, LayerMask.NameToLayer("GUI"));

        m_goState       = new GameObject(owner.m_id + "_state");
        m_goState.layer = LayerMask.NameToLayer("GUI");

        GameObject state = new GameObject("sprite");

        state.layer                   = LayerMask.NameToLayer("GUI");
        state.transform.parent        = m_goState.transform;
        state.transform.localPosition = Vector3.zero;
        state.transform.localScale    = Vector3.one;

        m_uiState = NGUITools.AddSprite(state, m_uiPosition.atlas, "none");
        m_uiState.MakePixelPerfect();
        m_uiState.gameObject.transform.localScale = Vector3.one * 0.3f;

        m_uiStaminaBar = GameUtils.FindChildRecursive(m_goPlayerInfo.transform, "StaminaBar").GetComponent <UIStaminaBar>();
        if (m_uiStaminaBar != null)
        {
            m_uiStaminaBar.m_attachedPlayer = m_owner;
            m_uiStaminaBar.gameObject.SetActive(false);
        }

        CreateStrengthBar();
        ShowStrengthBar(false);
    }
Beispiel #2
0
 private void Awake()
 {
     instance = this;
 }