示例#1
0
    public void init(GameObject target,int pNum)
    {
        forNext = GameObject.Find ("ForNextScene").GetComponent<For_next> ();
        myOb = target;
        playerNum = forNext.playerNum;
        control_bar = new GameObject[playerNum + 1];
        ghostB = target.GetComponent<ghost_base> ();

        for (int i=0; i<=playerNum; i++) {
            control_bar [i] = Instantiate (control_barOb);
            RectTransform rt = control_bar [i].GetComponent<RectTransform> ();
            if (i == playerNum) {
                rt.pivot = new Vector2 (1f, 0.5f);
                rt.anchoredPosition = Vector2.right * rt.sizeDelta.x / 2;
                transform.SetAsFirstSibling();
            } else {
                control_bar [i].GetComponent<Image> ().color = ghostB.domiColor[i];
                rt.anchoredPosition = Vector2.left * rt.sizeDelta.x / 2;
            }
            control_bar [i].transform.SetParent (transform);
        }
        control_bar [pNum].transform.SetAsLastSibling ();
        control_bar [playerNum].transform.SetAsFirstSibling ();
        canShow = false;
        barLength = control_bar [playerNum].GetComponent<RectTransform> ().sizeDelta.x;
        LenUnit = barLength / 100;
        cando = true;
    }
示例#2
0
 public void init(int num, Vector2 offset, ghost_base a)
 {
     myNum = num;
     transform.FindChild ("Number").GetComponent<UnityEngine.UI.Text> ().text = num.ToString ();
     rt = transform.GetComponent<RectTransform> ();
     rt.anchoredPosition = offset;
     ghostB = a;
     myGroupNum = -10 - num;
     cando = true;
 }