public void calculateWeightsGeneratesProperArray() { GameObject[] spawnableObstacles = new GameObject[5]; for (int i = 0; i < 5; i++) { GameObject spawnableObj = new GameObject(); spawnableObj.AddComponent <ModuleWeightContainer>().weight = i; spawnableObstacles[i] = spawnableObj; } int[] expectedContinousSumOfWeights = new int[] { 0, 1, 3, 6, 10 }; GameObject spawnControllerHolder = new GameObject(); ModuleSpawner spawner = spawnControllerHolder.AddComponent <ModuleSpawner>(); spawner.spawnableModules = spawnableObstacles; spawner.calculateWeights(); Assert.AreEqual(expectedContinousSumOfWeights, spawner.continuousSumOfWeights); }
public void spawnRandomModuleSpawnsModule() { GameObject[] spawnableModules = new GameObject[5]; for (int i = 0; i < 5; i++) { GameObject spawnableObj = new GameObject(); spawnableObj.AddComponent <ModuleWeightContainer>().weight = i; spawnableModules[i] = spawnableObj; } GameObject spawnControllerHolder = new GameObject(); ModuleSpawner spawnController = spawnControllerHolder.AddComponent <ModuleSpawner>(); spawnController.spawnableModules = spawnableModules; spawnController.totalSumOfWeights = 10; spawnController.continuousSumOfWeights = new int[] { 0, 1, 3, 6, 10 }; GameObject newModule = spawnController.spawnRandomModule(spawnControllerHolder.transform.position, spawnControllerHolder.transform.rotation); Assert.IsNotNull(newModule); }
public void calculateWeightsSumsWeightsProperly() { GameObject[] spawnableModules = new GameObject[5]; for (int i = 0; i < 5; i++) { GameObject spawnableObj = new GameObject(); spawnableObj.AddComponent <ModuleWeightContainer>().weight = i; spawnableModules[i] = spawnableObj; } int expectedTotalSumOfWeights = 10; GameObject spawnControllerHolder = new GameObject(); ModuleSpawner spawnController = spawnControllerHolder.AddComponent <ModuleSpawner>(); spawnController.spawnableModules = spawnableModules; spawnController.calculateWeights(); Assert.AreEqual(expectedTotalSumOfWeights, spawnController.totalSumOfWeights); }
private void Start() { moduleSpawner = FindObjectOfType <ModuleSpawner>(); audioManager = FindObjectOfType <AudioManager>(); frames = moduleSpawner.frames; }
void Awake() { if (!isSizing) { isSizing = true; } panel = gameObject.transform.Find("Panel").gameObject; gameManager = FindObjectOfType <GameManager>(); moduleSpawner = FindObjectOfType <ModuleSpawner>(); destination = new Vector3(0, threshold + 10, 0); tGUI = GetComponentInChildren <TextMeshProUGUI>(); float x = Random.Range(xPosMin, xPosMax); if (prevXisPositive) { x = -Mathf.Abs(x); prevXisPositive = false; } else { x = Mathf.Abs(x); prevXisPositive = true; } float y = Random.Range(yPosMin, yPosMax); panel.GetComponent <RectTransform>().localPosition = new Vector3(x, y, 0); lerpSpeed = lerpSpeedMin; if (moduleSpawner.starPower) // here { StartCoroutine(flashCoroutine()); } else { tGUI.color = new Color(0.5f, 0.5f, 1, 1); } switch (moduleSpawner.difficultyLevel) // here { case 0: break; case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break; //....... (how high does number actually go?) } }
void Awake() { instance = this; }