예제 #1
0
    public void HealDmg(float dmg, int target)
    {
        // aquires values from the object
        hbar  barvars = bars [target].GetComponent <hbar> ();
        float curhp   = barvars.curhp;
        float maxhp   = barvars.maxhp;

        // decrements and makes sure we dont go under
        curhp += Mathf.Abs(dmg);
        if (curhp > maxhp)
        {
            curhp = maxhp;
        }
        barvars.curhp = curhp;
        Updatehbar(target);
    }
예제 #2
0
    private void createAllyBar(string name, int maxHP = default(int))
    {
        bars.Add(Instantiate((GameObject)Resources.Load("hbar"), ally.transform));
        if (maxHP > 0)
        {
            hbar barvars = bars [bars.Count - 1].GetComponent <hbar> ();
            barvars.maxhp = maxHP;
            barvars.curhp = maxHP;
        }
        allies++;
        bars [bars.Count - 1].transform.localPosition -= new Vector3(-30, 50 * allies + 75 * (allies - 1), 0);
        Updatehbar(bars.Count - 1);
        Text txt;

        txt      = bars [bars.Count - 1].gameObject.GetComponentsInChildren <Text> ()[1];
        txt.text = name;
    }
예제 #3
0
    private void Updatehbar(int target)
    {
        // aquires parts so we can change a particular health bar
        Image hpbar;
        Text  txt;

        hpbar = bars [target].gameObject.GetComponentsInChildren <Image> ()[1];
        txt   = bars [target].gameObject.GetComponentInChildren <Text> ();
        // aquires values from the object
        hbar  barvars = bars [target].GetComponent <hbar> ();
        float curhp   = barvars.curhp;
        float maxhp   = barvars.maxhp;
        // ratio is made and applied to the transform and text is adjusted to display the ratio
        float ratio = curhp / maxhp;

        hpbar.rectTransform.localScale = new Vector3(ratio, 1, 1);
        txt.text = curhp.ToString() + " / " + maxhp.ToString();
    }
예제 #4
0
    void Start()
    {
        Debug.Log("start button");
        e1.SetActive(true);
        e2.SetActive(true);
        e3.SetActive(true);
        e4.SetActive(true);
        e5.SetActive(true);
        e6.SetActive(false);
        e7.SetActive(false);
        ab.SetActive(false);  //ammobox
        ab2.SetActive(false); //ammobox boss
        go.SetActive(false);  //gameover

        e1p  = e1.transform.localPosition;
        e2p  = e2.transform.localPosition;
        e3p  = e3.transform.localPosition;
        e4p  = e4.transform.localPosition;
        e5p  = e5.transform.localPosition;
        e6p  = e6.transform.localPosition;
        e7p  = e7.transform.localPosition;
        abp  = ab.transform.localPosition;
        ab2p = ab2.transform.localPosition;
        //cnt = 0;
        cnt1 = 0;
        cnt2 = 0;
        cnt3 = 0;
        cnt4 = 0;
        cnt5 = 0;
        cnt6 = 0;
        cnt7 = 0;
        w    = 1;
        f1   = 0;
        am   = 7;
        time = 15.0f;
        t2   = 2.0f;
        //t1 = 10.0f;
        _uicomp      = GameObject.Find("Canvas").GetComponent <uicomponent>();
        _hbar        = GameObject.Find("barh").GetComponent <hbar>();
        _audioSource = GetComponent <AudioSource>();
        _hbar.gameObject.SetActive(false);
        //_audio[0] = _audioSource;
        // _audio[1] = gameover;
    }