Exemplo n.º 1
0
        public static void DoFacebookShare(string value)
        {
            if (Const.Region != RegionType.KOREA || string.IsNullOrEmpty(value))
            {
                return;
            }

            var       bridge = DBOSManager.getDBOSManager().getBridge();
            Hashtable extmap = new Hashtable();

            GlobalConfig globalConfig = GlobalConfig.GetInstance();

            extmap.Add("roleID", globalConfig.LoginInfo.RId);
            extmap.Add("roleName", globalConfig.LoginInfo.Name);
            extmap.Add("serverID", globalConfig.LoginInfo.ServerInfo.ServerId);
            extmap.Add("shareEvent", "forevershare");
            extmap.Add("shareDetail", value);
            extmap.Add("screenShotFile", "");

            Hashtable parameter = new Hashtable();

            parameter.Add("action", "doFacebookShare");
            parameter.Add("extmap", extmap);

            Hashtable hashtable = new Hashtable();

            hashtable.Add("action", "sdkInvoke");
            hashtable.Add("parameter", parameter);

            string str = MiniJSON.JsonEncode(hashtable);

            bridge.doAction2SDK(str);
            //GameDebug.LogError(str);
        }
Exemplo n.º 2
0
    /*
     * 发送消息给SDK,SDK会把这些参数发送给有角色采集需求的SDK
     *
     *  dataType	int	调用时机, 1、选择服务器。2、创建角色。3、进入游戏。4、等级提升。5退出游戏
     *  serverID	String	玩家所在服务器的ID
     *  serverName	String	玩家所在的服务器名称
     *  roleID	String	玩家角色ID
     *  roleType	String	玩家角色类型
     *  roleName	String	玩家角色名字
     *  roleLevel	String	玩家角色等级
     *  moneyNum	String	当前角色身上拥有的游戏币
     *  roleCreateTime	Long	角色创建时间
     *  roleLevelUpTime	Long	角色等级变化
     *  Vip	String	玩家VIP等级
     *
     */
    public void sendRoleInfo2SDK(int dataType, string serverID, string serviceName, string roleId, string roleType, string roleName, string roleLevel, string moneyNum, string roleCreateTime, string roleLevelUpTime, string vip, string accName)
    {
        if (GlobalConfig.Instance.IsDisableDoAction2SDK == true)
        {
            return;
        }

        Dictionary <string, string> parameters = new Dictionary <string, string>();

        parameters.Add("dataType", dataType.ToString());//1.选择服务器2.创建角色3.进入游戏4.等级提升5.退出游戏
        parameters.Add("serverID", serverID);
        parameters.Add("serviceName", serviceName);
        parameters.Add("moneyNum", moneyNum);//金币数量
        parameters.Add("roleCreateTime", roleCreateTime);
        parameters.Add("service", serviceName);
        parameters.Add("roleId", roleId);
        parameters.Add("roleType", roleType);
        parameters.Add("roleName", roleName);
        parameters.Add("roleLevel", roleLevel);
        parameters.Add("roleLevelUpTime", roleLevelUpTime);
        parameters.Add("vip", vip);
        parameters.Add("accName", accName);

        Dictionary <string, string> all = new Dictionary <string, string>();

        all.Add("action", "roleInfo");
        all.Add("parameter", MiniJSON.JsonEncode(new Hashtable(parameters)));
        Hashtable hashtable = new Hashtable(all);
        string    str       = MiniJSON.JsonEncode(hashtable);
        IBridge   bridge    = DBOSManager.getDBOSManager().getBridge();

        bridge.doAction2SDK(str);
    }
