public new static BooleanVariable Random()
        {
            var x = new BooleanVariable();

            x.SetRandomValues();
            return(x);
        }
Exemplo n.º 2
0
        public void TestFalseStringValue()
        {
            BooleanVariable var = new BooleanVariable();

            var.CheckForStore("false");
            Assert.IsFalse((bool)var.Value);
        }
Exemplo n.º 3
0
        public void TestGetNotBoolValue()
        {
            BooleanVariable var    = new BooleanVariable();
            bool            actual = var.CheckForStore(var.CheckForStore(4));

            Assert.IsTrue(actual);
        }
Exemplo n.º 4
0
        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();
 }
Exemplo n.º 6
0
        public void TestTrueStringValue()
        {
            BooleanVariable var = new BooleanVariable();

            var.CheckForStore("true");
            Assert.IsTrue((bool)var.Value);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 9
0
        public void TestGetNullValue()
        {
            BooleanVariable var    = new BooleanVariable();
            bool            actual = var.CheckForStore(null);

            Assert.IsFalse(actual);
        }
Exemplo n.º 10
0
        public void BooleanVariableChangeValueTest()
        {
            var variable = new BooleanVariable(false);

            Assert.IsFalse(variable.Value);
            variable.Value = true;
            Assert.IsTrue(variable.Value);
        }
Exemplo n.º 11
0
    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);
        }
    }
Exemplo n.º 12
0
 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;
 }
Exemplo n.º 13
0
    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);
    }
Exemplo n.º 14
0
        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();
        }
Exemplo n.º 15
0
    /// <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;
        }
    }
Exemplo n.º 16
0
    /// <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;
        }
    }
Exemplo n.º 17
0
    /// <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);
        }
    }
Exemplo n.º 18
0
        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;
            }
        }
Exemplo n.º 19
0
    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.... :/
    }
Exemplo n.º 20
0
    //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;
            }
        }
    }
Exemplo n.º 21
0
        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();
        }
Exemplo n.º 22
0
        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));
        }
Exemplo n.º 23
0
 public VarExpression(BooleanVariable var, bool not = false)
 {
     Var = var;
 }
Exemplo n.º 24
0
 public void SetValue(BooleanVariable boolVariable)
 {
     Value = boolVariable.Value;
 }
Exemplo n.º 25
0
        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();
        }
Exemplo n.º 26
0
        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);
        }
Exemplo n.º 27
0
 public OpExpression(BooleanOperation op, BooleanVariable left, BooleanVariable right)
 {
     Op = op;
     Left = new VarExpression(left);
     Right = new VarExpression(right);
 }
Exemplo n.º 28
0
 public void SetBool(BooleanVariable state)
 {
     State = state.State;
 }
Exemplo n.º 29
0
        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;
                }
            }
        }
Exemplo n.º 30
0
 public OpExpression(BooleanOperation op, BooleanVariable left, BooleanVariable right)
 {
     Op    = op;
     Left  = new VarExpression(left);
     Right = new VarExpression(right);
 }
Exemplo n.º 31
0
        public void BooleanVariableInitialFalseValueTest()
        {
            var variable = new BooleanVariable(false);

            Assert.IsFalse(variable.Value);
        }
Exemplo n.º 32
0
        public void BooleanVariableInitialTrueValueTest()
        {
            var variable = new BooleanVariable(true);

            Assert.IsTrue(variable.Value);
        }
Exemplo n.º 33
0
        public void BooleanVariableDefaultValueTest()
        {
            var variable = new BooleanVariable();

            Assert.IsFalse(variable.Value);
        }
Exemplo n.º 34
0
 public VarExpression(BooleanVariable var, bool not = false)
 {
     Var = var;
 }