Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (!donesel)
        {
            if (gameObject.transform.GetChild(0).gameObject.GetComponent <TUISelector> ().ready&& gameObject.transform.GetChild(1).gameObject.GetComponent <TUISelector> ().ready)
            {
                co.GoTo(new Vector2(0, -1.8f), 5.5f, 1);
                donesel = true;
                leftw   = gameObject.transform.GetChild(0).gameObject.GetComponent <TUISelector> ().chosen;
                rightw  = gameObject.transform.GetChild(1).gameObject.GetComponent <TUISelector> ().chosen;
            }
        }
        else
        {
            GameObject.Find("NumberWindowL").GetComponent <NumberWindow> ().value = leftscore;
            GameObject.Find("NumberWindowR").GetComponent <NumberWindow> ().value = rightscore;
            if (!waitforgame)
            {
                GameObject og = GameObject.Instantiate(onegame);
                ongoing          = og.GetComponent <TUIGame> ();
                ongoing.leftWiz  = leftw;
                ongoing.rightWiz = rightw;

                waitforgame = true;
            }
            else
            {
                if (ongoing.finished)
                {
                    waitforgame = false;
                    totalgames += 1;
                    if (ongoing.winner == 1)
                    {
                        leftscore += 1;
                    }
                    else
                    {
                        rightscore += 1;
                    }
                    if (Mathf.Max(leftscore, rightscore) == 7)
                    {
                        Application.LoadLevel(Application.loadedLevel);
                    }
                    ongoing.Kill();
                }
            }
        }
    }
Example #2
0
    // Update is called once per frame
    void Update()
    {
        GameObject.Find("NumberWindowL").GetComponent <NumberWindow> ().value = leftscore;
        GameObject.Find("NumberWindowR").GetComponent <NumberWindow> ().value = rightscore;
        if (!waitforgame)
        {
            GameObject og = GameObject.Instantiate(onegame);
            ongoing = og.GetComponent <TUIGame> ();

            leftw  = wizards [Random.Range(0, wizards.Length)];
            rightw = wizards [Random.Range(0, wizards.Length)];

            ongoing.leftWiz  = leftw;
            ongoing.rightWiz = rightw;

            waitforgame = true;
        }
        else
        {
            if (ongoing.finished)
            {
                waitforgame = false;
                totalgames += 1;
                if (ongoing.winner == 1)
                {
                    leftscore += 1;
                }
                else
                {
                    rightscore += 1;
                }
                if (Mathf.Max(leftscore, rightscore) == 7)
                {
                    Application.LoadLevel(Application.loadedLevel);
                }
                ongoing.Kill();
            }
        }
    }