Пример #1
0
        public override AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember)
        {
            lastRunningNode = null;
            for (; index < Childs.Count; index++)
            {
                AINode       node    = Childs[index];
                AINodeResult nResult = node.Run(ref lastRunningNode, aiMember);

                if (nResult == AINodeResult.Failure)
                {
                    continue;
                }

                if (nResult == AINodeResult.Success)
                {
                    index = 0;
                    return(AINodeResult.Success);
                }

                if (nResult == AINodeResult.Running)
                {
                    lastRunningNode = node;
                    return(AINodeResult.Running);
                }
            }

            index = 0;
            return(AINodeResult.Failure);
        }
Пример #2
0
        public AINodeResult Run(ref AINode lastRunningNode, AIMember aiMember)
        {
            AINodeResult result = Execute(ref lastRunningNode, aiMember);

            ResultState = result;
            return(result);
        }
Пример #3
0
 public override AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember)
 {
     if (!string.IsNullOrEmpty(_print))
     {
         Debug.LogFormat("[PrintAction] {0}", _print);
     }
     return(AINodeResult.Failure);
 }
Пример #4
0
        public override AINodeContainer AddChild(AINode node)
        {
            if (Childs.Count > 0)
            {
                Debug.LogErrorFormat("[Condition][AddChild] Have it already. ");
            }

            return(base.AddChild(node));
        }
Пример #5
0
        private AINodeResult RunTrueNode(ref AINode lastRunningNode, AIMember aiMember)
        {
            AINodeResult nResult = TrueNode.Run(ref lastRunningNode, aiMember);

            if (nResult == AINodeResult.Running)
            {
                _trueNodeInRunning = true;
                lastRunningNode    = TrueNode;
                return(AINodeResult.Running);
            }

            return(nResult);
        }
Пример #6
0
        public override AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember)
        {
            if (_trueNodeInRunning)
            {
                _trueNodeInRunning = false;
                return(RunTrueNode(ref lastRunningNode, aiMember));
            }

            if (_conditionFunc() == false)
            {
                return(AINodeResult.Failure);
            }

            if (TrueNode == null)
            {
                return(AINodeResult.Success);
            }
            else
            {
                return(RunTrueNode(ref lastRunningNode, aiMember));
            }
        }
Пример #7
0
 public override AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember)
 {
     Debug.LogFormat("[PrintAction] {0}", _print);
     return(AINodeResult.Success);
 }
Пример #8
0
 /// <summary>
 /// Child Need Call
 /// </summary>
 /// <param name="aiNode"></param>
 public void OnGetInstance(AINode aiNode)
 {
     aiNode.OnResult += OnResult;
 }
Пример #9
0
 public override AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember)
 {
     _setValAction();
     return(AINodeResult.Success);
 }
Пример #10
0
 public virtual AINodeContainer AddChild(AINode node)
 {
     node.Parent = this;
     _childs.Add(node);
     return(this);
 }
Пример #11
0
 public abstract AINodeResult Execute(ref AINode lastRunningNode, AIMember aiMember);
Пример #12
0
        private static void SearchAndSetChild(Transform t, AINodeContainer composite, AIMember aiMember)
        {
            foreach (Transform child in t)
            {
                AINode node = null;

                SelectMono selectMono = child.GetComponent <SelectMono>();
                if (selectMono != null)
                {
                    node = selectMono.Create();
                }

                SequeterMono sequterMono = child.GetComponent <SequeterMono>();
                if (sequterMono != null)
                {
                    node = sequterMono.Create();
                }

                ConditionMono conditionMono = child.GetComponent <ConditionMono>();
                if (conditionMono != null)
                {
                    if (conditionMono is WhileConditionMono)
                    {
                        WhileConditionMono wCondition = conditionMono as WhileConditionMono;
                        node = wCondition.Create(aiMember);
                    }
                    else
                    {
                        node = conditionMono.Create(aiMember);
                    }
                }

                PrintActionMono printMono = child.GetComponent <PrintActionMono>();
                if (printMono != null)
                {
                    node = printMono.Create();
                }

                DelayActionMono delayMono = child.GetComponent <DelayActionMono>();
                if (delayMono != null)
                {
                    node = delayMono.Create();
                }

                SetValActionMono setValMono = child.GetComponent <SetValActionMono>();
                if (setValMono != null)
                {
                    node = setValMono.Create(aiMember);
                }

                #region AGAction
                CustomAiNodeMono customMono = child.GetComponent <CustomAiNodeMono>();
                if (customMono != null)
                {
                    node = customMono.Create();
                }
                MonsterSwitchNavNodeMono monsterNavMono = child.GetComponent <MonsterSwitchNavNodeMono>();
                if (monsterNavMono != null)
                {
                    node = monsterNavMono.Create();
                }
                ShootBulletNodeMono shootMono = child.GetComponent <ShootBulletNodeMono>();
                if (shootMono != null)
                {
                    node = shootMono.Create();
                }
                MonsterAtkNodeMono monsterAtkMono = child.GetComponent <MonsterAtkNodeMono>();
                if (monsterAtkMono != null)
                {
                    node = monsterAtkMono.Create();
                }

                #endregion
                composite.AddChild(node);
                if (node is AINodeContainer)
                {
                    AINodeContainer nodeC = node as AINodeContainer;
                    SearchAndSetChild(child.transform, nodeC, aiMember);
                }
            }
        }