switch case statment
Hello, I am trying to create a 'buff' in my game that doubles the normal behaviour, but I am having real trouble doing it. I have tried doing it various ways, but always causes a bug and breaks my game.. I really want to add this 'buff' and i know its possible, and prehaps very easy to do, but my c# and development knowlegde isnt helping me here.
switch (_gameManager.pizzaSlices) { case 5: case 10://10 Destroy(childPizza); SpawnPizzaModel(reducedPizzas[0], pizzaPosition, reducedPizzas[0].transform.rotation, pizzaPosition); //5 and 10 slices left break; case 4: case 8://8 Destroy(childPizza); SpawnPizzaModel(reducedPizzas[1], pizzaPosition, reducedPizzas[1].transform.rotation, pizzaPosition); // 4 and 8 slices left break; case 3: case 6://6 Destroy(childPizza); SpawnPizzaModel(reducedPizzas[2], pizzaPosition, reducedPizzas[2].transform.rotation, pizzaPosition); // 3 and 6 slices left break; case 2: //case 4: //4 Destroy(childPizza); SpawnPizzaModel(reducedPizzas[3], pizzaPosition, reducedPizzas[3].transform.rotation, pizzaPosition); // 2 and 4 slices left break; case 1: //2 //case 2: Destroy(childPizza); SpawnPizzaModel(reducedPizzas[4], pizzaPosition, reducedPizzas[4].transform.rotation, pizzaPosition); //1 and 2 slices left break; case 0: _pizzaAttach.hasPizza = false; Destroy(childPizza); break; default: break; } }
The normal case is player picks up pizza, has 6 slices, fires 1 and spawns a new model representing a pizza without said slices fired... However the buff i want to add is the ability to have 12 slices instead of 6 and still keep the current 'models' so 5 slice pizza model would become 10 with the buff, 4 to 8, 3 to 6 and so on. However the problem occurs when i get to 2 > 4 and 1 > 2 as they are already in the switch statement.
My attempt caused me to create a new method to get the index value according to case numbers and do an if check in the case to see if the player has the buff, and leave the SpawnPizzaModel() call in this method but when it gets to zero it instantly spawns another pizza as though it was case 5: and the bigger numbers don't work at all.
Thanks
Your answer
Follow this Question
Related Questions
Switch-Case Statements and stateInfo.fullPathHash 1 Answer
Scaling a Line 0 Answers
Area filling like Paper.io using fllod fill algorithm 0 Answers