Exemplo n.º 3
0
        public static void ReportTjPlacementEvnet(string value, string category = "")
        {
            if (Const.Region != RegionType.KOREA || string.IsNullOrEmpty(value))
            {
                return;
            }

            var       bridge = DBOSManager.getDBOSManager().getBridge();
            Hashtable extmap = new Hashtable();

            extmap.Add("event", value);
            extmap.Add("category", category);

            Hashtable parameter = new Hashtable();

            parameter.Add("action", "tj_placement");
            parameter.Add("extmap", extmap);

            Hashtable hashtable = new Hashtable();

            hashtable.Add("action", "reportEvent");
            hashtable.Add("parameter", parameter);

            string str = MiniJSON.JsonEncode(hashtable);

            bridge.doAction2SDK(str);
            //GameDebug.LogError(str);
        }
Exemplo n.º 4
0
        public static void GoogleSubmitAchievements(string value)
        {
            if (Const.Region != RegionType.KOREA || string.IsNullOrEmpty(value))
            {
                return;
            }

            var       bridge = DBOSManager.getDBOSManager().getBridge();
            Hashtable extmap = new Hashtable();

            extmap.Add("achievementsId", value);

            Hashtable parameter = new Hashtable();

            parameter.Add("action", "GoogleSubmitAchievements");
            parameter.Add("extmap", extmap);

            Hashtable hashtable = new Hashtable();

            hashtable.Add("action", "sdkInvoke");
            hashtable.Add("parameter", parameter);

            string str = MiniJSON.JsonEncode(hashtable);

            bridge.doAction2SDK(str);
            //GameDebug.LogError(str);
        }
Exemplo n.º 5
0
        public static void ReportEsaAppsflyerEvnet(string eventName, string argKey, int argValue)
        {
            if (Const.Region != RegionType.SEASIA)
            {
                return;
            }

            var       bridge = DBOSManager.getDBOSManager().getBridge();
            Hashtable extmap = new Hashtable();

            extmap.Add(argKey, argValue);

            Hashtable parameter = new Hashtable();

            parameter.Add("action", eventName);
            parameter.Add("extmap", extmap);

            Hashtable hashtable = new Hashtable();

            hashtable.Add("action", "reportEvent");
            hashtable.Add("parameter", parameter);

            string str = MiniJSON.JsonEncode(hashtable);

            bridge.doAction2SDK(str);
            //GameDebug.LogError(string.Format("ReportEsaAppsflyerEvnet ==> {0}", str));
        }
Exemplo n.º 6
0
        public static void Save()
#endif
        {
            string str = MiniJSON.JsonEncode(playerPrefs);

            File.WriteAllText(filePath, str);
        }
Exemplo n.º 7
0
    public static void WriteJsonFile(string fileName, object content)
    {
        string fileContent = MiniJSON.JsonEncode(content);

        System.IO.StreamWriter sw = new System.IO.StreamWriter(fileName);
        sw.Write(fileContent);

        sw.Close();
    }
Exemplo n.º 8
0
        /// <summary>
        /// 云梯事件上报
        /// </summary>
        public void PostCloudLadderEventAction(CloudLadderMarkEnum mark)
        {
            if (GlobalConfig.Instance.IsPostCloudLadderAction == false)
            {
                return;
            }

            FieldInfo fi = mark.GetType().GetField(mark.ToString());

            DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
            string desc      = (attributes.Length > 0) ? attributes[0].Description : "";
            var    descBytes = Encoding.UTF8.GetBytes(desc);

            desc = Encoding.UTF8.GetString(descBytes);

            var loginInfo = GlobalConfig.Instance.LoginInfo;

            Hashtable parameters = new Hashtable();

            parameters.Add("step", ((int)mark).ToString());                     //步骤编号
            parameters.Add("mark", mark.ToString());                            // 步骤标识
            parameters.Add("desc", desc);                                       //描述
            parameters.Add("gamever", VersionInfoManager.Instance.GameVersion); // 游戏版本
            parameters.Add("ram", SystemInfo.systemMemorySize.ToString());


            string rid = ""; // 游戏角色id

            if (null != loginInfo)
            {
                rid = loginInfo.RId;
            }

            parameters.Add("rid", rid);

            Hashtable all = new Hashtable();

            all.Add("action", "checkpoint");

            string uid = ""; // 游戏后台分配的账号id(passport)

            if (null != loginInfo)
            {
                uid = loginInfo.AccName;
            }

            all.Add("userId", uid);
            all.Add("parameter", MiniJSON.JsonEncode(parameters));

            string  str    = MiniJSON.JsonEncode(all);
            IBridge bridge = DBOSManager.getDBOSManager().getBridge();

            bridge.cloudLadderEventWithAction(str);
        }
