public override void DoAction()
    {
        //Conseguimos el camino de A* y ademas lo hacemos mejor con SmoothPath
        Vector3[] newPath = smoothPath.Smooth(aStar.GetPath());

        //Le damos el nuevo camino a follow
        follow.UpdatePath(newPath);
    }
예제 #2
0
    //Funcion que actualiza a cual pokemon seguiremos y reestructura A* adecuadamente
    void UpdatePath()
    {
        pokemonPosition = pokemons[currentPokemon].transform.position;
        //actualizamos el a start
        aStar.goal  = graph.FindNode(pokemonPosition, walkable);
        aStar.start = graph.FindNode(transform.position, walkable);
        //generamos nuevo camino
        currentPath = aStar.GetPath();
        utilities.DrawPath(currentPath, 40f);

        indexPath = 0;
    }
예제 #3
0
    void Start()
    {
        //POKEMONES
        pokemons = GameObject.FindGameObjectsWithTag("Pokemon");

        for (int i = 0; i < pokemons.Length; i++)//le sacamos todos los kinetics a los pokes
        {
            kinsList.Add(pokemons[i].GetComponent <static_data>().kineticsAgent);
        }

        pokemonKins   = kinsList.ToArray();
        amountPokemon = pokemons.Length;

        //TRAINER
        kineticsAgent = agent.kineticsAgent;
        steeringAgent = agent.steeringAgent;


        //Inicializamos movimiento (no es necesario pasar el pokemon porque lo haremos por posicion)
        seek = new Seek(kineticsAgent, kineticsAgent, maxAccel);

        //Inicializamos grafo y A*


        graph           = graphComponent.graph;
        pokemonPosition = pokemonKins[0].transform.position;

        walkable = new string[] { "Earth" };                       //sobre que podemos movernos

        Node start = graph.FindNode(transform.position, walkable); //buscamos el triangulos con nuestra posicion actual
        Node goal  = graph.FindNode(pokemonPosition, walkable);    //buscamos el triangulo donde esta el primer pokemon

        if (goal is null)                                          //si no hay un triangulo para el goal vamos a donde estamos parados
        {
            goal = start;
        }
        Euclidean euclidean = new Euclidean(goal);

        aStar         = new PathFindAStar(graph, start, goal, euclidean, walkable);
        currentPath   = aStar.GetPath();
        currentTarget = currentPath[0];
        utilities.DrawPath(currentPath, 40f);
    }