private void Awake() { enemySpawnPosition = Vector3.zero; enemies = new List <GameObject>(); waiter = FindObjectOfType <Waiter>(); borderDetector = FindObjectOfType <ScreenBorderDetector>(); enemyTypes = System.Enum.GetValues(typeof(EnemyType)); }
private void Awake() { // Initialize rb = GetComponent <Rigidbody2D>(); collider = GetComponent <BoxCollider2D>(); playerShooter = GetComponent <PlayerShots>(); defaultColliderSize = collider.size; screenBorderDetector = FindObjectOfType <ScreenBorderDetector>(); GameManager.Instance.PlayerSpawned(this.gameObject); }
/// <summary> /// Checks if the position is out of bounds /// </summary> /// <param name="position">The position to check</param> /// <param name="offset">The offset after the end of the screen</param> /// <returns>If the position is out of bounds</returns> public bool IsOutOfBoundsCheck(Vector3 position, float offset = 0.1f) { latestBorderDetector = latestBorderDetector != null ? latestBorderDetector : FindObjectOfType <ScreenBorderDetector>(); if (latestBorderDetector == null) { return(false); } float x = position.x; float y = position.y; float xl = latestBorderDetector.leftBorder - offset; float xr = latestBorderDetector.rightBorder + offset; float yu = latestBorderDetector.upperBorder + offset; float yb = latestBorderDetector.bottomBorder - offset; return(x > xr || x < xl || y < yb || y > yu); }
void Awake() { waiter = FindObjectOfType <Waiter>(); sceneChanger = FindObjectOfType <SceneChanger>(); borderDetector = FindObjectOfType <ScreenBorderDetector>(); }
private void Awake() { // Initialize rb = GetComponent <Rigidbody2D>(); screenBorderDetector = FindObjectOfType <ScreenBorderDetector>(); }