public override void DoAction(IEventArgs args) { if (string.IsNullOrEmpty(player)) { player = "current"; } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player); IParable item = args.GetUnit("item"); if (playerEntity != null && item != null) { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ChangeAvatar; int itemId = FreeUtil.ReplaceInt("{item.itemId}", args); playerEntity.WeaponController().PickUpWeapon(WeaponUtil.CreateScan(itemId)); //playerEntity.bag.Bag.SetWeaponBullet(30); //playerEntity.bag.Bag.SetReservedCount(100); message.Ins.Add(itemId); message.Ks.Add(2); playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message); } }
public override void DoAction(IEventArgs args) { int minX = FreeUtil.ReplaceInt(MinX, args); int maxX = FreeUtil.ReplaceInt(MaxX, args); int minY = FreeUtil.ReplaceInt(MinY, args); int maxY = FreeUtil.ReplaceInt(MaxY, args); int stopX = FreeUtil.ReplaceInt(StopX, args); int stopY = FreeUtil.ReplaceInt(StopY, args); int stopR = FreeUtil.ReplaceInt(StopR, args); int random = RandomUtil.Random(1, 4); // 飞机航线 if (stopR == 0) { FlyLine line = SelectStart(random, minX, minY, maxX, maxY); Set(args, (int)line.from.x, (int)line.from.y, (int)line.to.x, (int)line.to.y); } else { FlyLine line = SelectStart(random, minX, minY, maxX, maxY); Set(args, (int)line.from.x, (int)line.from.y, (int)line.to.x, (int)line.to.y); } }
public override void DoAction(IEventArgs args) { string realKeys = FreeUtil.ReplaceVar(keys, args); if (!cache.ContainsKey(realKeys)) { string[] ks = StringUtil.Split(realKeys, new string[] { ",", "," }); ks = GetSpecialString(ks); int[] priority = new int[ks.Length]; for (int i = 0; i < ks.Length; i++) { string k = ks[i]; string[] vs = StringUtil.Split(k, "="); if (vs.Length == 2 && StringUtil.IsNumberString(vs[1])) { ks[i] = vs[0].Trim(); priority[i] = NumberUtil.GetInt(vs[1]); } else { priority[i] = 1; } } RandomStringAction.KeyProperty kp = new RandomStringAction.KeyProperty(); kp.v = realKeys; kp.ks = ks; kp.priority = priority; cache[realKeys] = kp; } string[] ks_1 = cache[realKeys].ks; int[] proAcc = cache[realKeys].priority; if (all) { for (int i = 0; i < ks_1.Length; i++) { HandleOne(ks_1.Length, i + 1, ks_1[i], args); } } else { if (StringUtil.IsNullOrEmpty(count)) { count = "1"; } int c = FreeUtil.ReplaceInt(count, args); int[] ins = null; if (repeat) { ins = RandomUtil.RandomWithProRepeat(0, proAcc, c); } else { ins = RandomUtil.RandomWithPro(0, proAcc, c); } for (int i = 0; i < ins.Length; i++) { HandleOne(ins.Length, i + 1, ks_1[ins[i]], args); } } }
public virtual bool Meet(IEventArgs args) { int realState = FreeUtil.ReplaceInt(state, args); PlayerEntity p = ((FreeRuleEventArgs)args).GetPlayer(player); if (p != null) { if (realState > 100) { switch (realState) { case InCar: return(p.IsOnVehicle()); default: return(false); } } else { return(PlayerStateUtil.HasPlayerState((EPlayerGameState)realState, p.gamePlay)); } } return(false); }
public override void DoAction(IEventArgs args) { int from = FreeUtil.ReplaceInt(this.from, args); int to = FreeUtil.ReplaceInt(this.to, args); if (StringUtil.IsNullOrEmpty(i)) { i = "i"; } if (from > to) { for (int i = from; i >= to; i--) { args.GetDefault().GetParameters().TempUse(new IntPara(this.i, i)); action.Act(args); args.GetDefault().GetParameters().Resume(this.i); } } else { for (int i = from; i <= to; i++) { args.GetDefault().GetParameters().TempUse(new IntPara(this.i, i)); action.Act(args); args.GetDefault().GetParameters().Resume(this.i); } } }
private void HandleDropWeapon(IEventArgs args) { if ("DropWeapon" == code) { int key = FreeUtil.ReplaceInt("{key}", args); FreeData fd = (FreeData)args.GetUnit("current"); ItemInventory defInv = fd.freeInventory.GetInventoryManager().GetDefaultInventory(); for (int i = 1; i <= 5; i++) { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory("w" + key + "" + i); if (ii.posList.Count > 0) { ItemPosition ip = ii.posList[0]; if (BagCapacityUtil.CanAddToBag(args, fd, ip)) { int[] next = defInv.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, defInv, next[0], next[1], (ISkillArgs)args); } else { ItemInventory ground = fd.freeInventory.GetInventoryManager().GetInventory("ground"); int[] next = ground.GetNextEmptyPosition(ip.key); ItemInventoryUtil.MovePosition(ip, ground, next[0], next[1], (ISkillArgs)args); } } } CarryClipUtil.AddCurrentClipToBag(key, fd, args); } }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit player = GetPlayer(args); if (player != null) { IParable pa = fr.GetUnit(item); if (pa is ItemPosition) { ItemPosition ip = (ItemPosition)pa; FreeData fd = (FreeData)player; ItemInventory toInv = fd.freeInventory.GetInventoryManager().GetInventory(FreeUtil.ReplaceVar(toInventory, args)); if (toInv != null) { int toX = 0; int toY = 0; if (string.IsNullOrEmpty(x) && string.IsNullOrEmpty(y)) { int[] next = toInv.GetNextEmptyPosition(ip.GetKey()); toX = next[0]; toY = next[1]; } else { toX = FreeUtil.ReplaceInt(x, args); toY = FreeUtil.ReplaceInt(y, args); } ItemInventoryUtil.MovePosition(ip, toInv, toX, toY, fr); } } } }
public override void DoAction(IEventArgs args) { PlayerEntity player = GetPlayerEntity(args); Vector3 dropPos = UnityPositionUtil.ToVector3(pos.Select(args)); if (player != null) { RaycastHit hit; Ray ray = new Ray(player.position.Value, dropPos); if (Physics.Raycast(ray, out hit, Vector3.Distance(player.position.Value, dropPos), UnityLayers.SceneCollidableLayerMask)) { RaycastHit vhit; if (Physics.Raycast(hit.point, Vector3.down, out vhit, 10000, UnityLayers.SceneCollidableLayerMask)) { dropPos = vhit.point; } else { dropPos = hit.point; } } } SceneObjectEntity entity = (SceneObjectEntity)args.GameContext.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (Assets.XmlConfig.ECategory)FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args), dropPos); if (entity != null && !string.IsNullOrEmpty(time)) { entity.AddLifeTime(DateTime.Now, args.GetInt(time)); } Debug.LogFormat("create item {0},{1},{2}", FreeUtil.ReplaceInt(cat, args), FreeUtil.ReplaceInt(id, args), FreeUtil.ReplaceInt(count, args)); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit player = GetPlayer(args); if (StringUtil.IsNullOrEmpty(count) || count.Equals("0")) { count = "0"; } method = new SelectMethod(FreeUtil.ReplaceVar(exp, args)); if (player != null) { FreeData fd = (FreeData)player; ItemPosition[] currentItems = fd.freeInventory.Select(method); fr.TempUse("current", fd); int c = FreeUtil.ReplaceInt(count, args); for (int i = 0; i < currentItems.Length; i++) { ItemPosition ip = currentItems[i]; ip.SetCount(c); ip.GetKey().SetCount(c); ip.GetInventory().GetInventoryUI().UpdateItem(fr, ip.GetInventory(), ip); } fr.Resume("current"); } }
public string Replace(string exp, IEventArgs args) { IniDesc(); exp = exp.Substring(TextDesc.Length); string[] vs = StringUtil.Split(exp, ","); int id = FreeUtil.ReplaceInt(vs[0].Trim(), args); if (descDic.ContainsKey(id)) { string text = descDic[id]; if (vs.Length > 1) { for (int i = 1; i < vs.Length; i++) { text = text.Replace("{" + (i - 1) + "}", vs[i].Trim()); } } return(text); } return(None); }
private void Log(IEventArgs args) { string s = string.Empty; int realScope = FreeUtil.ReplaceInt(scope, args); switch (realScope) { case SCOPE_ALL: { s = "全部玩家"; break; } case SCOPE_OBSERVER: { s = "观察者"; break; } case SCOPE_PLYAER: { s = "玩家" + player; break; } case SCOPE_TEAMATE: { s = "玩家" + player + "的队友"; break; } } FreeLog.Message(string.Format("{0} \n{1}\n范围:{2}", FreeMessageConstant.GetMessageDesc(builder.Key), builder, s), args); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; IGameUnit unit = GetPlayer(args); if (unit != null) { PlayerEntity p = ((FreeData)unit).Player; int index = FreeUtil.ReplaceInt(weaponKey, args); EWeaponSlotType currentSlot = p.GetBagLogicImp().GetCurrentWeaponSlot(); if (index > 0) { currentSlot = FreeWeaponUtil.GetSlotType(index); } Debug.LogFormat("remove weapon: " + index); p.playerAction.Logic.DropWeapon(currentSlot); //SimpleProto message = new SimpleProto(); //message.Key = FreeMessageConstant.ChangeAvatar; //message.Ins.Add((int)currentSlot); //message.Ks.Add(6); //p.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message); } }
public override void DoAction(IEventArgs args) { if (string.IsNullOrEmpty(player)) { player = "current"; } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player); IParable item = args.GetUnit("item"); if (playerEntity != null && item != null) { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ChangeAvatar; int itemId = FreeUtil.ReplaceInt("{item.itemId}", args); if (takeoff) { TakeOff(playerEntity, itemId); } else { PutOn(playerEntity, itemId); } ReduceDamageUtil.UpdateArmorAndHelmet((FreeData)playerEntity.freeData.FreeData); } }
public override void DoAction(IEventArgs args) { string from = FreeUtil.ReplaceVar(ParaFrom, args); string to = FreeUtil.ReplaceVar(ParaTo, args); string itemCat = FreeUtil.ReplaceVar(ParaItemCat, args); int clipType = FreeUtil.ReplaceInt(ParaClipType, args); IParable item = args.GetUnit(FreeArgConstant.Item); if (to == ChickenConstant.BagDefault && itemCat == ChickenConstant.ItemCatGrenadeWeapon) { HandleAddGrenade(args); } if (from == ChickenConstant.BagDefault && itemCat == ChickenConstant.ItemCatGrenadeWeapon) { HandleRemoveGrenade(args); } if (to == ChickenConstant.BagDefault && item.GetParameters().HasPara(ClipType)) { HandleSetClip(args, clipType); } else if (from == ChickenConstant.BagDefault && item.GetParameters().HasPara(ClipType)) { HandleClearClip(args, clipType); } HandleCapacity(args); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; if (StringUtil.IsNullOrEmpty(count) || count.Equals("0")) { count = INI_COUNT; } int c = FreeUtil.ReplaceInt(count, args); FreeItem item = FreeItemManager.GetItem(fr, FreeUtil.ReplaceVar(key, args), c); if (item != null) { if (!StringUtil.IsNullOrEmpty(time)) { ((FreeGameItem)item).SetTime(time); } item.Drop(fr, pos.Select(args)); if (action != null) { args.TempUse(ParaConstant.PARA_ITEM, item); action.Act(args); args.Resume(ParaConstant.PARA_ITEM); } } }
public bool Meet(IEventArgs args) { int realX = FreeUtil.ReplaceInt(x, args); int realY = FreeUtil.ReplaceInt(y, args); Ray r = new Ray(new Vector3(realX, 1000, realY), new Vector3(0, -1000, 0)); RaycastHit hitInfo; bool hited = Physics.Raycast(r, out hitInfo); switch (type) { case Water: if (hited) { return(SingletonManager.Get <MapConfigManager>().InWater(new Vector3(hitInfo.point.x, hitInfo.point.y - 0.1f, hitInfo.point.z))); } return(false); case Ground: if (hited) { return(!SingletonManager.Get <MapConfigManager>().InWater(new Vector3(hitInfo.point.x, hitInfo.point.y - 0.1f, hitInfo.point.z))); } return(false); } return(false); }
/// <summary> /// 手雷加入背包 /// </summary> /// <param name="args"></param> private void HandleAddGrenade(IEventArgs args) { PlayerEntity playerEntity = ((FreeRuleEventArgs)args).GetPlayer(FreeArgConstant.PlayerCurrent); if (playerEntity != null) { int itemId = FreeUtil.ReplaceInt(ParaItemId, args); int count = FreeUtil.ReplaceInt(ParaItemCount, args); for (int i = 0; i < count; i++) { var helper = playerEntity.WeaponController().GrenadeHelper; playerEntity.WeaponController().TryHoldGrenade(itemId); SimpleProto message = new SimpleProto(); message.Ks.Add(8); message.Ins.Add(itemId); message.Bs.Add(true); message.Key = FreeMessageConstant.ChangeAvatar; FreeMessageSender.SendMessage(playerEntity, message); //playerEntity.network.NetworkChannel.SendReliable((int)EServer2ClientMessage.FreeData, message); } } }
public override bool IsIn(IEventArgs args, UnitPosition entity) { bool isIn = false; foreach (MapConfigPoints.ID_Point p in MapConfigPoints.current.IDPints) { if (p.ID == FreeUtil.ReplaceInt(type, args)) { foreach (MapConfigPoints.SavedPointData spd in p.points) { float dx = MyMath.Abs(entity.GetX() - spd.pos.x); float dz = MyMath.Abs(entity.GetZ() - spd.pos.z); float dy = MyMath.Abs(entity.GetY() - spd.pos.y); if (dx * dx + dz * dz <= spd.cylinderVolR * spd.cylinderVolR && dy <= spd.cylinderVolH) { isIn = true; break; } } if (isIn) { break; } } } if (useOut) { return(!isIn); } return(isIn); }
private void HandleBullet(IEventArgs args) { if ("SetWeaponClip" == code) { FreeData fd = (FreeData)((FreeRuleEventArgs)args).GetUnit("current"); int ClipType = FreeUtil.ReplaceInt("{item.ClipType}", args); fd.Player.WeaponController().SetReservedBullet((EBulletCaliber)ClipType, CarryClipUtil.GetClipCount(ClipType, fd, args)); } else if ("ClearWeaponClip" == code) { FreeData fd = (FreeData)((FreeRuleEventArgs)args).GetUnit("current"); int ClipType = FreeUtil.ReplaceInt("{item.ClipType}", args); if (fd != null) { fd.Player.WeaponController().SetReservedBullet((EBulletCaliber)ClipType, 0); } } else if ("SetItemClip" == code) { FreeData fd = (FreeData)((FreeRuleEventArgs)args).GetUnit("current"); int ClipType = FreeUtil.ReplaceInt("{state.ClipType}", args); int count = fd.Player.WeaponController().GetReservedBullet((EBulletCaliber)ClipType); int itemCount = CarryClipUtil.GetClipCount(ClipType, fd, args); int delta = count - itemCount; if (delta > 0) { CarryClipUtil.AddClip(Math.Abs(delta), ClipType, fd, args); } else { CarryClipUtil.DeleteClip(Math.Abs(delta), ClipType, fd, args); } } }
private void HandleScore(IEventArgs args) { if (code == "WaitInfo") { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ScoreInfo; message.Ks.Add(1); message.Ins.Add(FreeUtil.ReplaceInt("{playerCount}", args)); //Debug.Log(message.ToString()); SendMessageAction.sender.SendMessage(args, message, 4, string.Empty); } else if (code == "ScoreInfo") { SimpleProto message = FreePool.Allocate(); message.Key = FreeMessageConstant.ScoreInfo; message.Ks.Add(2); message.Bs.Add(true); message.Ins.Add(FreeUtil.ReplaceInt("{current.killNum}", args)); message.Ins.Add(FreeUtil.ReplaceInt("{startPlayerCount}", args)); //Debug.Log(message.ToString()); SendMessageAction.sender.SendMessage(args, message, 1, "current"); } }
public override bool InRectange(FreeUIUtil.Rectangle rec, IEventArgs args) { if (pos == null || change) { pos = selector.Select(args); } int px = (int)(pos.GetX()); int py = (int)(pos.GetY()); int r = 0; try { r = int.Parse(radius); } catch (Exception) { r = FreeUtil.ReplaceInt(radius, args); } int x1 = rec.x - r; int x2 = rec.x + rec.width + r; int y1 = rec.y - r; int y2 = rec.y + rec.height + r; // 圆心在矩形的加上圆半径的范围内 return(px >= x1 && px <= x2 && py >= y1 && py <= y2); }
public virtual bool Meet(IEventArgs args) { int realState = FreeUtil.ReplaceInt(state, args); PlayerEntity p = ((FreeRuleEventArgs)args).GetPlayer(player); if (p != null) { if (realState > 100) { switch (realState) { case InCar: return(p.IsOnVehicle()); case Jump: return(p.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Jump); case Stand: return(p.stateInterface.State.GetCurrentMovementState() == MovementInConfig.Idle); default: return(false); } } else { return(PlayerStateUtil.HasPlayerState((EPlayerGameState)realState, p.gamePlay)); } } return(false); }
protected override void BuildMessage(IEventArgs args) { builder.Key = FreeMessageConstant.DuplicateUI; builder.Ss.Add(FreeUtil.ReplaceVar(key, args) + FreeMessageConstant.SpilterField + FreeUtil.ReplaceVar(type, args)); builder.Fs.Add(FreeUtil.ReplaceFloat(x, args)); builder.Fs.Add(FreeUtil.ReplaceFloat(y, args)); builder.Bs.Add(FreeUtil.ReplaceBool(show, args)); builder.Ks.Add(FreeUtil.ReplaceInt(relative, args)); if (values != null) { foreach (IFreeUIValue com in values) { builder.Ks.Add(com.GetSeq(args)); builder.Ins.Add(com.GetAutoStatus() * 100 + com.GetAutoIndex()); } foreach (IFreeUIValue com_1 in values) { object obj = com_1.GetValue(args); if (obj == null) { builder.Ss.Add("null"); } else { builder.Ss.Add(obj.ToString()); } } } }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; PlayerEntity player = (PlayerEntity)fr.GetEntity(target); if (player != null) { if (player.gamePlay.IsDead()) { return; } PlayerEntity sourcePlayer = null; if (!string.IsNullOrEmpty(source)) { sourcePlayer = (PlayerEntity)fr.GetEntity(source); } if (string.IsNullOrEmpty(part)) { part = ((int)EBodyPart.Chest).ToString(); } PlayerDamageInfo damageInfo = new PlayerDamageInfo(FreeUtil.ReplaceFloat(damage, args), FreeUtil.ReplaceInt(type, args), FreeUtil.ReplaceInt(part, args), 0, false, false, FreeUtil.ReplaceBool(dead, args)); BulletPlayerUtility.DoProcessPlayerHealthDamage(args.GameContext, (IGameRule)fr.Rule, sourcePlayer, player, damageInfo, null); } }
public virtual int GetRealTime(IEventArgs args) { if (realTime == 0) { realTime = FreeUtil.ReplaceInt(time, args); } return(realTime); }
public override void DoAction(IEventArgs args) { FreeRuleEventArgs fr = (FreeRuleEventArgs)args; PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player); int index = FreeUtil.ReplaceInt(weaponKey, args); EWeaponSlotType st = FreeWeaponUtil.GetSlotType(index); WeaponToHand(playerEntity, st); }
public virtual int GetInt(IEventArgs args) { if (!initialed || dynamic) { realValue = FreeUtil.ReplaceInt(para, args); initialed = true; } return((int)realValue); }
protected internal virtual int GetID(IEventArgs args) { int id = 0; if (!StringUtil.IsNullOrEmpty(this.id)) { id = FreeUtil.ReplaceInt(this.id, args); } return(id); }
public override void DoAction(IEventArgs args) { UnitPosition up = pos.Select(args); Contexts con = args.GameContext; VehicleEntityUtility.CreateNewVehicle(con.vehicle, FreeUtil.ReplaceInt(carId, args), con.session.commonSession.EntityIdGenerator.GetNextEntityId(), map.position.UnityPositionUtil.ToVector3(up)); }
private void Initial(IEventArgs args) { if (iWidth == 0) { iX = FreeUtil.ReplaceInt(x, args); iY = FreeUtil.ReplaceInt(y, args); iWidth = FreeUtil.ReplaceInt(width, args); iHeight = FreeUtil.ReplaceInt(height, args); } }