Exemplo n.º 1
0
        public static void Handle(string InType, JSONNode InParam, JSONNode InThroughParam, string InExtra)
        {
            JSONNode backDataJson = null;

            switch (InType)
            {
            case "getRoomConfig":
            {
                var graphicOption      = SceneManager.Instance.GetComponent <graphicOptionCTRL>();
                int defaultPerformance = 2;
                if (null != graphicOption)
                {
                    switch (graphicOption.graphicOption)
                    {
                    case graphicOptionCTRL.TierSetting.High:
                        defaultPerformance = 2;
                        break;

                    case graphicOptionCTRL.TierSetting.Mid:
                        defaultPerformance = 1;
                        break;
                    }
                }

                backDataJson = new JSONObject
                {
                    ["result"]      = "succeed",
                    ["bgm"]         = AudioManager.Instance.MusicVolume,
                    ["effect"]      = AudioManager.Instance.EffectVolume,
                    ["performance"] =
                        LocalDataController.GetLocalDataValue_Int(LocalDataController.GraphicOption,
                                                                  defaultPerformance)
                };
            }
            break;

            case "setSoundBgm":
                AudioManager.Instance.MusicVolume = InParam["value"].AsInt;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setSoundEffect":
                AudioManager.Instance.EffectVolume = InParam["value"].AsInt;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setSoundBGMOn":
                AudioManager.Instance.MusicSwitch = true;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setSoundBGMOff":
                AudioManager.Instance.MusicSwitch = false;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setSoundEffectOn":
                AudioManager.Instance.EffectSwitch = true;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setSoundEffectOff":
                AudioManager.Instance.EffectSwitch = false;
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setGoldValue":
                int gold = AccountManager.Instance.SetPropertyGold(InParam["value"].AsInt);
                AdaNetwork.GetProcess <MissionProcess>().missionManager.UpdateMission_GOLD(gold);
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setCashValue":
                int cash = AccountManager.Instance.SetPropertyCash(InParam["value"].AsInt);
                AdaNetwork.GetProcess <MissionProcess>().missionManager.UpdateMission_CASH(cash);
                backDataJson = new JSONObject
                {
                    ["result"] = "succeed"
                };
                break;

            case "setGraphicPerf":
            {
                int quality = InParam["value"].AsInt;

                var graphicOption = SceneManager.Instance.GetComponent <graphicOptionCTRL>();

                if (graphicOption != null)
                {
                    switch (quality)
                    {
                    case 1:
                        graphicOption.SetGraphicTierMid();
                        LocalDataController.SetLocalDataValue_Int(LocalDataController.GraphicOption, quality);
                        break;

                    case 2:
                        graphicOption.SetGraphicTierHigh();
                        LocalDataController.SetLocalDataValue_Int(LocalDataController.GraphicOption, quality);
                        break;

                    default:
                        backDataJson = new JSONObject
                        {
                            ["result"] = "failed",
                            ["value"]  = 2,
                            ["msg"]    = "Out of range, Set graphic level = 2"
                        };
                        graphicOption.SetGraphicTierHigh();
                        LocalDataController.SetLocalDataValue_Int(LocalDataController.GraphicOption, 2);
                        break;
                    }
                }
                else
                {
                    backDataJson = new JSONObject
                    {
                        ["result"] = "failed",
                        ["value"]  = 2,
                        ["msg"]    = "Not found graphic setting."
                    };
                }


                if (null == backDataJson)
                {
                    backDataJson = new JSONObject
                    {
                        ["result"] = "succeed"
                    };
                }
            }
            break;

            case "gotoUnityPage":
                ThirdPartyGotoUnity.GotoUnity(InParam);
                break;

            case "mission":
                if (InParam != null)
                {
                    string        playType     = InParam["play_type"].Value;
                    string        categoryType = InParam["category_type"].Value;
                    JSONArray     missionTag   = InParam["mission_tag"].AsArray;
                    List <string> list         = new List <string>();
                    for (int i = 0; i < missionTag.Count; i++)
                    {
                        list.Add(missionTag[i]);
                    }
                    MissionProcess.NativeSendMission(playType, categoryType, list.ToArray());
                }
                break;

            case "missionCheck":
                var        aCharacter     = AdaAvatar.Instance.GetCurrCharacter();
                var        partsDatas     = aCharacter.GetCurrEquipAllSlotID();
                int        stylebookId    = InParam["stylebookId"].AsInt;
                bool       customBg       = InParam["customBg"].AsBool;
                JSONArray  stampListArray = InParam["stampList"].AsArray;
                List <int> stampList      = new List <int>();
                for (int i = 0; i < stampListArray.Count; i++)
                {
                    stampList.Add(stampListArray[i]);
                }

                AdaNetwork.GetProcess <MissionProcess>().StyleBookMissionCheck(stylebookId, partsDatas, stampList.ToArray(), customBg);
                break;

            case "attendMissionCheck":
                var data = DataTableManager.Instance.dailyAttendanceData.GetDailyData();
                if (data != null)
                {
                    AdaNetwork.GetProcess <MissionProcess>().missionManager.UpdateMission(MissionPlay_type.PARTICIPATE, MissionCategory_type.DAILYATTENDANCE, data.mission_tag);
                }
                break;

            case "playEffect":
                AudioManager.Instance.PlayEffect((AudioKey)InParam["index"].AsInt);
                break;

            case "playMusic":
                AudioManager.Instance.PlayMusic((AudioKey)InParam["index"].AsInt);
                break;

            case "mailReceive":
            {
                Log.Info("开始处理邮件", ColorName.Red);
                ResponseMailRecive value = JsonUtility.FromJson <ResponseMailRecive>(InParam.Value);
                MailH5MissionProcess.OnReceiveMailReceive(value);
                break;
            }

            case "mialReceiveAll":
            {
                Log.Info("开始处理全部邮件", ColorName.Red);
                ResponseMailReciveAll value = JsonUtility.FromJson <ResponseMailReciveAll>(InParam.Value);
                MailH5MissionProcess.OnReceiveMailReceiveAll(value);
                break;
            }

            case "ChallengeResult":
            {
                backDataJson = AdaNetwork.GetProcess <ChallengeProcess>().challengeResult;
                break;
            }

            default:
                Log.Error($"Not found third party H5 dispatch handle named {InType}.");
                backDataJson = new JSONObject()
                {
                    ["result"] = "failed",
                    ["msg"]    = $"Not found third party H5 dispatch handle named {InType}."
                };
                break;
            }

            Log.Info(
                $"[ThirdPartyH5Dispatch] -- Type = {InType}\nParam = {InParam}\nThroughParam = {InThroughParam}\nBackParam = {backDataJson}");

            ThirdPartyBridge.ToNative(CommandType.H5AndUnity,
                                      MakeBackJsonNode(InType, backDataJson, InThroughParam));

            ToNativeDone(InType);
        }
        public static void GotoUnity(JSONNode InParam)
        {
            Debug.Log("ThirdPartyGotoUnity GotoUnity " + InParam.ToString());
            string url = InParam["url"];

            if (url == "Stylebook")
            {   // is not page only funciton
                ThirdPartyBridge.SetNativeTabBarActivity(false);
                OnStylebookEdit(InParam);
                return;
            }

            WebViewController.Instance.ActiveGameSceneCam(true);
            Szn.Framework.Audio.AudioManager.Instance.FadeTurnSound(false);
            if (url == "Home")
            {
                ThirdPartyBridge.SetNativeTabBarActivity(true);
                UIPageInterface.OnMainLobby();
                return;
            }
            ThirdPartyBridge.SetNativeTabBarActivity(false);



            switch (url)
            {
            case "RankingInfo":
            {
                StyleBookCaptureImage.Instance.SetAllPartsDefault();
                int type      = InParam["type"];
                int accountId = InParam["account_id"];
                if (accountId == AccountManager.Instance.GetUserAccountID())
                {
                    ThirdPartyBridge.SetNativeTabBarActivity(true);
                    UIPageInterface.OnMainLobby();
                }
                else
                {
                    UIPageInterface.OnRankingRoom(accountId, type);
                    EventTrackingBackendProcess.FollowLobbyEvent(EventTrackingBackendProcess.InFolloLobbyType.GotoUnityRank, accountId);
                }
                break;
            }

            case "FollowLobby":
            {
                StyleBookCaptureImage.Instance.SetAllPartsDefault();
                int accountId = InParam["account_id"];
                if (accountId == AccountManager.Instance.GetUserAccountID())
                {
                    ThirdPartyBridge.SetNativeTabBarActivity(true);
                    UIPageInterface.OnMainLobby();
                }
                else
                {
                    UIPageInterface.OnFollowLobby(accountId);
                    EventTrackingBackendProcess.FollowLobbyEvent(EventTrackingBackendProcess.InFolloLobbyType.GotoUnityFollow, accountId);
                }
                break;
            }

            case "SeasonBook":
            {
                UIPageInterface.OnWebViewSeasonBook();
                break;
            }

            case "Mission":
            {
                UIPageInterface.OnWebViewMission();
                break;
            }

            case "Styling":
            {
                var pageinfo = PageManager.Instance.CurrOpenPageInfo();
                if (pageinfo.CurrPage == PageEnum.ActivityStyling)
                {
                    return;
                }
                int  partID  = InParam["partId"];
                bool isEquip = InParam["isEquip"];
                if (isEquip == true)
                {
                    AdaAvatar.Instance.EquipPartsItem(AdaAvatar.Instance.selectedCharacterID, partID);
                    UIPageInterface.OnStylingParts(true, partID);
                }
                else
                {
                    UIPageInterface.OnStylingParts(false, partID);
                }

                break;
            }

            case "ActivityStyling":
            {
                var pageinfo = PageManager.Instance.CurrOpenPageInfo();
                if (pageinfo.CurrPage == PageEnum.ActivityStyling)
                {
                    return;
                }
                int challengeId = InParam["challengeId"];
                int partID      = InParam["partId"];
                UIPageInterface.OnStylingActivityParts(challengeId, partID);
                break;
            }

            case "Challenge":
            {
                UIPageInterface.OnWebViewStyleChallenge();
                break;
            }

            case "CelebList":
            {
                UIPageInterface.OnCelebritySelect();
                break;
            }

            case "RoomChange":
            {
                UIPageInterface.OnRoomChange();
                break;
            }

            case "ActivityLookRoom":
            {
                ChallengeH5Data challengeH5Data = ChallengeH5Data_Parser.Parsing(InParam["challengeData"]);
                if (challengeH5Data == null)
                {
                    return;
                }
                string viewPage            = InParam["viewPage"];
                string webUrl              = InParam["webUrl"];
                int    webType             = InParam["webType"];
                ICharacterEquipParts equip = JsonUtility.FromJson <ICharacterEquipParts>(InParam["equip"]);
                UIPageInterface.OnActivityStylingChallenge(challengeH5Data, viewPage, equip, webUrl: webUrl, webType: webType);
                break;
            }

            case "ActivityLook":
            {
                ICharacterEquipParts equip = JsonUtility.FromJson <ICharacterEquipParts>(InParam["equip"]);
                var pageinfo = PageManager.Instance.CurrOpenPageInfo();
                if (pageinfo.CurrPage == PageEnum.ActivityStyling)
                {
                    var adaCharacter = AdaAvatar.Instance.GetCurrCharacter();
                    adaCharacter.EquipLook(equip);
                }
                else
                {
                    UIPageInterface.OnActivityStylingLook(equip);
                }
                break;
            }

            case "ChatRoomRunWay":
            {
                UIPageInterface.OnChatRoomRunWay();
                break;
            }

            case "ChallengeRoom":
            {
                ChallengeH5Data challengeH5Data = ChallengeH5Data_Parser.Parsing(InParam["challengeData"]);
                if (challengeH5Data == null)
                {
                    return;
                }
                AdaNetwork.GetProcess <ChallengeProcess>().backH5DataJson = InParam["challengeData"];
                UIPageInterface.OnStylingChallenge(challengeH5Data);
                break;
            }
            }
        }
        public static void Handle(CommandType InCommandType, JSONNode InJsonNode, string InExtra)
        {
            switch (InCommandType)
            {
            case CommandType.Logout:
                AccountManager.Instance.ClearPlayerPrefs();
                GameStarter.Instance.GameLogout();
                break;

            case CommandType.Mission:
                if (null != InJsonNode)
                {
                    string        playType     = InJsonNode["play_type"].Value;
                    string        categoryType = InJsonNode["category_type"].Value;
                    JSONArray     missionTag   = InJsonNode["mission_tag"].AsArray;
                    List <string> list         = new List <string>();
                    for (int i = 0; i < missionTag.Count; i++)
                    {
                        list.Add(missionTag[i]);
                    }
                    MissionProcess.NativeSendMission(playType, categoryType, list.ToArray());
                }

                break;

            case CommandType.H5AndUnity:
                if (null != InJsonNode)
                {
                    JSONNode param = InJsonNode["requestParam"];
                    ThirdPartyH5Dispatch.Handle(param["type"].Value, param["data"], InJsonNode["passThroughParam"],
                                                InExtra);
                }

                break;

            case CommandType.NavbarEvent:
                if (null != InJsonNode)
                {
                    int type = InJsonNode["type"].AsInt;
                    if (type != nativeBarState)
                    {
                        nativeBarState = type;

                        //SetUnityActivity(type == 1);
                        AudioManager.Instance.FadeTurnSound(type != 1);
                        EventManager.Instance.Trigger(EventKey.OnTabBarClicked, type);
                    }
                }
                break;

            case CommandType.NativeWebviewHandle:
            {
                if (null != InJsonNode)
                {
                    if (InJsonNode["type"].Value == "close")
                    {
                        if (PageManager.Instance.CurrOpenPageInfo() is MainPage)
                        {
                            ThirdPartyBridge.SetNativeTabBarActivity(true);
                        }
                        else
                        {
                            ThirdPartyBridge.SetNativeTabBarActivity(false);
                        }

                        WebViewController.Instance.ActiveGameSceneCam(true);
                    }
                }
            }
            break;

            case CommandType.ProfileImg:
            {
                AccountManager.Instance.SetUserThumbnailURL(InJsonNode["ProfileImage"].Value);
            }
            break;

            case CommandType.Username:
            {
                AccountManager.Instance.SetUserName(InJsonNode["Username"].Value);
            }
            break;

            case CommandType.PlayEffect:
                AudioManager.Instance.PlayEffect((AudioKey)InJsonNode["index"].AsInt);
                break;

            case CommandType.PlayMusic:
                AudioManager.Instance.PlayMusic((AudioKey)InJsonNode["index"].AsInt);
                break;

            case CommandType.EffectSwitch:
                AudioManager.Instance.EffectSwitch = InJsonNode["Switch"].Value == "On";
                break;

            case CommandType.MusicSwitch:
                AudioManager.Instance.MusicSwitch = InJsonNode["Switch"].Value == "On";
                break;

            case CommandType.GoToUnity:
                ThirdPartyGotoUnity.GotoUnity(InJsonNode);
                break;

            default:
                Log.Error($"Not found third party dispatch handle named {InCommandType}.");
                break;
            }

            Log.Info($"[ThirdPartyH5Dispatch] -- Type = {InCommandType}\nParam = {InJsonNode}");
        }