void SpawnWeaponsInPlanet() { weapons = new List <PlanetWeapon>(); int numberOfWeapons = Random.Range(minNumberOfWeapons, maxNumberOfWeapons + 1); for (int i = 0; i < numberOfWeapons; i++) { PlanetWeapon weapon = PoolsManager.Instance.GetObjectFromPool <PlanetWeapon>(); weapon.transform.SetParent(transform); weapons.Add(weapon); } }
private void OnTriggerEnter2D(Collider2D _collider) { // Debug.LogError(_collider.gameObject.name); if (_collider.CompareTag("GravitationField")) { // Changes active buttons on GUI if it enters a planet PlayerInOrbit(); isOnGravitationField = true; } if (_collider.CompareTag("ShootZone")) { PlanetWeapon weapon = _collider.GetComponent <PlanetWeapon>(); weapon.SetTarget(transform); } }
void OnTriggerExit2D(Collider2D _collider) { if (_collider.CompareTag("GravitationField")) { // Changes active buttons on GUI if it goes out of a planet PlayerInOrbit(); UpdateButton(); if (atractorRayComponent.IsAlienRayOn) { ToggleShipRay(); } isOnGravitationField = false; } if (_collider.CompareTag("ShootZone")) { PlanetWeapon weapon = _collider.GetComponent <PlanetWeapon>(); weapon.SetTarget(null); } }