コード例 #1
0
ファイル: StopAbility.cs プロジェクト: TopKekstar/IAV
        public override TaskStatus OnUpdate()
        {
            var target = GetDefaultGameObject(targetGameObject.Value);

            if (target != prevTarget)
            {
                controller        = target.GetComponentInParent <RigidbodyCharacterController>();
                controllerHandler = target.GetComponentInParent <ControllerHandler>();
                var abilities = controller.GetComponents(TaskUtility.GetTypeWithinAssembly(abilityType.Value));
                if (abilities.Length > 1)
                {
                    if (priorityIndex.Value != -1)
                    {
                        for (int i = 0; i < abilities.Length; ++i)
                        {
                            var localAbility = abilities[i] as Ability;
                            if (localAbility.Index == priorityIndex.Value)
                            {
                                ability = localAbility;
                                break;
                            }
                        }
                    }
                    else
                    {
                        ability = abilities[0] as Ability;
                    }
                }
                else if (abilities.Length == 1)
                {
                    ability = abilities[0] as Ability;
                }
                prevTarget = target;
            }
            if (ability == null)
            {
                return(TaskStatus.Failure);
            }

            controllerHandler.TryStopAbility(ability);
            return(TaskStatus.Success);
        }