/// <summary> /// 操作家园信息,在角色登录或在线进行操作 /// </summary> /// <param name="pb"></param> public static void HomeInfoCall(PlayerBusiness pb) { string soleid = pb.ID + "HomeInfoCall"; if (!m_dic.TryAdd(soleid, soleid)) return; try { Variant mv = MemberAccess.MemberInfo(pb.MLevel); if (mv == null) return; //表示没有自动发送邮件的功能 if (!mv.GetBooleanOrDefault("IsHome")) return; PlayerEx home = pb.Home; if (home == null) return; Variant hv = home.Value; if (hv == null) return; Variant produces = hv.GetVariantOrDefault("Produces"); //自动取得道具功能 Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("GuoYuan", "CaiJi"); dic.Add("ShuFang", "JuanZhou"); dic.Add("JiaGongFang", "JiaGong"); foreach (var item in dic) { GameConfig model = null; if (item.Key == "GuoYuan") { model = GameConfigAccess.Instance.FindOneById("Home_CJ00002"); } else if (item.Key == "ShuFang") { model = GameConfigAccess.Instance.FindOneById("Home_CJ00001"); } else if (item.Key == "JiaGongFang") { model = GameConfigAccess.Instance.FindOneById("Home_CJ00003"); } if(model==null) return; string goodsid = model.Value.GetStringOrDefault("GoodsID"); Variant vp = produces.GetVariantOrDefault(item.Key); if (vp == null) continue; IList petList = vp.GetValue<IList>("PetList"); //表示没有放入宠物 if (petList == null || petList.Count == 0) continue; Variant p = petList[0] as Variant; if (p == null) continue; //string goodsid = vp.GetStringOrDefault("GoodsID"); string st = vp.GetStringOrDefault("StartTime"); string et = vp.GetStringOrDefault("EndTime"); if (string.IsNullOrEmpty(st) || string.IsNullOrEmpty(et)) continue; DateTime startTime = vp.GetDateTimeOrDefault("StartTime"); DateTime endTime = vp.GetDateTimeOrDefault("EndTime"); DateTime dt = DateTime.UtcNow; int zv = p.GetIntOrDefault(item.Value); //得到总供生产秒数 if (endTime > dt) continue; int t = Convert.ToInt32((endTime - startTime).TotalSeconds); //技算得到道具数量 int number = Convert.ToInt32(HomeNumber(zv) * t / 7200); if (number <= 0) continue; GameConfig gc = GameConfigAccess.Instance.FindOneById(goodsid); if (gc == null) continue; vp["StartTime"] = dt; vp["EndTime"] = dt.AddHours(mv.GetIntOrDefault("HomeHour")); if (home.Save()) { string title = ""; // "亲爱的会员玩家【{0}】,您在家园中生产的物品【{1}】已到达自动生产的上限时间【{2}】小时,现将您生产出的【{1}】总共【{3}】个邮寄给您,请您及时查收.同时生产又自动开始"; string content = string.Format(TipManager.GetMessage(HomeReturn.HomeInfoCall4), pb.Name, gc.Name, (t / 3600), number); switch (item.Key) { case "GuoYuan": // "家园自动采集"; title =TipManager.GetMessage(HomeReturn.HomeInfoCall1); break; case "ShuFang": //"家园自动养殖"; title = TipManager.GetMessage(HomeReturn.HomeInfoCall2); break; case "JiaGongFang": //"家园自动挖掘"; title = TipManager.GetMessage(HomeReturn.HomeInfoCall3); break; } Variant gs = new Variant(); gs.Add("G", goodsid); gs.Add("A", number); gs.Add("E", goodsid); gs.Add("H", 1); List<Variant> goodsList = new List<Variant>(); if (number > 0) { goodsList.Add(gs); } else { goodsList = null; } int reTime = Convert.ToInt32(TipManager.GetMessage(EmailReturn.HameDay)); if (EmailAccess.Instance.SendEmail(title, TipManager.GetMessage(PetsReturn.StealPet12), pb.ID, pb.Name, content, string.Empty, goodsList, reTime)) { if (pb.Online) { pb.Call(EmailCommand.NewEmailTotalR, EmailAccess.Instance.NewTotal(pb.ID)); } } } Variant gs1 = new Variant(); gs1[goodsid] = number; Variant os = new Variant(); os["StartTime"] = startTime; os["EndTime"] = endTime; os["PetsID"] = p.GetStringOrDefault("PetID"); os["ID"] = p.GetStringOrDefault("ID"); os["Number"] = zv; os["Name"] = item.Value; os["IsHand"] = 0;//自动 pb.AddLogVariant(Actiontype.JiaZheng, null, gs1,os); } } finally { m_dic.TryRemove(soleid, out soleid); } }