Beispiel #1
0
 bool NextNavNode()
 {
     if (mWayPoints != null && mWayPoints.Count > 0)
     {
         PathFind.Waypoint mNode = mWayPoints.First <PathFind.Waypoint>();
         mWayPoints.Remove(mNode);
         MoveTo(new Vector2(mNode.X, mNode.Y));
         return(false);
     }
     else
     {
         mWayPoints = null;
         return(true);
     }
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetButtonDown("Fire1"))
     {
         GameObject[,]   tMap = LevelManager.GetComponent <LevelManager> ().Map;
         Vector3 position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
         int     tX       = Mathf.RoundToInt(position.x);
         int     tY       = Mathf.RoundToInt(position.y);
         Target.transform.position = new Vector3(tX, tY, 0);
         PathFind.Waypoint tFrom = new PathFind.Waypoint(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y));
         PathFind.Waypoint tTo   = new PathFind.Waypoint(tX, tY);
         mWayPoints = mPathFind.Find(tFrom,
                                     tTo,
                                     tMap,
                                     true); //Debug on
         NextNavNode();
     }
 }
Beispiel #3
0
 // Update is called once per frame
 void Update()
 {
     if (Player)
     {
         sTimeout -= Time.deltaTime;
         if (sTimeout <= 0.0f)
         {
             mMap     = LevelManager.GetComponent <LevelManager> ().Map;
             sTimeout = UnityEngine.Random.Range(1, 7);
             PathFind.Waypoint tFrom = new PathFind.Waypoint(Mathf.RoundToInt(transform.position.x), Mathf.RoundToInt(transform.position.y));
             PathFind.Waypoint tTo   = new PathFind.Waypoint(Mathf.RoundToInt(Player.transform.position.x), Mathf.RoundToInt(Player.transform.position.y));
             mWayPoints = mPathFind.Find(tFrom,
                                         tTo,
                                         mMap);
             NextNavNode();
         }
     }
 }