public SubtractFromInteger(string variableName, string npcName, NumericOperand operand, Conversation conversation)
 {
     this.variableName = variableName;
     if (npcName != null){
         GameObject npc = CharacterManager.GetCharacter(npcName);
         variableSet = ((CharacterState)npc.GetComponent("CharacterState")).GetVariableSet();
     } else {
         variableSet = conversation.GetVariableSet();
     }
     this.operand = operand;
 }
 public AbstractImpressionAdjuster(string impressionName, NumericOperand operand, bool excludeSpeaker, string recepientName)
 {
     impression = AILoader.GetImpression(impressionName);
     if (impression == null){
         throw new InvalidScriptException("Invalid impression name: " + impressionName);
     }
     this.operand = operand;
     this.excludeSpeaker = excludeSpeaker;
     if (recepientName != null){
         recepient = CharacterManager.GetMajorNPC(recepientName);
         if (recepient == null){
             throw new InvalidScriptException("Invalid NPC name: " + recepientName);
         }
     } else {
         recepient = null;
     }
 }
 public NumericExpression(
     string numericProperty,
     NumericOperand numericOperand,
     double value,
     Conditional conditional)
     : base(numericProperty, value, numericOperand, conditional)
 {
     this._binaryExpression =
         new CodeBinaryOperatorExpression(
             new CodeCastExpression(
                 "System.Double",
                 new CodePropertyReferenceExpression(
                     new CodeThisReferenceExpression(),
                     numericProperty)),
             (CodeBinaryOperatorType)
             Enum.Parse(typeof(CodeBinaryOperatorType), numericOperand.ToString(), true),
             new CodePrimitiveExpression(value));
 }
Beispiel #4
0
 /// <summary>
 /// string length functions
 /// </summary>
 /// <example>
 /// "abc".Length >= 3 ?
 /// </example>
 public StringExpression(
     string stringProperty,
     NumericOperand operand,
     int value,
     Conditional conditional)
     : base(stringProperty, value, operand, conditional)
 {
     this._binaryExpression = new CodeBinaryOperatorExpression
         {
             Left =
                 new CodeMethodInvokeExpression(
                     CodeTypeReferenceExpression, "LengthFunction",
                     new CodeExpression[]
                         {
                             new CodePropertyReferenceExpression(new CodeThisReferenceExpression(),
                                                                 stringProperty),
                             new CodePrimitiveExpression(value),
                             new CodePrimitiveExpression(operand),
                         }),
             Operator = CodeBinaryOperatorType.ValueEquality,
             Right = CodePrimitiveExpressionTrue
         };
 }
 public GiveMoneyConsequenceNode(GameObject actor, string recipientName, NumericOperand amount)
     : base(actor, false)
 {
     this.recipientName = recipientName;
     this.amount = amount;
 }
 private static ImpressionAdjuster InterpretImpressionAdjuster(string assignmentOperator, string impressionName, NumericOperand operand, string npcName, Conversation conversation)
 {
     bool excludeSpeaker = npcName != null && npcName.ToLower().Equals("others");
     if (excludeSpeaker){
         npcName = null;
     }
     if (assignmentOperator.Equals("->")){
         return new ImpressionPush(impressionName, operand, excludeSpeaker, npcName);
     } else if (assignmentOperator.Equals("=")){
         return new SetImpression(impressionName, operand, excludeSpeaker, npcName);
     } else {
         throw new InvalidScriptException("No arrow or equals sign in consequence script!");
     }
 }
 public ImpressionPush(string impressionName, NumericOperand operand, bool excludeSpeaker, string recepientName)
     : base(impressionName, operand, excludeSpeaker, recepientName)
 {
 }
 public LessThanOrEqualTo(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }
 public GreaterThanOrEqualTo(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }
Beispiel #10
0
 public Equals(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }
Beispiel #11
0
 public LessThan(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }
 public GreaterThan(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }
Beispiel #13
0
 /// <summary>
 /// instance string methods could bomb due to null, so we just wrap these
 /// </summary>
 /// <remarks>unfortunately this must remain public for the codedom dispatch</remarks>
 public static bool LengthFunction(string a, int length, NumericOperand operand)
 {
     if (null == a) return false;
     if (operand == NumericOperand.GreaterThan)
         return a.Length > length;
     if (operand == NumericOperand.GreaterThanOrEqual)
         return a.Length >= length;
     if (operand == NumericOperand.LessThan)
         return a.Length < length;
     if (operand == NumericOperand.LessThanOrEqual)
         return a.Length <= length;
     if (operand == NumericOperand.NotEqual)
         return a.Length != length;
     if (operand == NumericOperand.ValueEquality)
         return a.Length == length;
     throw new ArgumentException("operand " + operand + " not mapped");
 }
 public NotEqualTo(NumericOperand operand0, NumericOperand operand1)
     : base(operand0, operand1)
 {
 }