Exemplo n.º 9
0
        public bool Save(Map map, string file, out string error)
        {
            string json = MiniJSON.JsonEncode(map, true);

            try
            {
                System.IO.File.WriteAllText(file, json);
            }
            catch (Exception e)
            {
                error = e.ToString();
                return(false);
            }
            error = string.Empty;
            return(true);
        }
Exemplo n.º 10
0
    public void GotoCSLogin(string msg)
    {
        mIsLogining = true;
        Hashtable hashtable = MiniJSON.JsonDecode(msg) as Hashtable;

        if (hashtable != null)
        {
            if (hashtable.Count <= 2)
            {
                if (mLoginCallback != null)
                {
                    endLogin((int)SDK_STATU_CODE.LOGIN_CANCEL, xc.TextHelper.SDKLoginCancel);
                }
                return;
            }
            GlobalConfig globalConfig = GlobalConfig.GetInstance();

            string loginAction = hashtable["_LoginAction_"] as string;

            string data = "";
            foreach (DictionaryEntry de in hashtable)
            {
                string key   = de.Key.ToString();
                string value = de.Value.ToString();
                if (!key.Equals("_LoginAction_"))
                {
                    value = WWW.EscapeURL(value, System.Text.Encoding.UTF8);
                    data  = data + key + "=" + value + "&";
                }
            }

            IBridge bridge = DBOSManager.getOSBridge();

            string url = "";
            // AppID超过350使用新接口
            if (GlobalConfig.Instance.AppId > 350)
            {
                url = globalConfig.LoginURL + "eagleV4/" + loginAction + "?" + data + "game_mark=" + GlobalConfig.Instance.GameMark + "&net=" + bridge.getNetType() + "&provider=" + GlobalConfig.Instance.Channel;
                // os_ext 韩国版用来标识是one_store还是google_play,还是app_store
                if (Const.Region == RegionType.KOREA)
                {
                    url += "&os_ext=" + Application.identifier;
                    url += "&sdkUserId=" + bridge.getSdkUserID();
                }
            }
            else
            {
                url = globalConfig.LoginURL + loginAction + "?" + data + "game_mark=" + GlobalConfig.Instance.GameMark + "&net=" + bridge.getNetType() + "&provider=" + GlobalConfig.Instance.Channel;
                if (Const.Region == RegionType.KOREA)
                {
                    url += "&os_ext=" + Application.identifier;
                    url += "&sdkUserId=" + bridge.getSdkUserID();
                }
            }

#if UNITY_IPHONE
            url = globalConfig.LoginURL + loginAction + "?" + data + "game_mark=" + GlobalConfig.Instance.GameMark + "&net=" + bridge.getNetType();
            if (Const.Region == RegionType.KOREA)
            {
                url += "&os_ext=" + Application.identifier;
                url += "&sdkUserId=" + bridge.getSdkUserID();
            }
            //ios 在xcode 已经传了
#endif



#if UNITY_IPHONE
            url = url + "&device_mark=" + globalConfig.DeviceMark;
            Debug.Log("SDKControler.GotoCSLogin" + url);
#endif

            // 加上二级渠道
            url = url + "&sub_chn=" + globalConfig.SubChannel;

            // 扩展参数
            Hashtable extendParams = new Hashtable();
            extendParams.Add("did", WWW.EscapeURL(bridge.getSDKDeviceID()));
            extendParams.Add("idfa", WWW.EscapeURL(bridge.GetPhoneIDFA()));
            extendParams.Add("extc", bridge.getExtChannel()); //三级渠道

            var extend = MiniJSON.JsonEncode(extendParams);
            url = url + "&extend=" + extend;

            MainGame.HttpRequest.GET(url, OnCSLoginFinished, null);
        }
        else
        {
            if (mLoginCallback != null)
            {
                mLoginCallback((int)SDK_STATU_CODE.LOGIN_MSG_FAIL, xc.TextHelper.SDKLoginCancel);
            }
            return;
        }
    }
