Пример #1
0
 private void Init()
 {
     iDefTokenThreshold    = 3;
     iAttackTokenThreshold = 7;
     iOffensiveThreshold   = 9;
     iPointPushThreshold   = 5;
     B_SuperDefense        = false;
     LI_ActiveTroops.Clear();
     LI_LaneAdvantage.Clear();
     LI_LaneTypes.Clear();
     iFriendlyCount = 0;
     I_Round        = 0;
     for (int iCount = 0; iCount < TournamentManager._instance.lanes.Count; iCount++)
     {
         LI_ActiveTroops.Add(0);
         LI_LaneAdvantage.Add(0);
         LI_LaneTypes.Add(false);
         iFriendlyCount += TournamentManager._instance.lanes[iCount].GetFriendliesInLane(this).Count;
     }
     B_StartLeft = GetStartSide();
     if (B_StartLeft)
     {
         Enemy = TournamentManager._instance.P2;
     }
     else
     {
         Enemy = TournamentManager._instance.P1;
     }
     responseState  = EResponseState.Basic;
     EAdaption      = EAdaptState.Neutral;
     ELearningState = EPerformanceState.Normal;
     TournamentManager.OnCreatureDead += TrackCreatureDeaths;
     B_Init = true;
 }
Пример #2
0
		private void CreateNode (TreeNode parentNode, LogicBase logic) {
			LogicTreeNode node = new LogicTreeNode (logic);
			
			if (logicNodeReferences.ContainsKey (logic) == false) {
				logicNodeReferences [logic] = new List<LogicTreeNode> ();
			}

			logicNodeReferences [logic].Add (node);
			node.Text = GetNodeName (logic);

			if (logic is LogicList) {
				LogicList list = (LogicList) logic;

				foreach (LogicBase l in list.Logics) {
					CreateNode (node, l);
				}

				node.ExpandAll ();
			}

			if (parentNode == null) {
				tree.Nodes.Add (node);
			} else {
				parentNode.Nodes.Add (node);
			}
		}
Пример #3
0
		public void AddLogicToTree (LogicBase logic) {
			CreateNode (null, logic);

			if (tree.Nodes.Count == 1) {
				tree.SelectedNode = tree.Nodes [0];
			}
		}
 public override void PopulateGrid(LogicBase logic)
 {
     base.PopulateGrid (logic);
     LogicReference foo = (LogicReference) logic;
     this.Grid.AddRow (Constants.Logic, Constants.LogicDescription, EditLogic);
     SetLogic (foo.Logic);
 }
Пример #5
0
        public async Task CreateMovements(LogicBase ai)
        {
            try
            {
                using (var call = _client.CreateMovements())
                {
                    await call.RequestStream.WriteAsync(Mapping.ToGrpc(ai.CreateMove()));

                    // Continuos bidirectional streaming
                    var responseReaderTask = Task.Run((Func <Task>)(async() =>
                    {
                        while (await call.ResponseStream.MoveNext(CancellationToken.None))
                        {
                            var opponentMove = call.ResponseStream.Current;
                            Logger.Log($"Received opponent move: {opponentMove.StartPosition} to {opponentMove.EndPosition}");

                            // Analyze opponent move
                            ai.ReceiveMove(Mapping.ToCommon(opponentMove));

                            // Create own move
                            await call.RequestStream.WriteAsync(Mapping.ToGrpc(ai.CreateMove()));
                        }
                    }));

                    await responseReaderTask;
                    await call.RequestStream.CompleteAsync();
                }
            }
            catch (RpcException e)
            {
                Logger.Log(e.ToString());
            }
        }
Пример #6
0
        static ModeManager()
        {
            // Initialize properties
            Modes = new List <ModeBase>();

            {
                QLogic = new QLogic();
                WLogic = new WLogic();
                ELogic = new ELogic();
                RLogic = new RLogic();
            }

            Modes.AddRange(new ModeBase[]
            {
                new PermaActive(),
                new Combo(),
                new Harass(),
                new LaneClear(),
                new JungleClear(),
                new LastHit(),
                new Flee()
            });


            Game.OnTick += OnTick;
        }
