Beispiel #1
0
        // Use this for initialization
        void Start()
        {
            character = GetComponent <Character>();
            ai        = GetComponent <AICharacterControl>();

            List <AIAction> extras = new List <AIAction>();
            Patrolling      patrol = GetComponent <Patrolling>();

            if (patrol)
            {
                extras.Add(ScriptableObject.CreateInstance <AIPatrol>());
            }

            int numActions = behaviours.Length + extras.Count;

            // set up a suitable rootnode, either a single power, or a group of them which compete!
            if (numActions == 0)
            {
                rootNode = null;
            }
            else if (numActions == 1)
            {
                if (behaviours.Length > 0)
                {
                    rootNode = behaviours[0].MakeInstance();
                }
                else
                {
                    rootNode = extras[0].MakeInstance();
                }
            }
            else
            {
                AIAction[] actions = new AIAction[numActions];
                for (int i = 0; i < behaviours.Length; i++)
                {
                    actions[i] = behaviours[i].MakeInstance();
                }
                for (int i = 0; i < extras.Count; i++)
                {
                    actions[i + behaviours.Length] = extras[i].MakeInstance();
                }

                AINodeEvaluate evalNode = ScriptableObject.CreateInstance <AINodeEvaluate>();
                evalNode.behaviours = actions;
                rootNode            = evalNode;
            }
            patrolling = GetComponent <Patrolling>();
        }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     ai = GetComponent <AICharacterControl>();
     ch = GetComponent <Character>();
 }