Example #1
0
        public static Vector2 EnsurePositionInScreenBoundaries(this Transform transform, Vector2 pos)
        {
            var cameraBoundaryX = ScreenHelper.GetOrthographicXRate() - transform.localScale.x / 2;
            var cameraBoundaryY = Camera.main.orthographicSize - transform.localScale.y / 2;

            pos.x = Mathf.Clamp(pos.x, cameraBoundaryX * -1, cameraBoundaryX);
            pos.y = Mathf.Clamp(pos.y, cameraBoundaryY * -1, cameraBoundaryY);
            return(pos);
        }
Example #2
0
 private GameObject CreateEnemy(EnemyWaveSet set)
 {
     if (_difficultyManager.CanCreateEnemy(set.Mode))
     {
         _difficultyManager.NotifyEnemyTypeSelected(set.EnemyType, set.Mode);
         var position = ScreenHelper.GetRandomScreenPoint(y: _defaultSpawnPoint.transform.position.y);
         return(_enemyFactory.Create(set.EnemyType, position));
     }
     return(null);
 }