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

        // 请求签到
        {
            Sign30DataContent temp = Sign30Data.getInstance().getSign30DataById(m_curChoiceId);

            if (temp.type == 1)
            {
                // 补签
                if (temp.day < CommonUtil.getCurDay())
                {
                    // 显示补签确认界面
                    BuQianQueRenPanelScript.create();

                    return;
                }
            }
        }

        reqSign(m_curChoiceId);
    }
Exemplo n.º 2
0
    public Sign30DataContent getSign30DataById(int id)
    {
        Sign30DataContent data = null;

        for (int i = 0; i < m_sign30DataContentList.Count; i++)
        {
            if (m_sign30DataContentList[i].id == id)
            {
                data = m_sign30DataContentList[i];
                break;
            }
        }

        return(data);
    }
Exemplo n.º 3
0
    public Sign30DataContent getSign30DataContent(int day, int type)
    {
        Sign30DataContent data = null;

        for (int i = 0; i < m_sign30DataContentList.Count; i++)
        {
            if ((m_sign30DataContentList[i].day == day) && (m_sign30DataContentList[i].type == type))
            {
                data = m_sign30DataContentList[i];
                break;
            }
        }

        return(data);
    }
        private void Sign(string uid, Sign30DataContent dataContent, JObject responseData)
        {
            int dataContentDay = dataContent.day;
            int nowYear        = DateTime.Now.Year;
            int nowMonth       = DateTime.Now.Month;
            int nowDay         = DateTime.Now.Day;

            string signYearMonth = $"{nowYear}-{nowMonth}";

            if (dataContentDay != nowDay)
            {
                OperatorFail(responseData, $"不是当天签到:{dataContentDay}");
                return;
            }

            UserMonthSign userMonthSign = MySqlManager <UserMonthSign> .Instance.GetUserMonthSign(uid, signYearMonth, dataContentDay + "");

            if (userMonthSign == null)
            {
                userMonthSign = new UserMonthSign()
                {
                    Uid           = uid,
                    SignDate      = dataContentDay + "",
                    SignYearMonth = signYearMonth,
                    Type          = 1
                };

                if (MySqlManager <UserMonthSign> .Instance.Add(userMonthSign))
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
                    responseData.Add("reward_prop", dataContent.reward_prop);
                    responseData.Add("msg", "签到成功");
                    AddSignReward(uid, dataContent.reward_prop);
                }
                else
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                    responseData.Add("msg", "已签到");
                }
            }
            else
            {
                responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                responseData.Add("msg", "已签到");
            }
        }