Пример #7
0
        public int GetNewId()
        {
            LogicBase LB = new LogicBase();

            LB.Connection = getSQLConnection();
            return(LB.GetIDX());
        }
Пример #8
0
    public void register(string name, LogicBase logic)
    {
        if (_mapLogic.ContainsKey(name))
        {
            Debug.LogWarning("LogicMgr register Name is Exist! " + name);
        }

        logic.onInit();
        _mapLogic.Add(name, logic);
    }
        public override void PopulateGrid(LogicBase logic)
        {
            base.PopulateGrid (logic);
            LogicList foo = (LogicList) logic;

            if (foo.ID.Length > 0) {
                this.Grid.AddRow (Constants.ID, Constants.IDLogicDescription, EditID);
                this.Grid.SetValue (Constants.ID, foo.ID);
            }
        }
Пример #10
0
    public LogicBase getLogic(string name)
    {
        LogicBase logic = null;

        if (_mapLogic.ContainsKey(name))
        {
            logic = _mapLogic[name];
        }
        return(logic);
    }
Пример #11
0
        /// <summary>
        /// Sets the value of the logic property.
        /// </summary>
        /// <param name="logic">The logic, can be <c>null</c> so the caller don't have to check for this.</param>
        /// <param name="action">The action that will set the actual value, will only be executed if <paramref name="logic"/> is not <c>null</c>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="action"/> is <c>null</c>.</exception>
        public static void SetValue <TLogic>(this LogicBase logic, Action <TLogic> action)
            where TLogic : LogicBase
        {
            Argument.IsNotNull("action", action);

            if (logic == null)
            {
                return;
            }

            action((TLogic)logic);
        }
Пример #12
0
        /// <summary>
        /// Sets the value of the logic property.
        /// </summary>
        /// <param name="logic">The logic, can be <c>null</c> so the caller don't have to check for this.</param>
        /// <param name="function">The function that will get the actual value, will only be executed if <paramref name="logic"/> is not <c>null</c>.</param>
        /// <param name="defaultValue">The default value to return if the logic is not available.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="function"/> is <c>null</c>.</exception>
        public static TValue GetValue <TLogic, TValue>(this LogicBase logic, Func <TLogic, TValue> function, TValue defaultValue)
            where TLogic : LogicBase
        {
            Argument.IsNotNull("function", function);

            if (logic == null)
            {
                return(defaultValue);
            }

            return(function((TLogic)logic));
        }
Пример #13
0
        public static void Initialize()
        {
            if (!initialized)
            {
                initialized = true;

                injectTime = Game.ClockTime;
                MenuBase.Initialize();
                LogicBase.Initialize();
                ChampionLoader.Initialize();
            }
        }
        public override void PopulateGrid(LogicBase logic)
        {
            base.PopulateGrid (logic);
            LogicText foo = (LogicText) logic;

            if (foo.ID.Length > 0) {
                this.Grid.AddRow (Constants.ID, Constants.IDLogicDescription, EditID);
                SetID (foo.ID);
            }

            this.Grid.AddRow (Constants.Text, Constants.TextLogicTextDescription, EditText);
            SetText (foo.Text);
        }
Пример #15
0
		private string GetNodeName (LogicBase logic) {
			string name = "";

			if (logic is LogicReference) {
				name = ((LogicReference) logic).Logic.ID + " ";
			} else {
				name = ((LogicItem) logic).ID + " ";
				name = (name.Length <= 1) ? "" : name;
			}

			name += "(" + logic.GetType ().Name + ")";
			return name;
		}
Пример #16
0
    public void unRegister(string name)
    {
        if (!_mapLogic.ContainsKey(name))
        {
            Debug.LogWarning("LogicMgr register Name is  Not Exist! " + name);
            return;
        }

        LogicBase logic = _mapLogic[name];

        logic.onUnInit();
        _mapLogic.Remove(name);
    }
    public List <CreatureBase> GetEnemiesInLane(LogicBase playerLogicBase)
    {
        List <CreatureBase> creaturesInRange = new List <CreatureBase> ();

        foreach (CreatureBase creature in creatures)
        {
            if (creature.Owner != playerLogicBase)
            {
                creaturesInRange.Add(creature);
            }
        }
        Debug.LogWarning("--|Amount of enemies in lane:" + creaturesInRange.Count);
        return(creaturesInRange);
    }
