Esempio n. 1
0
 /// <summary>
 ///   generate a random position inside left and right boundaries of the screen
 /// </summary>
 Vector3 SpawnPosition(ISize item)
 {
     for (int i = 0; i < 10; ++i)
     {
         float x_pos = UnityEngine.Random.Range(-1.0f, 1.0f) * waveSpawnXOffset;
         if (x_pos + (item.GetWidth() / 2) < ScreenUtils.ScreenRight && x_pos - (item.GetWidth() / 2) > ScreenUtils.ScreenLeft)
         {
             return(new Vector3(x_pos, 0, ScreenUtils.ScreenTop + item.GetHeight()));
         }
     }
     return(Vector3.zero);
 }
Esempio n. 2
0
 void KeepInsideScreen()
 {
     _rb.position = new Vector3(
         Mathf.Clamp(_rb.position.x, ScreenUtils.ScreenLeft + (_size.GetWidth() / 2), ScreenUtils.ScreenRight - (_size.GetWidth() / 2)),
         _rb.position.y,
         _rb.position.z
         );
 }