public void InitVip()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("ShopPanelScript_hotfix", "InitVip"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.ShopPanelScript_hotfix", "InitVip", null, null);
            return;
        }

        int vipLevel        = VipUtil.GetVipLevel(UserData.rechargeVip);
        int currentVipToTal = VipUtil.GetCurrentVipTotal(vipLevel);

        CommonUtil.setImageSpriteByAssetBundle(VipImage, "vip.unity3d", "shop_vip_" + vipLevel);

        var vipText = string.Format("累计充值" + "<color=#FF0000FF>{0}</color>" + ",即可升级到" + "<color=#FF0000FF>{1}</color>",
                                    currentVipToTal + "元", "贵族" + (vipLevel + 1));

        if (vipLevel >= 10)
        {
            vipText = string.Format("<color=#FF0000FF>{0}</color>", "贵族等级已满");
        }
        VipExplain.text = vipText;

        SlideText.text  = UserData.rechargeVip + "/" + currentVipToTal;
        SliderVip.value = UserData.rechargeVip / (float)currentVipToTal;
    }
    private void InitMyRank()
    {
        var  Text_Ranking = MyRank.transform.Find("Text_Ranking");
        Text RankText     = Text_Ranking.GetComponent <Text>();
        var  Image_Head   = MyRank.transform.Find("Image_Head");
        var  Name         = MyRank.transform.Find("Name");
        var  Count        = MyRank.transform.Find("Count");
        var  Ranking      = MyRank.transform.Find("Ranking");
        var  Image_icon   = MyRank.transform.Find("Image_icon");
        var  Image_vip    = MyRank.transform.Find("Image_vip").GetComponent <Image>();

        CommonUtil.setImageSpriteByAssetBundle(Image_vip, "vip.unity3d", "user_vip_" + VipUtil.GetVipLevel(UserData.rechargeVip));
        Image rankImage = Ranking.GetComponent <Image>();

        Count.GetComponent <Text>().text = "" + UserData.medal;
        string s = "Sprites/Head/head_" + UserData.head;

        LogUtil.Log("head" + s);
        Image_Head.GetComponent <Image>().sprite = AssetBundlesManager.getInstance().getAssetBundlesDataByName("head.unity3d").LoadAsset <Sprite>(UserData.head);
        Name.GetComponent <Text>().text          = UserData.name;
        if (VipUtil.GetVipLevel(UserData.rechargeVip) > 0)
        {
            Name.GetComponent <Text>().color = new Color(253 / (float)255, 239 / (float)255, 82 / (float)255, 1);
        }

        CommonUtil.setImageSpriteByAssetBundle(MyRank.GetComponent <Image>(), "main.unity3d", "di7");

        Image_icon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_huizhang");

        if (string.IsNullOrEmpty(mymedalRank))
        {
            Text_Ranking.gameObject.SetActive(true);
            Ranking.gameObject.SetActive(false);
            RankText.text = "无";
        }
        else
        {
            int i = int.Parse(mymedalRank) - 1;
            if (i < 3)
            {
                Text_Ranking.gameObject.SetActive(false);
                Ranking.gameObject.SetActive(true);
                if (i == 1)
                {
                    CommonUtil.setImageSpriteByAssetBundle(rankImage, "main.unity3d", "award_2");
                }
                else if (i == 2)
                {
                    CommonUtil.setImageSpriteByAssetBundle(rankImage, "main.unity3d", "award_3");
                }
            }
            else
            {
                Text_Ranking.gameObject.SetActive(true);
                Ranking.gameObject.SetActive(false);
                RankText.text = i + 1 + "";
            }
        }
    }
        private bool AddYuanbao(Goods goods, UserInfo userInfo, int num, float price, string orderid)
        {
            string[] strings = goods.props.Split(':');
            int      propId  = Convert.ToInt32(strings[0]);
            int      propNum = Convert.ToInt32(strings[1]);

            if (propId == 2)
            {
                userInfo.YuanBao += propNum * num;
                //之前的vip等级
                int vipFirstLevel = VipUtil.GetVipLevel(userInfo.RechargeVip);

                userInfo.RechargeVip += goods.price * num;
                //充值之后的vip等级
                int vipLevel = VipUtil.GetVipLevel(userInfo.RechargeVip);
                if (NHibernateHelper.userInfoManager.Update(userInfo))
                {
                    //记录玩家财富变化日志
                    int after  = userInfo.YuanBao;
                    int change = propNum * num;
                    StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, MyCommon.YUANBAO, "人民币购买元宝", after - change, change, after);
                    var format = string.Format("花费了{0}元,购买了{1}元宝,订单号:{2}", price, propNum * num, orderid);
                    LogUtil.Log(userInfo.Uid, MyCommon.OpType.BUYYUANBAO, format);

                    var result = vipLevel - vipFirstLevel;

                    //vip等级发生
                    if (result > 0)
                    {
                        for (int i = vipFirstLevel; i < vipLevel; i++)
                        {
                            var reward = $"1:{MySqlService.VipDatas[i].vipOnce.goldNum};{MySqlService.VipDatas[i].vipOnce.prop}";

                            //发送vip一次福利
                            SendEmailUtil.SendEmail(userInfo.Uid, $"贵族一次性福利", $"恭喜您升级到贵族{i + 1}", reward);

                            var temp = string.Format($"恭喜你升级到Vip{i + 1},发送邮件奖励:{reward}");
                            LogUtil.Log(userInfo.Uid, MyCommon.OpType.VIP_ONCE_REWARD, temp);
                        }

                        var level1 = GetLevel(vipFirstLevel);
                        var level2 = GetLevel(vipLevel);

                        userInfo.freeCount += level2 - level1;
                        MySqlService.log.Info($"{userInfo.Uid} vip等级变化:{result},加了转盘次数:{level2 - level1}");
                        NHibernateHelper.userInfoManager.Update(userInfo);
                    }
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("MyUIScript_hotfix", "Start"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.MyUIScript_hotfix", "Start", null, null);
            return;
        }

        int vipLevel = VipUtil.GetVipLevel(UserData.rechargeVip);

        CommonUtil.setImageSpriteByAssetBundle(m_imageZhuanVipLevel, "vip.unity3d", "user_vip_" + vipLevel);
    }
예제 #5
0
        //每天更新转盘次数
        private static void UpdateTurnTableCount()
        {
            string sql = "update user_info set huizhangCount = '3' ,freeCount = '0'";

            using (var session = NHibernateHelper.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    try
                    {
                        session.CreateSQLQuery(sql).ExecuteUpdate();
                        transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        transaction.Rollback();
                    }
                }
            }

            List <UserInfo> userInfos = NHibernateHelper.userInfoManager.GetAll().ToList();

            //vip要特殊处理
            foreach (var userinfo in userInfos)
            {
                int level = VipUtil.GetVipLevel(userinfo.RechargeVip);

                if (level < 3)
                {
                    userinfo.freeCount = 0;
                }
                else if (level <= 5)
                {
                    userinfo.freeCount = 1;
                    NHibernateHelper.userInfoManager.Update(userinfo);
                }
                else if (level <= 8)
                {
                    userinfo.freeCount = 2;
                    NHibernateHelper.userInfoManager.Update(userinfo);
                }
                else if (level <= 10)
                {
                    userinfo.freeCount = 3;
                    NHibernateHelper.userInfoManager.Update(userinfo);
                }
            }
        }
    public override void OnResponse(string data)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("GetUserInfoRequest_hotfix", "OnResponse"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.GetUserInfoRequest_hotfix", "OnResponse", null, data);
            return;
        }

        JsonData jsonData = JsonMapper.ToObject(data);
        var      code     = (int)jsonData["code"];

        if (code == (int)Consts.Code.Code_OK)
        {
            try
            {
                UserData.name           = (string)jsonData["name"];
                UserData.phone          = (string)jsonData["phone"];
                UserData.myTuiGuangCode = (string)jsonData["myTuiGuangCode"];
                //UserData.head = "Sprites/Head/head_" + jsonData["head"];
                UserData.head           = "head_" + jsonData["head"];
                UserData.gold           = (int)jsonData["gold"];
                UserData.yuanbao        = (int)jsonData["yuanbao"];
                UserData.medal          = (int)jsonData["medal"];
                UserData.IsRealName     = (bool)jsonData["isRealName"];
                UserData.isSetSecondPsw = (bool)jsonData["isSetSecondPsw"];
                //UserData.isOldPlayerBind = (bool)jsonData["isOldPlayerBind"];
                UserData.rechargeVip     = (int)jsonData["recharge_vip"];
                UserData.vipLevel        = VipUtil.GetVipLevel(UserData.rechargeVip);
                UserData.gameData        = JsonMapper.ToObject <UserGameData>(jsonData["gameData"].ToString());
                UserData.buffData        = JsonMapper.ToObject <List <BuffData> >(jsonData["BuffData"].ToString());
                UserData.userRecharge    = JsonMapper.ToObject <List <UserRecharge> >(jsonData["userRecharge"].ToString());
                UserData.myTurntableData = JsonMapper.ToObject <MyTurntableData>(jsonData["turntableData"].ToString());
                OtherData.s_hasShouChong = (bool)jsonData["hasShouChong"];
            }
            catch (Exception e)
            {
                LogUtil.Log("解析用户信息json失败:" + e);
            }
            result = data;
            flag   = true;
        }
        else
        {
            LogUtil.Log("用户信息数据错误:" + code);
        }
    }