Пример #18
0
        public async Task CreateMovements(LogicBase ai)
        {
            try
            {
                using (var call = _client.Act())
                {
                    await call.RequestStream.WriteAsync(Mapping.ToGrpc(ai.CreateMove()));

                    // Continuos bidirectional streaming
                    var responseReaderTask = Task.Run((Func <Task>)(async() =>
                    {
                        while (await call.ResponseStream.MoveNext(CancellationToken.None))
                        {
                            var opponentMove = call.ResponseStream.Current;
                            if (opponentMove == null || opponentMove.Chess == null)
                            {
                                // Error or game end
                                return;
                            }
                            else if (opponentMove.Chess.CheckMate)
                            {
                                // TODO should we trust this
                                // TODO for now CheckMate also used to sign any game ending and errors
                                return;
                            }

                            Logger.Log($"Received opponent move: {opponentMove.Chess.StartPosition} to {opponentMove.Chess.EndPosition}");

                            // Analyze opponent move
                            ai.ReceiveMove(Mapping.ToCommon(opponentMove));

                            // Create own move
                            await call.RequestStream.WriteAsync(Mapping.ToGrpc(ai.CreateMove()));
                        }
                    }));

                    await responseReaderTask;
                    await call.RequestStream.CompleteAsync();
                }
            }
            catch (RpcException e)
            {
                Logger.Log($"DEBUG: {e.ToString()}");
                throw new GameEndedException(e);
            }
        }
Пример #19
0
		public void UpdatedLogic (LogicBase logic) {
			Stack <LogicTreeNode> nodes = new Stack<LogicTreeNode> ();

			foreach (LogicTreeNode node in tree.Nodes) {
				nodes.Push (node);
			}
			
			while (nodes.Count > 0) {
				LogicTreeNode node = nodes.Pop ();
				node.Text = GetNodeName (node.Logic);

				if (node.Logic is LogicList) {
					foreach (LogicTreeNode n in node.Nodes) {
						nodes.Push (n);
					}
				}
			}
		}
Пример #20
0
 public void Init(LogicBase _owner, LaneManager _lane, Spawnable _type, UIHealth _healthUI, float _damageAmount)
 {
     if (init == false)
     {
         owner          = _owner;
         lane           = _lane;
         creatureType   = _type;
         uiHealth       = _healthUI;
         damageAmount   = _damageAmount;
         range          = _type == Spawnable.Bunny ? TournamentManager._instance.bunnyRange : TournamentManager._instance.unicornRange;
         init           = true;
         activeLaneNode = lane.GetFirstLaneNode(owner);
         activeLaneNode.activeCreature = this;
         owner._Creatures.Add(this);
         rightFacing = owner._RightFacing;
         // Debug.Log ("Creature owned by " + owner);
     }
 }
    public List <CreatureBase> SearchRange(int range, LaneNode currentNode, LogicBase player)
    {
        List <CreatureBase> creaturesInRange = new List <CreatureBase> ();

        for (int i = -range; i < range + 1; i++)
        {
            if (allNodes.IndexOf(currentNode) + i >= 0 && allNodes.IndexOf(currentNode) + i < allNodes.Count)
            {
                if (allNodes[allNodes.IndexOf(currentNode) + i].activeCreature != null)
                {
                    creaturesInRange.Add(allNodes[allNodes.IndexOf(currentNode) + i].activeCreature);
                }
            }
        }
        if (player._PlayerNumber == 2)
        {
            creaturesInRange.Reverse();
        }

        return(creaturesInRange);
    }
