private void SetOne(IEventArgs args, string field, int value) { IntPara para = (IntPara)args.GetDefault().GetParameters().Get(field); if (para != null) { para.SetValue(value); } }
public override void DoAction(IEventArgs args) { ParaList target = GetTarget(args); object source = GetSource(args); if (fields != null && source != null && target != null) { foreach (FieldPair fN in FieldPair.Parse(fields)) { string[] ffs = new string[2]; ffs[0] = fN.GetFrom(); ffs[1] = fN.GetTo(); try { FieldInfo f = ReflectionCache.GetField(source, ffs[0].Trim()); AbstractPara para = null; string type = f.GetType().Name.ToLower(); if ("long".Equals(type)) { para = new LongPara(ffs[1].Trim()); } if ("int".Equals(type)) { para = new IntPara(ffs[1].Trim()); } if ("float".Equals(type)) { para = new FloatPara(ffs[1].Trim()); } if ("double".Equals(type)) { para = new DoublePara(ffs[1].Trim()); } if ("string".Equals(type)) { para = new StringPara(ffs[1].Trim()); } if ("boolean".Equals(type)) { para = new BoolPara(ffs[1].Trim()); } if (para == null) { throw new GameConfigExpception(ffs[1].Trim() + "'s type '" + type + "' is not supported."); } para.SetValue(f.GetValue(source)); target.AddPara(para); } catch (Exception e) { throw new GameConfigExpception(fN + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e)); } } } }
public override void DoAction(IEventArgs args) { if (addtimePara == null) { addtimePara = new IntPara(ParaConstant.PARA_ITEM_ADD_TIME, 0); } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; if (StringUtil.IsNullOrEmpty(count)) { count = INI_COUNT; } FreeItem fi = FreeItemManager.GetItem(fr, FreeUtil.ReplaceVar(key, args), FreeUtil.ReplaceInt(count, args)); if (StringUtil.IsNullOrEmpty(name)) { name = InventoryManager.DEFAULT; } IGameUnit player = GetPlayer(args); if (player != null) { FreeData fd = (FreeData)player; args.TempUse(ParaConstant.PARA_PLAYER_CURRENT, fd); args.TempUse(ParaConstant.PARA_ITEM, fi); args.TempUsePara(new StringPara("from", ChickenConstant.BagGround)); if (action != null) { action.Act(args); } if (fd.freeInventory.GetInventoryManager().GetInventory(FreeUtil.ReplaceVar(name, args)).AddItem((ISkillArgs)args, fi, true)) { //addtimePara.setValue(fr.room.getServerTime()); fi.GetParameters().AddPara(addtimePara); } else { if (failAction != null) { fr.TempUse(ParaConstant.PARA_ITEM, fi); failAction.Act(args); fr.Resume(ParaConstant.PARA_ITEM); } } fr.ResumePara("from"); fr.Resume(ParaConstant.PARA_PLAYER_CURRENT); fr.Resume(ParaConstant.PARA_ITEM); } }
public static IPara GetPara(object obj, string field) { if (obj == null) { return(null); } FieldInfo f = GetField(obj, field); AbstractPara para = null; if (f != null) { string type = f.FieldType.Name; if (ParseUtility.IsInt64(type)) { para = new LongPara(field); } if (ParseUtility.IsInt32(type)) { para = new IntPara(field); } if (ParseUtility.IsSingle(type)) { para = new FloatPara(field); } if (ParseUtility.IsDouble(type)) { para = new DoublePara(field); } if (ParseUtility.IsString(type)) { para = new StringPara(field); } if (ParseUtility.IsBoolean(type)) { para = new BoolPara(field); } try { if (para != null) { para.SetValue(f.GetValue(obj)); } } catch (Exception e) { throw new GameConfigExpception(field + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e)); } } return(para); }
public static IPara GetPara(object obj, string field) { if (obj == null) { return(null); } FieldInfo f = GetField(obj, field); AbstractPara para = null; if (f != null) { string type = f.FieldType.Name.ToLower(); if ("int64".Equals(type)) { para = new LongPara(field); } if ("int32".Equals(type)) { para = new IntPara(field); } if ("single".Equals(type)) { para = new FloatPara(field); } if ("double".Equals(type)) { para = new DoublePara(field); } if ("string".Equals(type)) { para = new StringPara(field); } if ("boolean".Equals(type)) { para = new BoolPara(field); } try { if (para != null) { para.SetValue(f.GetValue(obj)); } } catch (Exception e) { throw new GameConfigExpception(field + " is not a valid field.\n" + ExceptionUtil.GetExceptionContent(e)); } } return(para); }
public FreeEntityData(FreeMoveEntity entity) { this._entity = entity; this.paras = new SimpleParaList(); this.paras.AddFields(new ObjectFields(this)); this.id = entity.entityKey.Value.EntityId; this.follows = new List <PlayerEntity>(); xPara = new IntPara("x", 0); yPara = new IntPara("y", 0); zPara = new IntPara("z", 0); paras.AddPara(xPara); paras.AddPara(yPara); paras.AddPara(zPara); }
public override void DoAction(IEventArgs args) { long serverTime = args.Rule.ServerTime; if (!string.IsNullOrEmpty(time) && realTime == 0) { realTime = args.GetInt(time); } if (startTime == 0) { startTime = serverTime; timePara = new IntPara(Time, 0); } timePara.SetValue(serverTime - startTime); args.TempUsePara(timePara); if (action != null) { action.Act(args); } if (realTime > 0 && serverTime - startTime >= realTime) { args.FreeContext.AiSuccess = true; startTime = 0; } if (condition != null && condition.Meet(args)) { args.FreeContext.AiSuccess = true; startTime = 0; } args.ResumePara(Time); }
public virtual void Draw(SimpleInventoryUI ui, IEventArgs args, ItemInventory inventory, ItemPosition ip) { this.inventory = inventory; if (fui == null) { fui = new FreeUICreateAction(); Sharpen.Collections.AddAll(fui.GetComponents(), components); } ip.GetParameters().AddPara(new StringPara("inventory", inventory.GetName())); StringPara img = new StringPara("img", string.Empty); StringPara itemName = new StringPara("name", string.Empty); IntPara count = new IntPara("count", 0); args.GetDefault().GetParameters().TempUse(img); args.GetDefault().GetParameters().TempUse(count); args.GetDefault().GetParameters().TempUse(itemName); img.SetValue(ip.GetKey().GetImg()); count.SetValue(ip.GetCount()); itemName.SetValue(ip.GetKey().GetName()); FreeImageComponet back = GetBackground(); if (ui.nomouse) { back.SetNoMouse("true"); } if (ui.itemFixed) { back.SetFixed("true"); } int startX = GetX(args, ui, ip, back); int startY = GetY(args, ui, ip, back); if (!StringUtil.IsNullOrEmpty(notused) && !StringUtil.IsNullOrEmpty(used)) { if (ip.IsUsed()) { back.SetUrl(used); } else { back.SetUrl(notused); } } back.SetX(startX.ToString()); back.SetY(startY.ToString()); back.SetRelative(ui.relative); back.SetEvent(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY()); FreeImageComponet itemImg = back; FreeImageComponet secondComponent = GetItemImage(); if (secondComponent != null) { back.SetEvent(string.Empty); itemImg = secondComponent; } if (ui.nomouse) { itemImg.SetNoMouse("true"); } if (ui.itemFixed) { itemImg.SetFixed("true"); } itemImg.SetUrl(ip.GetKey().GetImg()); itemImg.SetOriginalSize(ip.GetKey().GetItemWidth() + "," + ip.GetKey().GetItemHeight()); if (itemImg == back) { AdjustSize(args, ui, ip, inventory, back, itemImg, startX, startY); } else { AdjustSize(args, ui, ip, inventory, back, itemImg, 0, 0); } SetCount(ip); fui.SetKey(ip.GetUIKey()); fui.SetShow(inventory.IsOpen()); fui.SetScope(1); fui.SetPlayer("current"); fui.Act(args); UpdateHotKey(ui, args, ip); args.GetDefault().GetParameters().Resume("img"); args.GetDefault().GetParameters().Resume("name"); args.GetDefault().GetParameters().Resume("count"); }