Exemplo n.º 5
0
    public void initJson(string json)
    {
        m_sign30DataContentList.Clear();

        JArray list = (JArray)JsonConvert.DeserializeObject(json);

        for (int i = 0; i < list.Count; i++)
        {
            Sign30DataContent temp = new Sign30DataContent();

            temp.id          = (int)list[i]["id"];
            temp.type        = (int)list[i]["type"];
            temp.day         = (int)list[i]["day"];
            temp.reward_name = (string)list[i]["reward_name"];
            temp.reward_prop = (string)list[i]["reward_prop"];

            m_sign30DataContentList.Add(temp);
        }
    }
        /// <summary>
        /// 查询签到数据库
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="id"></param>
        /// <param name="signType">1:签到,2:补签</param>
        /// <param name="responseData"></param>
        private void Sign30Sql(string uid, int id, int signType, JObject responseData)
        {
            Sign30DataContent dataContent = Sign30Data.getInstance().getSign30DataById(id);

            switch (signType)
            {
            case 1:
                Sign(uid, dataContent, responseData);
                break;

            case 2:
                AddSign(uid, dataContent, responseData);
                break;

            case 3:
                TotalSign(uid, dataContent, responseData);
                break;
            }
        }
    public void reqSign(int id)
    {
        // 优先使用热更新的代码
        if (ILRuntimeUtil.getInstance().checkDllClassHasFunc("Sign30PanelScript_hotfix", "reqSign"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.Sign30PanelScript_hotfix", "reqSign", null, id);
            return;
        }

        NetLoading.getInstance().Show();

        // 请求签到
        {
            LogicEnginerScript.Instance.GetComponent <Sign30Request>().CallBack = onReceive_Sign30;

            Sign30DataContent temp = Sign30Data.getInstance().getSign30DataById(id);

            LogicEnginerScript.Instance.GetComponent <Sign30Request>().m_id = temp.id;

            // 签到、补签
            if (temp.type == 1)
            {
                // 正常签到
                if (temp.day == CommonUtil.getCurDay())
                {
                    LogicEnginerScript.Instance.GetComponent <Sign30Request>().m_type = 1;
                }
                // 补签
                else if (temp.day < CommonUtil.getCurDay())
                {
                    LogicEnginerScript.Instance.GetComponent <Sign30Request>().m_type = 2;
                }
            }
            // 累计签到奖励
            else if (temp.type == 2)
            {
                LogicEnginerScript.Instance.GetComponent <Sign30Request>().m_type = 3;
            }

            LogicEnginerScript.Instance.GetComponent <Sign30Request>().OnRequest();
        }
    }
    // Use this for initialization
    void Start()
    {
        OtherData.s_sign30LeiJiPanelScript = this;

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

        if (Sign30Data.getInstance().getSign30DataContentList().Count == 0)
        {
            Debug.Log("签到奖励配置表未赋值");
            return;
        }

        Sign30DataContent temp = Sign30Data.getInstance().getSign30DataById(m_id);

        // 全勤奖
        if (temp.day == CommonUtil.getCurMonthAllDays())
        {
            m_text_title.text = ("累计签到" + CommonUtil.getCurMonthAllDays().ToString() + "天");
            gameObject.transform.Find("Image_bg/Text_quanqin_tip").localScale = new Vector3(1, 1, 1);
        }
        else
        {
            m_text_title.text = ("累计签到" + temp.day.ToString() + "天");
        }

        // 领取奖励按钮状态
        {
            int signAllDays = Sign30RecordData.getInstance().getSign30RecordList().Count;

            if (m_id == 35)
            {
                // 达成
                if (signAllDays == CommonUtil.getCurMonthAllDays())
                {
                    bool isGet = Sign30RecordData.getInstance().isLeiJiSignTheDay(m_id);

                    // 达成已领取
                    if (isGet)
                    {
                        CommonUtil.setButtonEnable(m_btn_lingqujiangli, false);
                        CommonUtil.setImageSprite(m_btn_lingqujiangli.transform.Find("Image").GetComponent <Image>(), "Sprites/Sign30/wz_yilingqu");
                        m_btn_lingqujiangli.transform.Find("Image").GetComponent <Image>().SetNativeSize();
                    }
                    // 达成未领取
                    else
                    {
                        CommonUtil.setButtonEnable(m_btn_lingqujiangli, true);
                    }
                }
                // 未达成
                else
                {
                    CommonUtil.setButtonEnable(m_btn_lingqujiangli, false);
                }
            }
            else
            {
                // 达成
                if (signAllDays >= Sign30Data.getInstance().getSign30DataContentList()[m_id - 1].day)
                {
                    bool isGet = Sign30RecordData.getInstance().isLeiJiSignTheDay(m_id);

                    // 达成已领取
                    if (isGet)
                    {
                        CommonUtil.setButtonEnable(m_btn_lingqujiangli, false);
                        CommonUtil.setImageSprite(m_btn_lingqujiangli.transform.Find("Image").GetComponent <Image>(), "Sprites/Sign30/wz_yilingqu");
                        m_btn_lingqujiangli.transform.Find("Image").GetComponent <Image>().SetNativeSize();
                    }
                    // 达成未领取
                    else
                    {
                        CommonUtil.setButtonEnable(m_btn_lingqujiangli, true);
                    }
                }
                // 未达成
                else
                {
                    CommonUtil.setButtonEnable(m_btn_lingqujiangli, false);
                }
            }
        }

        // 奖励
        {
            List <string> list1 = new List <string>();
            CommonUtil.splitStr(temp.reward_prop, list1, ';');

            for (int i = 0; i < list1.Count; i++)
            {
                List <string> list2 = new List <string>();
                CommonUtil.splitStr(list1[i], list2, ':');

                int prop_id  = int.Parse(list2[0]);
                int prop_num = int.Parse(list2[1]);

                GameObject obj = transform.Find("Image_bg/Reward_" + (i + 1).ToString()).gameObject;
                obj.transform.localScale = new Vector3(1, 1, 1);
                CommonUtil.setImageSprite(obj.transform.Find("Image").GetComponent <Image>(), GameUtil.getPropIconPath(prop_id));
                obj.transform.Find("Text").GetComponent <Text>().text = prop_num.ToString();

                obj.transform.localPosition = new Vector3(CommonUtil.getPosX(list1.Count, 130, i, 0), 0, 0);
            }
        }
    }
        private void AddSign(string uid, Sign30DataContent dataContent, JObject responseData)
        {
            int dataContentDay = dataContent.day;
            int nowYear        = DateTime.Now.Year;
            int nowMonth       = DateTime.Now.Month;
            int nowDay         = DateTime.Now.Day;

            string signYearMonth = $"{nowYear}-{nowMonth}";

            if (dataContentDay >= nowDay)
            {
                OperatorFail(responseData, $"当天不能补签:{dataContentDay}");
                return;
            }
            List <UserMonthSign> userMonthSigns = GetSign30RecordHandler.GetSign30RecordSql(uid);
            List <UserMonthSign> userAddSigns   = new List <UserMonthSign>();

            foreach (var userSigns in userMonthSigns)
            {
                if (userSigns.Type == 2)
                {
                    userAddSigns.Add(userSigns);
                }
            }

            int cost = (userAddSigns.Count / 3 + 1) * 5000;
//            int cost = 2000;
            UserInfo userInfo = MySqlManager <UserInfo> .Instance.GetByUid(uid);

            if (userInfo.Gold >= cost)
            {
                userInfo.Gold -= cost;
                MySqlManager <UserInfo> .Instance.Update(userInfo);
            }
            else
            {
                OperatorFail(responseData, $"补签金币不足");
                return;
            }
            UserMonthSign userMonthSign = MySqlManager <UserMonthSign> .Instance.GetUserMonthSign(uid, signYearMonth, dataContentDay + "");

            if (userMonthSign == null)
            {
                userMonthSign = new UserMonthSign()
                {
                    Uid           = uid,
                    SignDate      = dataContentDay + "",
                    SignYearMonth = signYearMonth,
                    Type          = 2
                };

                if (MySqlManager <UserMonthSign> .Instance.Add(userMonthSign))
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
                    responseData.Add("reward_prop", dataContent.reward_prop);
                    responseData.Add("msg", "补签成功");
                    AddSignReward(uid, dataContent.reward_prop);
                }
                else
                {
                    responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                    responseData.Add("msg", "已补签");
                }
            }
            else
            {
                responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_CommonFail);
                responseData.Add("msg", "已补签");
            }
        }
