Пример #1
0
    protected override void StateEnter_Voting()
    {
        voteExpiration.Set();
        timerStart  = TimeMilliseconds();
        timerLength = (int)(voteExpiration.expiration * 1000);

        connectedPlayers[curJudge].iconObject.Express();
        shockSound.Play();

        foreach (var c in connectedPlayers)
        {
            if (c.receivedInsult != null && c.receivedInsult.Length > 0)
            {
                var t  = Instantiate(insultViewPrefab).GetComponent <RectTransform>();
                var t2 = t.GetComponentInChildren <Text>();
                t2.text = c.receivedInsult;

                if (t2.text.Length > 300)
                {
                    t2.text = t2.text.Substring(0, 300) + "...";
                }

                InsultStacc.inst.Push(t);
                c.insultViewObject = t.gameObject;
            }
        }
    }
Пример #2
0
    protected override void StateEnter_PostGame()
    {
        endExpiration.Set();
        timerStart  = TimeMilliseconds();
        timerLength = (int)(endExpiration.expiration * 1000);

        if (winner != null)
        {
            winner.iconObject.Win();
            winSound.Play();

            if (winner.insultViewObject != null)
            {
                winner.insultViewObject.GetComponent <Image>().color = Color.green;
            }
        }
    }
Пример #3
0
    public override void GetInput()
    {
        for (int i = 0; i < connectedPlayers.Count; i++)
        {
            var con = connectedPlayers[i];

            if (con.timeout == null)
            {
                con.timeout = new ExpirationTimer(10);
                con.timeout.Set();
            }

            if (con.keepAlive)
            {
                con.timeout.Set();
                con.keepAlive = false;
            }

            while (con.left || con.timeout.expired)
            {
                con.iconObject.Leave();
                Destroy(con.iconObject.transform.parent.gameObject, 10);

                connectedPlayers.RemoveAt(i);

                for (int j = i; j < connectedPlayers.Count; j++)
                {
                    connectedPlayers[j].iconObject.transform.parent.GetComponent <RectTransform>().anchoredPosition += Vector2.left * 100;
                }

                if (state != StateID.Waiting && i == curJudge)
                {
                    quitSignal  = true;
                    startSignal = true;
                    base.GetInput();
                    return;
                }
                else if (i < connectedPlayers.Count - 1)
                {
                    con = connectedPlayers[i];

                    if (curJudge > i)
                    {
                        curJudge--;
                    }
                }
                else
                {
                    con = null;
                    break;
                }
            }

            if (con == null)
            {
                continue;
            }

            if (!con.iconObject)
            {
                var obj = Instantiate(playerIconPrefab, new Vector2(0, -7), Quaternion.Euler(0, 0, 0)).GetComponent <RectTransform>();
                con.iconObject = obj.GetComponentInChildren <PlayerIcon>();
                con.iconObject.Init(icons[nextIcon], expr[nextIcon]);
                con.iconObject.GetComponentInChildren <Text>().text = con.name;
                obj.SetParent(FindObjectOfType <Canvas>().transform, false);
                obj.anchoredPosition = new Vector2(-300 + 100 * i, 0);
                joinSound.Play();

                nextIcon = (nextIcon + 1) % icons.Length;
            }

            con.iconObject.SetSubmitted(con.receivedInsult != null && con.receivedInsult.Length > 0);
        }

        base.GetInput();
    }