Example #1
0
        /// <summary>
        /// 单件物品维修费用
        /// </summary>
        /// <param name="g"></param>
        /// <returns></returns>
        private int RepairFee(Goods g)
        {
            //得到物品持久度
            Variant Stamina = g.Value.GetValueOrDefault<Variant>("Stamina");
            Variant price = g.Value.GetValueOrDefault<Variant>("Price");

            int Score = price.GetValueOrDefault<Variant>("Buy").GetIntOrDefault("Score");
            int Max = Stamina.GetIntOrDefault("M");
            int Mix = Stamina.GetIntOrDefault("V");
            int Price = Convert.ToInt32(Score * 0.1 * (Max - Mix));

            return (Price / Max);
        }
Example #2
0
 /// <summary>
 /// 计算宝石加成
 /// </summary>
 /// <param name="p"></param>
 /// <param name="gs"></param>
 private static void BaoShiAddition(PlayerProperty p, Goods gs)
 {
     object baoShiInfo;
     if (gs.Value.TryGetValueT("BaoShiInfo", out baoShiInfo)
         && baoShiInfo is IDictionary<string, object>)
     {
         foreach (var x in baoShiInfo as IDictionary<string, object>)
         {
             if (x.Value != null)
             {
                 string bID = x.Value.ToString();
                 //"-1":无孔,"0"或"":无宝石
                 if (bID == string.Empty || bID == "0" || bID == "-1")
                 {
                     continue;
                 }
                 var bs = GameConfigAccess.Instance.FindOneById(bID);
                 p.Add(bs.Value.GetVariantOrDefault("Life"));
             }
         }
     }
 }
