コード例 #1
0
 void updatePlayerLocation()
 {
     if (gameObject != null || gameObject.activeInHierarchy)
     {
         this.directionsToPlayer = tileAutomata.getShortestPath(transform.position.x, transform.position.y, lastKnownPlayerLocation.x, lastKnownPlayerLocation.y);
         Debug.Log("Human = " + string.Join("",
                                            new List <Vector2>(directionsToPlayer)
                                            .ConvertAll(i => i.ToString())
                                            .ToArray()));
         currentDestination = Vector3.zero;
         Debug.Log("Reset timer");
     }
     else
     {
         timer.Pause();
     }
 }
コード例 #2
0
 void Start()
 {
     mPlayerObject = GameObject.FindGameObjectWithTag("Player");
     tileAutomata  = GameObject.FindGameObjectWithTag("TileAutomata").GetComponent <TileAutomata>();
     if (mPlayerObject != null)
     {
         lastKnownPlayerLocation = mPlayerObject.transform.position;
     }
     if (directionsToPlayer == null && mPlayerObject != null)
     {
         this.directionsToPlayer = tileAutomata.getShortestPath(transform.position.x, transform.position.y, mPlayerObject.transform.position.x, mPlayerObject.transform.position.y);
     }
     timer = Timer.Register(2f, () => updatePlayerLocation(), isLooped: true);
     //Debug.Log(tileAutomata.name);
     m_Animator = GetComponent <Animator>();
 }