// Use this for initialization void Start() { state = Mstates.INITIAL; timer = new TimerData(10, 50, 50, 80, 10, 20, 30); progressPoints = 0; //Anim = Bubbler.GetComponent<Animator>(); }
// Use this for initialization void Start() { state = Mstates.INITIAL; cycleCounter = 0; initialWait = GetValueFromRange(100, initialWaitRange); WaitCyclesSpawn = GetValueFromRange(minWaitSpawn, maxWaitSpawn + 1); WaitCyclesDestroy = GetValueFromRange(minWaitDestroy, maxWaitDestroy + 1); WaitCyclesBubbling = GetValueFromRange(100, 200 + 1); progressPoints = progressBar.value; Anim = Bubbler.GetComponent <Animator>(); }
private void FixedUpdate() { //progressPoints = progressBar.value; switch (state) { case Mstates.INITIAL: SpawnedFood = Instantiate(foods[Random.Range(0, foods.Length)], transform.position, transform.rotation) as GameObject; state = Mstates.FOODSPAWNED; counterScript.IncrementCounter(); if (counterScript.GetPoints() >= 1f) { state = Mstates.FINAL; } break; case Mstates.FOODSPAWNED: if (SpawnedFood.activeSelf == false) { Destroy(SpawnedFood); state = Mstates.NOFOOD; } if (counterScript.GetPoints() >= 1f) { state = Mstates.FINAL; } break; case Mstates.NOFOOD: counterCheck = counterScript.GetCounter(); if (counterCheck == 0) { SpawnedFood = Instantiate(foods[Random.Range(0, foods.Length)], transform.position, transform.rotation) as GameObject; state = Mstates.FOODSPAWNED_DELAY; } if (counterScript.GetPoints() >= 1f) { state = Mstates.FINAL; } break; case Mstates.FOODSPAWNED_DELAY: state = Mstates.FOODSPAWNED_INC; // Delay for one cycle so that all the SpawnPoints can pick up the counter and spawn food. if (counterScript.GetPoints() >= 1f) { state = Mstates.FINAL; } break; case Mstates.FOODSPAWNED_INC: counterScript.IncrementCounter(); // Increment the counter to account for the newly spawned food object. state = Mstates.FOODSPAWNED; if (counterScript.GetPoints() >= 1f) { state = Mstates.FINAL; } break; case Mstates.FINAL: if (!SpawnedFood.Equals(null)) { Destroy(SpawnedFood); } else { ; } break; default: break; } }
// Use this for initialization void Start() { counterScript = Counter.GetComponent <SpawnCounterScript>(); state = Mstates.INITIAL; }
private void FixedUpdate() { //progressPoints = progressBar.value; switch (state) { case Mstates.INITIAL: if (timer.getCycleCounter() < timer.getInitialWait()) { timer.incrementCycleCounter(); } else { state = Mstates.BUBBLING; timer.resetCycleCounter(); //Anim.SetInteger("Ripple", 1); } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.FOODSPAWNED: if (SpawnedFood /*.activeSelf*/ == false) { //Destroy(SpawnedFood); timer.resetCycleCounter(); state = Mstates.NOFOOD; } else if (timer.getCycleCounter() < timer.getWaitCyclesDestroy()) { timer.incrementCycleCounter(); } else { //Destroy(SpawnedFood); timer.resetCycleCounter(); state = Mstates.NOFOOD; } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.BUBBLING: if (timer.getCycleCounter() < timer.getWaitCyclesBubbling()) { timer.incrementCycleCounter(); } else { //Anim.SetInteger("Ripple", 0); SpawnedFood = setSpawnedFood(true) /*Instantiate(foods[Random.Range(0, foods.Length)], transform.position, transform.rotation) as GameObject*/; state = Mstates.FOODSPAWNED; timer.resetCycleCounter(); } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.NOFOOD: //trackPlayer = new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y); //hypotenuse = Mathf.Sqrt((trackPlayer.x * trackPlayer.x) + (trackPlayer.y * trackPlayer.y)); if (timer.getCycleCounter() < timer.getWaitCyclesDestroy() /* && hypotenuse >= minSpawnRange*/) { timer.incrementCycleCounter(); } else if (timer.getCycleCounter() >= timer.getWaitCycleSpawn()) { //Anim.SetInteger("Ripple", 1); state = Mstates.BUBBLING; timer.resetCycleCounter(); } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.FINAL: if (!SpawnedFood /*.Equals(null)*/) { //Destroy(SpawnedFood); } else { ; } break; default: break; } }
private void FixedUpdate() { progressPoints = progressBar.value; switch (state) { case Mstates.INITIAL: if (cycleCounter < initialWait) { cycleCounter++; } else { state = Mstates.BUBBLING; cycleCounter = 0; Anim.SetInteger("Ripple", 1); } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.FOODSPAWNED: if (SpawnedFood.activeSelf == false) { Destroy(SpawnedFood); cycleCounter = 0; state = Mstates.NOFOOD; } else if (cycleCounter < WaitCyclesDestroy) { cycleCounter++; } else { Destroy(SpawnedFood); cycleCounter = 0; state = Mstates.NOFOOD; } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.BUBBLING: if (cycleCounter < WaitCyclesBubbling) { cycleCounter++; } else { Anim.SetInteger("Ripple", 0); SpawnedFood = Instantiate(foods[Random.Range(0, foods.Length)], transform.position, transform.rotation) as GameObject; state = Mstates.FOODSPAWNED; cycleCounter = 0; } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.NOFOOD: trackPlayer = new Vector2(player.transform.position.x - transform.position.x, player.transform.position.y - transform.position.y); hypotenuse = Mathf.Sqrt((trackPlayer.x * trackPlayer.x) + (trackPlayer.y * trackPlayer.y)); if (cycleCounter < WaitCyclesSpawn && hypotenuse >= minSpawnRange) { cycleCounter++; } else if (cycleCounter >= minWaitSpawn) { Anim.SetInteger("Ripple", 1); state = Mstates.BUBBLING; cycleCounter = 0; } if (progressPoints >= 1f) { state = Mstates.FINAL; } break; case Mstates.FINAL: if (!SpawnedFood.Equals(null)) { Destroy(SpawnedFood); } else { ; } break; default: break; } }