コード例 #1
0
 void MoveToObject()
 {
     if (_movingToResource || _movingToTown || _movingToFactory || _movingToHarbour)
     {
         float distance = Vector3.Distance(transform.position, _objectPos);
         if (distance <= _range)
         {
             if (_movingToResource)
             {
                 _resourceScript.Activate();
                 _movingToResource = false;
             }
             else if (_movingToFactory)
             {
                 _factoryScript.EnableFactory();
                 _movingToFactory = false;
             }
             else if (_movingToHarbour)
             {
                 _endGame.OpenCanvas();
                 _movingToHarbour = false;
             }
             else
             {
                 _townCanvas._townManager._visited = true;
                 _townCanvas.OpenCanvas();
                 _agent.SetDestination(transform.position);
                 _agent.Stop();
                 _movingToTown = false;
             }
             _agent.SetDestination(transform.position);
             _agent.ResetPath();
         }
     }
 }