Пример #22
0
        private void OnGetObjectList(ushort id, MemoryStream stream)
        {
            MsgBase xMsg = new MsgBase();

            xMsg = Serializer.Deserialize <MsgBase>(stream);

            AckPlayerEntryList xData = new AckPlayerEntryList();

            xData = Serializer.Deserialize <AckPlayerEntryList>(new MemoryStream(xMsg.msg_data));

            for (int i = 0; i < xData.object_list.Count; ++i)
            {
                PlayerEntryInfo xInfo = xData.object_list[i];

                NFIDataList var = new NFCDataList();
                var.AddString("X");
                var.AddFloat(xInfo.x);
                var.AddString("Y");
                var.AddFloat(xInfo.z);
                var.AddString("Z");
                var.AddFloat(xInfo.y);

                NFIObject xGO = CreateObject(LogicBase.PBToNF(xInfo.object_guid), xInfo.scene_id, 0,
                                             Encoding.Default.GetString(xInfo.class_id),
                                             Encoding.Default.GetString(xInfo.config_id), var);
//            var.AddObject(PBToNF(xInfo.object_guid));
//
//            DoEvent((int) Event.OtherClientShow, var);

                if (null == xGO)
                {
                    continue;
                }

                mGroupPlayerList.Add(xGO);
            }
        }
 public void UpdatedLogic(LogicBase logic)
 {
     logicEditor.UpdatedLogic (logic);
 }
        private void btnGo_Click(object sender, EventArgs e)
        {
            StringBuilder stringBuilder    = null;
            string        messageText      = "";
            Exception     exceptionDetails = null;
            string        path             = tbPath.Text;
            string        fileName         = tbFileName.Text;
            ReadFileLogic readFileLogic    = null;

            try
            {
                logicBase = new LogicBase();
                ResetListBox();
                if ((string.IsNullOrEmpty(path) == false) && (string.IsNullOrEmpty(fileName) == false))
                {
                    readFileLogic = new ReadFileLogic();
                    if (readFileLogic != null)
                    {
                        readFileLogic.PathName = path;
                        readFileLogic.FileName = fileName;
                        readFileLogic.ReadFile();
                        messageText = ConvertLogic.ConvertPersonallyIdentifiableInformationToString(readFileLogic.personallyIdentifiableInformation);
                        listBox1.Items.Add(messageText);

                        logicBase.personallyIdentifiableInformation = new PersonallyIdentifiableInformation(readFileLogic.personallyIdentifiableInformation);

                        foreach (BloodGlucose bloodGlucose in readFileLogic.listBloodGlucose)
                        {
                            messageText = ConvertLogic.ConvertBloodGlucoseToString(bloodGlucose);
                            listBox1.Items.Add(messageText);
                            logicBase.listBloodGlucose.Add(new BloodGlucose(bloodGlucose));
                        }

                        foreach (PulseAndOxygen pulseAndOxygen in readFileLogic.listPulseAndOxygen)
                        {
                            messageText = ConvertLogic.ConvertPulseAndOxygenToString(pulseAndOxygen);
                            listBox1.Items.Add(messageText);
                            logicBase.listPulseAndOxygen.Add(new PulseAndOxygen(pulseAndOxygen));
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                stringBuilder    = new StringBuilder();
                exceptionDetails = exception;

                while (exceptionDetails != null)
                {
                    messageText = "\r\nMessage: " + exceptionDetails.Message + "\r\nSource: " + exceptionDetails.Source + "\r\nStack Trace: " + exceptionDetails.StackTrace + "\r\n----------\r\n";

                    stringBuilder.Append(messageText);

                    exceptionDetails = exceptionDetails.InnerException;
                }

                messageText = stringBuilder.ToString();

                listBox1.Items.Add(messageText);
            }
        }
Пример #25
0
 public async Task Play(LogicBase ai)
 {
     // TODO handle exceptions and game end
     await _client.CreateMovements(ai);
 }
 public virtual void PopulateGrid(LogicBase logic)
 {
     Logic = logic;
 }
Пример #27
0
 public AttackingPair(int thelane, LogicBase Owner)
 {
     //  Debug.Log ("-----Create Pair-----");
     _Lane = thelane;
     owner = Owner;
 }
Пример #28
0
 public BinaryLogicExpression([NotNull] LogicBase @operator, [NotNull] IValue left, [NotNull] IValue right) :
     base(@operator)
 {
     Left  = left ?? throw new ArgumentNullException(nameof(left));
     Right = right ?? throw new ArgumentNullException(nameof(right));
 }
Пример #29
0
        private static List <ExpressionBase> ConvertRoslynExpressionToWandaExpression(
            SimpleCompoundStatement wandaBlock,
            ExpressionSyntax expressionSyntax)
        {
            var result = new List <ExpressionBase>();

            switch (expressionSyntax)
            {
            case AssignmentExpressionSyntax assignmentExpressionSyntax:
            {
                var            left          = assignmentExpressionSyntax.Left;
                var            operatorToken = assignmentExpressionSyntax.OperatorToken;
                var            right         = assignmentExpressionSyntax.Right;
                var            leftValue     = wandaBlock.ResolveLValue(result, left, true);
                var            rightValue    = wandaBlock.ResolveValue(result, right, true);
                AssignmentBase assignment    = null;

                switch (operatorToken.Kind())
                {
                case SyntaxKind.EqualsToken:
                    assignment = new SimpleAssignment(leftValue, rightValue);
                    break;

                case SyntaxKind.SlashEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryDivideOperator.Instance);
                    break;

                case SyntaxKind.PlusEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryAddOperator.Instance);
                    break;

                case SyntaxKind.MinusEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinarySubtractOperator.Instance);
                    break;

                case SyntaxKind.AsteriskEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryMultiplyOperator.Instance);
                    break;

                case SyntaxKind.PercentEqualsToken:
                    assignment =
                        new OperatorAssignment(leftValue, rightValue, BinaryRemainderOperator.Instance);
                    break;

                case SyntaxKind.AmpersandEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitAndOperator.Instance);
                    break;

                case SyntaxKind.CaretEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitXorOperator.Instance);
                    break;

                case SyntaxKind.BarEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue, BinaryBitOrOperator.Instance);
                    break;

                case SyntaxKind.LessThanLessThanEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue,
                                                        BinaryBitShiftLeftOperator.Instance);
                    break;

                case SyntaxKind.GreaterThanGreaterThanEqualsToken:
                    assignment = new OperatorAssignment(leftValue, rightValue,
                                                        BinaryBitShiftRightOperator.Instance);
                    break;

                case SyntaxKind.QuestionQuestionEqualsToken:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (assignment != null)
                {
                    result.Add(assignment);
                }
                else
                {
                    Log.Debug("{Left} {Operator} {Right}", left,
                              operatorToken.Text,
                              right);
                }

                break;
            }

            case PrefixUnaryExpressionSyntax unaryExpressionSyntax:
            {
                var            operand       = unaryExpressionSyntax.Operand;
                var            leftValue     = wandaBlock.ResolveLValue(result, operand, true);
                AssignmentBase assignment    = null;
                var            operatorToken = unaryExpressionSyntax.OperatorToken;
                switch (operatorToken.Kind())
                {
                case SyntaxKind.PlusToken:
                case SyntaxKind.MinusToken:
                case SyntaxKind.TildeToken:
                case SyntaxKind.ExclamationToken:
                    break;

                case SyntaxKind.PlusPlusToken:
                    assignment = new OperatorAssignment(leftValue, IntegerLiteral.One,
                                                        BinaryAddOperator.Instance);
                    break;

                case SyntaxKind.MinusMinusToken:
                    assignment = new OperatorAssignment(leftValue, IntegerLiteral.One,
                                                        BinarySubtractOperator.Instance);
                    break;

                case SyntaxKind.AmpersandToken:
                case SyntaxKind.AsteriskToken:
                case SyntaxKind.CaretToken:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (assignment != null)
                {
                    result.Add(assignment);
                }
                else
                {
                    Log.Debug("{Operator} {Right}", operatorToken.Text,
                              unaryExpressionSyntax.Operand);
                }

                break;
            }

            case PostfixUnaryExpressionSyntax unaryExpressionSyntax:
            {
                var            operand       = unaryExpressionSyntax.Operand;
                var            leftValue     = wandaBlock.ResolveLValue(result, operand, true);
                AssignmentBase assignment    = null;
                var            operatorToken = unaryExpressionSyntax.OperatorToken;
                switch (operatorToken.Kind())
                {
                case SyntaxKind.PlusPlusToken:
                    assignment = new OperatorAssignment(leftValue, IntegerLiteral.One,
                                                        BinaryAddOperator.Instance);
                    break;

                case SyntaxKind.MinusMinusToken:
                    assignment = new OperatorAssignment(leftValue, IntegerLiteral.One,
                                                        BinarySubtractOperator.Instance);
                    break;

                case SyntaxKind.ExclamationToken:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                if (assignment != null)
                {
                    // todo: that's not right. The value returned by expression is not as simple
                    result.Add(assignment);
                }
                else
                {
                    Log.Debug("{Left} {Operator}", unaryExpressionSyntax.Operand,
                              operatorToken.Text);
                }

                break;
            }

            case InvocationExpressionSyntax invocationExpressionSyntax:
            {
                var what = invocationExpressionSyntax.Expression.ToString();

                FunctionCallParameter Selector(ArgumentSyntax x)
                {
                    var xRefKindKeyword = x.RefKindKeyword.Kind();

                    var(isRef, isOut) = (
                        xRefKindKeyword == SyntaxKind.RefKeyword,
                        xRefKindKeyword == SyntaxKind.OutKeyword);

                    return(new FunctionCallParameter
                        {
                            Value = wandaBlock.ResolveValue(result, x.Expression, true),
                            Out = isOut,
                            Ref = isRef
                        });
                }

                var with = invocationExpressionSyntax.ArgumentList.Arguments.Select(Selector);

                var functionCallOperator = new FunctionCallOperator {
                    Name = what
                };
                functionCallOperator.Arguments.AddRange(with);

                result.Add(functionCallOperator);
                break;
            }

            case IdentifierNameSyntax identifierNameSyntax:
            {
                result.Add(wandaBlock.ResolveVariableByName(identifierNameSyntax.Identifier.Text));
                break;
            }

            case LiteralExpressionSyntax literalExpressionSyntax:
            {
                result.Add(ResolveLiteral(literalExpressionSyntax));
                break;
            }

            case ElementAccessExpressionSyntax elementAccessExpressionSyntax:
            {
                result.Add(
                    ResolveRoslynElementAccessExpressionToWandaOperator(elementAccessExpressionSyntax,
                                                                        result,
                                                                        wandaBlock));
                break;
            }

            case BinaryExpressionSyntax binaryExpressionSyntax:
            {
                var       operatorToken = binaryExpressionSyntax.OperatorToken;
                PureBase  operatorBase  = null;
                LogicBase logicBase     = null;
                switch (operatorToken.Kind())
                {
                case SyntaxKind.PlusToken:
                    operatorBase = BinaryAddOperator.Instance;
                    break;

                case SyntaxKind.MinusToken:
                    operatorBase = BinarySubtractOperator.Instance;
                    break;

                case SyntaxKind.AsteriskToken:
                    operatorBase = BinaryMultiplyOperator.Instance;
                    break;

                case SyntaxKind.SlashToken:
                    operatorBase = BinaryDivideOperator.Instance;
                    break;

                case SyntaxKind.PercentToken:
                    operatorBase = BinaryRemainderOperator.Instance;
                    break;

                case SyntaxKind.LessThanLessThanToken:
                    operatorBase = BinaryBitShiftLeftOperator.Instance;
                    break;

                case SyntaxKind.GreaterThanGreaterThanToken:
                    operatorBase = BinaryBitShiftRightOperator.Instance;
                    break;

                case SyntaxKind.BarBarToken:
                    logicBase = OrLogic.Instance;
                    break;

                case SyntaxKind.AmpersandAmpersandToken:
                    logicBase = AndLogic.Instance;
                    break;

                case SyntaxKind.BarToken:
                    operatorBase = BinaryBitOrOperator.Instance;
                    break;

                case SyntaxKind.AmpersandToken:
                    operatorBase = BinaryBitAndOperator.Instance;
                    break;

                case SyntaxKind.CaretToken:
                    operatorBase = BinaryBitXorOperator.Instance;
                    break;

                case SyntaxKind.EqualsEqualsToken:
                    logicBase = EqualLogic.Instance;
                    break;

                case SyntaxKind.ExclamationEqualsToken:
                    logicBase = NotEqualLogic.Instance;
                    break;

                case SyntaxKind.LessThanToken:
                    logicBase = LessLogic.Instance;
                    break;

                case SyntaxKind.LessThanEqualsToken:
                    logicBase = LessOrEqualLogic.Instance;
                    break;

                case SyntaxKind.GreaterThanToken:
                    logicBase = GreaterLogic.Instance;
                    break;

                case SyntaxKind.GreaterThanEqualsToken:
                    logicBase = GreaterOrEqualLogic.Instance;
                    break;

                case SyntaxKind.IsKeyword:
                case SyntaxKind.AsKeyword:
                case SyntaxKind.QuestionQuestionToken:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                switch (operatorBase != null, logicBase != null)
                {
                case (true, false):
                {
                    var left  = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Left, true);
                    var right = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Right, true);

                    var dummy = new DummyVariable
                    {
                        TypeRef = ApproximateResultTypeOfBinaryOperator(left, right)
                    };
                    wandaBlock.LocalVariables.Add(dummy);

                    var assignment = new SimpleAssignment(dummy, left);
                    result.Add(assignment);

                    var operatorAssignment = new OperatorAssignment(dummy, right, operatorBase);
                    result.Add(operatorAssignment);
                    break;
                }

                case (false, true):
                {
                    var left  = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Left, true);
                    var right = wandaBlock.ResolveValue(result, binaryExpressionSyntax.Right, true);

                    var operatorAssignment = new BinaryLogicExpression(logicBase, left, right);
                    result.Add(operatorAssignment);
                    break;
                }

                case (false, false):
                {
                    Log.Debug("BINARY: {Left} {Operator} {Right} ({Kind})",
                              binaryExpressionSyntax.Left,
                              operatorToken.Text,
                              binaryExpressionSyntax.Right,
                              operatorToken.Kind());
                    break;
                }

                default:
                    throw new ArgumentOutOfRangeException();
                }

                break;
            }
