Example #1
0
    internal void Start()
    {
        UIBarInfo ubi = new UIBarInfo();

        ubi.FillColor  = Color.red;
        ubi.UILabel    = "Health";
        ubi.funcUpdate = UpdateHealthValues;
        ubi.target     = gameObject;
        if (GetComponent <CharacterBase>() != null)
        {
            GetComponent <CharacterBase>().AddUIBar(ubi);
        }

        /*
         *      if (DisplayHealth) {
         *              if (GetComponent<BasicMovement>() != null && GetComponent<BasicMovement> ().IsCurrentPlayer) {
         *                      UIBarInfo ubi = new UIBarInfo ();
         *                      ubi.FillColor = Color.red;
         *                      ubi.UILabel = "Health";
         *                      ubi.funcUpdate = UpdateHealthValues;
         *                      ubi.target = gameObject;
         *                      FindObjectOfType<GUIHandler>().AddUIBar (ubi);
         *              } else {
         *                      m_display = Instantiate (UIList.Instance.HealthBarPrefab, this.transform).GetComponent<HealthDisplay>();
         *                      m_display.SetMaxHealth (MaxHealth);
         *              }
         *      } */
    }
Example #2
0
    public override void OnControllableChange(bool isControllable)
    {
        //Debug.Log ("On controllable change");
        if (isControllable)
        {
            //Debug.Log ("adding bar");
            UIBarInfo ubi = new UIBarInfo();
            ubi.FillColor  = Color.blue;
            ubi.UILabel    = "Focus";
            ubi.id         = "Focus";
            ubi.funcUpdate = UpdateHealthValues;
            ubi.target     = gameObject;
            //ubi.DisplayMode = UIBarDisplayMode.PERCENT;
            FindObjectOfType <GUIHandler> ().AddUIBar(ubi);

            m_displayString = ubi.UILabel;

            /*
             * m_display = Instantiate (UIList.Instance.HealthBarPrefab, this.transform).GetComponent<HealthDisplay>();
             * m_display.SetMaxHealth (MaxFocus);
             */
        }
        else
        {
            if (m_displayString.Length > 0)
            {
                FindObjectOfType <GUIHandler> ().RemoveUIBar(m_displayString);
            }
            //Destroy (m_display);
        }
    }
Example #3
0
 public void AddUIBar(UIBarInfo uib)
 {
     if (m_uiBars == null)
     {
         m_uiBars = new List <UIBarInfo>();
     }
     m_uiBars.Add(uib);
 }
Example #4
0
    public void AddUIBar(UIBarInfo uib)
    {
        if (uib.id == "SameAsLabel")
        {
            uib.id = uib.UILabel;
        }
        RemoveUIBar(uib.id);
        GameObject newBar = Instantiate(UIBarPrefab, transform);

        uib.element = newBar;
        UIBar uibar = uib.element.GetComponent <UIBar>();

        uibar.Initialize(uib, uibars.Count);
        uib.uib = uibar;
        uibars.Add(uib.id, uib);
    }
Example #5
0
    public void Initialize(UIBarInfo ubi, int Num)
    {
        SetColor(ubi.FillColor);
        if (ubi.DisplayLabel)
        {
            SetLabel(ubi.UILabel);
        }
        else
        {
            SetLabel("");
        }
        SetUseScale(ubi.useScale);
        SetScale(ubi.scale);
        SetDisplayMode(ubi.DisplayMode);
        Vector2 v = new Vector2(StartingX, BarHeight * Num + StartingHeight);

        GetComponent <RectTransform> ().anchoredPosition = v;
        Num = Num;
    }
Example #6
0
 public override void OnAddProperty()
 {
     if (GetComponent <BasicMovement>() != null &&
         GetComponent <BasicMovement> ().IsCurrentPlayer)
     {
         UIBarInfo ubi = new UIBarInfo();
         ubi.FillColor   = new Color(0.2f, 0.2f, 0f);
         ubi.UILabel     = "Sentiment";
         ubi.funcUpdate  = UpdateSentiment;
         ubi.target      = gameObject;
         ubi.DisplayMode = UIBarDisplayMode.BASE;
         ubi.useScale    = false;
         FindObjectOfType <GUIHandler>().AddUIBar(ubi);
         Debug.Log("Adding a GUI bar");
     }
     m_display = Instantiate(UIList.Instance.HealthBarPrefab, this.transform).GetComponent <HealthDisplay>();
     m_display.SetMaxHealth(ActivateThreashold);
     m_display.DisplayAsFraction = true;
     m_display.ValueLabel        = "SNT";
     Debug.Log("Adding for: " + gameObject);
 }
Example #7
0
 void UpdateHealthValues(UIBarInfo ubi)
 {
     ubi.element.GetComponent <UIBar> ().UpdateValues(Mathf.Round(m_focus), Mathf.Round(MaxFocus));
 }
Example #8
0
 void UpdateHealthValues(UIBarInfo ubi)
 {
     ubi.element.GetComponent <UIBar> ().UpdateValues(Mathf.Round(ubi.target.GetComponent <Attackable>().Health),
                                                      Mathf.Round(ubi.target.GetComponent <Attackable>().MaxHealth));
 }
Example #9
0
 void UpdateSentiment(UIBarInfo ubi)
 {
     ubi.element.GetComponent <UIBar> ().UpdateValues(CurrentSentiment, MaxSentiment);
 }
Example #10
0
 void UpdateSpeedValues(UIBarInfo ubi)
 {
     ubi.element.GetComponent <UIBar> ().UpdateValues(Mathf.Abs(Mathf.Round(ubi.target.GetComponent <PhysicsSS>().TrueVelocity.x * 100f)),
                                                      20f);
 }