コード例 #1
0
        public override void Execute()
        {
            Debug.Log("MAP WAS CHOSEN");

            switch (jC.type)
            {
            case "mapChoose":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);
                ClientStaticData.currentParty.mapSelected = HomeUtil.mapIdsToMaps(bM.s1);
                HomeUtil.deCommitAll();
                //SocketHandler.commit();
                break;
            }

            case "mapSuggest":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);
                ClientStaticData.currentParty.suggestedMaps.Add(HomeUtil.mapIdsToMaps(bM.s1));
                break;
            }
            }
        }
コード例 #2
0
        IEnumerator GetAllUnitsAsync()
        {
            Debug.Log("GetAllAsync...");
            yield return(1);

            var task = RestClient.Get(ServerPath);             //rest client get

            yield return(task.SendWebRequest());

            if (task.isNetworkError)
            {
                Debug.LogError(task.error);
            }
            else
            {
                var unitLists = task.Deserialize <LoadUnitsResponse>();
                if (unitLists == null)
                {
                    Debug.Log("list was null");
                }
                else if (unitLists.unitPrepJsons == null)
                {
                    Debug.Log("prep jsons were null");
                }
                else if (unitLists.unitPrepJsons.Count == 0)
                {
                    Debug.Log("0 in list");
                }


                if (unitLists != null && unitLists.unitPrepJsons != null && unitLists.unitPrepJsons.Count > 0)
                {
                    Debug.Log("received units !");
                    foreach (UnitListContainer unitCont in unitLists.unitPrepJsons)
                    {
                        UnitPrepsModel unitPrepsM = JsonUtility.FromJson <UnitPrepsModel>(unitCont.UnitPrepJson);
                        foreach (UnitPrep unit in unitPrepsM.unitPrepList)
                        {
                            StaticAllData.currentMap._formationUnits.Add(unit);
                        }
                    }
                    HomeUtil.startHomeGame();
                }
                else
                {
                    Debug.Log("either of lists is null or no units");
                }
            }

            task.Dispose();
        }
コード例 #3
0
        public void parseJoinRe(PartyServerModel _serverParty)
        {
            foreach (MemberModelInt membInt in _serverParty.members)
            {
                MemberModel newMemb = getMember(membInt);
                ClientStaticData.currentParty.partyMembers.Add(newMemb);
            }

            if (!string.IsNullOrEmpty(_serverParty.mapIDSelected))
            {
                ClientStaticData.currentParty.mapSelected = HomeUtil.mapIdsToMaps(_serverParty.mapIDSelected);
            }

            ClientStaticData.currentParty.partyState = getPartyState(_serverParty.state);

            ClientStaticData.currentParty.mapHistory     = HomeUtil.mapIdsToMaps(_serverParty.mapHistory);
            ClientStaticData.currentParty.suggestedMaps  = HomeUtil.mapIdsToMaps(_serverParty.suggestedMaps);
            ClientStaticData.currentParty.inviteRequests = _serverParty.inviteRequests;
        }
コード例 #4
0
        public override void Execute()
        {
            switch (jC.type)
            {
            case "commit":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);
                var member = ClientStaticData.currentParty.partyMembers
                             .FirstOrDefault(m => m.userId == bM.userId);
                if (member.state == MemberModel.userState.lobbying)
                {
                    member.state = MemberModel.userState.committed;
                }
                else
                {
                    Debug.Log("member commited from something other than lobbying, shouldn't happen");
                }


                break;
            }

            case "formationSet":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);
                break;
            }

            //probably should receieve the map name to verify same map
            case "formationPhase":
            {
                //playmap is static
                HomeUtil.homePlayMap(ClientStaticData.currentParty.mapSelected);
                break;
            }

            //the client needs to request troops from the server!
            case "requestTroops":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);

                //tells home to request troops
                HomeUtil.homeRequestTroops();

                break;
            }

            case "battleEnded":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);

                break;
            }

            case "returnToLobby":
            {
                Debug.Log("Deserialized obj to : " + bM.GetType());
                Debug.Log(bM.userId + " says " + bM.s1 + " of type " + jC.type);
                break;
            }
            }
        }