Beispiel #1
0
    public IEnumerator MovePartyTo()
    {
        // select a random node from current node's neighbour
        currentNode.partyList.Remove(this);
        WM_Node        chosenNode;
        List <WM_Node> possibleNodes = new List <WM_Node>();

        for (int i = 0; i < currentNode.neighbours.Count; i++)
        {
            if (currentNode.neighbours[i].faction == faction)
            {
                possibleNodes.Add(currentNode.neighbours[i]);
            }
        }

        if (possibleNodes.Count > 0)
        {
            chosenNode = possibleNodes[Random.Range(0, possibleNodes.Count)];
        }
        else
        {
            chosenNode = currentNode.neighbours[Random.Range(0, currentNode.neighbours.Count)];
        }
        yield return(SetDestination(chosenNode));

        currentNode = chosenNode;
        currentNode.partyList.Add(this);
        UpdatePosOnNode(currentNode.PartyPositionOnNode(this));
        yield return(null);
    }
Beispiel #2
0
    public IEnumerator MovePartyTo(WM_Node endNode)
    {
        currentNode.partyList.Remove(this);

        //Debug.Log("MovePartyTo " + path[i].gameObject.name);
        yield return(SetDestination(endNode));

        currentNode = endNode;

        currentNode.partyList.Add(this);
        UpdatePosOnNode(currentNode.PartyPositionOnNode(this));
        yield return(null);
    }