Exemplo n.º 10
0
        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("Sign30PanelScript_hotfix", "initUI"))
        {
            ILRuntimeUtil.getInstance().getAppDomain().Invoke("HotFix_Project.Sign30PanelScript_hotfix", "initUI", null, null);
            return;
        }

        // 年月
        m_text_time.text = CommonUtil.getCurYear() + "年" + CommonUtil.getCurMonth() + "月";

        // 本月天数
        m_curMonthdays = CommonUtil.getCurMonthAllDays();

        // 显示当天签到奖励
        {
            int day = CommonUtil.getCurDay();

            for (int i = 0; i < Sign30Data.getInstance().getSign30DataContentList().Count; i++)
            {
                if (Sign30Data.getInstance().getSign30DataContentList()[i].type == 1)
                {
                    if (Sign30Data.getInstance().getSign30DataContentList()[i].day == day)
                    {
                        m_curChoiceId = Sign30Data.getInstance().getSign30DataContentList()[i].id;
                        showCurDayReward(Sign30Data.getInstance().getSign30DataContentList()[i].reward_prop);
                        break;
                    }
                }
            }
        }

        for (int i = 0; i < m_curMonthdays; i++)
        {
            GameObject pre = Resources.Load("Prefabs/UI/Item/Item_Sign30") as GameObject;
            GameObject obj = Instantiate(pre);
            obj.transform.name = i.ToString();
            obj.transform.SetParent(gameObject.transform.Find("Image_bg"));
            obj.transform.localScale = new Vector3(1, 1, 1);
            obj.GetComponent <Button>().onClick.AddListener(() => onClickItemDay(obj));

            {
                Vector2 vec2_firstPos = new Vector2(-394, 168);
                int     jiange        = 85;

                float x = vec2_firstPos.x + (i % 7) * jiange;
                float y = vec2_firstPos.y - (i / 7) * jiange;
                obj.transform.localPosition = new Vector3(x, y, 1);
            }

            // 奖励icon
            {
                int prop_id = GameUtil.getPropIdFromReward(Sign30Data.getInstance().getSign30DataContentList()[i].reward_prop);
                CommonUtil.setImageSprite(obj.transform.Find("Image_icon").GetComponent <Image>(), GameUtil.getPropIconPath(prop_id));
            }

            // 奖励数量
            obj.transform.Find("Text_rewardNum").GetComponent <Text>().text = GameUtil.getPropNumFromReward(Sign30Data.getInstance().getSign30DataContentList()[i].reward_prop).ToString();

            // 第几天
            obj.transform.Find("Text_day").GetComponent <Text>().text = (i + 1).ToString();

            // 当天的做一些其他处理
            if ((i + 1) == CommonUtil.getCurDay())
            {
                // 当天的方块专门设置一个颜色
                CommonUtil.setImageColor(obj.GetComponent <Image>(), 255, 253, 113);

                setBtnSignState(CommonUtil.getCurDay());
            }

            // 签到状态
            {
                for (int j = 0; j < Sign30Data.getInstance().getSign30DataContentList().Count; j++)
                {
                    int day = Sign30Data.getInstance().getSign30DataContentList()[j].day;

                    if (day == (i + 1))
                    {
                        bool isSigned = false;

                        for (int k = 0; k < Sign30RecordData.getInstance().getSign30RecordList().Count; k++)
                        {
                            // 已签
                            if (Sign30RecordData.getInstance().getSign30RecordList()[k] == day)
                            {
                                isSigned = true;

                                obj.transform.Find("Image_buqian").localScale = new Vector3(0, 0, 0);
                                //obj.transform.Find("Image_yiguoqi").localScale = new Vector3(0, 0, 0);
                                //obj.transform.Find("Image_icon").localScale = new Vector3(0, 0, 0);
                                break;
                            }
                        }

                        // 过去
                        if (day < CommonUtil.getCurDay())
                        {
                            if (!isSigned)
                            {
                                obj.transform.Find("Image_yiqian").localScale = new Vector3(0, 0, 0);

                                // 如果是今天没有签到的话,不显示补签
                                if (day == CommonUtil.getCurDay())
                                {
                                    obj.transform.Find("Image_buqian").localScale = new Vector3(0, 0, 0);
                                    //obj.transform.Find("Image_yiguoqi").localScale = new Vector3(0, 0, 0);
                                }
                            }
                        }
                        // 当天
                        else if (day == CommonUtil.getCurDay())
                        {
                            if (isSigned)
                            {
                                obj.transform.Find("Image_buqian").localScale = new Vector3(0, 0, 0);
                                //obj.transform.Find("Image_yiguoqi").localScale = new Vector3(0, 0, 0);
                            }
                            else
                            {
                                obj.transform.Find("Image_yiqian").localScale = new Vector3(0, 0, 0);
                                obj.transform.Find("Image_buqian").localScale = new Vector3(0, 0, 0);
                                //obj.transform.Find("Image_yiguoqi").localScale = new Vector3(0, 0, 0);
                            }
                        }
                        // 未来
                        else
                        {
                            obj.transform.Find("Image_yiqian").localScale = new Vector3(0, 0, 0);
                            obj.transform.Find("Image_buqian").localScale = new Vector3(0, 0, 0);
                            //obj.transform.Find("Image_yiguoqi").localScale = new Vector3(0, 0, 0);
                        }
                    }
                }
            }
        }

        // 累计签到奖励
        {
            for (int i = 1; i <= 3; i++)
            {
                Sign30DataContent data = Sign30Data.getInstance().getSign30DataById(31 + i);
                int prop_id            = GameUtil.getPropIdFromReward(data.reward_prop);
                int prop_num           = GameUtil.getPropNumFromReward(data.reward_prop);

                GameObject parent = transform.Find("Image_bg/Image_leiji_" + i.ToString()).gameObject;

                // 天数
                parent.transform.Find("Text_day").GetComponent <Text>().text = data.day.ToString() + "天";

                // 奖励icon
                CommonUtil.setImageSprite(parent.transform.Find("Image_rewardIcon").GetComponent <Image>(), GameUtil.getPropIconPath(prop_id));

                // 奖励数量
                parent.transform.Find("Text_rewardNum").GetComponent <Text>().text = "*" + prop_num.ToString();
            }
        }

        // 累计签到天数显示
        m_text_lianxuqiandaotianshu.text = "累计签到天数:" + Sign30RecordData.getInstance().getSign30RecordList().Count.ToString() + "天";

        // 累计签到奖励
        setLeiJiSignState();
    }