Пример #1
0
    // Update is called once per frame
    void Update()
    {
        timer += Time.deltaTime;
        //loop through the characters, update their status (ie senses, poi, etc)
        //if the character is not reaching a goal, then wipe it's search state clean

        //loop through chatacters again and do behavior.Updatea

        //finally, pass in array of characters to pathfinding scheduler and let it do its thing

        for (int i = 0; i < numChars; i++)
        {
            GameObject      currChar = characters.transform.GetChild(i).gameObject;
            MasterBehaviour mb       = behaviourScripts[i];
            updateStatus(currChar, mb);
            mb.Updatea();
            bool contained    = pathFindingChars.Contains(currChar);
            bool findingAPath = mb.isReachingGoal();
            if (findingAPath && !contained)
            {
                LinkedListNode <GameObject> c = new LinkedListNode <GameObject>(currChar);
                pathFindingChars.AddLast(c);
                if (currCharForPath == null)
                {
                    currCharForPath = c;
                }
            }
            else if (!findingAPath && contained)
            {
                if (currCharForPath != null && (currChar.name == currCharForPath.Value.name))
                {
                    currCharForPath = currCharForPath.Next;
                }
                pathFindingChars.Remove(currChar);                 //not sure if it finds the actualy character though
                //if we're doing continue search thing, need to reinit the characters search state
            }
        }

//		//perform the behaviors now that their staus is updated
//		for (int j = 0; j < numChars; j++) {
//			behaviourScripts[j].Updatea();
//		}

        pathfinder.characters   = pathFindingChars;
        pathfinder.currCharNode = currCharForPath;
        //do pathfinding stuff
        pathfinder.Updatea();
        if (currCharForPath != null)
        {
            currCharForPath = currCharForPath.Next;
        }
        if (currCharForPath == null)
        {
            currCharForPath = pathFindingChars.First;
        }
    }