Esempio n. 1
0
    void Update()
    {
        //gravity
        controller.Move(new Vector3(0f, -gravity * Time.deltaTime, 0f));

        //follow path
        if (seek)
        {
            if (!(currentWaypoint > waypoints.Count - 1))
            {
                target = waypoints[currentWaypoint];
                Vector3 offset = (target - transform.position);
                offset.y = 0;
                controller.Move((offset.normalized * moveSpeed) * Time.deltaTime);
                if (offset.magnitude < satisfactionRadius)
                {
                    currentWaypoint++;
                    location = new orderedPair(Mathf.RoundToInt(target.x), Mathf.RoundToInt(target.z));
                }
            }
            else
            {
                seek     = false;
                location = new orderedPair(Mathf.RoundToInt(target.x), Mathf.RoundToInt(target.z));
            }
        }

        xPos = location.x;
        yPos = location.y;
    }
Esempio n. 2
0
 public node(orderedPair inputLocation, bool inputTraversable, node inputFrom, int inputCost)
 {
     location    = inputLocation;
     traversable = inputTraversable;
     from        = inputFrom;
     cost        = inputCost;
 }
Esempio n. 3
0
    /*
     * public List<node> graph = new List<node>();
     * public List<node> open = new List<node>();
     * public List<node> closed = new List<node>();
     * public List<node> path = new List<node>();
     */

    void Start()
    {
        controller = GetComponent <CharacterController> ();
        location   = new orderedPair(0, 0);
        //foreach(tile tile in tileGenerator.tiles){
        //	graph.Add (new node(new orderedPair(tile.x, tile.y), tile.isObstacle));
        //}
    }
Esempio n. 4
0
 public node(orderedPair inputLocation, bool inputTraversable)
 {
     location    = inputLocation;
     traversable = inputTraversable;
 }