コード例 #1
0
ファイル: MemberBussiness.cs プロジェクト: abel/sinan
        /// <summary>
        /// 登录可以得到的成长度数量
        /// </summary>
        /// <param name="note"></param>
        /// <returns></returns>
        public static void LoginCZD(PlayerBusiness pb)
        {
            string soleid = pb.ID + "LoginCZD";
            if (!m_dic.TryAdd(soleid, soleid))
                return;
            try
            {
                //上次登陆时间
                PlayerEx member = pb.Member;
                Variant v = member.Value;
                int czd = 0;

                int num = 0;//天数
                DateTime dt = DateTime.UtcNow;

                if (v.ContainsKey("MemberTime"))
                {
                    DateTime mt = v.GetDateTimeOrDefault("MemberTime");
                    num = Convert.ToInt32((dt.Date - mt.Date).TotalDays);
                }
                else
                {
                    DateTime created = pb.Created;
                    num = Convert.ToInt32((dt.Date - created.Date).TotalDays);
                }
                if (num < 1)
                    return;

                Variant mv = MemberAccess.MemberInfo(pb.MLevel);
                if (mv != null)
                {
                    //每天增加量
                    int b = mv.GetIntOrDefault("B");
                    czd = b * num;
                    if (czd > 0)
                    {
                        pb.AddCZD(czd, GoodsSource.LoginCZD);
                    }
                }
                v["MemberTime"] = DateTime.UtcNow;
                member.Save();

                //更新会员扩展
                pb.Call(ClientCommand.UpdateActorR, new PlayerExDetail(member));
            }
            finally
            {
                m_dic.TryRemove(soleid, out soleid);
            }
        }