コード例 #1
0
        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);
            }
        }
コード例 #2
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);
            }
        }