public override void Func(string[] _params) { bool stopOrStart = false; // false == stop, true == start if (_params[0].Equals("start")) { stopOrStart = true; } else if (_params[0].Equals("stop")) { stopOrStart = false; } else { Debug.LogError("Invalid parameter on SnowEffect function!"); this.scriptMaster.NextLine(); return; } // starting if (stopOrStart == true) { SnowEffectInstance = GameObject.Instantiate <GameObject>(SnowEffectPrefab, GameObject.Find("PostCharacterEffectCanvas").transform); SnowEffectScript = SnowEffectInstance.GetComponent <SnowEffectObjectScript>(); } else // stopping { if (SnowEffectInstance == null || SnowEffectScript == null) { var gameObjects = GameObject.FindObjectsOfType <GameObject>() as GameObject[]; for (var i = 0; i < gameObjects.Length; i++) { if (gameObjects[i].name.Contains("SakuraPrefab")) { SnowEffectInstance = gameObjects[i]; SnowEffectScript = SnowEffectInstance.GetComponent <SnowEffectObjectScript>(); break; } } if (!SnowEffectInstance || !SnowEffectScript) { Debug.LogError("Trying to stop SnowEffect when there isn't one!"); this.scriptMaster.NextLine(); return; } } SnowEffectScript.Stop(); } this.scriptMaster.NextLine(); }
public override void Func(string[] _params) { bool stopOrStart = false; // false == stop, true == start if (_params[0].Equals("start")) { stopOrStart = true; } else if (_params[0].Equals("stop")) { stopOrStart = false; } else { Debug.LogError("Invalid parameter on SnowEffect function!"); Camera.main.GetComponent <M22.ScriptMaster>().NextLine(); return; } // starting if (stopOrStart == true) { SnowEffectInstance = GameObject.Instantiate <GameObject>(SnowEffectPrefab, GameObject.Find("PostCharacterEffectCanvas").transform); SnowEffectScript = SnowEffectInstance.GetComponent <SnowEffectObjectScript>(); } else // stopping { if (SnowEffectInstance == null || SnowEffectScript == null) { Debug.LogError("Trying to stop SnowEffect when there isn't one!"); Camera.main.GetComponent <M22.ScriptMaster>().NextLine(); return; } SnowEffectScript.Stop(); } Camera.main.GetComponent <M22.ScriptMaster>().NextLine(); }