コード例 #1
0
    public async void OnShipBuilderMessage(object msg)
    {
        if (msg is Statistics)
        {
            Statistics stats = msg as Statistics;
            RoomManager.HandleStats(stats);
        }
        else if (msg is UnlockMessage)
        {
            Debug.Log("Unlock message received.");
            UnlockMessage unlocks = msg as UnlockMessage;
            PlayerData.SetUnlocks(unlocks);
        }
        else if (msg is ShipList)
        {
            Debug.Log("ShipList message received.");
            ShipList sl = msg as ShipList;
            PlayerData.myShips = sl.ships;
            RoomManager.HandleShipListUpdated();
        }
        else if (msg is ErrorMessage)
        {
            ErrorMessage er = msg as ErrorMessage;
            RoomManager.HandleErrorMessage(er.message);
        }
        else
        {
            IndexedDictionary <string, object> message = (IndexedDictionary <string, object>)msg;

            string action = message["action"].ToString();

            if (action == "message")
            {
                RoomManager.HandleMessage((string)message["message"]);
            }

            if (action == "ship_upgrade_success")
            {
                PlayerData.ResetUpgrades();
                RoomManager.HandleUpgradeSuccess();
            }

            if (action == "enter_match_making")
            {
                await shipBuilderRoom.Leave();

                shipBuilderRoom = null;

                Dictionary <string, object> options = new Dictionary <string, object>()
                {
                    { "token", PlayerPrefs.GetString("token") },
                    { "rank", PlayerData.CurrentShip().rank }
                };
                RoomManager.HandleEnterMatchMaking(options);
            }
        }
    }
コード例 #2
0
 public static void SetUnlocks(UnlockMessage u)
 {
     unlockMessage = u;
 }