public GameObject SpawnDummyAsteroid(int prefabIndex, ResourceType resourceType, int resourceQuantity, Vector3 position, Quaternion rotation, bool setActive) { GameObject prefab = dummyAsteroidsPrefabs[prefabIndex]; GameObject createdAsteroid = Instantiate(prefab, position, rotation); DummyAsteroid dummyAsteroid = createdAsteroid.GetComponent <DummyAsteroid>(); dummyAsteroid.resourceType = resourceType; dummyAsteroid.resourceQuantity = resourceQuantity; createdAsteroid.SetActive(setActive); return(createdAsteroid); }
private int GetResourceQuantity() { AsteroidController asteroidController = GetComponent <AsteroidController>(); if (asteroidController != null) { return(asteroidController.ResourceQuantity); } else { DummyAsteroid dummyAsteroid = GetComponent <DummyAsteroid>(); if (dummyAsteroid != null) { return(dummyAsteroid.resourceQuantity); } } return(0); }
void Start() { asteroidCanvas = asteroidCanvasGO.GetComponentInChildren <AsteroidCanvas>(true); AsteroidController asteroidController = GetComponent <AsteroidController>(); if (asteroidController != null) { asteroidCanvas.resourceQuantity = asteroidController.ResourceQuantity; asteroidCanvas.resource = new Resource(asteroidController.resourceType); } else { DummyAsteroid dummyAsteroid = GetComponent <DummyAsteroid>(); if (dummyAsteroid != null) { asteroidCanvas.resourceQuantity = dummyAsteroid.resourceQuantity; asteroidCanvas.resource = new Resource(dummyAsteroid.resourceType); } } asteroidCanvas.gameObject.SetActive(true); }