Example #3
0
        /// <summary>
        /// 换装操作
        /// </summary>
        /// <param name="note"></param>
        private void Dress(UserNote note, Goods g)
        {
            //表示角色正在战斗中,客户端提交信息不进行处理
            if (note.Player.AState == ActionState.Fight)
                return;
            string goodsid = note.GetString(0);
            if (g == null)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.NoGoodsInfo));
                return;
            }
            int check = DressLimit(note.Player, g);
            if (check != 0)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(check));
                return;
            }
            //得到装备面板
            PlayerEx panel = note.Player.Equips;
            if (panel == null)
            {
                panel = note.Player.Value["Equips"] as PlayerEx;
                if (panel == null)
                {
                    //LogWrapper.Error("角色:" + note.Player.Name + "装被面板为空");
                    return;
                }
            }

            Variant pv = panel.Value;

            PlayerEx b = note.Player.B0;
            if (b == null)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.EquipError));
                return;
            }

            IList c = b.Value.GetValue<IList>("C");

            string str = g.Value.GetStringOrDefault("GoodsType");
            //得到装备可以存放的位置
            GameConfig gc = GameConfigAccess.Instance.FindOneById(g.GoodsID);
            if (gc == null)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.EquipError));
                return;
            }

            IDictionary<string, object> k = null;
            string name = string.Empty;

            switch (str)
            {

                case "111001"://武器
                    k = pv["P0"] as IDictionary<string, object>;
                    name = "P0";
                    break;
                case "111002"://头盔
                    k = pv["P5"] as IDictionary<string, object>;
                    name = "P5";
                    break;
                case "111003"://衣服
                    k = pv["P6"] as IDictionary<string, object>;
                    name = "P6";
                    break;
                case "111004"://护腕
                    IDictionary<string, object> p3 = pv["P3"] as IDictionary<string, object>;
                    IDictionary<string, object> p8 = pv["P8"] as IDictionary<string, object>;
                    if (p3.GetStringOrEmpty("E") == string.Empty)
                    {
                        k = p3;
                        name = "P3";
                    }
                    else if (p8.GetStringOrEmpty("E") == string.Empty)
                    {
                        k = p8;
                        name = "P8";
                    }
                    else if (p111004 == 0)
                    {
                        k = p3;
                        name = "P3";
                        p111004 = p111004 == 0 ? 1 : 0;
                    }
                    else
                    {
                        k = p8;
                        name = "P8";
                        p111004 = p111004 == 0 ? 1 : 0;
                    }
                    break;

                case "111005"://腰带
                    k = pv["P2"] as IDictionary<string, object>;
                    name = "P2";
                    break;
                case "111006"://鞋子
                    k = pv["P7"] as IDictionary<string, object>;
                    name = "P7";
                    break;
                case "111007"://项链
                    k = pv["P1"] as IDictionary<string, object>;
                    name = "P1";
                    break;
                case "111008"://戒子
                    IDictionary<string, object> p4 = pv["P4"] as IDictionary<string, object>;
                    IDictionary<string, object> p9 = pv["P9"] as IDictionary<string, object>;
                    if (p4.GetStringOrEmpty("E") == string.Empty)
                    {
                        k = p4;
                        name = "P4";
                    }
                    else if (p9.GetStringOrEmpty("E") == string.Empty)
                    {
                        k = p9;
                        name = "P9";
                    }
                    else if (p111008 == 0)
                    {
                        k = p4;
                        name = "P4";
                        p111008 = p111008 == 0 ? 1 : 0;
                    }
                    else
                    {
                        k = p9;
                        name = "P9";
                        p111008 = p111008 == 0 ? 1 : 0;
                    }

                    break;

                //case "111010"://坐骑
                //    k = pv["P10"] as IDictionary<string, object>;
                //    name = "P10";
                //    break;

                //case "111000"://时装
                //    k = pv["P11"] as IDictionary<string, object>;
                //    name = "P11";
                //    break;
            }

            if (k == null || name == string.Empty)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.EquipError));
                return;
            }

            IDictionary<string, object> info = null;
            foreach (IDictionary<string, object> p in c)
            {
                if (g.ID == p.GetStringOrDefault("E"))
                {
                    //得到装备所在格子的信息
                    info = p;
                    break;
                }
            }

            if (info == null)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(GoodsReturn.BurdenError));
                return;
            }

            string name2 = null;
            string skin = gc.UI.GetStringOrDefault("Skin");
            switch (str)
            {
                //case "111000":
                //    //时装
                //    name2 = "Coat";
                //    note.Player.Coat = skin;
                //    break;
                case "111001":
                    //武器
                    name2 = "Weapon";
                    note.Player.Weapon = skin;
                    break;
                case "111003":
                    //衣服
                    name2 = "Body";
                    note.Player.Body = skin;
                    break;
                //case "111010":
                //    //坐骑
                //    name2 = "Mount";
                //    note.Player.Mount = skin;
                //    break;
            }

            Variant tmp = new Variant();
            tmp["E"] = k["E"];
            tmp["G"] = k["G"];
            tmp["A"] = k["A"];
            tmp["S"] = k["S"];
            tmp["H"] = k["H"];
            tmp["D"] = k["D"];
            tmp["T"] = k["T"];
            //tmp["R"] = k["R"];
            //换装

            string g1 = info.GetStringOrDefault("G");
            string g2 = string.Empty;
            if (k["E"].ToString() == string.Empty)
            {
                k["E"] = info["E"];
                k["G"] = info["G"];
                k["A"] = info["A"];
                k["S"] = info["S"];
                k["H"] = info["H"];
                k["D"] = info["D"];
                k["T"] = info["T"];
                //k["R"] = info["R"];
                //更新包袱

                BurdenManager.BurdenClear(info);
            }
            else
            {
                k["E"] = info["E"];
                k["G"] = info["G"];
                k["A"] = info["A"];
                k["S"] = info["S"];
                k["H"] = info["H"];
                k["D"] = info["D"];
                k["T"] = info["T"];
                //k["R"] = info["R"];
                //note.Player.UserNote_T(k.GetStringOrDefault("G"));//表示两类道具交换,都要通知任务
                //更新包袱
                info["E"] = tmp["E"];
                info["G"] = tmp["G"];
                info["A"] = tmp["A"];
                info["S"] = tmp["S"];
                info["H"] = tmp["H"];
                info["D"] = tmp["D"];
                info["T"] = tmp["T"];
                g2 = tmp.GetStringOrDefault("G");
                //note.Player.UserNote_T(info.GetStringOrDefault("G"));
                //info["R"] = tmp["R"];
            }

            b.Save();
            note.Player.SaveClothing();
            panel.Save();
            note.Player.RefreshPlayer(name2, skin);
            note.Call(GoodsCommand.UseGoodsR, true, g.ID);
            note.Call(GoodsCommand.GetEquipPanelR, true, pv);

            note.Player.UpdateBurden();
            //通知任务
            if (!string.IsNullOrEmpty(g1))
            {
                note.Player.UpdateTaskGoods(g1);
            }
            if (!string.IsNullOrEmpty(g2))
            {
                note.Player.UpdateTaskGoods(g2);
            }
        }
