public new static BooleanVariable Random() { var x = new BooleanVariable(); x.SetRandomValues(); return(x); }
public void TestFalseStringValue() { BooleanVariable var = new BooleanVariable(); var.CheckForStore("false"); Assert.IsFalse((bool)var.Value); }
public void TestGetNotBoolValue() { BooleanVariable var = new BooleanVariable(); bool actual = var.CheckForStore(var.CheckForStore(4)); Assert.IsTrue(actual); }
public void TestBoolValue() { BooleanVariable var = new BooleanVariable(); var.CheckForStore(true); Assert.IsTrue((bool)var.Value); }
protected virtual void Awake() { swapEnabled = tileSwapVals.GetVariable("swapEnabled") as BooleanVariable; SetToHighlightWhenTileClicked(); SetToResetWhenSwapHappens(); RegisterTheAirTileType(); }
public void TestTrueStringValue() { BooleanVariable var = new BooleanVariable(); var.CheckForStore("true"); Assert.IsTrue((bool)var.Value); }
public bool EvaluateCondition() { BooleanVariable booleanVariable = variable as BooleanVariable; IntegerVariable integerVariable = variable as IntegerVariable; FloatVariable floatVariable = variable as FloatVariable; StringVariable stringVariable = variable as StringVariable; bool condition = false; if (booleanVariable != null) { condition = booleanVariable.Evaluate(compareOperator, booleanData.Value); } else if (integerVariable != null) { condition = integerVariable.Evaluate(compareOperator, integerData.Value); } else if (floatVariable != null) { condition = floatVariable.Evaluate(compareOperator, floatData.Value); } else if (stringVariable != null) { condition = stringVariable.Evaluate(compareOperator, stringData.Value); } return(condition); }
public static void SerializeBooleanVariable() { var a = new BooleanVariable("foobar"); var b = SerializationUtil.Reserialize(a); Assert.AreEqual(a, b); }
public void TestGetNullValue() { BooleanVariable var = new BooleanVariable(); bool actual = var.CheckForStore(null); Assert.IsFalse(actual); }
public void BooleanVariableChangeValueTest() { var variable = new BooleanVariable(false); Assert.IsFalse(variable.Value); variable.Value = true; Assert.IsTrue(variable.Value); }
private void AddValueToList(FieldInfo f) { IBaseVariable variable = null; if (f.FieldType.ToString() == "System.String") { variable = new StringVariable(); } else if (f.FieldType.ToString() == "System.Int32") { variable = new IntegerVariable(); } else if (f.FieldType.ToString() == "System.Single") { variable = new FloatVariable(); } else if (f.FieldType.ToString() == "System.Boolean") { variable = new BooleanVariable(); } else if (f.FieldType.ToString() == "System.String[]") { variable = new StringVariableArray(); } else if (f.FieldType.ToString() == "System.Int32[]") { variable = new IntegerVariableArray(); } else if (f.FieldType.ToString() == "System.Single[]") { variable = new FloatVariableArray(); } else if (f.FieldType.ToString() == "System.Boolean[]") { variable = new BooleanVariableArray(); } else if (f.FieldType.ToString() == "UnityEngine.Vector2") { variable = new Vector2Variable(); } else if (f.FieldType.ToString() == "UnityEngine.Vector3") { variable = new Vector3Variable(); } else if (f.FieldType.ToString() == "UnityEngine.Vector2[]") { variable = new Vector2VariableArray(); } else if (f.FieldType.ToString() == "UnityEngine.Vector3[]") { variable = new Vector3VariableArray(); } if (variable != null) { variable.value = f.GetValue(this); ListValue.Add((string)f.Name, variable); } }
protected virtual void Awake() { tileBoard = FindObjectOfType <TileBoardController>(); TileController.AnyClicked += OnAnyTileClicked; swapDurationVar = tileSwapVals.GetVariable("swapDuration") as FloatVariable; swapEnabledVar = tileSwapVals.GetVariable("swapEnabled") as BooleanVariable; cancelAxisVar = tileSwapVals.GetVariable("cancelAxis") as StringVariable; airTileVar = gameVals.GetVariable("airTileType") as ObjectVariable; AnyPhysicalSwapMade += this.OnAnyPhysicalSwapMade; }
public BooleanVariable boolVar; //tells others if it is playerTurn or not public void Enter() { BattleController.instance.voice.shareRecognitionEvent += BattleController.instance.TrySpellString; BattleController.instance.enemy.Die += EndBattleWin; boolVar = BattleController.instance.isPlayerTurn; BattleController.instance.battleText.text = BattleController.instance.player.name + "の番です!よく言ってね!"; //Generate new forced spell BattleController.instance.mustBeCast = BattleController.instance.ChooseRandomSpell(BattleController.instance.player); }
public override void OnEnter() { if (key == "" || variable == null) { Continue(); return; } var flowchart = GetFlowchart(); // Prepend the current save profile (if any) string prefsKey = SetSaveProfile.saveProfile + "_" + flowchart.SubstituteVariables(key); System.Type variableType = variable.GetType(); if (variableType == typeof(BooleanVariable)) { BooleanVariable booleanVariable = variable as BooleanVariable; if (booleanVariable != null) { // PlayerPrefs does not have bool accessors, so just use int booleanVariable.Value = (PlayerPrefs.GetInt(prefsKey) == 1); } } else if (variableType == typeof(IntegerVariable)) { IntegerVariable integerVariable = variable as IntegerVariable; if (integerVariable != null) { integerVariable.Value = PlayerPrefs.GetInt(prefsKey); } } else if (variableType == typeof(FloatVariable)) { FloatVariable floatVariable = variable as FloatVariable; if (floatVariable != null) { floatVariable.Value = PlayerPrefs.GetFloat(prefsKey); } } else if (variableType == typeof(StringVariable)) { StringVariable stringVariable = variable as StringVariable; if (stringVariable != null) { stringVariable.Value = PlayerPrefs.GetString(prefsKey); } } Continue(); }
/// <summary>Toggles a BooleanVariable.</summary> /// <param name="variable">The boolean variable.</param> public void ToggleBooleanVariable(BooleanVariable variable) { switch (variable) { case BooleanVariable.MusicEnabled: ToggleMusicEnabled(); break; case BooleanVariable.SFXEnabled: ToggleSFXEnabled(); break; } }
/// <summary>Set a BooleanVariable to a given value.</summary> /// <param name="variable">The boolean variable.</param> /// <param name="value">The value to set.</param> public void SetBooleanVariable(BooleanVariable variable, bool value) { switch (variable) { case BooleanVariable.MusicEnabled: SetMusicEnabled(value); break; case BooleanVariable.SFXEnabled: SetSFXEnabled(value); break; } }
/// <summary>Gets the value of a BooleanVariable.</summary> /// <param name="variable">The boolean variable.</param> public bool GetBooleanVariableValue(BooleanVariable variable) { switch (variable) { case BooleanVariable.MusicEnabled: return(musicEnabled); case BooleanVariable.SFXEnabled: return(sfxEnabled); default: Debug.LogErrorFormat("{0} is not cated for in the swich statement", variable); return(false); } }
public override void OnStepStart() { base.OnStepStart(); originalControlsTriggerIsBlocked = toggleControlsHud.isTriggerBlocked; if (toggleControlsHud != null) { toggleControlsHud.isTriggerBlocked = null; } if (tutorialController != null && tutorialController.hudController != null) { tutorialController.hudController.controlsHud.OnControlsOpened += ControlsHud_OnControlsOpened; tutorialController.hudController.controlsHud.OnControlsClosed += ControlsHud_OnControlsClosed; } }
private Spell toCast; //chosen by AI public void Enter() { BattleController.instance.battleText.text = BattleController.instance.enemy.name + "は考えている。。。"; BattleController.instance.player.animator.SetBool("Casting", false); BattleController.instance.player.Die += EndBattleLoss; boolVar = BattleController.instance.isPlayerTurn; toCast = BattleController.instance.ChooseRandomSpell(BattleController.instance.enemy); if (toCast == null) { Debug.Log("I didn't have any spells to cast, so you can have your turn back..."); } BattleController.instance.StartCoroutine(BattleController.instance.CastAfterSeconds(enemyThinkTime, toCast)); //why is StartCoroutine a MonoBehaviour method.... :/ }
//If a block is activated by the user, then this is not needed in the flowchart //Copies the variables in the list from the GM flowcharts to the activated flowchart public void CopyGameMasterToFlowchart() { gm = GameObject.Find("GameMaster").GetComponent <GameMaster>(); Flowchart gmQuest = gm.GetQuestFlowchart(); Flowchart target = this.GetComponent <Flowchart>(); Variable sourceVar = null; for (int i = 0; i < varNames.Length; i++) { sourceVar = gmQuest.GetVariable(varNames[i]); StringVariable tempstr = sourceVar as StringVariable; if (tempstr != null) { target.SetStringVariable(varNames[i], tempstr.Value); continue; } BooleanVariable tempBool = sourceVar as BooleanVariable; if (tempBool != null) { target.SetBooleanVariable(varNames[i], tempBool.Value); continue; } IntegerVariable tempInt = sourceVar as IntegerVariable; if (tempInt != null) { target.SetIntegerVariable(varNames[i], tempInt.Value); continue; } FloatVariable tempFloat = sourceVar as FloatVariable; if (tempFloat != null) { target.SetFloatVariable(varNames[i], tempFloat.Value); continue; } } }
public Settings() { if (qualitySettingsPreset == null) { qualitySettingsPreset = Resources.Load <SettingsData.QualitySettingsData>("ScriptableObjects/QualitySettingsData"); } if (autoqualitySettings == null) { autoqualitySettings = Resources.Load <SettingsData.QualitySettingsData>("ScriptableObjects/AutoQualitySettingsData"); lastValidAutoqualitySet = autoqualitySettings[autoqualitySettings.Length / 2]; } if (autosettingsEnabled == null) { autosettingsEnabled = Resources.Load <BooleanVariable>("ScriptableObjects/AutoQualityEnabled"); } LoadQualitySettings(); LoadGeneralSettings(); }
BooleanFunction FixVar(BooleanVariable variable, int value) { int res = 0; switch (variable) { case BooleanVariable.A: res = FixA(value); break; case BooleanVariable.B: res = FixB(value); break; case BooleanVariable.C: res = FixC(value); break; default: throw new ArgumentException("The variable argument for FixVar should be A, B or C"); } return(new BooleanFunction((byte)res)); }
public VarExpression(BooleanVariable var, bool not = false) { Var = var; }
public void SetValue(BooleanVariable boolVariable) { Value = boolVariable.Value; }
public static BooleanExpression FindMininalExpressionInBasis(int n, BooleanOperation[] ops, BooleanVariable[] vars, ExpressionSearchMode mode = ExpressionSearchMode.CountOps) { var queue = new ImprovisedPriorityQueue<BooleanExpression>(20); var knownTruthTables = new HashSet<byte>(); var knownExpressions = new HashSet<BooleanExpression>(); foreach(var variable in vars) { queue.TryEnqueue(new VarExpression(variable), 1); } while(queue.Count != 0) { var curExperession = queue.Dequeue(); byte truthTable = curExperession.Eval(); if(knownTruthTables.Contains(truthTable)) { continue; } if(curExperession.Eval() == n) { return curExperession; } knownExpressions.Add(curExperession); knownTruthTables.Add(truthTable); foreach(var anotherExpression in knownExpressions) { foreach(var neighbourExpression in curExperession.CombineWith(anotherExpression, ops)) { queue.TryEnqueue(neighbourExpression, mode == ExpressionSearchMode.CountBlocks ? neighbourExpression.CountBlocks() : neighbourExpression.CountOps()); } } } throw new CouldntFindExpressionException(); }
BooleanFunction FixVar(BooleanVariable variable, int value) { int res = 0; switch(variable) { case BooleanVariable.A: res = FixA(value); break; case BooleanVariable.B: res = FixB(value); break; case BooleanVariable.C: res = FixC(value); break; default: throw new ArgumentException("The variable argument for FixVar should be A, B or C"); } return new BooleanFunction((byte)res); }
public OpExpression(BooleanOperation op, BooleanVariable left, BooleanVariable right) { Op = op; Left = new VarExpression(left); Right = new VarExpression(right); }
public void SetBool(BooleanVariable state) { State = state.State; }
protected virtual void DoSetOperation() { if (variable == null) { return; } if (variable.GetType() == typeof(BooleanVariable)) { BooleanVariable lhs = (variable as BooleanVariable); bool rhs = booleanData.Value; switch (setOperator) { default: case SetOperator.Assign: lhs.Value = rhs; break; case SetOperator.Negate: lhs.Value = !rhs; break; } } else if (variable.GetType() == typeof(IntegerVariable)) { IntegerVariable lhs = (variable as IntegerVariable); int rhs = integerData.Value; switch (setOperator) { default: case SetOperator.Assign: lhs.Value = rhs; break; case SetOperator.Add: lhs.Value += rhs; break; case SetOperator.Subtract: lhs.Value -= rhs; break; case SetOperator.Multiply: lhs.Value *= rhs; break; case SetOperator.Divide: lhs.Value /= rhs; break; } } else if (variable.GetType() == typeof(FloatVariable)) { FloatVariable lhs = (variable as FloatVariable); float rhs = floatData.Value; switch (setOperator) { default: case SetOperator.Assign: lhs.Value = rhs; break; case SetOperator.Add: lhs.Value += rhs; break; case SetOperator.Subtract: lhs.Value -= rhs; break; case SetOperator.Multiply: lhs.Value *= rhs; break; case SetOperator.Divide: lhs.Value /= rhs; break; } } else if (variable.GetType() == typeof(StringVariable)) { StringVariable lhs = (variable as StringVariable); string rhs = stringData.Value; switch (setOperator) { default: case SetOperator.Assign: lhs.Value = rhs; break; } } }
public void BooleanVariableInitialFalseValueTest() { var variable = new BooleanVariable(false); Assert.IsFalse(variable.Value); }
public void BooleanVariableInitialTrueValueTest() { var variable = new BooleanVariable(true); Assert.IsTrue(variable.Value); }
public void BooleanVariableDefaultValueTest() { var variable = new BooleanVariable(); Assert.IsFalse(variable.Value); }