示例#1
0
 public ConnectionNode(BaseNodeBlock pblock, String Name, Point p, ECOnnectionType nodetype)
 {
     this.ParentBlock  = pblock;
     this.Name         = Name;
     this.NodeLocation = p;
     this.NodeType     = nodetype;
 }
示例#2
0
 public override void OnEndNodeBlockExecution(ref BaseNodeBlock currentNB)
 {
     if (bOutputTrue)
     {
         currentNB = TrueOutput.ConnectedNodes[0].ParentBlock;
     }
     else
     {
         currentNB = FalseOutput.ConnectedNodes[0].ParentBlock;
     }
     this.ActiveStatus = EActiveStatus.Disabled;
 }
示例#3
0
        /// <summary>
        /// check to make sure all the nodes on this block have valid connection points.
        /// </summary>
        /// <param name="currentNB"></param>
        /// <returns></returns>
        public override bool OnStartNodeBlockExecution(ref BaseNodeBlock currentNB)
        {
            bool temp = true;
            int  i    = 0;

            this.ActiveStatus = EActiveStatus.Active;
            foreach (ConnectionNode cn in InputNodes)
            {
                if (!(cn.ConnectedNodes.Count > 0))
                {
                    if (InputNodes.Count - 1 == i && (!NewValConnected && NewValue_Constant != ""))
                    {
                        continue;
                    }
                    temp = false;
                    ErrorStack.Push(new InputNodeConnectionException(i, this.GetType().Name));
                }
                i++;
            }

            i = 0;
            foreach (ConnectionNode cn in OutputNodes)
            {
                if (!(cn.ConnectedNodes.Count > 0))
                {
                    temp = false;
                    ErrorStack.Push(new OutputNodeConnectionException(i, this.GetType().Name));
                }
                i++;
            }

            if (!(EntryNode.ConnectedNodes.Count > 0))
            {
                temp = false;
                ErrorStack.Push(new EntryNodeConnectionException(this.GetType().Name));
            }

            if (!temp)
            {
                this.ActiveStatus = EActiveStatus.Error;
            }
            return(temp);
        }
示例#4
0
        /// <summary>
        /// This method is here to check where or not execution can occur.
        /// It also checks every eval node before to make sure the "expression" is valid
        /// </summary>
        /// <param name="currentNB"></param>
        /// <returns></returns>
        public override bool NodeBlockExecution(ref BaseNodeBlock currentNB)
        {
            bool temp = true;

            if (this.InputNodes.Count == 0)
            {
                return(true);
            }
            else
            {
                //we need to evaluate the inputs to determine the calculated output.
                if (!this.OnStartEvaluateInternalData())
                {
                    //error found
                    Console.WriteLine(@"Dialogue Eval failed");
                    this.ActiveStatus = EActiveStatus.Error;
                    return(false);
                }
            }
            return(temp);
        }
示例#5
0
        /// <summary>
        /// we need to determine what state the expression is in
        /// if connectedBlock is GetConstantBlock then we don't need to do any equations.
        /// </summary>
        /// <param name="connectedBlock"></param>
        public override bool EvaluateInternalData(BaseNodeBlock connectedBlock)
        {
            Console.WriteLine(String.Format("From {0} -> {1}", this.GetType().Name, connectedBlock.GetType().Name));
            bool temp = true;

            if (connectedBlock is GetConstantNodeBlock block)
            {
                ResultsStack.Push(block?.InternalData.VarData);
                Console.WriteLine(String.Format("Result: {0}", ResultsStack.Peek()));
                return(true);
            }
            else
            {
                if (connectedBlock.AnswerToOutput != null)
                {
                    ResultsStack.Push(connectedBlock.AnswerToOutput);
                    Console.WriteLine(String.Format("Result: {0}", ResultsStack.Peek()));
                    connectedBlock.AnswerToOutput = null;
                }
                //else if (connectedBlock.NewValue_Constant != null && !(connectedBlock as BaseArithmeticBlock).NewValConnected)
                //{
                //	ResultsStack.Push(Int32.Parse(connectedBlock.NewValue_Constant));
                //	Console.WriteLine(String.Format("Result: {0}", ResultsStack.Peek()));
                //}
                else
                {
                    temp &= connectedBlock.OnStartEvaluateInternalData();                     //it's not a constant thus we MUST evaluate this node.
                    if (temp)
                    {
                        this.ResultsStack.Push(connectedBlock.AnswerToOutput);
                        Console.WriteLine(String.Format("Result: {0}", ResultsStack.Peek()));
                        connectedBlock.AnswerToOutput = null;
                    }
                }
            }
            return(temp);
        }
示例#6
0
 public override void OnEndNodeBlockExecution(ref BaseNodeBlock currentNB)
 {
     //TODO: make the unlocking variables work
     currentNB         = this.OutputNodes[ChoiceVar].ConnectedNodes[0].ParentBlock;
     this.ActiveStatus = EActiveStatus.Disabled;
 }