Exemplo n.º 11
0
        public void Pay(DBPay.PayItemInfo pay_info)
        {
            if (pay_info == null)
            {
                return;
            }

            var server_id   = 0;
            var server_name = "0";
            var server_info = GlobalConfig.Instance.LoginInfo.ServerInfo;

            if (server_info == null)
            {
                Debug.LogError("OnClickPayButton: server_info is null");
            }
            else
            {
                server_id   = server_info.ServerId;
                server_name = server_info.Name;
            }



#if UNITY_IPHONE
            var pay_request_info = new Dictionary <string, string>();
            //IPHONE 从ProductInfo.json里面读取商品数据
            ProductInfoManager.ProductInfo info = ProductInfoManager.GetInstance().GetProductInfo(pay_info.RmbLow);
            if (info == null)
            {
                //ProductInfo.json   不存在则 读取  C充值商品id.xlsx
                var db_pay_product = DBManager.Instance.GetDB <DBPayProduct>();
                DBPayProduct.PayDroductInfo product_info = db_pay_product.getProductInfo(pay_info.RmbLow);
                pay_request_info.Add("productID", product_info.ProductId);
                pay_request_info.Add("productName", product_info.ProductName);
                pay_request_info.Add("productDesc", product_info.ProductDesc);
            }
            else
            {
                //ProductInfo.json   存在则  读取  ProductInfo.json
                pay_request_info.Add("productID", info.productId);
                pay_request_info.Add("productName", info.productName);
                pay_request_info.Add("productDesc", info.productDesc);
            }
#else
            var db_pay_product = DBManager.Instance.GetDB <DBPayProduct>();
            DBPayProduct.PayDroductInfo product_info = db_pay_product.getProductInfo(pay_info.RmbLow);

            var pay_request_info = new Dictionary <string, string>();
            pay_request_info.Add("productID", product_info.ProductId);
            pay_request_info.Add("productName", product_info.ProductName);
            pay_request_info.Add("productDesc", product_info.ProductDesc);
#endif


            pay_request_info.Add("passport", GlobalConfig.Instance.LoginInfo.AccName);
            pay_request_info.Add("serverID", server_id.ToString());
            pay_request_info.Add("roleId", GlobalConfig.Instance.LoginInfo.RId.ToString());
            pay_request_info.Add("price", pay_info.RmbLow.ToString());
            if (Const.Region == RegionType.HKTW || Const.Region == RegionType.SEASIA)
            {
                pay_request_info.Add("currency", GameConstHelper.GetString("GAME_PAYMENT_CURRENCY_USD"));
            }
            else if (Const.Region == RegionType.KOREA)
            {
                pay_request_info.Add("currency", GameConstHelper.GetString("GAME_PAYMENT_CURRENCY_KR"));
            }
            else
            {
                pay_request_info.Add("currency", GameConstHelper.GetString("GAME_PAYMENT_CURRENCY"));
            }
            pay_request_info.Add("serverName", server_name);
            pay_request_info.Add("roleName", GlobalConfig.Instance.LoginInfo.Name);
            pay_request_info.Add("roleLevel", GlobalConfig.Instance.LoginInfo.Level.ToString());
            pay_request_info.Add("vip", VipHelper.GetVipValidLevel().ToString());                                                     //角色VIP等级
            pay_request_info.Add("coinNum", LocalPlayerManager.Instance.GetMoneyByConst(GameConst.MONEY_DIAMOND).ToString());         //当前玩家身上拥有的金锭数量
            if (DBOSManager.getOSBridge().getAppID() == 529)                                                                          // 卓梦
            {
                pay_request_info.Add("currencyNum", LocalPlayerManager.Instance.GetMoneyByConst(GameConst.MONEY_DIAMOND).ToString()); //当前玩家身上拥有的金锭数量
            }
#if UNITY_IPHONE
            pay_request_info.Add("gameMark", GlobalConfig.Instance.GameMark); //角色VIP等级
#endif


            //使用sdk接口发送充值请求
            string pay_requeset_str = MiniJSON.JsonEncode(new Hashtable(pay_request_info));
            DBOSManager.getDBOSManager().getBridge().pay(pay_requeset_str);
            Debug.Log(string.Format("OnClickPayButton pay_rmb: {0}", pay_info.RmbLow));
        }
