Example #1
0
        /// <summary>
        /// Called every time a node is saved.
        /// </summary>
        /// <param name="node"></param>
        private void ManageNodeSaving(WireNode node)
        {
            if (node is SayReplyWireNode)
            {
                SayReplyWireNode replyNode = node as SayReplyWireNode;
                replyNode.ReplyResourcePath  = AssetDatabase.GetAssetPath(replyNode.Reply).Replace("Assets/Resources/", "").Replace(".asset", "");
                replyNode.TargetResourcePath = AssetDatabase.GetAssetPath(replyNode.Target).Replace("Assets/Resources/", "").Replace(".asset", "");
            }
            else if (node is SetAnimatorVariableWireNode)
            {
                SetAnimatorVariableWireNode setVarNode = node as SetAnimatorVariableWireNode;
                setVarNode.TargetResourcePath = AssetDatabase.GetAssetPath(setVarNode.TargetActor).Replace("Assets/Resources/", "").Replace(".asset", "");
            }
            else if (node is GetAnimatorVariableWireNode)
            {
                GetAnimatorVariableWireNode getVarNode = node as GetAnimatorVariableWireNode;
                getVarNode.TargetResourcePath = AssetDatabase.GetAssetPath(getVarNode.TargetActor).Replace("Assets/Resources/", "").Replace(".asset", "");
            }

            if (node is ISavable)
            {
                (node as ISavable).Save();
            }

            if (OnSaveNode != null)
            {
                OnSaveNode.Invoke(node);
            }
        }
Example #2
0
 private GetAnimatorVariableNodeDisplayer(GetAnimatorVariableWireNode node) : base(node)
 {
     ActorField = new ActorIdentifierNodeField(this)
     {
         FieldName = "Target"
     };
     ActorField.FieldValue = node.TargetActor;
 }
Example #3
0
        public static GetAnimatorVariableNodeDisplayer CreateDisplayerFor(GetAnimatorVariableWireNode node)
        {
            GetAnimatorVariableNodeDisplayer nodeRenderer = new GetAnimatorVariableNodeDisplayer(node)
            {
                WindowRect = new Rect(node.DisplayerPosition.x, node.DisplayerPosition.y, 220, 80)
            };

            return(nodeRenderer);
        }
