示例#1
0
文件: Jovios.cs 项目: Ar2rZ/Cards
    public void ButtonPress(int player, string buttonJSON)
    {
        Dictionary <string, object> myJSON = Json.Deserialize(buttonJSON) as Dictionary <string, object>;

        switch ((string)myJSON["type"])
        {
        case "button":
            JoviosButtonEvent e = new JoviosButtonEvent((string)myJSON["button"], GetPlayer(new JoviosUserID(player)).GetControllerStyle(), (string)myJSON["action"]);
            foreach (IJoviosControllerListener listener in GetPlayer(new JoviosUserID(player)).GetControllerListeners())
            {
                if (listener.ButtonEventReceived(e))
                {
                    return;
                }
            }
            if (GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetButton((string)myJSON["button"]) != null)
            {
                if ((string)myJSON["action"] == "press")
                {
                    GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetButton((string)myJSON["button"]).is_pressed = true;
                }
                else
                {
                    GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetButton((string)myJSON["button"]).is_pressed = false;
                }
            }
            break;

        case "direction":
            JoviosButtonEvent e1 = new JoviosButtonEvent((string)myJSON["direction"], GetPlayer(new JoviosUserID(player)).GetControllerStyle(), (string)myJSON["action"]);
            foreach (IJoviosControllerListener listener in GetPlayer(new JoviosUserID(player)).GetControllerListeners())
            {
                if (listener.ButtonEventReceived(e1))
                {
                    return;
                }
            }
            if (GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetButton((string)myJSON["direction"]) != null)
            {
                if (myJSON["action"] == "press")
                {
                    GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetDirection((string)myJSON["direction"]).is_pressed = true;
                }
                else
                {
                    GetPlayer(new JoviosUserID(player)).GetControllerStyle().GetDirection((string)myJSON["direction"]).is_pressed = false;
                }
            }
            break;

        default:
            break;
        }
    }
示例#2
0
    bool IJoviosControllerListener.ButtonEventReceived(JoviosButtonEvent e)
    {
        if (e.GetAction() == "release")
        {
            if (e.GetResponse() == cardOption1 || e.GetResponse() == cardOption2)
            {
                ChooseCard(e.GetResponse());
            }
            else
            {
                switch (e.GetAction())
                {
                case "submit":
                    break;

                case "discard":
                    break;

                case "manage":
                    break;

                case "good":
                    break;

                case "meh":
                    break;

                case "bad":
                    break;

                case "winner":
                    break;

                default:
                    Debug.Log("error in button event");
                    break;
                }
            }
        }
        return(false);
    }