Exemplo n.º 12
0
        public static void Build()
        {
            string luaCompilerPath = PlayerPrefs.GetString("luajit_path");
            string luaPath         = PlayerPrefs.GetString("lua_path");

            DirectoryInfo di = new DirectoryInfo(luaCompilerPath);

            if (string.IsNullOrEmpty(luaCompilerPath) || !di.Exists)
            {
                throw new Exception("Luajit path not exist.");
            }

            di = new DirectoryInfo(luaPath);
            if (string.IsNullOrEmpty(luaPath) || !di.Exists)
            {
                throw new Exception("Lua path not exist.");
            }

            //md5
            Hashtable md5Map;
            string    v = luaPath + "\\ver.txt";

            if (File.Exists(v))
            {
                string vJson = File.ReadAllText(v);
                md5Map = ( Hashtable )MiniJSON.JsonDecode(vJson);
            }
            else
            {
                md5Map = new Hashtable();
            }

            string        driver = luaCompilerPath.Substring(0, luaCompilerPath.IndexOf("\\", StringComparison.Ordinal)).ToLower();
            StringBuilder sb     = new StringBuilder();

            sb.AppendLine("@echo off");
            sb.AppendLine(driver);
            sb.AppendLine("cd " + luaCompilerPath);

            FileInfo[] fis = di.GetFiles("*.lua", SearchOption.AllDirectories);
            foreach (FileInfo fi in fis)
            {
                if (fi.Extension != ".lua")
                {
                    continue;
                }
                string md5Digest = MD5Util.GetMd5HexDigest(fi);
                string subPath   = fi.DirectoryName.Replace(luaPath, string.Empty);
                string toPath    = Application.dataPath.Replace("/", "\\") + "\\Sources\\Lua" + subPath;
                string destName  = fi.Name.Replace(".lua", ".bytes");
                string dest      = toPath + "\\" + destName;

                string key = subPath + "\\" + fi.Name;
                if (md5Map.ContainsKey(key) &&
                    ( string )md5Map[key] == md5Digest &&
                    File.Exists(dest))
                {
                    continue;
                }
                md5Map[key] = md5Digest;

                if (!Directory.Exists(toPath))
                {
                    Directory.CreateDirectory(toPath);
                }

                string cmd = $"luajit -b {fi.FullName} {dest}";

                sb.AppendLine(cmd);
                sb.AppendLine("echo Compiled: " + subPath + "\\" + destName);

                //string bundlePath = subPath.Replace( "\\", "/" ) + "/";
                //assets.Add( "Assets/Sources/Lua" + bundlePath + destName );
                ////assetNames.Add( "lua" + bundlePath + fi.Name.Replace( fi.Extension, string.Empty ) );
                ////打成一个包
                //bundleNames.Add( "lua" );
            }

            string bat = luaPath + "\\Build.bat";

            File.WriteAllText(bat, sb.ToString());

            RunCmd(bat);

            AssetDatabase.Refresh();

            List <string> assets    = new List <string>();
            string        assetPath = Application.dataPath.Replace("/", "\\") + "\\Sources\\Lua";
            DirectoryInfo di2       = new DirectoryInfo(assetPath);

            DirectoryInfo[] di2S = di2.GetDirectories();
            foreach (DirectoryInfo di3 in di2S)
            {
                assets.Add("Assets/Sources/Lua/" + di3.Name);
            }

            FileInfo[] fi2S = di2.GetFiles();
            foreach (FileInfo fi2 in fi2S)
            {
                if (fi2.Extension == ".bytes")
                {
                    assets.Add("Assets/Sources/Lua/" + fi2.Name);
                }
            }

            for (int i = 0; i < assets.Count; i++)
            {
                string assetPath2 = assets[i];
                WriteAssetBundleName(assetPath2, "lua");
            }

            AssetDatabase.Refresh();

            string nv = MiniJSON.JsonEncode(md5Map);

            File.WriteAllText(v, nv);
        }
