// Start is called before the first frame update private void OnTriggerEnter2D(Collider2D collision) { GameObject levelLoader = GameObject.FindWithTag("LevelLoader"); LevelLoader ll = levelLoader.GetComponent <LevelLoader>(); ll.BeginCombat("CombatBase"); }
// Update is called once per frame void FixedUpdate() { if (player != null) { if (playerRB2D.velocity.x != 0 || playerRB2D.velocity.y != 0) { framesSinceCombat++; if (Random.Range(0, 100) % framesSinceCombat >= 99.0f) { framesSinceCombat = 1.0f; //New stuff is creating a semaphore and configuring it with relavent information. Debug.Log("Starting battle, generating enemies"); GameObject semaphore = Instantiate(semaphoreRef); CombatSemaphore comSem = semaphore.GetComponent <CombatSemaphore>(); DontDestroyOnLoad(semaphore); //TODO do I need this? int monstersToSpawn = Random.Range(0, 100); Debug.Log("Random number is " + monstersToSpawn); for (int i = 0; i < enemies.Count; i++) { Debug.Log("Checking random against " + enemies[i].probability + " with result " + monstersToSpawn % enemies[i].probability); if ((monstersToSpawn % enemies[i].probability) <= 1) { Debug.Log("Monster added to encounter list"); comSem.enemiesToSpawn.Add(enemies[i].enemy); } } if (comSem.enemiesToSpawn.Count == 0) { comSem.enemiesToSpawn.Add(enemies[0].enemy); } comSem.playerParty = playerParty; LevelLoader ll = GameObject.FindGameObjectWithTag("LevelLoader").GetComponent <LevelLoader>(); ll.BeginCombat("CombatBase"); } } } }