예제 #7
0
        /// <summary>
        /// 每周发放vip奖励
        /// </summary>
        private static void SendVipWeeklyReWard()
        {
            StreamReader sr  = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "VipRewardData.json");
            string       str = sr.ReadToEnd();

            sr.Close();
            List <VipData> vipDatas = JsonConvert.DeserializeObject <List <VipData> >(str);

            List <UserInfo> userInfos = NHibernateHelper.userInfoManager.GetAll().ToList();

            foreach (var userInfo in userInfos)
            {
                int vipLevel = VipUtil.GetVipLevel(userInfo.RechargeVip);
                if (vipLevel > 0)
                {
                    VipData vipData = vipDatas[vipLevel - 1];
                    var     reward  = $"1:{vipData.vipWeekly.goldNum};107:{vipData.vipWeekly.diamondNum}";
                    var     sql     = $"INSERT INTO user_email (uid, title, content,reward,state)" +
                                      $" VALUES ('{userInfo.Uid}', 'vip每周奖励','vip每周奖励','{reward}','0')";

                    using (var session = NHibernateHelper.OpenSession())
                    {
                        using (var transaction = session.BeginTransaction())
                        {
                            try
                            {
                                session.CreateSQLQuery(sql).ExecuteUpdate();
                                transaction.Commit();
                            }
                            catch (Exception e)
                            {
                                transaction.Rollback();
                            }
                        }
                    }
                }
            }
        }
