private void InitWindows()
        {
            Rect previous = new Rect(0, 25, 0, 100);

            for (int i = 0; i < effects.getEffects().Count; i++)
            {
                AbstractEffect myEffect = this.effects.getEffects()[i];

                EffectEditor editor = EffectEditorFactory.Intance.createEffectEditorFor(myEffect);
                editor.Effect = myEffect;

                if (i > 0)
                {
                    previous = editors[effects.getEffects()[i - 1]].Window;
                }

                Rect current = new Rect(previous.x + previous.width + 35, previous.y, 150, 0);
                if (!tmpRects.ContainsKey(effects.getEffects()[i]))
                {
                    tmpRects.Add(effects.getEffects()[i], current);
                }

                editor.Window = current;

                editor.Effect.setConditions(myEffect.getConditions());
                editors.Add(editor.Effect, editor);
            }
        }
Exemplo n.º 2
0
    public override bool doTool()
    {
        effects.add(effectToAdd);
        if (conditions != null)
        {
            condition = new ConditionsController(effectToAdd.getConditions(), Controller.EFFECT, EffectsController.getEffectInfo(effectToAdd));
            conditions.Add(condition);
        }

        return(true);
    }
Exemplo n.º 3
0
    public bool execute()
    {
        bool forcewait = false;

        if (!(runs_once && times_runed > 0))
        {
            if (effect == null || effect.getConditions() == null)
            {
                Debug.Log("Asd");
            }
            else
            {
                if (!validated)
                {
                    is_valid  = ConditionChecker.check(effect.getConditions());
                    validated = true;
                }

                if (is_valid)
                {
                    switch (effect.getType())
                    {
                    case EffectType.ACTIVATE:
                        Game.Instance.GameState.setFlag(((ActivateEffect)effect).getTargetId(), FlagCondition.FLAG_ACTIVE);
                        break;

                    case EffectType.DEACTIVATE:
                        Game.Instance.GameState.setFlag(((DeactivateEffect)effect).getTargetId(), FlagCondition.FLAG_INACTIVE);
                        break;

                    case EffectType.SPEAK_PLAYER:
                        Game.Instance.talk(((SpeakPlayerEffect)effect).getLine(), null);
                        forcewait = true;
                        break;

                    case EffectType.SPEAK_CHAR:
                        Game.Instance.talk(((SpeakCharEffect)effect).getLine(), ((SpeakCharEffect)effect).getTargetId());
                        forcewait = true;
                        break;

                    case EffectType.TRIGGER_SCENE:
                        runs_once = false;
                        Game.Instance.renderScene(((TriggerSceneEffect)effect).getTargetId());
                        break;

                    case EffectType.TRIGGER_CUTSCENE:
                        runs_once = false;
                        TriggerCutsceneEffect tce = (TriggerCutsceneEffect)effect;
                        if (times_runed > 0)
                        {
                            forcewait = ((SceneMB)aditional_info ["scene"]).Interacted() == InteractuableResult.REQUIRES_MORE_INTERACTION;
                        }
                        else
                        {
                            aditional_info = new Dictionary <string, object> ();
                            aditional_info.Add("lastscene", Game.Instance.GameState.CurrentScene);
                            aditional_info.Add("scene", Game.Instance.renderScene(tce.getTargetId()).GetComponent <SceneMB> ());
                            forcewait = true;
                        }

                        if (!forcewait && ((Slidescene)((SceneMB)aditional_info ["scene"]).sceneData).getNext() == Slidescene.GOBACK)
                        {
                            string last = (string)aditional_info ["lastscene"];
                            Game.Instance.renderScene(last);
                        }

                        break;

                    case EffectType.TRIGGER_LAST_SCENE:
                        runs_once = false;
                        Game.Instance.renderLastScene();
                        break;

                    case EffectType.TRIGGER_CONVERSATION:
                        runs_once = false;
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            TriggerConversationEffect tcoe = (TriggerConversationEffect)effect;
                            this.aditional_info.Add("conversation", new GraphConversationHolder(Game.Instance.GameState.getConversation(tcoe.getTargetId())));
                        }
                        forcewait = ((GraphConversationHolder)this.aditional_info ["conversation"]).execute();
                        break;

                    case EffectType.RANDOM_EFFECT:
                        runs_once = false;
                        RandomEffect re = (RandomEffect)effect;

                        if (!aditional_info.ContainsKey("first"))
                        {
                            aditional_info.Add("first", new EffectHolderNode(re.getPositiveEffect()));
                            aditional_info.Add("second", new EffectHolderNode(re.getNegativeEffect()));
                        }

                        if (times_runed == 0)
                        {
                            int pro = re.getProbability(), now = Random.Range(0, 100);
                            if (aditional_info.ContainsKey("current"))
                            {
                                aditional_info.Remove("current");
                            }

                            if (pro <= now)
                            {
                                aditional_info.Add("current", "first");
                            }
                            else
                            {
                                aditional_info.Add("current", "second");
                            }

                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }
                        else
                        {
                            forcewait = ((EffectHolderNode)aditional_info [((string)aditional_info ["current"])]).execute();
                        }

                        break;

                    case EffectType.SET_VALUE:
                        SetValueEffect sve = (SetValueEffect)effect;
                        Game.Instance.GameState.setVariable(sve.getTargetId(), sve.getValue());
                        break;

                    case EffectType.INCREMENT_VAR:
                        IncrementVarEffect ive = (IncrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(ive.getTargetId(), Game.Instance.GameState.getVariable(ive.getTargetId()) + ive.getIncrement());
                        break;

                    case EffectType.DECREMENT_VAR:
                        DecrementVarEffect dve = (DecrementVarEffect)effect;
                        Game.Instance.GameState.setVariable(dve.getTargetId(), Game.Instance.GameState.getVariable(dve.getTargetId()) - dve.getDecrement());
                        break;

                    case EffectType.MACRO_REF:
                        runs_once = false;
                        if (times_runed == 0)
                        {
                            MacroReferenceEffect mre = (MacroReferenceEffect)effect;
                            this.aditional_info.Add("macro", new EffectHolder(Game.Instance.GameState.getMacro(mre.getTargetId())));
                        }
                        forcewait = ((EffectHolder)this.aditional_info ["macro"]).execute();
                        break;

                    case EffectType.MOVE_OBJECT:
                        MoveObjectEffect moe = (MoveObjectEffect)effect;
                        Game.Instance.GameState.Move(moe.getTargetId(), new Vector2(moe.getX(), 600 - moe.getY()) / 10f);
                        break;
                    }
                }
            }
        }

        if (!forcewait)
        {
            times_runed = 0;
        }
        else
        {
            times_runed++;
        }

        return(forcewait);
    }
        void nodeWindow(int id)
        {
            AbstractEffect myEffect = this.effects.getEffects()[id];

            EffectEditor editor = null;

            editors.TryGetValue(myEffect, out editor);

            if (editor != null && editor.Collapsed)
            {
                if (GUILayout.Button(TC.get("GeneralText.Open")))
                {
                    editor.Collapsed = false;
                }
            }
            else
            {
                string[] editorNames = EffectEditorFactory.Intance.CurrentEffectEditors;

                GUILayout.BeginHorizontal();
                int preEditorSelected = EffectEditorFactory.Intance.EffectEditorIndex(myEffect);
                int editorSelected    = EditorGUILayout.Popup(preEditorSelected, editorNames);

                if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15)))
                {
                    editor.Collapsed = true;
                }
                if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                {
                    effects.getEffects().Remove(myEffect);
                    return;
                }

                GUILayout.EndHorizontal();

                GUILayout.BeginVertical(conditionStyle);
                GUILayout.Label("CONDITIONS");
                if (GUILayout.Button("Add Block"))
                {
                    myEffect.getConditions().add(new FlagCondition(""));
                }

                if (editor == null || preEditorSelected != editorSelected)
                {
                    editor = EffectEditorFactory.Intance.createEffectEditorFor(editorNames[editorSelected]);

                    if (editors.ContainsKey(myEffect))
                    {
                        editor.Window = editors[myEffect].Window;
                        editors.Remove(myEffect);
                    }
                    else
                    {
                        editor.Window = tmpRects[myEffect];
                    }

                    editors.Add(editor.Effect, editor);
                    editor.Effect.setConditions(myEffect.getConditions());
                }

                //##################################################################################
                //############################### CONDITION HANDLING ###############################
                //##################################################################################

                var toRemove      = new List <Condition>();
                var listsToRemove = new List <List <Condition> >();
                var conditions    = editor.Effect.getConditions();
                ConditionEditorWindow.LayoutConditionEditor(conditions);

                //##################################################################################


                GUILayout.EndVertical();

                editor.draw();

                this.effects.getEffects()[id] = editor.Effect;

                if (Event.current.type != EventType.layout)
                {
                    Rect lastRect = GUILayoutUtility.GetLastRect();
                    Rect myRect   = editor.Window;
                    myRect.height = lastRect.y + lastRect.height;
                    editor.Window = myRect;
                    this.Repaint();
                }
            }

            GUI.DragWindow();
        }
