コード例 #1
0
ファイル: KeyManager.cs プロジェクト: UNFDanmark/GDC2018-GR7
    private void Update()
    {
        if (!string.IsNullOrEmpty(p1Key1))
        {
            if (Input.GetKeyDown(p1Key1) && !p1key1turn && p1Amount > 0)
            {
                ui.KeyPressed(p1l, p1r);
                p1Amount--;
                p1key1turn = true;
            }

            if (Input.GetKeyDown(p1Key2) && p1key1turn && p1Amount > 0)
            {
                ui.KeyPressed(p1r, p1l);
                p1Amount--;
                p1key1turn = false;
            }
        }

        if (!string.IsNullOrEmpty(p2Key1))
        {
            if (Input.GetKeyDown(p2Key1) && !p2key1turn && p2Amount > 0)
            {
                ui.KeyPressed(p2l, p2r);
                p2Amount--;
                p2key1turn = true;
            }

            if (Input.GetKeyDown(p2Key2) && p2key1turn && p2Amount > 0)
            {
                ui.KeyPressed(p2r, p2l);
                p2Amount--;
                p2key1turn = false;
            }
        }

        if (p1Amount == 0)
        {
            p1cg.alpha = 0;

            if (p1event != null)
            {
                p1event.Invoke();
                p1event = null;
            }
        }

        if (p2Amount == 0)
        {
            p2cg.alpha = 0;

            if (p2event != null)
            {
                p2event.Invoke();
                p2event = null;
            }
        }
    }
コード例 #2
0
ファイル: KeyManager.cs プロジェクト: UNFDanmark/GDC2018-GR7
    public static void TriggerQuickEvent(PlayerManager player, int amount, OnQuickEventOver _event)
    {
        string key1 = keys[Random.Range(0, keys.Length - 1)];
        string key2 = keys[Random.Range(0, keys.Length - 1)];

        while (key1 == key2)
        {
            key2 = keys[Random.Range(0, keys.Length - 1)];
        }

        player.UIkey.GetComponentInChildren <TextMeshProUGUI>().text  = key1;
        player.UIkey2.GetComponentInChildren <TextMeshProUGUI>().text = key2;


        if (player.playerRole == PlayerManager.Role.cook)
        {
            p1Key1 = key1;
            p1Key2 = key2;

            p1Amount = amount;

            p1cg.alpha = 1;

            ui.KeyPressed(p1r, p1l);

            p1event = _event;
        }
        else
        {
            p2Key1 = key1;
            p2Key2 = key2;

            p2Amount = amount;

            p2cg.alpha = 1;

            ui.KeyPressed(p2r, p2l);

            p2event = _event;
        }
    }