예제 #8
0
        //数据库操作成功
        private void OperatorSuccess(UserInfo userInfo, UserGame userGame, UserInfo_Game userInfo_Game)
        {
            userInfo_Game.code = (int)Consts.Code.Code_OK;
            userInfo_Game.name = userInfo.NickName;

            var vipLevel = VipUtil.GetVipLevel(userInfo.RechargeVip);

            userInfo_Game.vipLevel = vipLevel;
            userInfo_Game.gold     = userInfo.Gold;
            userInfo_Game.head     = userInfo.Head;
            userInfo_Game.gameData = new UserInfo_Game.Gamedata();
            userInfo_Game.gameData.allGameCount = userGame.AllGameCount;
            userInfo_Game.gameData.winCount     = userGame.WinCount;
            userInfo_Game.gameData.runCount     = userGame.RunCount;
            userInfo_Game.gameData.meiliZhi     = userGame.MeiliZhi;

            //用户buff
            List <UserInfo_Game.UserBuff> userBuffJsonObjects = new List <UserInfo_Game.UserBuff>();
            List <UserProp> userProps = NHibernateHelper.userPropManager.GetListByUid(userInfo.Uid);

            if (userProps != null)
            {
                for (int i = 0; i < userProps.Count; i++)
                {
                    if (userProps[i].BuffNum > 0)
                    {
                        UserInfo_Game.UserBuff userBuffJsonObject = new UserInfo_Game.UserBuff()
                        {
                            prop_id  = userProps[i].PropId,
                            buff_num = userProps[i].BuffNum
                        };
                        userBuffJsonObjects.Add(userBuffJsonObject);
                    }
                }
            }
            userInfo_Game.BuffData = userBuffJsonObjects;
        }