Example #4
0
        /// <summary>
        /// 礼包
        /// </summary>
        /// <param name="note"></param>
        /// <param name="g"></param>
        private void LiBao(UserNote note, Goods g)
        {
            int check = DressLimit(note.Player, g);
            if (check != 0)
            {
                note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(check));
                return;
            }
            Variant package = note.GetVariant(0);
            int p = package.GetIntOrDefault("P");
            int isbinding = g.Value.GetIntOrDefault("IsBinding");
            Variant libao = g.Value.GetVariantOrDefault("LiBao");
            if (libao == null)
            {
                note.Call(GoodsCommand.UseGoodsR, false, string.Format(TipManager.GetMessage(GoodsReturn.LiBao1), g.Name));
                return;
            }
            Dictionary<string, Variant> dic = new Dictionary<string, Variant>();
            int bond = 0;
            int score = 0;
            int coin = 0;
            if (!libao.ContainsKey("Award"))
            {
                #region 礼包固定信息
                foreach (var item in libao)
                {
                    switch (item.Key)
                    {
                        case "Bond":
                            bond = libao.GetIntOrDefault(item.Key);
                            break;
                        case "Score":
                            score = libao.GetIntOrDefault(item.Key);
                            break;
                        case "Coin":
                            coin = libao.GetIntOrDefault(item.Key);
                            break;
                        default:
                            GetLiBaoAward(dic, item.Key, (int)item.Value, isbinding);
                            break;
                    }
                }
                #endregion
            }
            else
            {
                #region 随机奖励礼包

                Variant award = libao.GetValue<Variant>("Award");
                Dictionary<string, int> goods = new Dictionary<string, int>();
                Award.GetPackets(award, goods);
                if (goods.Count > 0)
                {
                    foreach (var item in goods)
                    {
                        GetLiBaoAward(dic, item.Key, item.Value, isbinding);
                    }
                }
                #endregion
            }

            PlayerEx burden = note.Player.B0;
            if (dic.Count > 0)
            {
                if (BurdenManager.IsFullBurden(burden, dic))
                {
                    note.Call(GoodsCommand.UseGoodsR, false, TipManager.GetMessage(BurdenReturn.BurdenFull));
                    return;
                }

            }
            //移除一个道具
            if (note.Player.RemoveGoods(p, GoodsSource.LiBao))
            {
                if (dic.Count > 0)
                {
                    //得到新物品
                    note.Player.AddGoods(dic, GoodsSource.LiBao);
                }
                if (bond > 0)
                {
                    //添加
                    note.Player.AddBond(bond, FinanceType.LiBao);
                }
                if (score > 0)
                {
                    //添加
                    note.Player.AddScore(score, FinanceType.LiBao);
                }

                if (ConfigLoader.Config.FreeCoin)
                {
                    if (coin > 0)
                    {
                        note.Player.AddCoin(coin, FinanceType.LiBao);
                        UserNote un = new UserNote(note.Player, PartCommand.Recharge, new object[] { coin });
                        Notifier.Instance.Publish(un);
                    }
                }
                note.Player.UpdateBurden();
                note.Call(GoodsCommand.UseGoodsR, true, g.ID);
            }
            else
            {
                note.Call(GoodsCommand.UseGoodsR, false, string.Format(TipManager.GetMessage(GoodsReturn.LiBao1), g.Name));
            }
        }
Example #5
0
 /// <summary>
 /// 创建道具变更信息
 /// </summary>
 /// <param name="gc"></param>
 /// <returns></returns>
 public static Variant CreateT(Goods g)
 {
     Variant v = g.Value;
     Variant msg = new Variant();
     //if (v.ContainsKey("Stamina"))
     //{
     //    Variant Stamina = v["Stamina"] as Variant;
     //    msg.Add("Stamina", Stamina["V"]);
     //}
     //if (v.ContainsKey("BaoShiInfo"))
     //{
     //    Variant bs = v["BaoShiInfo"] as Variant;
     //    foreach (string p in bs.Keys)
     //    {
     //        if (msg.ContainsKey(p))
     //            continue;
     //        msg.Add(p, bs[p]);
     //    }
     //}
     //if (v.ContainsKey("PetsWild"))
     //{
     //    //野性值
     //    msg.Add("PetsWild", v["PetsWild"]);
     //}
     //msg.Add("Created", g.Created);
     if (v.ContainsKey("EndTime"))
     {
         msg.Add("EndTime", v["EndTime"]);
     }
     return msg;
 }
Example #6
0
File: Goods.cs Project: abel/sinan
 public static Goods Create(Variant v)
 {
     Goods g = new Goods();
     g.m_value = v;
     return g;
 }
Example #7
0
File: Goods.cs Project: abel/sinan
 public static Goods Create()
 {
     Goods g = new Goods();
     g.m_value = new Variant();
     return g;
 }
Example #8
0
        /// <summary>
        /// 装备使用限制
        /// </summary>
        /// <param name="player"></param>
        /// <param name="g"></param>
        /// <returns></returns>
        private static int DressLimit(Player player, Goods g)
        {
            Variant limit = g.Value.GetVariantOrDefault("UserLimit");
            if (limit == null) return 0;

            int fail = CheckRole(player, limit);
            if (fail != 0)
            {
                return fail;
            }
            fail = CheckSex(player, limit);
            if (fail != 0)
            {
                return fail;
            }
            fail = CheckLevel(player, limit);
            if (fail != 0)
            {
                return fail;
            }
            fail = CheckTimeLines(player, g);
            if (fail != 0)
            {
                return fail;
            }
            return 0;
        }
Example #9
0
 /// <summary>
 /// 限时使用
 /// </summary>
 /// <param name="player"></param>
 /// <param name="limit">限制条件</param>
 /// <param name="created">开始计时时间</param>
 /// <returns></returns>
 private static int CheckTimeLines(Player player, Goods g)
 {
     Variant TimeLines = g.Value.GetVariantOrDefault("TimeLines");
     //表示没有时间限制
     if (TimeLines != null && TimeLines.GetIntOrDefault("Type") > 0)
     {
         //Type 永久有效0
         //获得时计时1
         //使用后计时2
         DateTime dt = DateTime.UtcNow;
         TimeSpan ts = dt - g.Created;
         if (ts.TotalHours >= TimeLines.GetIntOrDefault("Hour"))
         {
             //表示道具已经过期不能使用
             //IsDestroy是否消失
             return GoodsReturn.TimeLines;
         }
     }
     return 0;
 }