private IEnumerator SpawnEnemies() { int randomEnemyIndex = Random.Range(0, enemyTypes.Length); Enemy.EnemyType enemyToSpawn = enemyTypes[randomEnemyIndex]; for (int i = 0; i < amountToSpawn; i++) { ObjectPooler.Instance.SpawnFromPool(enemyToSpawn.ToString(), transform.position, transform.rotation); yield return(new WaitForSeconds(spawnSpeed)); } print("SPAWNING"); yield return(new WaitForSeconds(timeBetweenSpawns)); //StartCoroutine(SpawnEnemies()); }
public void EnemyKilled_AddOrRemoveRep(float distance, string enemyType) { //Debug.Log(distance); int rep = Mathf.RoundToInt(distance); if (enemyType == playerTarget.ToString()) { playerRep += (int)(rep * repGainScalar); numOfEnemyToKill -= 1; // Target Switch Mechanic Check - Continue... if (numOfEnemyToKill <= 0) { targetSwitchOn = false; } } else { playerRep -= (int)(rep * repGainScalar); } updateUI(); }
/// <summary> /// Draws text above an object. Currently used to draw the enemyType, but can draw anything you pass in as second param. /// Create a new function to draw different objects above enemes /// </summary> /// <param name="gameObject">Target object we are drawing on top of </param> /// <param name="enemyType">should consider moving this to a different object, instead of enemyType</param> //[Conditional("DEBUG")] public static void DrawEnemyTypeAboveObject(GameObject gameObject, Enemy.EnemyType enemyType, int offsetX = 40, int offsetY = 40, int rectWidth = 90, int rectHeight = 40) { // Converts 3d space to 2d, to create a plane to draw text to var objectPos = Camera.main.WorldToScreenPoint(gameObject.transform.position); // BeginArea positioned in relation to my character GUILayout.BeginArea(new Rect((objectPos.x - offsetX), (Screen.height - objectPos.y) - offsetY, Screen.width, Screen.height)); // Draw the text above the enemy GUI.Label(new Rect(gameObject.transform.position.x, gameObject.transform.position.y, rectWidth, rectHeight), enemyType.ToString()); GUILayout.EndArea(); }