예제 #9
0
        private void MedalExchange(string uid, int goodsId, int num, JObject responseData)
        {
            try
            {
                MedalExchargeRewardData exchargeRewardData = null;
                foreach (var medalExchargeRewardData in MySqlService.medalExchargeRewardDatas)
                {
                    if (medalExchargeRewardData.goods_id == goodsId)
                    {
                        exchargeRewardData = medalExchargeRewardData;
                        break;
                    }
                }

                if (exchargeRewardData == null)
                {
                    OperatorFail(responseData, "goodsId:" + goodsId);
                    return;
                }

                int      cost     = exchargeRewardData.price * num;
                UserInfo userInfo = MySqlManager <UserInfo> .Instance.GetByUid(uid);

                if (userInfo.Medel < cost)
                {
                    OperatorFail(responseData, "徽章不足");
                }
                else
                {
                    //徽章限额

                    List <UserExchange> medalLimitMonth = MySqlManager <UserExchange> .Instance.GetMedalLimitMonth(uid);

                    int total = 0;
                    foreach (var exchange in medalLimitMonth)
                    {
                        total += exchange.medal_cost;
                    }

                    if (total >= 300)
                    {
                        OperatorFail(responseData, $"当月已达限额300,已花费{total}");
                        return;
                    }

                    UserInfo info = MySqlManager <UserInfo> .Instance.GetByUid(uid);

                    int vipLevel = VipUtil.GetVipLevel(info.RechargeVip);

                    if (vipLevel < exchargeRewardData.vipLevel)
                    {
                        OperatorFail(responseData, "贵族等级不足");
                        return;
                    }

                    string reward = $"110:{-cost}";

                    string curYearMonth = CommonUtil.getCurYearMonth();

                    string day = curYearMonth + "/" + DateTime.Now.Day;

                    List <JDCard> tenJDCard = MySqlManager <JDCard> .Instance.GetByPorperty("price", "10", "state", "0");

                    List <JDCard> twentyJDCard = MySqlManager <JDCard> .Instance.GetByPorperty("price", "20", "state", "0");

                    //判断是否兑换京东卡
                    if (exchargeRewardData.goods_id == 4)
                    {
                        if (tenJDCard.Count == 0)
                        {
                            OperatorFail(responseData, "10元京东卡数量不足");
                            return;
                        }
                    }

                    if (exchargeRewardData.goods_id == 5)
                    {
                        if (twentyJDCard.Count == 0)
                        {
                            OperatorFail(responseData, "20元京东卡数量不足");
                            return;
                        }
                    }

                    if (MySqlManager <UserExchange> .Instance.Add(new UserExchange()
                    {
                        Uid = uid,
                        goods_id = goodsId,
                        num = num,
                        day = day,
                        medal_cost = cost,
                        create_time = DateTime.Now
                    }))
                    {
                        for (int i = 0; i < num; i++)
                        {
                            MySqlUtil.AddProp(uid, exchargeRewardData.reward_prop, "徽章兑换话费");
                        }

                        if (MySqlUtil.AddProp(uid, reward, "徽章兑换话费"))
                        {
                            responseData.Add("reward", exchargeRewardData.reward_prop);
                            OperatorSuccess(responseData, "兑换成功");

                            switch (exchargeRewardData.goods_id)
                            {
                            case 4:
                                tenJDCard[0].state = 1 + "";
                                tenJDCard[0].Uid   = uid;
                                MySqlManager <JDCard> .Instance.Update(tenJDCard[0]);

                                break;

                            case 5:
                                twentyJDCard[0].state = 1 + "";
                                twentyJDCard[0].Uid   = uid;
                                MySqlManager <JDCard> .Instance.Update(twentyJDCard[0]);

                                break;
                            }
                        }
                        else
                        {
                            OperatorFail(responseData, "该道具已兑换,当天只能兑换一次");
                        }
                    }
                    else
                    {
                        OperatorFail(responseData, "该道具已兑换,当天只能兑换一次");
                    }
                }
            }
            catch (Exception e)
            {
                OperatorFail(responseData, "goodsId:" + goodsId);
                MySqlService.log.Warn(e);
            }
        }
    public void InitUI()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("UserInfoScript_hotfix", "InitUI"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.UserInfoScript_hotfix", "InitUI", null, null);
            return;
        }

        nickName.text     = UserData.name;
        account.text      = UserData.uid;
        gold.text         = UserData.gold.ToString();
        yuanBaoCount.text = UserData.yuanbao.ToString();
        meiLiZhi.text     = UserData.gameData.meiliZhi + "";
        int vipLevel = VipUtil.GetVipLevel(UserData.rechargeVip);

        CommonUtil.setImageSpriteByAssetBundle(Vip, "vip.unity3d", "user_vip_" + vipLevel);
        if (UserData.IsRealName)
        {
            ButtonRealName.interactable         = false;
            ButtonRealName.transform.localScale = Vector3.zero;
            AlReadyRN.transform.localScale      = Vector3.one;
        }
        else
        {
            ButtonRealName.interactable         = true;
            ButtonRealName.transform.localScale = Vector3.one;
            AlReadyRN.transform.localScale      = Vector3.zero;
        }

        if (string.IsNullOrEmpty(UserData.phone))
        {
            ButtonBindPhone.interactable           = true;
            ButtonBindPhone.transform.localScale   = Vector3.one;
            ButtonChangePhone.transform.localScale = Vector3.zero;
        }
        else
        {
            ButtonBindPhone.interactable           = false;
            ButtonBindPhone.transform.localScale   = Vector3.zero;
            ButtonChangePhone.transform.localScale = Vector3.one;
        }


        headIcon.GetComponent <HeadIconScript>().setIcon(UserData.head);

        if (UserData.gameData.allGameCount == 0)
        {
            shengLv.text  = "0%";
            allGame.text  = "0";
            taoPaoLv.text = "0%";
        }
        else
        {
            //默认为保留两位
            shengLv.text  = String.Format("{0:F}", (UserData.gameData.winCount / (float)UserData.gameData.allGameCount) * 100) + "%";
            allGame.text  = UserData.gameData.allGameCount + "";
            taoPaoLv.text = String.Format("{0:F}", (UserData.gameData.runCount / (float)UserData.gameData.allGameCount) * 100) + "%";;
        }

        headIcon.GetComponent <HeadIconScript>().setIcon(UserData.head);
    }
        private void TotalSign(string uid, Sign30DataContent dataContent, JObject responseData)
        {
            List <UserMonthSign> userMonthSigns = GetSign30RecordHandler.GetSign30RecordSql(uid);
            int        dataContentDay           = dataContent.day;
            List <int> list = new List <int>();

            for (int i = userMonthSigns.Count - 1; i >= 0; i--)
            {
                if (userMonthSigns[i].Type == 3)
                {
                    userMonthSigns.RemoveAt(i);
                }
            }

            foreach (var userSign in userMonthSigns)
            {
                list.Add(int.Parse(userSign.SignDate));
            }

            int lianXuSignDays = CommonUtil.GetLianXuSignDays(list);

            //全勤奖
            if (dataContent.id == 35)
            {
                if (lianXuSignDays == DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month))
                {
                    UserInfo userInfo = MySqlManager <UserInfo> .Instance.GetByUid(uid);

                    List <Log_Game> gameCountByMonth = MySqlManager <UserGame> .Instance.GetGameCountByMonth(uid);


                    int vipLevel = VipUtil.GetVipLevel(userInfo.RechargeVip);

                    if (vipLevel < 1 || gameCountByMonth.Count < 30)
                    {
                        responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                        responseData.Add("msg", $"每月游戏对局数满30局且贵族等级为V1方可领取");
                        return;
                    }

                    UserMonthSign userMonthSign = new UserMonthSign()
                    {
                        Uid           = uid,
                        SignYearMonth = GetSign30RecordHandler.GetYearMonth(),
                        SignDate      = DateTime.Now.Day + ":" + dataContent.id + "",
                        Type          = 3
                    };

                    MySqlService.log.Info($"```````````{JsonConvert.SerializeObject(userMonthSign)}");

                    if (MySqlManager <UserMonthSign> .Instance.Add(userMonthSign))
                    {
                        responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
                        responseData.Add("msg", $"{dataContent.reward_name}领取成功");
                        responseData.Add("reward_prop", dataContent.reward_prop);
                        AddSignReward(uid, dataContent.reward_prop);
                    }
                    else
                    {
                        responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                        responseData.Add("msg", $"{dataContent.reward_name}的奖励已领取,不可重复领取");
                    }
                    return;
                }
            }


            //连续签到大于需要的天数
