public virtual int comparePrecedence(BaseOperator paramBaseOperator) { if (paramBaseOperator is BaseOperator) { BaseOperator baseOperator = paramBaseOperator; return((this.precedence > baseOperator.precedence) ? 1 : ((baseOperator.precedence == this.precedence) ? 0 : -1)); } return(-paramBaseOperator.comparePrecedence(this)); }
public void CallOperator(string operatorName, params string[] operatorParams) { //OperatorSemaphore.WaitOne(); lock (OperatorLock) { Console.WriteLine($"Call method CallOperator :{operatorName} .Current Thread:{Thread.CurrentThread.ManagedThreadId}"); BaseOperator concreteOperator = OperatorFactory.Instance.GetOperator(operatorName); concreteOperator.InitializationParameters(operatorParams); concreteOperator.Execute(); } //OperatorSemaphore.Release(); }
void RayCast() { curOperatorPos = MousePosition; operatorLayer = LayerMask.GetMask("Operator"); //Debug.Log("enterbattlestate"); RaycastHit2D hit = Physics2D.Raycast(MousePosition - new Vector2(0.5f, 0), new Vector2(1, 0), 0.9f, operatorLayer); if (hit.collider != null && hit.collider.tag == "Operator") { CameraTransform(); baseOperator = hit.collider.GetComponent <BaseOperator>(); Time.timeScale = 0.1f; ShowDirChoosePanel(); //Debug.Log(hit.collider.gameObject); baseOperator.ShowDirChoosePanel(); isChoosingDir = true; } }
public VBOperator(BaseOperator opToCopyFrom) : base(opToCopyFrom) { }
public override ONPEquatationInterpreterResult Interpret(string equatation) { Stack <BaseOperator> operators = new Stack <BaseOperator>(); Queue <BaseElement> output = new Queue <BaseElement>(); var splittedEquatation = this.SplitNumberAndOperators(equatation); foreach (var element in splittedEquatation) { var equatationElement = parsers.OrderByDescending(x => x.Priority) .Select(x => x.Parse(element.ToString())) .Where(x => x != null) .FirstOrDefault(); if (equatationElement == null) { throw new NotImplementedException("The element is null"); } else if (equatationElement is BaseNumber) { output.Enqueue(equatationElement); } else if (equatationElement is BaseOperator) { var currentOperator = equatationElement as BaseOperator; if (operators.Any()) { BaseOperator topOperator = operators.Peek(); bool hasLowerPriority = true; while (hasLowerPriority) { if (topOperator == null) { break; } hasLowerPriority = ((currentOperator.Associativity == Associativity.Left && topOperator.Priority >= currentOperator.Priority) || (topOperator.Associativity == Associativity.Right && topOperator.Priority > currentOperator.Priority)); if (hasLowerPriority) { output.Enqueue(operators.Pop()); } topOperator = operators.Any() ? operators.Peek() : null; } } operators.Push(currentOperator); } else { throw new NotImplementedException("The element is not supported"); } } while (operators.Any()) { output.Enqueue(operators.Pop()); } return(new ONPEquatationInterpreterResult() { OnpNotation = output }); }
public IEvaluator <BaseOperator> FilterOperatorEvaluator(BaseOperator baseOperator) { return(this.evaluators.FirstOrDefault(x => x.OperatorType == baseOperator.GetType())); }