Пример #30
0
 /// <summary>
 /// Sets the value of the logic property.
 /// </summary>
 /// <param name="logic">The logic, can be <c>null</c> so the caller don't have to check for this.</param>
 /// <param name="function">The function that will get the actual value, will only be executed if <paramref name="logic"/> is not <c>null</c>.</param>
 /// <exception cref="ArgumentNullException">The <paramref name="function"/> is <c>null</c>.</exception>
 public static TValue GetValue <TLogic, TValue>(this LogicBase logic, Func <TLogic, TValue> function)
     where TLogic : LogicBase
 {
     return(GetValue(logic, function, default(TValue)));
 }
Пример #31
0
 protected LogicExpressionBase([NotNull] LogicBase @operator)
 {
     Operator = @operator ?? throw new ArgumentNullException(nameof(@operator));
 }
Пример #32
0
 public LogicTreeNode(LogicBase logic)
 {
     Edited = false;
     Logic = logic;
 }
 public LaneNode GetFirstLaneNode(LogicBase logicBase)
 {
     return(allNodes[logicBase._RightFacing ? 0 : allNodes.Count - 1]);
 }
 public LaneNode PreviousNode(LaneNode nextNode, LogicBase owner)
 {
     nextNode = nextNode.laneManager.allNodes[nextNode.laneManager.allNodes.IndexOf(nextNode) + (owner._RightFacing ? -1 : 1)];
     return(nextNode);
 }
Пример #35
0
 public void Delete(int id)
 {
     LogicBase.DeleteEntity(id);
 }
Пример #36
0
        public static List <CreatureBase> GetEnemies(this List <CreatureBase> creatures, LogicBase owner)
        {
            List <CreatureBase> enemies = new List <CreatureBase> ();

            foreach (CreatureBase creature in creatures)
            {
                if (creature.Owner != owner)
                {
                    enemies.Add(creature);
                }
            }
            return(enemies);
        }
Пример #37
0
 public void Delete(EntityBase objectToDelete)
 {
     Invoke(() => LogicBase.Delete(objectToDelete));
 }
Пример #38
0
 public TApiModel Update(int id, TModel model)
 {
     return(Map(LogicBase.UpdateEntity(id, model)));
 }
Пример #39
0
 public UnaryLogicExpression([NotNull] LogicBase @operator, [NotNull] IValue value) : base(@operator)
 {
     Value = value ?? throw new ArgumentNullException(nameof(value));
 }
Пример #40
0
 public TApiModel Create(TModel model)
 {
     return(Map(LogicBase.CreateEntity(model)));
 }