//            if (lianXuSignDays >= dataContent.day)
//            {
//                UserMonthSign userMonthSign = new UserMonthSign()
//                {
//                    Uid = uid,
//                    SignYearMonth = GetSign30RecordHandler.GetYearMonth(),
//                    SignDate = DateTime.Now.Day +":"+ dataContent.id + "",
//                    Type = 3
//                };
//
//                MySqlService.log.Info($"```````````{JsonConvert.SerializeObject(userMonthSign)}");
//
//                if (MySqlManager<UserMonthSign>.Instance.Add(userMonthSign))
//                {
//                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
//                    responseData.Add("msg", $"{dataContent.reward_name}领取成功");
//                    responseData.Add("reward_prop", dataContent.reward_prop);
//                    AddSignReward(uid, dataContent.reward_prop);
//                }
//                else
//                {
//                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
//                    responseData.Add("msg", $"{dataContent.reward_name}的奖励已领取,不可重复领取");
//                }
//            }
//            else
//            {
//                responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
//                responseData.Add("msg", $"未满足{dataContent.reward_name},当前签到累计{userMonthSigns.Count}");
//            }


            //不可重复领取
            if (userMonthSigns.Count >= dataContentDay)
            {
                UserMonthSign userMonthSign = new UserMonthSign()
                {
                    Uid           = uid,
                    SignYearMonth = GetSign30RecordHandler.GetYearMonth(),
                    SignDate      = dataContent.id + "",
                    Type          = 3
                };

                if (MySqlManager <UserMonthSign> .Instance.Add(userMonthSign))
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
                    responseData.Add("msg", $"{dataContent.reward_name}领取成功");
                    responseData.Add("reward_prop", dataContent.reward_prop);
                    AddSignReward(uid, dataContent.reward_prop);
                }
                else
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                    responseData.Add("msg", $"{dataContent.reward_name}的奖励已领取,不可重复领取");
                }
            }
            else
            {
                responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                responseData.Add("msg", $"未满足{dataContent.reward_name},当前签到累计{userMonthSigns.Count}");
            }
        }
    public void InitUI()
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("RankListJifenScript_hotfix", "InitUI"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.RankListJifenScript_hotfix", "InitUI", null, null);
            return;
        }

        RectTransform ContentRect       = Content.GetComponent <RectTransform>();
        RectTransform ItemRect          = Item.GetComponent <RectTransform>();
        Vector2       itemRectSizeDelta = ItemRect.sizeDelta;

        //自己是否上榜
        for (int i = 0; i < _GoldRankList.Count; i++)
        {
            if (_GoldRankList[i].name.Equals(UserData.name))
            {
                myGoldRank = i + 1 + "";
            }
        }

        float f;

        if (string.IsNullOrEmpty(myGoldRank))
        {
            f = itemRectSizeDelta.y * _GoldRankList.Count;
        }
        else
        {
            LogUtil.Log("----1");
            f = itemRectSizeDelta.y * (_GoldRankList.Count - 1);
        }
        ContentRect.sizeDelta = new Vector2(0, f);


        for (int i = 0; i < _GoldRankList.Count; i++)
        {
            GoldRankItemData goldRankItemData = _GoldRankList[i];

            if (goldRankItemData.name.Equals(UserData.name))
            {
                continue;
            }

            GameObject goChild = GameObject.Instantiate(Item, Content.transform);

            if (goldRankItemData.name.Equals(UserData.name))
            {
                myGoldRank = i + 1 + "";
//                goChild.GetComponent<Image>().color = new Color(255 / (float)255, 255 / (float)255, 0 / (float)255, 1);
                CommonUtil.setImageSpriteByAssetBundle(goChild.GetComponent <Image>(), "main.unity3d", "di7");
            }

            goChild.layer = Content.layer;
            var  Text_Ranking = goChild.transform.Find("Text_Ranking");
            Text RankText     = Text_Ranking.GetComponent <Text>();
            var  Image_Head   = goChild.transform.Find("Image_Head");
            var  Name         = goChild.transform.Find("Name");
            var  Count        = goChild.transform.Find("Count");
            var  Ranking      = goChild.transform.Find("Ranking");
            var  Image_icon   = goChild.transform.Find("Image_icon");
            var  Image_vip    = goChild.transform.Find("Image_vip").GetComponent <Image>();
            CommonUtil.setImageSpriteByAssetBundle(Image_vip, "vip.unity3d", "user_vip_" + VipUtil.GetVipLevel(goldRankItemData.recharge));
            Image rankImage = Ranking.GetComponent <Image>();

            Count.GetComponent <Text>().text = "" + goldRankItemData.gold;
            //Image_Head.GetComponent<Image>().sprite = Resources.Load<Sprite>("Sprites/Head/head_" + goldRankItemData.head);
            goChild.GetComponent <HeadIconScript>().setIcon("head_" + goldRankItemData.head);
            Name.GetComponent <Text>().text = goldRankItemData.name;
            if (VipUtil.GetVipLevel(goldRankItemData.recharge) > 0)
            {
                Name.GetComponent <Text>().color = new Color(253 / (float)255, 239 / (float)255, 82 / (float)255, 1);
            }
            //GameUtil.setNickNameFontColor(Name.GetComponent<Text>(), VipUtil.GetVipLevel(goldRankItemData.recharge));

            Image_icon.GetComponent <Image>().sprite = Resources.Load <Sprite>("Sprites/Icon/Prop/icon_jinbi");

            if (i < 3)
            {
                Text_Ranking.gameObject.SetActive(false);
                Ranking.gameObject.SetActive(true);
                if (i == 1)
                {
                    CommonUtil.setImageSpriteByAssetBundle(rankImage, "main.unity3d", "award_2");
                }
                else if (i == 2)
                {
                    CommonUtil.setImageSpriteByAssetBundle(rankImage, "main.unity3d", "award_3");
                }
            }
            else
            {
                Text_Ranking.gameObject.SetActive(true);
                Ranking.gameObject.SetActive(false);
                RankText.text = i + 1 + "";
            }
        }

        if (string.IsNullOrEmpty(myGoldRank))
        {
            LogUtil.Log("未上榜");
            JifenRank.text = "我的排名:未上榜";
        }
        else
        {
            JifenRank.text = "我的排名:" + myGoldRank;
        }

        JifenCount.text = "我的金币:" + UserData.gold;

        InitMyRank();
    }
