Beispiel #1
0
 void UpdateMoving()
 {
     bMoving = false;
     for (int x = 0; x < xIndex; ++x)
     {
         for (int y = 0; y < yIndex; ++y)
         {
             TileScript tileScript = tiles[x, y].GetComponent <TileScript>();
             Vector2    vDest      = tileScript.GetDest();
             if (vDest.x != -999 && vDest.y != -999)
             {
                 Vector2 vNowPos = tiles[x, y].transform.localPosition;
                 if (Mathf.Abs(vDest.x - vNowPos.x) < 0.01 && Mathf.Abs(vDest.y - vNowPos.y) < 0.01)
                 {
                     tileScript.SetDest(-999, -999);
                     continue;
                 }
                 Vector2 vDelta = vDest - vNowPos;
                 float   fSpd   = tileScript.GetSpeed();
                 vNowPos.x = vNowPos.x + fSpd * vDelta.x;
                 vNowPos.y = vNowPos.y + fSpd * vDelta.y;
                 tiles[x, y].transform.localPosition = vNowPos;
                 bMoving = true;
             }
         }
     }
 }