示例#1
0
        public override void DeleteNode()
        {
            base.DeleteNode();
            LogicEffect function = (LogicEffect)logicFunction;

            foreach (LogicFunction actionInput in function.actionInputs)
            {
                actionInput.RemoveActionOutput(function);
            }
            LogicMapEditor.logicMap.effects.Remove(function);
            DestroyImmediate(function.gameObject);
        }
示例#2
0
        public override void OnInspectorGUI()
        {
            LogicEffect function = (LogicEffect)target;

            EditorGUILayout.PropertyField(serializedObject.FindProperty("type"), GUIContent.none);
            serializedObject.ApplyModifiedProperties();
            if (function.type == LogicEffectType.SINGLE)
            {
                base.OnInspectorGUI();
            }
            else if (function.type == LogicEffectType.ARRAY)
            {
                bool show = true;
                eUtils.DrawEffectsSelector(function.effects, function.transform, ref show);
            }
            serializedObject.ApplyModifiedProperties();
        }
示例#3
0
        public override void DrawWindow()
        {
            LogicEffect logicEffect = logicFunction as LogicEffect;

            EditorGUILayout.BeginHorizontal();
            GUIStyle noneActionStyle = new GUIStyle();

            noneActionStyle.normal.background = eUtils.MakeTex(10, 10, Color.gray);
            GUIStyle actionStyle = new GUIStyle();

            actionStyle.normal.background = eUtils.MakeTex(10, 10, Color.blue);
            GUIStyle realizeActionStyle = new GUIStyle();

            realizeActionStyle.normal.background = eUtils.MakeTex(10, 10, Color.magenta);
            if (logicEffect.actionInputs.Count == 0)
            {
                if (!logicEffect.startFunction)
                {
                    GUILayout.Box(GUIContent.none, noneActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
                else
                {
                    if (!LogicMapEditor.logicMap.startRealize)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                }
            }
            else
            {
                bool realizeFlag = false;
                foreach (LogicFunction actionInput in logicEffect.actionInputs)
                {
                    if (actionInput is DataSplitter)
                    {
                        DataSplitter input = (DataSplitter)actionInput;
                        if (input.trueOutput == logicEffect && input.realizeTrue)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.falseOutput == logicEffect && input.realizeFalse)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is LogicSplitter)
                    {
                        LogicSplitter input = (LogicSplitter)actionInput;
                        int           index = input.actionOutputs.IndexOf(logicEffect);
                        if (input.realizeOutputs[index])
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is WaitFunction)
                    {
                        WaitFunction input = (WaitFunction)actionInput;
                        if (input.actionOutput == logicEffect && input.realize)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is ChallengeFunction)
                    {
                        ChallengeFunction input = (ChallengeFunction)actionInput;
                        if (input.trueOutput == logicEffect && input.realizeTrue)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.falseOutput == logicEffect && input.realizeFalse)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is ChooseMethodFunction)
                    {
                        ChooseMethodFunction input = (ChooseMethodFunction)actionInput;
                        if (input.brutalOutput == logicEffect && input.realizeBrutal)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.carefulOutput == logicEffect && input.realizeCareful)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.diplomatOutput == logicEffect && input.realizeDiplomat)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.scienceOutput == logicEffect && input.realizeScience)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else
                        {
                            for (int i = 0; i < input.dialogOutputs.Count; i++)
                            {
                                if (input.dialogOutputs[i] == logicFunction && input.realizeDialogOutput[i])
                                {
                                    realizeFlag = true;
                                    break;
                                }
                            }
                        }
                    }
                    else if (actionInput is ChooseTemperFunction)
                    {
                        ChooseTemperFunction input = (ChooseTemperFunction)actionInput;
                        if (input.rudeOutput == logicFunction && input.realizeRude)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.prudentOutput == logicFunction && input.realizePrudent)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.cruelOutput == logicFunction && input.realizeCruel)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.principledOutput == logicFunction && input.realizePrincipled)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else
                        {
                            for (int i = 0; i < input.dialogOutputs.Count; i++)
                            {
                                if (input.dialogOutputs[i] == logicFunction && input.realizeDialogOutput[i])
                                {
                                    realizeFlag = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (realizeFlag)
                {
                    GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
                else
                {
                    GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
            }
            GUILayout.FlexibleSpace();
            if (logicEffect.type == LogicEffectType.SINGLE)
            {
                logicEffect.windowRect.height = 140;
                Effect           effect   = logicEffect.effect;
                SerializedObject soEffect = new SerializedObject(effect);
                eUtils.DrawEffectSelector(effect);
            }
            else if (logicEffect.type == LogicEffectType.ARRAY)
            {
                if (logicEffect.effects.Count > 0)
                {
                    logicEffect.windowRect.height = 42 + 20 * logicEffect.effects.Count;
                }
                else
                {
                    logicEffect.windowRect.height = 60;
                }
                EditorGUILayout.BeginVertical();
                for (int i = 0; i < logicEffect.effects.Count; i++)
                {
                    EditorGUILayout.LabelField(logicEffect.effects[i].type.ToString(), new GUILayoutOption[] { GUILayout.Width(140) });
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Dublicate"))
            {
                EffectNode newNode = LogicMapEditor.editor.CreateEffectNode(logicEffect.windowRect.position + new Vector2(20, 20));
                ((LogicEffect)newNode.logicFunction).effect.copyContentFrom(logicEffect.effect);
            }
        }
示例#4
0
        public override void DrawWindow()
        {
            WaitFunction     waitFunction = logicFunction as WaitFunction;
            SerializedObject soWait       = new SerializedObject(waitFunction);

            EditorGUILayout.BeginHorizontal();
            GUIStyle noneActionStyle = new GUIStyle();

            noneActionStyle.normal.background = eUtils.MakeTex(10, 10, Color.gray);
            GUIStyle actionStyle = new GUIStyle();

            actionStyle.normal.background = eUtils.MakeTex(10, 10, Color.blue);
            GUIStyle realizeActionStyle = new GUIStyle();

            realizeActionStyle.normal.background = eUtils.MakeTex(10, 10, Color.magenta);
            if (logicFunction.actionInputs.Count == 0)
            {
                if (!logicFunction.startFunction)
                {
                    GUILayout.Box(GUIContent.none, noneActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
                else
                {
                    if (!LogicMapEditor.logicMap.startRealize)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                }
            }
            else
            {
                bool realizeFlag = false;
                foreach (LogicFunction actionInput in logicFunction.actionInputs)
                {
                    if (actionInput is DataSplitter)
                    {
                        DataSplitter input = (DataSplitter)actionInput;
                        if (input.trueOutput == logicFunction && input.realizeTrue)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.falseOutput == logicFunction && input.realizeFalse)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is LogicSplitter)
                    {
                        LogicSplitter input = (LogicSplitter)actionInput;
                        int           index = input.actionOutputs.IndexOf(logicFunction);
                        if (input.realizeOutputs[index])
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is WaitFunction)
                    {
                        WaitFunction input = (WaitFunction)actionInput;
                        if (input.actionOutput == logicFunction && input.realize)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is ChallengeFunction)
                    {
                        ChallengeFunction input = (ChallengeFunction)actionInput;
                        if (input.trueOutput == logicFunction && input.realizeTrue)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.falseOutput == logicFunction && input.realizeFalse)
                        {
                            realizeFlag = true;
                            break;
                        }
                    }
                    else if (actionInput is ChooseMethodFunction)
                    {
                        ChooseMethodFunction input = (ChooseMethodFunction)actionInput;
                        if (input.brutalOutput == logicFunction && input.realizeBrutal)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.carefulOutput == logicFunction && input.realizeCareful)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.diplomatOutput == logicFunction && input.realizeDiplomat)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.scienceOutput == logicFunction && input.realizeScience)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else
                        {
                            for (int i = 0; i < input.dialogOutputs.Count; i++)
                            {
                                if (input.dialogOutputs[i] == logicFunction && input.realizeDialogOutput[i])
                                {
                                    realizeFlag = true;
                                    break;
                                }
                            }
                        }
                    }
                    else if (actionInput is ChooseTemperFunction)
                    {
                        ChooseTemperFunction input = (ChooseTemperFunction)actionInput;
                        if (input.rudeOutput == logicFunction && input.realizeRude)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.prudentOutput == logicFunction && input.realizePrudent)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.cruelOutput == logicFunction && input.realizeCruel)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else if (input.principledOutput == logicFunction && input.realizePrincipled)
                        {
                            realizeFlag = true;
                            break;
                        }
                        else
                        {
                            for (int i = 0; i < input.dialogOutputs.Count; i++)
                            {
                                if (input.dialogOutputs[i] == logicFunction && input.realizeDialogOutput[i])
                                {
                                    realizeFlag = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                if (realizeFlag)
                {
                    GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
                else
                {
                    GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
            }
            GUILayout.FlexibleSpace();
            EditorGUILayout.BeginVertical();
            EditorGUILayout.LabelField(waitFunction.waitType.ToString(), new GUILayoutOption[] { GUILayout.Width(100) });
            if (waitFunction.waitType == WaitType.ABSOLUTE || waitFunction.waitType == WaitType.RELATION)
            {
                EditorGUILayout.LabelField(string.Format("{0}m, {1}w, {2}d", waitFunction.waitTime.months, waitFunction.waitTime.weeks, waitFunction.waitTime.days), new GUILayoutOption[] { GUILayout.Width(100) });
                EditorGUILayout.LabelField(string.Format("{0}:{1}", waitFunction.waitTime.hours, waitFunction.waitTime.minutes.ToString("00")), new GUILayoutOption[] { GUILayout.Width(100) });
            }
            else if (waitFunction.waitType == WaitType.ABSOLUTE_HOURS)
            {
                EditorGUILayout.LabelField(string.Format("{0}:{1}", waitFunction.waitTime.hours, waitFunction.waitTime.minutes.ToString("00")), new GUILayoutOption[] { GUILayout.Width(100) });
            }
            EditorGUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            if (waitFunction.actionOutput == null)
            {
                if (!waitFunction.startFunction)
                {
                    GUILayout.Box(GUIContent.none, noneActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                }
                else
                {
                    if (!LogicMapEditor.logicMap.startRealize)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                }
            }
            else
            {
                if (waitFunction.actionOutput is DataSplitter)
                {
                    DataSplitter output = (DataSplitter)waitFunction.actionOutput;
                    if (output.trueOutput == waitFunction && !output.realizeTrue)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else if (output.trueOutput == waitFunction && output.realizeTrue)
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else if (output.falseOutput == waitFunction && !output.realizeFalse)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else if (output.falseOutput == waitFunction && output.realizeFalse)
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                }
                else if (waitFunction.actionOutput is LogicSplitter)
                {
                    LogicSplitter output = (LogicSplitter)waitFunction.actionOutput;
                    int           index  = output.actionOutputs.IndexOf(waitFunction);
                    if (index == -1)
                    {
                        GUILayout.Box(GUIContent.none, noneActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else
                    {
                        if (!waitFunction.realize)
                        {
                            GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                        }
                        else
                        {
                            GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                        }
                    }
                }
                else if (waitFunction.actionOutput is LogicEffect)
                {
                    LogicEffect output = (LogicEffect)waitFunction.actionOutput;
                    if (!waitFunction.realize)
                    {
                        GUILayout.Box(GUIContent.none, actionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                    else
                    {
                        GUILayout.Box(GUIContent.none, realizeActionStyle, new GUILayoutOption[] { GUILayout.Width(10), GUILayout.Height(10) });
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            soWait.ApplyModifiedProperties();
        }