// 获取玩家总容量 public static float GetCapacity(FreeData fd) { float w = 20; foreach (string name in fd.freeInventory.GetInventoryManager().GetInventoryNames()) { if (name != "ground") { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(name); if (ii != null) { foreach (ItemPosition ip in ii.GetItems()) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey()); if (info.cat == 9) { RoleAvatarConfigItem avatar = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(info.id); w += avatar.Capacity; } } } } } return(w); }
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); } } } }
private static void DropPart(string inv, FreeData fd, ServerRoom room) { int c3 = fd.freeInventory.GetInventoryManager().GetInventory(inv).posList.Count; ItemInventory w3 = fd.freeInventory.GetInventoryManager().GetInventory(inv); if (c3 > 0) { ItemPosition ip = w3.posList[0]; w3.RemoveItem(room.FreeArgs, ip); FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey()); if (BagCapacityUtil.CanAddToBag(room.FreeArgs, fd, ip)) { fd.freeInventory.GetInventoryManager().GetDefaultInventory().AddItem(room.FreeArgs, ip.key, true); } else { if (info.cat > 0) { room.RoomContexts.session.entityFactoryObject.SceneObjectEntityFactory.CreateSimpleEquipmentEntity( (ECategory)info.cat, info.id, ip.GetCount(), fd.Player.position.Value); } } } }
public override void DoAction(IEventArgs args) { fr = (FreeRuleEventArgs)args; PlayerEntity playerEntity = (PlayerEntity)fr.GetEntity(player); _playerEntity = playerEntity; if (playerEntity != null) { FreeData fd = (FreeData)playerEntity.freeData.FreeData; _ground = fd.freeInventory.GetInventoryManager().GetInventory(ChickenConstant.BagGround); _ground.Clear(); var bin2Ds = args.GameContext.session.serverSessionObjects.Bin2dManager.GetBin2Ds(); foreach (var bin2DState in bin2Ds) { bin2DState.Bin2D.Retrieve( new Rect(playerEntity.position.Value.x - 100, playerEntity.position.Value.z - 100, 200, 200), onFind); } _ground.GetInventoryUI().ReDraw(fr, _ground, true); } }
public static void UseItem(ItemPosition ip, FreeData fd, FreeRuleEventArgs fr) { if (ip != null) { fr.TempUse(PARA_ITEM, ip.GetKey()); if (ip.GetKey().Effect(fr)) { if (!ip.GetKey().IsGoods()) { if (ip.GetKey().IsUseClose()) { CloseInventory(ip.GetInventory(), fr); } ip.GetInventory().UseItem(fr, ip); if (ip.GetCount() <= 0 && ip.GetKey().IsConsume()) { RemoveUI(ip, fr); } } } fr.Resume(PARA_ITEM); if (!ip.GetKey().IsGoods()) { fd.freeInventory.SetCurrentItem(ip, fr); } ip.GetKey().GetParameters().AddPara(new IntPara(PARA_ITEM_USE_TIME, fr.GameContext.session.currentTimeObject.CurrentTime)); } }
public static void UseItem(string key, FreeData fd, ISkillArgs args) { if (fd.Player.stateInterface.State.GetCurrentPostureState() == PostureInConfig.Climb) { return; } FreeRuleEventArgs fr = (FreeRuleEventArgs)args; ItemPosition ip = GetItemPosition(args, key, fd.freeInventory.GetInventoryManager()); if (ip != null && ip.key.IsConsume() && FreeItemConfig.GetSing(ip.key) > 0) { args.TempUse("current", fd); args.TempUse("item", ip); if (ip.key.CanUse(args)) { FreeItemConfig.UseAnimation(args.GameContext, fd, ip.key.GetKey()); fd.freeInventory.StartUseItem(args, fd, ip, FreeItemConfig.GetSing(ip.key), FreeItemConfig.GetSound(ip.key.GetKey())); } args.Resume("current"); args.Resume("item"); } else { UseItem(ip, fd, fr); } }
private void Reset(FreeData fd) { foreach (PlayerHonorAction.PlayerHonor ph in honors) { fd.GetParameters().AddPara(new BoolPara("is" + StringUtil.GetPascalString(ph.name), false)); } }
public static void UseAnimation(Contexts contexts, FreeData fd, string key) { FreeItemInfo info = GetItemInfo(key); if (info.cat == 13 && (info.id == 103)) { PlayerAnimationAction.DoAnimation(contexts, 0, fd.Player); } if (info.cat == 13 && (info.id == 105)) { PlayerAnimationAction.DoAnimation(contexts, 4, fd.Player); } if (info.cat == 13 && (info.id == 102 || info.id == 104)) { PlayerAnimationAction.DoAnimation(contexts, 1, fd.Player); } if (info.cat == 13 && (info.id == 101)) { PlayerAnimationAction.DoAnimation(contexts, 2, fd.Player); } if (info.cat == 13 && (info.id == 100)) { PlayerAnimationAction.DoAnimation(contexts, 3, fd.Player); } }
private void handleToGround(string from, string to, ServerRoom room, FreeData fd) { if (!from.StartsWith(Ground) && to.StartsWith(Ground)) { FreeItemManager.DragItem(from, fd, room.FreeArgs, Ground); } }
public static void DetachParachute(Contexts contexts, PlayerEntity player) { _logger.InfoFormat("SKyDive : Detach Patachute"); var transform = player.RootGo().transform; var playerSkyMove = player.playerSkyMove; var parachute = playerSkyMove.Parachute; if (parachute != null && player.playerSkyMove.IsParachuteAttached) { player.position.Value = transform.position; transform.parent = parachute.parent; parachute.gameObject.SetActive(false); // playerSkyMove.Parachute = null; // playerSkyMove.ParachuteAnchor = null; // UnityEngine.Object.Destroy(parachute.gameObject); } if (SharedConfig.IsServer) { FreeData fd = (FreeData)player.freeData.FreeData; ItemInventory bag = fd.freeInventory.GetInventoryManager().GetInventory("bag"); if (bag.posList.Count > 0) { ISkillArgs args = (ISkillArgs)contexts.session.commonSession.FreeArgs; args.TempUse("current", fd); bag.RemoveItem(args, bag.posList[0]); args.Resume("current"); } } player.playerSkyMove.IsParachuteAttached = false; }
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"); } }
private static float ReduceDamage(IEventArgs args, FreeData fd, PlayerDamageInfo damage, ItemPosition ip, int percent, ItemType itemType) { if (ip != null) { float realDamage = damage.damage; float reduce = damage.damage * percent / 100; float realReduce = reduce; damage.damage -= realReduce; fd.Player.statisticsData.Statistics.DefenseDamage += reduce; // 普通帽子不减少 if (reduce > 0) { ip.SetCount(ip.GetCount() - (int)realDamage); UpdateGamePlayData(fd, ip, itemType); args.TempUse("current", fd); if (ip.GetCount() <= 0) { ip.GetInventory().RemoveItem((FreeRuleEventArgs)args, ip); FuntionUtil.Call(args, "showBottomTip", "msg", "{desc:10075," + ip.key.GetName() + "}"); } else { ip.GetInventory().GetInventoryUI().UpdateItem((FreeRuleEventArgs)args, ip.GetInventory(), ip); } args.Resume("current"); } } return(damage.damage); }
private void clearPart(ItemInventory inventory, ISkillArgs args, FreeData fd) { if (inventory.name == "w1" || inventory.name == "w2" || inventory.name == "w3") { ShowPartAction show = new ShowPartAction(); show.show = false; show.SetPlayer("current"); show.SetScope(1); if (inventory.name == "w1") { show.weaponKey = "1"; ClearPart(args, fd, 1); } else if (inventory.name == "w2") { show.weaponKey = "2"; ClearPart(args, fd, 2); } else if (inventory.name == "w3") { show.weaponKey = "3"; ClearPart(args, fd, 3); } show.parts = "1,2,3,4,5"; show.Act(args); } }
public static bool CanChangeBag(IEventArgs args, FreeData fd, int cat, int id) { bool can = true; float capacity = GetCapacity(fd); float weight = GetWeight(fd); FreeItemInfo info = FreeItemConfig.GetItemInfo(cat, id); if (cat == (int)ECategory.Avatar) { float oldCap = GetCapacity(fd, cat, id); can = Math.Round(capacity - weight, 3) >= Math.Round(oldCap - info.capacity, 3); } if (!can) { UseCommonAction use = new UseCommonAction(); use.key = "showBottomTip"; use.values = new List <ArgValue>(); use.values.Add(new ArgValue("msg", "{desc:10074}")); args.TempUse("current", fd); use.Act(args); args.Resume("current"); } return(can); }
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 handleFromGround(string from, string to, ServerRoom room, FreeData fd) { if (from.StartsWith(Ground) && !to.StartsWith(Ground)) { SimpleItemInfo info = PickupItemUtil.GetGroundItemInfo(room, fd, from); if (info.cat > 0) { ItemInventory inv = fd.freeInventory.GetInventoryManager().GetInventory("ground"); if (inv != null) { inv.Clear(); FreeItem item = FreeItemManager.GetItem(room.FreeArgs, FreeItemConfig.GetItemKey(info.cat, info.id), info.count); item.GetParameters().AddPara(new IntPara("entityId", info.entityId)); inv.AddItem(room.FreeArgs, item, false); DragGroundOne(fd, room, to); } else { Debug.LogErrorFormat("inventory {0} not existed.", from); } } } }
public override void DoAction(IEventArgs args) { FreeData targetPlayer = ((FreeData)args.GetUnit(this.player)); if (bufs != null) { foreach (FreeBuf buf in bufs) { FreeBuf copy = (FreeBuf)SerializeUtil.Clone(buf); if (targetPlayer != null) { copy.SetCreator(targetPlayer.Player); } if (!copy.OnCreate(args)) { continue; } args.TempUse("buf", copy); try { args.FreeContext.Bufs.AddFreeBuf(copy, args); } catch (Exception e) { Sharpen.Runtime.PrintStackTrace(e); } args.Resume("buf"); } } }
public void StartUseItem(IEventArgs args, FreeData fd, ItemPosition ip, int sing, int sound) { PlayerStateUtil.RemoveGameState(EPlayerGameState.InterruptItem, fd.Player.gamePlay); fd.Player.playerMove.InterruptAutoRun(); SkillTimeTrigger trigger = (SkillTimeTrigger)itemSkill.trigger; trigger.SetTime(sing * 1000); trigger.Reset(); UsingItemAction interAction = (UsingItemAction)trigger.interAction; interAction.fd = fd; interAction.ip = ip; UsingItemAction action = (UsingItemAction)itemSkill.GetEffect(); action.fd = fd; action.ip = ip; StartCounter(args, sing, fd, true); startUse = true; FreeSoundUtil.Stop("use", args, fd); if (sound > 0) { FreeSoundUtil.PlayOnce("use", sound, args, fd); } }
public PlayerValue(FreeData data, double value, bool desc) : base() { this.data = data; this.value = value; this.desc = desc; }
public void Handle(SimpleProto data) { PlayerEntity player = SingletonManager.Get <FreeUiManager>().Contexts1.player.flagSelfEntity; if (player != null) { FreeData fd = (FreeData)player.freeData.FreeData; if (fd != null) { byte[] bs = new byte[data.Ins.Count]; for (int i = 0; i < bs.Length; i++) { bs[i] = (byte)data.Ins[i]; } try { List <ISkill> skills = (List <ISkill>)SerializeUtil.ByteToObject(bs); foreach (var skill in skills) { fd.GetUnitSkill().AddSkill(skill); } }catch (Exception e) { _logger.ErrorFormat("client skill initial failed.\n{0}", e.StackTrace); } } } }
public bool IsInterrupted(ISkillArgs args) { FreeData fd = (FreeData)args.GetUnit("current"); if (fd != null) { if (PlayerStateUtil.HasPlayerState(EPlayerGameState.InterruptItem, fd.Player.gamePlay)) { return(true); } var manager = SingletonManager.Get <StateTransitionConfigManager>(); foreach (EPlayerState state in fd.Player.StateInteractController().GetCurrStates()) { StateTransitionConfigItem condition = manager.GetConditionByState(state); if (condition == null) { continue; } if (!condition.GetTransition(Transition.IsUseItem) /*IsUseItem*/) { return(true); } } return(false); } return(false); }
public override TestValue GetCaseValue(IEventArgs args) { TestValue tv = new TestValue(); FreeData fd = (FreeData)args.GetUnit(UnitTestConstant.Tester); //tv.AddField("动作", fd.Player.state.ActionStateId); //tv.AddField("移动", fd.Player.state.MovementStateId); tv.AddField("动作状态标识", fd.Player.state.ActionStateId); //动作 tv.AddField("动作转换标识", fd.Player.state.ActionTransitionId); tv.AddField("移动状态标识", fd.Player.state.MovementStateId); //移动 tv.AddField("移动转换标识", fd.Player.state.MovementTransitionId); tv.AddField("保持状态标识", fd.Player.state.KeepStateId); tv.AddField("保持转换标识", fd.Player.state.KeepTransitionId); tv.AddField("姿势状态标识", fd.Player.state.PostureStateId); tv.AddField("姿势转换标识", fd.Player.state.PostureTransitionId); tv.AddField("倾斜状态标识", fd.Player.state.LeanStateId); tv.AddField("倾斜转换标识", fd.Player.state.LeanTransitionId); return(tv); }
private static bool FindSomeOne(IEventArgs args, FreeData fd, bool sameTeam, bool wiseFlag) { foreach (PlayerEntity p in args.GameContext.player.GetInitializedPlayerEntities()) { if (CanOb(fd.Player, p)) { if (sameTeam && p.playerInfo.Camp == fd.Player.playerInfo.Camp || !sameTeam && p.playerInfo.Camp != fd.Player.playerInfo.Camp) { if (wiseFlag) { if (p.entityKey.Value.EntityId > fd.Player.gamePlay.CameraEntityId) { fd.Player.gamePlay.CameraEntityId = p.entityKey.Value.EntityId; return(true); } } else { if (p.entityKey.Value.EntityId < fd.Player.gamePlay.CameraEntityId) { fd.Player.gamePlay.CameraEntityId = p.entityKey.Value.EntityId; return(true); } } } } } return(false); }
public override void DoAction(IEventArgs args) { int id = 0; PlayerEntity p = GetPlayerEntity(args); if (p != null) { if (id == 0 && !string.IsNullOrEmpty(target)) { FreeData fd = (FreeData)args.GetUnit(target); if (fd != null) { id = fd.Player.entityKey.Value.EntityId; } if (id == 0) { foreach (FreeMoveEntity freeMoveEntity in args.GameContext.freeMove.GetEntities()) { if (freeMoveEntity.freeData.Key == target) { id = freeMoveEntity.entityKey.Value.EntityId; } } } } p.gamePlay.CameraEntityId = id; } }
public void PlayerPressCmd(Contexts room, PlayerEntity player, IUserCmd cmd) { FreeLog.Reset(); args.input.SetUserCmd(cmd); FreeData freeData = (FreeData)player.freeData.FreeData; if (freeData.Player.gamePlay.LifeState != (int)EPlayerLifeState.Dead) { args.TempUse("current", freeData); args.FreeContext.Bufs.Eat(player, args); freeData.freeInventory.UsingItem(args); //freeData.GetUnitSkill().Frame(args); freeData.StateTimer.AutoRemove(args, serverTime); args.Resume("current"); } FreeLog.Print(); }
protected override void ExecuteUserCmd(PlayerEntity player, IUserCmd cmd) { ISkillArgs args = (ISkillArgs)contexts.session.commonSession.FreeArgs; if (SharedConfig.IsServer) { FreeLog.Reset(); } args.GetInput().SetUserCmd(cmd); if (player.gamePlay.LifeState != (int)EPlayerLifeState.Dead) { FreeData fd = ((FreeData)player.freeData.FreeData); args.TempUse("current", fd); if (cmd.IsPDown) { Debug.LogFormat("p down {0}, is server {1}", cmd.Seq, SharedConfig.IsServer); } fd.GetUnitSkill().Frame(args); args.Resume("current"); } if (SharedConfig.IsServer) { FreeLog.Print(); } }
private static string putOnPart(FreeData fd, int weaponType, FreeItemInfo info, string toInv = "", ServerRoom room = null) { WeaponResConfigItem weapon = GetWeapon(fd, weaponType); if (weapon != null) { foreach (EWeaponPartType part in SingletonManager.Get <WeaponPartsConfigManager>().GetAvaliablePartTypes(weapon.Id)) { int p = FreeWeaponUtil.GetWeaponPart(part); int detailId = WeaponUtil.GetRealAttachmentId(info.id, weapon.Id); if (SingletonManager.Get <WeaponPartsConfigManager>().IsPartMatchWeapon(detailId, weapon.Id)) { if ("p" + p == info.subType) { string inv = "w" + weaponType + p; ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(inv); if (ii != null && (ii.posList.Count == 0 || toInv.StartsWith("w" + weaponType))) { if (ii.posList.Count > 0) { DropPart(inv, fd, room); } return(inv); } } } } } return(null); }
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 static float GetCapacity(FreeData fd, int cat, int id) { foreach (string name in fd.freeInventory.GetInventoryManager().GetInventoryNames()) { if (name != ChickenConstant.BagGround) { ItemInventory ii = fd.freeInventory.GetInventoryManager().GetInventory(name); if (ii != null) { foreach (ItemPosition ip in ii.GetItems()) { FreeItemInfo currentInfo = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey()); if (currentInfo.cat == (int)ECategory.Avatar && cat == (int)ECategory.Avatar) { RoleAvatarConfigItem avatar1 = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(currentInfo.id); RoleAvatarConfigItem avatar2 = SingletonManager.Get <RoleAvatarConfigManager>().GetConfigById(id); if (avatar1.Type == avatar2.Type) { return(avatar1.Capacity); } } } } } } return(0); }
public void ReDraw(ISkillArgs args, ItemInventory inventory, bool includeBack) { SimpleProto sp = FreePool.Allocate(); sp.Key = FreeMessageConstant.InventoyUI; // 0 重绘,1 添加,2 删除, 3 更新 sp.Ks.Add(0); sp.Bs.Add(true); sp.Ks.Add(inventory.posList.Count); foreach (ItemPosition ip in inventory.posList) { FreeItemInfo info = FreeItemConfig.GetItemInfo(ip.GetKey().GetKey()); sp.Ins.Add(info.cat); sp.Ins.Add(info.id); sp.Ins.Add(ip.GetCount()); sp.Ss.Add(inventory.GetName() + "," + ip.GetX() + "," + ip.GetY()); } FreeData fd = (FreeData)args.GetUnit("current"); sp.Ks.Add((int)BagCapacityUtil.GetCapacity(fd)); sp.Ks.Add((int)Math.Ceiling(BagCapacityUtil.GetWeight(fd))); SendMessageAction.sender.SendMessage(args, sp, 1, "current"); ChickenFuncUtil.UpdateBagCapacity(args, (int)Math.Ceiling(BagCapacityUtil.GetWeight(fd)), BagCapacityUtil.GetCapacity(fd)); }