Example #4
0
        public static GetAnimatorVariableNodeDisplayer CreateGetAnimatorVariableNodeDisplayer(Vector2 position)
        {
            GetAnimatorVariableWireNode node = new GetAnimatorVariableWireNode(DialogEditor.Instance.EditingDialog)
            {
                NodeName = "Get animator variable"
            };

            DialogEditor.InitializeNode(ref node);

            node.Outputs.Add(new OutputWirePin(node, DialogEditor.Instance.EditingDialog)
            {
                PinName  = "Variable",
                DataType = typeof(AnimatorVariable)
            });
            GetAnimatorVariableNodeDisplayer nodeRenderer = new GetAnimatorVariableNodeDisplayer(node)
            {
                WindowRect = new Rect(position.x, position.y, 220, 80)
            };

            return(nodeRenderer);
        }
        public override bool GetResult()
        {
            A = Inputs[0];
            B = Inputs[1];
            WireNode aOwner = A.GetConnectedPin().GetOwner();
            WireNode bOwner = B.GetConnectedPin().GetOwner();

            if (aOwner is GetVariableWireNode)
            {
                GetVariableWireNode varNode = (GetVariableWireNode)aOwner;
                if (bOwner is GetVariableWireNode)
                {
                    return(!varNode.RetrievedVariable.Equals((bOwner as GetVariableWireNode).RetrievedVariable));
                }
                else if (bOwner is ConstantWireNode)
                {
                    return(!varNode.RetrievedVariable.Equals((bOwner as ConstantWireNode).Constant));
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode animVar = (GetAnimatorVariableWireNode)bOwner;
                    switch (varNode.RetrievedVariable.Type)
                    {
                    case VariableType.FLOAT:
                        return(varNode.RetrievedVariable.GetValueAs <float>() != animVar.GetVariableAsFloat());

                    case VariableType.INT:
                        return(varNode.RetrievedVariable.GetValueAs <int>() != animVar.GetVariableAsInteger());

                    case VariableType.STRING:
                        return(true);
                    }
                }
            }
            else if (aOwner is ConstantWireNode)
            {
                ConstantWireNode constNode = (ConstantWireNode)aOwner;

                if (bOwner is GetVariableWireNode) // To compare a variable and a constant, use the equal method of the variable class
                {
                    return(!((GetVariableWireNode)bOwner).RetrievedVariable.Equals(constNode.Constant));
                }
                else if (bOwner is ConstantWireNode) // To compare two constants, just compare their raw value
                {
                    return(!constNode.Constant.Value.Equals((bOwner as ConstantWireNode).Constant.Value));
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode animVar = (GetAnimatorVariableWireNode)bOwner;
                    switch (constNode.Constant.Type)
                    {
                    case VariableType.FLOAT:
                        return(((float)constNode.Constant.Value) != animVar.GetVariableAsFloat());

                    case VariableType.INT:
                        return(((int)constNode.Constant.Value) != animVar.GetVariableAsInteger());

                    case VariableType.STRING:
                        return(true);
                    }
                }
            }
            else if (aOwner is GetAnimatorVariableWireNode)
            {
                GetAnimatorVariableWireNode animVarNode = (GetAnimatorVariableWireNode)aOwner;
                if (bOwner is GetVariableWireNode) // To compare a variable and a animator variable, use the equal method of the variable class
                {
                    Variable myVar = (bOwner as GetVariableWireNode).RetrievedVariable;
                    switch (myVar.Type)
                    {
                    case VariableType.FLOAT:
                        return(!myVar.Equals(animVarNode.GetVariableAsFloat()));

                    case VariableType.INT:
                        return(!myVar.Equals(animVarNode.GetVariableAsInteger()));

                    case VariableType.STRING:
                        return(true);
                    }
                }
                else if (bOwner is ConstantWireNode) // To compare two constants, just compare their raw value
                {
                    Constant myConst = (bOwner as ConstantWireNode).Constant;
                    switch (myConst.Type)
                    {
                    case VariableType.FLOAT:
                        return(myConst.GetValueAs <float>() != animVarNode.GetVariableAsFloat());

                    case VariableType.INT:
                        return(myConst.GetValueAs <int>() != animVarNode.GetVariableAsInteger());

                    case VariableType.STRING:
                        return(false);
                    }
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode other = (GetAnimatorVariableWireNode)bOwner;
                    try
                    {
                        return(!(other.GetVariableAsFloat() == animVarNode.GetVariableAsFloat() ||
                                 other.GetVariableAsInteger() == animVarNode.GetVariableAsInteger() ||
                                 other.GetVariableAsBool() == animVarNode.GetVariableAsBool()));
                    }
                    catch (Exception)
                    {
                        return(!(other.GetVariableAsBool() == animVarNode.GetVariableAsBool()));
                    }
                }
            }

            return(true);
        }
        public override bool GetResult()
        {
            A = Inputs[0];
            B = Inputs[1];

            WireNode    aOwner = A.GetConnectedPin().GetOwner();
            WireNode    bOwner = B.GetConnectedPin().GetOwner();
            IComparable va     = null;
            IComparable vb     = null;

            if (aOwner is ConstantWireNode)
            {
                Constant constantA = ((ConstantWireNode)aOwner).Constant;
                if (constantA.Type == VariableType.FLOAT)
                {
                    va = constantA.GetValueAs <float>();
                }
                if (constantA.Type == VariableType.INT)
                {
                    va = constantA.GetValueAs <int>();
                }

                if (bOwner is ConstantWireNode)
                {
                    Constant constantB = ((ConstantWireNode)bOwner).Constant;
                    if (constantB.Type == VariableType.FLOAT)
                    {
                        vb = constantB.GetValueAs <float>();
                    }
                    if (constantB.Type == VariableType.INT)
                    {
                        vb = constantB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetVariableWireNode)
                {
                    Variable variableB = ((GetVariableWireNode)bOwner).RetrievedVariable;
                    if (variableB.Type == VariableType.FLOAT)
                    {
                        vb = variableB.GetValueAs <float>();
                    }
                    if (variableB.Type == VariableType.INT)
                    {
                        vb = variableB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode bGavwn = (GetAnimatorVariableWireNode)bOwner;
                    try
                    {
                        vb = bGavwn.GetVariableAsFloat();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            vb = bGavwn.GetVariableAsInteger();
                        }
                        catch (Exception) { }
                    }
                }
            }

            else if (aOwner is GetVariableWireNode)
            {
                Variable variableA = ((GetVariableWireNode)aOwner).RetrievedVariable;
                if (variableA.Type == VariableType.FLOAT)
                {
                    va = variableA.GetValueAs <float>();
                }
                if (variableA.Type == VariableType.INT)
                {
                    va = variableA.GetValueAs <int>();
                }
                if (bOwner is ConstantWireNode)
                {
                    Constant constantB = ((ConstantWireNode)bOwner).Constant;
                    if (constantB.Type == VariableType.FLOAT)
                    {
                        vb = constantB.GetValueAs <float>();
                    }
                    if (constantB.Type == VariableType.INT)
                    {
                        vb = constantB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetVariableWireNode)
                {
                    Variable variableB = ((GetVariableWireNode)bOwner).RetrievedVariable;
                    if (variableB.Type == VariableType.FLOAT)
                    {
                        vb = variableB.GetValueAs <float>();
                    }
                    if (variableB.Type == VariableType.INT)
                    {
                        vb = variableB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode bGavwn = (GetAnimatorVariableWireNode)bOwner;
                    try
                    {
                        vb = bGavwn.GetVariableAsFloat();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            vb = bGavwn.GetVariableAsInteger();
                        }
                        catch (Exception) { }
                    }
                }
            }

            else if (aOwner is GetAnimatorVariableWireNode)
            {
                GetAnimatorVariableWireNode aGavwn = (GetAnimatorVariableWireNode)aOwner;
                try
                {
                    va = aGavwn.GetVariableAsFloat();
                }
                catch (Exception)
                {
                    try
                    {
                        va = aGavwn.GetVariableAsInteger();
                    }
                    catch (Exception) { }
                }
                if (bOwner is ConstantWireNode)
                {
                    Constant constantB = ((ConstantWireNode)bOwner).Constant;
                    if (constantB.Type == VariableType.FLOAT)
                    {
                        vb = constantB.GetValueAs <float>();
                    }
                    if (constantB.Type == VariableType.INT)
                    {
                        vb = constantB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetVariableWireNode)
                {
                    Variable variableB = ((GetVariableWireNode)bOwner).RetrievedVariable;
                    if (variableB.Type == VariableType.FLOAT)
                    {
                        vb = variableB.GetValueAs <float>();
                    }
                    if (variableB.Type == VariableType.INT)
                    {
                        vb = variableB.GetValueAs <int>();
                    }
                }
                else if (bOwner is GetAnimatorVariableWireNode)
                {
                    GetAnimatorVariableWireNode bGavwn = (GetAnimatorVariableWireNode)bOwner;
                    try
                    {
                        vb = bGavwn.GetVariableAsFloat();
                    }
                    catch (Exception)
                    {
                        try
                        {
                            vb = bGavwn.GetVariableAsInteger();
                        }
                        catch (Exception) { }
                    }
                }
            }

            if (va == null || vb == null)
            {
                return(false);
            }
            int comparation = va.CompareTo(vb);

            return(comparation < 0);
        }
 public static GetAnimatorVariableNodeDisplayer CreateDisplayer(this GetAnimatorVariableWireNode node)
 {
     return(GetAnimatorVariableNodeDisplayer.CreateDisplayerFor(node));
 }