bool EvalExpression(string expression) { int i = -1; int i1 = expression.IndexOf("="); int i2 = expression.IndexOf("<"); int i3 = expression.IndexOf(">"); if (i1 != -1) { i = i1; } if (i2 != -1) { i = i2; } if (i3 != -1) { i = i3; } int?worldval = PersistentEngine.GetState(expression.Substring(0, i)); if (worldval == null) { return(false); } string cmpvalstr = expression.Substring(i + 1); int cmpval = -1; try { cmpval = Int32.Parse(cmpvalstr); } catch { return(false); } int worldvalnotnull = (int)worldval; if (i1 != -1) // operator = { return(cmpval == worldvalnotnull); } else if (i2 != -1) // operator = { return(worldvalnotnull < cmpval); } else if (i3 != -1) // operator = { return(worldvalnotnull > cmpval); } return(false); }
// Use this for initialization void Start() { int?level = PersistentEngine.GetState("Global loadingLevel"); if (level < 10) { level = 15; } level++; }
IEnumerator Start() { Application.backgroundLoadingPriority = ThreadPriority.High; int?level = PersistentEngine.GetState("Global loadingLevel"); Debug.Log("LoadingScene: level " + level.ToString()); SceneManager.LoadScene((int)level); yield return(null); }
public void LoadState() { if (!allowSaving) { return; } var fields = this.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(field => field.IsDefined(typeof(SaveStateAttribute), true)); foreach (var field in fields) { if (field.FieldType.IsEnum) { if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null) { field.SetValue(this, PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name)); } } else if (PersistentEngine.IsNumericType(field)) { if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null) { field.SetValue(this, PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name)); } } else if (PersistentEngine.IsBooleanType(field)) { if (PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name) != null) { var val = PersistentEngine.GetState(GetObjectIdentifier(sceneName) + field.Name); GetObjectIdentifier(sceneName); field.SetValue(this, val == 1 ? true : false); } } else if (PersistentEngine.IsStringType(field)) { var val = PersistentEngine.GetStateStr(GetObjectIdentifier(sceneName) + field.Name); GetObjectIdentifier(sceneName); field.SetValue(this, val); } } }