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); } }
public virtual bool Effect(ISkillArgs args) { if (isGoods) { args.TempUse("item", this); if (buyAction != null) { buyAction.Act(args); } args.Resume("item"); return(true); } if (condition == null || condition.Meet(args)) { if (clickSkill != null && args != null) { args.TempUse("item", this); this.clickSkill.Frame(args); args.Resume("item"); } return(true); } else { if (condition != null && !condition.Meet(args)) { if (notReadyAction != null) { notReadyAction.Act(args); } } } return(false); }
private void RealEat(PlayerEntity player, ISkillArgs skill) { if (!this.disable && (bufCondition == null || bufCondition.Meet(skill))) { ShowEffect(skill, player); skill.TempUse("buf", this); if (creator != null) { skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData); } pos.SetX(player.position.Value.x); pos.SetY(player.position.Value.y); pos.SetZ(player.position.Value.z); if (region.In(skill, pos)) { if (!ins.Contains(player.playerInfo.PlayerId)) { if (enterAction != null) { enterAction.Act(skill); } ins.Add(player.playerInfo.PlayerId); } if (trigger == null || trigger.Triggered(skill) == ISkillTrigger.TriggerStatus.Success) { if (eatAction != null) { eatAction.Act(skill); if (consume) { skill.FreeContext.Bufs.RemoveBuf(skill, this.realKey); } } } } else { if (ins.Contains(player.playerInfo.PlayerId)) { if (leaveAction != null) { leaveAction.Act(skill); } ins.Remove(player.playerInfo.PlayerId); } } if (creator != null) { skill.Resume("creator"); } skill.Resume("buf"); } }
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; }
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 bool AddNewItem(ISkillArgs args, FreeItem item, bool useMove) { for (int i = 0; i <= row - item.GetGridHeight(); i++) { for (int j = 0; j <= column - item.GetGridWidth(); j++) { bool filled = false; for (int ii = i; ii < i + item.GetGridHeight(); ii++) { for (int jj = j; jj < j + item.GetGridWidth(); jj++) { if (ins[ii][jj]) { filled = true; } } } if (!filled) { ItemPosition ip = new ItemPosition(item, j, i); ip.inventory = this; posList.Add(ip); for (int ii_1 = i; ii_1 < i + item.GetGridHeight(); ii_1++) { for (int jj = j; jj < j + item.GetGridWidth(); jj++) { ins[ii_1][jj] = true; } } if (inventoryUI != null && args != null) { inventoryUI.AddItem(args, this, ip); } //if ("default".Equals(name)) //{ args.TempUsePara(new StringPara("inventory", name)); item.Added(args); if (inventoryUI != null && inventoryUI.MoveAction != null && useMove) { args.TempUsePara(new StringPara("to", this.name)); args.TempUse("item", ip); inventoryUI.MoveAction.Act(args); args.Resume("item"); args.ResumePara("to"); } args.ResumePara("inventory"); //} return(true); } } } if (inventoryUI != null) { inventoryUI.Error(args, this, "物品栏已满"); } return(false); }
public virtual void Removed(ISkillArgs args) { if (removeAction != null && args != null) { args.TempUse("item", this); removeAction.Act(args); args.Resume("item"); } }
public virtual void Added(ISkillArgs args) { if (addAction != null && args != null) { args.TempUse("item", this); addAction.Act(args); args.Resume("item"); } }
public virtual void Created(ISkillArgs args) { if (createAction != null && args != null) { args.TempUse("item", this); createAction.Act(args); args.Resume("item"); } }
public virtual void CheckTimeOut(ISkillArgs skill) { if (realTime > 0 && skill.Rule.ServerTime - startTime >= realTime) { if (timeOutAction != null) { skill.TempUse("buf", this); timeOutAction.Act(skill); skill.Resume("buf"); } } skill.FreeContext.Bufs.RemoveBuf(skill, this.realKey); }
public static void UseItem(string key, FreeData fd, ISkillArgs args) { 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; } } 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); } }
public void UsingItem(ISkillArgs args, FreeData fd) { if (startUse) { if (itemSkill.inter != null && itemSkill.inter.IsInterrupted(args)) { args.TempUse("item", currentItem); itemSkill.interAction.Act(args); StopUseItem(args, fd, true); args.Resume("item"); return; } itemSkill.Frame(args); } }
public void Update(IPlayerWeaponState playerWeapon, IUserCmd cmd) { if (SharedConfig.IsServer) { if (!_unitSkill.IsEmtpy()) { _freeArgs.GetInput().SetUserCmd(cmd); _freeArgs.TempUse("current", (FreeData)playerWeapon.FreeData); _unitSkill.Frame(_freeArgs); _freeArgs.Resume("current"); } } }
public void Update(EntityKey owner, IUserCmd cmd, Contexts contexts) { if (SharedConfig.IsServer) { if (!_unitSkill.IsEmtpy()) { _freeArgs.GetInput().SetUserCmd(cmd); _freeArgs.TempUse("current", owner.WeaponController().RelatedFreeData); _unitSkill.Frame(_freeArgs); _freeArgs.Resume("current"); } } }
private void UseItem(ItemPosition ip, FreeData fd, ISkillArgs fr) { if (ip != null) { fr.TempUse("item", ip.GetKey()); if (ip.GetKey().Effect(fr)) { ip.GetInventory().UseItem(fr, ip); } fr.Resume("item"); if (!ip.GetKey().IsGoods()) { fd.freeInventory.SetCurrentItem(ip, fr); } } }
public void Update(PlayerWeaponController controller, IUserCmd cmd) { if (SharedConfig.IsServer) { if (!_unitSkill.IsEmtpy()) { _freeArgs.GetInput().SetUserCmd(cmd); _freeArgs.TempUse("current", controller.RelatedFreeData); _unitSkill.Frame(_freeArgs); _freeArgs.Resume("current"); } } }
public virtual void RemoveItem(ISkillArgs args, ItemPosition ip) { ip.key.Removed(args); RemoveItemPosition(ip); if (inventoryUI != null) { inventoryUI.DeleteItem(args, this, ip); } if (inventoryUI != null && inventoryUI.MoveAction != null) { args.TempUsePara(new StringPara("from", this.name)); args.TempUse("item", ip); inventoryUI.MoveAction.Act(args); args.ResumePara("from"); args.Resume("item"); } }
private void RealEat(PlayerEntity player, ISkillArgs skill) { if (!this.disable && (bufCondition == null || bufCondition.Meet(skill))) { ShowEffect(skill, player); skill.TempUse("buf", this); if (creator != null) { skill.TempUse("creator", (FreeData)this.creator.freeData.FreeData); } pos.SetX(player.position.Value.x); pos.SetY(player.position.Value.y); pos.SetZ(player.position.Value.z); if (region.In(skill, pos)) { if (!ins.Contains(player.playerInfo.PlayerId)) { if (enterAction != null) { enterAction.Act(skill); } ins.Add(player.playerInfo.PlayerId); } if (trigger == null || trigger.Triggered(skill) == ISkillTrigger.TriggerStatus.Success) { if (eatAction != null) { // record parentkey IPosSelector posCenter = GetPos(region.GetCenter(skill)); skill.GetDefault().GetParameters().TempUse(new IntPara("posindex", posCenter.Select(skill).GetRandomindex())); eatAction.Act(skill); skill.GetDefault().GetParameters().RemovePara("posindex"); // handle if (posindex >= 0) { skill.GetDefault().GetParameters().TempUse(new IntPara("resetpos", posindex)); skill.Triggers.Trigger(FreeTriggerConstant.PLAYER_EAT_BUF, skill); skill.GetDefault().GetParameters().RemovePara("resetpos"); } if (consume) { skill.FreeContext.Bufs.RemoveBuf(skill, this.realKey); } } } } else { if (ins.Contains(player.playerInfo.PlayerId)) { if (leaveAction != null) { leaveAction.Act(skill); } ins.Remove(player.playerInfo.PlayerId); } } if (creator != null) { skill.Resume("creator"); } skill.Resume("buf"); } }