I have a row of 12 bools and whenever I set either one of those bools to true.
it turns on a effect for that bool that’s true and then when that bool is set to false it turns off a effect. and I am trying to figure out a way to repeat how many times those row of bools is set to true or false to repeat the effect for that bool turning off and on. here’s my code so far I cant get it to repeat accurately.
// Start is called before the first frame update
void Start()
{
if (enablePattern == false)
{
StartCoroutine(Ignite());
}
if (enablePattern == true)
{
StopCoroutine(Ignite());
}
}
IEnumerator Ignite()
{
while(true)
{
for (int i = 0; i < flameThrowers.Length; i++)
{
flameThrowers*.Play();*
igniteFlames*.Stop();*
}
yield return new WaitForSeconds(igniteSpeed);
for (int i = 0; i < igniteFlames.Length; i++)
{
igniteFlames*.Play();*
flameThrowers*.Stop();*
}
yield return new WaitForSeconds(igniteSpeed);
}
}
void Update()
{
Debug.Log(PlayerPrefs.GetInt(“FlameThrowerPatternOn”));
if (recordPattern == true)
{
StopCoroutine(IgnitePattern());
stopForLoop = false;
if (flameThrowerPattern1 == true && playFlameThrowerOnce1 == true)
{
flameThrowers1.Play();
igniteFlame1.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn1”, test += 1);
playFlameThrowerOnce1 = false;
}
if (flameThrowerPattern1 == false && playFlameThrowerOnce1 == false)
{
flameThrowers1.Stop();
igniteFlame1.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff1”, test2 += 1);
playFlameThrowerOnce1 = true;
}
if (flameThrowerPattern2 == true && playFlameThrowerOnce2 == true)
{
flameThrowers2.Play();
igniteFlame2.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn2”, test += 1);
playFlameThrowerOnce2 = false;
}
if (flameThrowerPattern2 == false && playFlameThrowerOnce2 == false)
{
igniteFlame2.Play();
flameThrowers2.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff2”, test2 += 1);
playFlameThrowerOnce2 = true;
}
if (flameThrowerPattern3 == true && playFlameThrowerOnce3 == true)
{
flameThrowers3.Play();
igniteFlame3.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn3”, test += 1);
playFlameThrowerOnce3 = false;
}
if (flameThrowerPattern3 == false && playFlameThrowerOnce3 == false)
{
flameThrowers3.Stop();
igniteFlame3.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff3”, test2 += 1);
playFlameThrowerOnce3 = true;
}
if (flameThrowerPattern4 == true && playFlameThrowerOnce4 == true)
{
flameThrowers4.Play();
igniteFlame4.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn4”, test += 1);
playFlameThrowerOnce4 = false;
}
if (flameThrowerPattern4 == false && playFlameThrowerOnce4 == false)
{
igniteFlame4.Play();
flameThrowers4.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff4”, test2 += 1);
playFlameThrowerOnce4 = true;
}
if (flameThrowerPattern5 == true && playFlameThrowerOnce5 == true)
{
flameThrowers5.Play();
igniteFlame5.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn5”, test += 1);
playFlameThrowerOnce5 = false;
}
if (flameThrowerPattern5 == false && playFlameThrowerOnce5 == false)
{
flameThrowers5.Stop();
igniteFlame5.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff5”, test2 += 1);
playFlameThrowerOnce5 = true;
}
if (flameThrowerPattern6 == true && playFlameThrowerOnce6 == true)
{
flameThrowers6.Play();
igniteFlame6.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn6”, test += 1);
playFlameThrowerOnce6 = false;
}
if (flameThrowerPattern6 == false && playFlameThrowerOnce6 == false)
{
igniteFlame6.Play();
flameThrowers6.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff6”, test2 += 1);
playFlameThrowerOnce6 = true;
}
if (flameThrowerPattern7 == true && playFlameThrowerOnce7 == true)
{
flameThrowers7.Play();
igniteFlame7.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn7”, test += 1);
playFlameThrowerOnce7 = false;
}
if (flameThrowerPattern7 == false && playFlameThrowerOnce7 == false)
{
flameThrowers7.Stop();
igniteFlame7.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff7”, test2 += 1);
playFlameThrowerOnce7 = true;
}
if (flameThrowerPattern8 == true && playFlameThrowerOnce8 == true)
{
flameThrowers8.Play();
igniteFlame8.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn8”, test += 1);
playFlameThrowerOnce8 = false;
}
if (flameThrowerPattern8 == false && playFlameThrowerOnce8 == false)
{
igniteFlame8.Play();
flameThrowers8.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff8”, test2 += 1);
playFlameThrowerOnce8 = true;
}
if (flameThrowerPattern9 == true && playFlameThrowerOnce9 == true)
{
flameThrowers9.Play();
igniteFlame9.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn9”, test += 1);
playFlameThrowerOnce9 = false;
}
if (flameThrowerPattern9 == false && playFlameThrowerOnce9 == false)
{
flameThrowers9.Stop();
igniteFlame9.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff9”, test2 += 1);
playFlameThrowerOnce9 = true;
}
if (flameThrowerPattern10 == true && playFlameThrowerOnce10 == true)
{
flameThrowers10.Play();
igniteFlame10.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn10”, test += 1);
playFlameThrowerOnce10 = false;
}
if (flameThrowerPattern10 == false && playFlameThrowerOnce10 == false)
{
igniteFlame10.Play();
flameThrowers10.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff10”, test2 += 1);
playFlameThrowerOnce10 = true;
}
if (flameThrowerPattern11 == true && playFlameThrowerOnce11 == true)
{
flameThrowers11.Play();
igniteFlame11.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn11”, test += 1);
playFlameThrowerOnce11 = false;
}
if (flameThrowerPattern11 == false && playFlameThrowerOnce11 == false)
{
flameThrowers11.Stop();
igniteFlame11.Play();
PlayerPrefs.SetInt(“FlameThrowerPatternOff11”, test2 += 1);
playFlameThrowerOnce11 = true;
}
if (flameThrowerPattern12 == true && playFlameThrowerOnce12 == true)
{
flameThrowers12.Play();
igniteFlame12.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn12”, test += 1);
playFlameThrowerOnce12 = false;
}
if (flameThrowerPattern12 == false && playFlameThrowerOnce12 == false)
{
igniteFlame12.Play();
flameThrowers12.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff12”, test2 += 1);
playFlameThrowerOnce12 = true;
}
}
if (recordPattern == false && stopForLoop == false)
{
StartCoroutine(IgnitePattern());
stopForLoop = true;
}
}
IEnumerator IgnitePattern()
{
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn1”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn1”); i++)
{
flameThrowers1.Play();
igniteFlame1.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn1”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff”) > 0)
{
igniteFlame1.Play();
flameThrowers1.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff1”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn2”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn2”); i++)
{
flameThrowers2.Play();
igniteFlame2.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn2”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff2”) > 0)
{
igniteFlame2.Play();
flameThrowers2.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff2”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn3”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn3”); i++)
{
flameThrowers3.Play();
igniteFlame3.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn3”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff3”) > 0)
{
igniteFlame3.Play();
flameThrowers3.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff3”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn4”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn4”); i++)
{
flameThrowers4.Play();
igniteFlame4.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn4”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff4”) > 0)
{
igniteFlame4.Play();
flameThrowers4.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff4”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn5”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn5”); i++)
{
flameThrowers5.Play();
igniteFlame5.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn5”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff5”) > 0)
{
igniteFlame5.Play();
flameThrowers5.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff5”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn6”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn6”); i++)
{
flameThrowers6.Play();
igniteFlame6.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn6”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff6”) > 0)
{
igniteFlame6.Play();
flameThrowers6.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff6”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn7”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn7”); i++)
{
flameThrowers7.Play();
igniteFlame7.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn7”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff7”) > 0)
{
igniteFlame7.Play();
flameThrowers7.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff7”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn8”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn8”); i++)
{
flameThrowers8.Play();
igniteFlame8.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn8”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff8”) > 0)
{
igniteFlame8.Play();
flameThrowers8.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff8”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn9”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn9”); i++)
{
flameThrowers9.Play();
igniteFlame9.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn9”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff9”) > 0)
{
igniteFlame9.Play();
flameThrowers9.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff9”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn10”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn10”); i++)
{
flameThrowers10.Play();
igniteFlame10.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn10”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff10”) > 0)
{
igniteFlame10.Play();
flameThrowers10.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff10”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn11”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn11”); i++)
{
flameThrowers11.Play();
igniteFlame11.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn11”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff11”) > 0)
{
igniteFlame11.Play();
flameThrowers11.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff11”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
if (PlayerPrefs.GetInt(“FlameThrowerPatternOn12”) > 0)
{
for (int i = 0; i < PlayerPrefs.GetInt(“FlameThrowerPatternOn12”); i++)
{
flameThrowers12.Play();
igniteFlame12.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOn12”, test -= 1);
yield return new WaitForSeconds(patternSpeed);
if (PlayerPrefs.GetInt(“FlameThrowerPatternOff12”) > 0)
{
igniteFlame12.Play();
flameThrowers12.Stop();
PlayerPrefs.SetInt(“FlameThrowerPatternOff12”, test2 -= 1);
yield return new WaitForSeconds(patternSpeed);
stopForLoop = false;
}
}
}
}
`