示例#1
0
        public bool Meet(IEventArgs args)
        {
            FreeData fd = (FreeData)args.GetUnit(player);

            if (fd != null)
            {
                if (fd.Player.stateInterface.State.GetNextActionKeepState() == ActionKeepInConfig.Sight)
                {
                    return(false);
                }
                var states  = fd.Player.StateInteractController().GetCurrStates();
                var manager = SingletonManager.Get <StateTransitionConfigManager>();
                foreach (var state in states)
                {
                    StateTransitionConfigItem condition = manager.GetConditionByState(state);
                    if (condition == null)
                    {
                        continue;
                    }
                    if (!condition.GetTransition(Transition.IsUseAction) /*IsUseAction*/)
                    {
                        return(false);
                    }
                }
                return(fd.Player.hasRaycastTarget && fd.Player.raycastTarget.Key == key);
            }
            return(false);
        }
示例#2
0
        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);
        }
示例#3
0
        protected bool IsUseActionEnabled()
        {
            var player  = _playerContext.flagSelfEntity;
            var states  = player.StateInteractController().GetCurrStates();
            var manager = SingletonManager.Get <StateTransitionConfigManager>();

            foreach (var state in states)
            {
                StateTransitionConfigItem condition = manager.GetConditionByState(state);
                if (condition == null)
                {
                    continue;
                }
                if (!condition.GetTransition(Transition.IsUseAction) /*IsUseAction*/)
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.DebugFormat("use action is limited by {0}", condition.State);
                    }
                    return(false);
                }
                else
                {
                    if (Logger.IsDebugEnabled)
                    {
                        Logger.DebugFormat("use action is allowed by {0}", condition.State);
                    }
                }
            }
            return(true);
        }
示例#4
0
        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);
            }
        }