Ejemplo n.º 1
0
    private void OnReachDest()
    {
        switch (currentMode)
        {
        case Mode.drop:
            hero.Drop(hero.currentNode);
            break;

        case Mode.pickup:
            break;

        default:
            break;
        }

        currentPath = null;
        hero.Stop();

        if (onDestinationReached != null)
        {
            Action theAction = onDestinationReached;
            onDestinationReached = null;
            theAction();
        }
        //print("On est arrivé, on clear le path et on stop le héro");
    }
Ejemplo n.º 2
0
    private PathOfDoom Reconstruct_path(Node[] cameFrom, Node current)
    {
        PathOfDoom total_path = new PathOfDoom();

        while (current != null)
        {
            total_path.nodes.Add(current);
            current = cameFrom[current.index];
        }
        return(total_path);
    }
Ejemplo n.º 3
0
    public void GoToNode(Node destination, Mode mode = Mode.pickup, Action onReached = null)
    {
        onDestinationReached = onReached;
        currentMode          = mode;

        //Meme chemin
        if (currentPath != null && destination == currentPath.GetDestination())
        {
            return;
        }

        if (state.IsInTransition())
        {
            if (destination == state.transition.to)
            {
                //On va deja a la bonne place, on arrete la
                ClearPath();
                return;
            }
            else if (destination == state.transition.from)
            {
                //On reviens sur nos pas et on arrete la
                state.transition.Flip();
                hero.SetNode(state.transition.to);
                ClearPath();
                return;
            }
        }
        else
        {
            if (state.stayNode == destination)
            {
                OnReachDest();
                return;
            }
        }

        currentPath = Game.Fastar.CalculatePath(state.GetNextOrStayNode(), destination);

        if (state.IsInTransition())
        {
            //Shit ! Go back !
            if (currentPath.Get2ndClosest() == state.transition.from)
            {
                OnCompleteTransition();
            }
        }
        else
        {
            PerformNextSegment();
        }
    }
Ejemplo n.º 4
0
 public void ClearPath()
 {
     currentPath = null;
 }