Exemplo n.º 13
0
        public static void BuildIOS()
        {
            //string luaCompilerPath = PlayerPrefs.GetString( "luac_path" );
            string luaCompilerPath = PlayerPrefs.GetString("luajit_path");
            string luaPath         = PlayerPrefs.GetString("lua_path");

            DirectoryInfo di = new DirectoryInfo(luaCompilerPath);

            if (string.IsNullOrEmpty(luaCompilerPath) || !di.Exists)
            {
                throw new Exception("Luajit path not exist.");
            }

            di = new DirectoryInfo(luaPath);
            if (string.IsNullOrEmpty(luaPath) || !di.Exists)
            {
                throw new Exception("Lua path not exist.");
            }

            //md5
            Hashtable md5Map;
            string    v = luaPath + "/ver.txt";

            if (File.Exists(v))
            {
                string vJson = File.ReadAllText(v);
                md5Map = ( Hashtable )MiniJSON.JsonDecode(vJson);
            }
            else
            {
                md5Map = new Hashtable();
            }

            FileInfo[] fis = di.GetFiles("*.lua", SearchOption.AllDirectories);
            foreach (FileInfo fi in fis)
            {
                string md5Digest = MD5Util.GetMd5HexDigest(fi);
                string subPath   = fi.DirectoryName.Replace(luaPath, string.Empty);
                string toPath    = Application.dataPath + "/Sources/Lua" + subPath;
                string destName  = fi.Name.Replace(".lua", ".bytes");
                string dest      = toPath + "/" + destName;

                string key = subPath + "/" + fi.Name;
                if (md5Map.ContainsKey(key) &&
                    ( string )md5Map[key] == md5Digest &&
                    File.Exists(dest))
                {
                    continue;
                }
                md5Map[key] = md5Digest;

                if (!Directory.Exists(toPath))
                {
                    Directory.CreateDirectory(toPath);
                }

                string text  = File.ReadAllText(fi.FullName);
                byte[] bytes = Encoding.UTF8.GetBytes(text);
                bytes = AesUtil.AesEncrypt(bytes);
                File.WriteAllBytes(dest, bytes);
            }

            AssetDatabase.Refresh();

            List <string> assets    = new List <string>();
            string        assetPath = Application.dataPath + "/Sources/Lua";
            DirectoryInfo di2       = new DirectoryInfo(assetPath);

            DirectoryInfo[] di2S = di2.GetDirectories();
            foreach (DirectoryInfo di3 in di2S)
            {
                assets.Add("Assets/Sources/Lua/" + di3.Name);
            }

            FileInfo[] fi2S = di2.GetFiles();
            foreach (FileInfo fi2 in fi2S)
            {
                if (fi2.Extension == ".bytes")
                {
                    assets.Add("Assets/Sources/Lua/" + fi2.Name);
                }
            }

            for (int i = 0; i < assets.Count; i++)
            {
                string assetPath2 = assets[i];
                WriteAssetBundleName(assetPath2, "lua");
            }

            AssetDatabase.Refresh();

            string nv = MiniJSON.JsonEncode(md5Map);

            File.WriteAllText(v, nv);
        }