Exemplo n.º 5
0
    void nodeWindow(int id)
    {
        AbstractEffect myEffect = this.effects.getEffects()[id];

        EffectEditor editor = null;

        editors.TryGetValue(myEffect, out editor);

        if (editor != null && editor.Collapsed)
        {
            if (GUILayout.Button(TC.get("GeneralText.Open")))
            {
                editor.Collapsed = false;
            }
        }
        else
        {
            string[] editorNames = EffectEditorFactory.Intance.CurrentEffectEditors;

            GUILayout.BeginHorizontal();
            int preEditorSelected = EffectEditorFactory.Intance.EffectEditorIndex(myEffect);
            int editorSelected    = EditorGUILayout.Popup(preEditorSelected, editorNames);

            if (GUILayout.Button("-", collapseStyle, GUILayout.Width(15), GUILayout.Height(15)))
            {
                editor.Collapsed = true;
            }
            if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
            {
                effects.getEffects().Remove(myEffect);
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginVertical(conditionStyle);
            GUILayout.Label("CONDITIONS");
            if (GUILayout.Button("Add Block"))
            {
                myEffect.getConditions().add(new FlagCondition(""));
            }

            if (editor == null || preEditorSelected != editorSelected)
            {
                editor = EffectEditorFactory.Intance.createEffectEditorFor(editorNames[editorSelected]);

                if (editors.ContainsKey(myEffect))
                {
                    editor.Window = editors[myEffect].Window;
                }
                else
                {
                    editor.Window = tmpRects[myEffect];
                }

                editor.Effect.setConditions(myEffect.getConditions());
                editors.Remove(myEffect);
                editors.Add(editor.Effect, editor);
            }

            //##################################################################################
            //############################### CONDITION HANDLING ###############################
            //##################################################################################

            foreach (List <Condition> cl in myEffect.getConditions().getConditionsList())
            {
                if (cl.Count > 1)
                {
                    GUILayout.BeginVertical(eitherConditionStyle);
                }
                for (int i = 0; i < cl.Count; i++)
                {
                    GUILayout.BeginHorizontal();
                    int preConEdiSel = ConditionEditorFactory.Intance.ConditionEditorIndex(cl[i]);
                    int conEdiSel    = EditorGUILayout.Popup(preConEdiSel,
                                                             ConditionEditorFactory.Intance.CurrentConditionEditors);

                    if (preConEdiSel != conEdiSel)
                    {
                        cl[i] = ConditionEditorFactory.Intance.Editors[conEdiSel].InstanceManagedCondition();
                    }

                    ConditionEditorFactory.Intance.getConditionEditorFor(cl[i]).draw(cl[i]);

                    if (GUILayout.Button("+", collapseStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        cl.Add(new FlagCondition(""));
                    }

                    if (GUILayout.Button("X", closeStyle, GUILayout.Width(15), GUILayout.Height(15)))
                    {
                        cl.Remove(cl[i]);

                        if (cl.Count == 0)
                        {
                            myEffect.getConditions().getConditionsList().Remove(cl);
                        }
                    }

                    GUILayout.EndHorizontal();
                }
                if (cl.Count > 1)
                {
                    GUILayout.EndVertical();
                }
            }

            //##################################################################################


            GUILayout.EndVertical();

            editor.draw();

            this.effects.getEffects()[id] = editor.Effect;
        }


        if (Event.current.type != EventType.layout)
        {
            Rect lastRect = GUILayoutUtility.GetLastRect();
            Rect myRect   = editors[myEffect].Window;
            myRect.height            = lastRect.y + lastRect.height;
            editors[myEffect].Window = myRect;
            this.Repaint();
        }

        GUI.DragWindow();
    }