예제 #13
0
    // Use this for initialization
    void Start()
    {
        OtherData.s_vipPanelScript = this;

        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("VipPanelScript_hotfix", "Start"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.VipPanelScript_hotfix", "Start", null, null);
            return;
        }

        InitVip();
        if (vipDatas == null || vipDatas.Count == 0)
        {
            ToastScript.createToast("贵族奖励配置表返回失败");
            return;
        }

        int childCount = VipWeekOnce.transform.childCount;

        LogUtil.Log(childCount);

        for (int j = 0; j < childCount; j++)
        {
            Transform child = VipWeekOnce.transform.GetChild(j);
            VipWeekOnceChild.Add(child.gameObject);
        }


        for (int i = 0; i < 10; i++)
        {
            VipData vipData = vipDatas[i];
            var     VipTab  = Content.transform.GetChild(i).gameObject;
            VipTab.transform.Find("Text").GetComponent <Text>().text = "贵族" + (i + 1);
            VipTab.transform.Find("Text").GetComponent <Text>().font = Resources.Load <Font>("Fonts/STXINWEI");

            var toggle = VipTab.GetComponent <Toggle>();


            var i2 = i;
            toggle.onValueChanged.AddListener(delegate(bool isOn)
            {
                var h = i2;
                if (isOn)
                {
                    CommonUtil.setImageSpriteByAssetBundle(VipImage2, "vip.unity3d", "user_vip_" + vipData.vipLevel);
                    if (vipData.medalNum > 0)
                    {
                        VipText2.gameObject.SetActive(true);
                    }
                    else
                    {
                        VipText2.gameObject.SetActive(false);
                    }

                    if (vipData.turnTableCount > 0)
                    {
                        VipText3.gameObject.SetActive(true);
                    }
                    else
                    {
                        VipText3.gameObject.SetActive(false);
                    }


                    string temp   = string.Format(@"比赛场第一名额外        *{0}", vipData.medalNum);
                    VipText2.text = temp;
                    string temp2  = string.Format(@",每日转盘免费次数加{0}", vipData.turnTableCount);
                    VipText3.text = temp2;

                    VipWeekOnceChild[0].transform.GetChild(0).GetComponent <Text>().text = "*" + vipData.vipOnce.goldNum;
                    string[] props = vipData.vipOnce.prop.Split(';');
                    foreach (var child in VipWeekOnceChild)
                    {
                        child.SetActive(false);
                    }

                    for (int j = 0; j <= props.Length; j++)
                    {
                        VipWeekOnceChild[j].SetActive(true);
                    }


                    //处理ui居中
                    if (h <= 2)
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            Vector3 current = VipWeekOnceChild[j].transform.localPosition;
                            VipWeekOnceChild[j].transform.localPosition = new Vector3(current.x, -39f, current.z);
                        }
                    }
                    else
                    {
                        for (int j = 0; j < 2; j++)
                        {
                            Vector3 current = VipWeekOnceChild[j].transform.localPosition;
                            VipWeekOnceChild[j].transform.localPosition = new Vector3(current.x, -12.5f, current.z);
                        }
                    }
                    if (h == 0)
                    {
                        VipText.transform.localPosition = new Vector3(0, 1.7f, 0);
                    }
                    else
                    {
                        VipText.transform.localPosition = new Vector3(0, 31.5f, 0);
                    }

                    if (h >= 3 && h <= 6)
                    {
                        Vector3 current = VipWeekOnceChild[2].transform.localPosition;
                        VipWeekOnceChild[2].transform.localPosition = new Vector3(0f, current.y, current.z);
                    }
                    else
                    {
                        Vector3 current = VipWeekOnceChild[2].transform.localPosition;
                        VipWeekOnceChild[2].transform.localPosition = new Vector3(-104.2f, current.y, current.z);
                    }

                    for (int j = 0; j < props.Length; j++)
                    {
                        var prop         = props[j];
                        GameObject go    = VipWeekOnceChild[j + 1];
                        Image propImage  = go.GetComponent <Image>();
                        Text propNum     = go.transform.GetChild(0).GetComponent <Text>();
                        string[] strings = prop.Split(':');
                        int propId       = Convert.ToInt32(strings[0]);
                        propNum.text     = "*" + strings[1];
                        CommonUtil.setImageSprite(propImage, GameUtil.getPropIconPath(propId));
                    }

                    //设置会员每周领取奖励
                    WeeklyGoldNumText.text    = "*" + vipData.vipWeekly.goldNum;
                    WeeklyDiamondNumText.text = "*" + vipData.vipWeekly.diamondNum;
                }
            });

            if (i == VipUtil.GetVipLevel(UserData.rechargeVip) - 1)
            {
                toggle.isOn = true;
            }
            else
            {
                toggle.isOn = false;
            }

            if (VipUtil.GetVipLevel(UserData.rechargeVip) == 0)
            {
                if (i == 0)
                {
                    toggle.isOn = true;
                }
            }
        }
    }