Example #1
0
 public abstract void AddData(StorytellController.ConditionStruct tmpCond);
Example #2
0
 public override void AddData(StorytellController.ConditionStruct tmpCond)
 {
     cond = tmpCond;
     EventController.current.onColliderTriggerEnter += CheckName;
 }
Example #3
0
 public override void AddData(StorytellController.ConditionStruct tmpCond)
 {
     cond = tmpCond;
     time = tmpCond.time;
 }
    void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(text);
        if (GUILayout.Button("Restart"))
        {
            temporalId = 0;
            nodeSet    = new Dictionary <int, NodeStruct>();
            prenodeSet = new Dictionary <int, PrenodeStruct>();
            //listNode = new List<NodeStruct>();
            CreateFirst();
        }

        if (GUILayout.Button("Recover"))
        {
            if (listNode.Count > 0)
            {
                ListToDictionary();
            }
            else
            {
                StorytellController smg = GameObject.Find("Controller").GetComponent <StorytellController>() as StorytellController;
                List <StorytellController.StepStruct> stepList = smg.listSteps;
                if (stepList.Count > 0)
                {
                    foreach (StorytellController.StepStruct scTmp in stepList)
                    {
                        NodeStruct nsTmp = new NodeStruct();
                        nsTmp.nodeId          = scTmp.id;
                        nsTmp.nodeName        = scTmp.nameStep;
                        nsTmp.nodeDescription = scTmp.descriptionStep;
                        nsTmp.rectangle       = scTmp.rectangle;
                        nsTmp.heightWindow    = scTmp.heightWindow;
                        nsTmp.parentId        = scTmp.parentId;

                        List <ConditionStructUI> conditions = new List <ConditionStructUI>();
                        nsTmp.conditionId = 0;
                        foreach (StorytellController.ConditionStruct cdTmp in scTmp.conditions)
                        {
                            ConditionStructUI tmpC = new ConditionStructUI();
                            tmpC.nextId   = cdTmp.nextId;
                            tmpC.popupPos = cdTmp.popupPos;
                            tmpC.time     = cdTmp.time;
                            tmpC.target   = cdTmp.objTarget;
                            tmpC.color    = cdTmp.color;
                            nsTmp.conditionId++;
                            conditions.Add(tmpC);
                        }
                        nsTmp.conditions = conditions;

                        List <ConsequenceStructUI> consequences = new List <ConsequenceStructUI>();
                        nsTmp.consequenceId = 0;
                        foreach (StorytellController.ConsequenceStruct csTmp in scTmp.consequences)
                        {
                            ConsequenceStructUI tmpC = new ConsequenceStructUI();
                            tmpC.popupPos   = csTmp.popupPos;
                            tmpC.integer    = csTmp.integer;
                            tmpC.objectAtr  = csTmp.objectAtr;
                            tmpC.primString = csTmp.secondaryAtribute;
                            nsTmp.consequenceId++;
                            consequences.Add(tmpC);
                        }
                        nsTmp.consequences = consequences;

                        listNode.Add(nsTmp);
                    }
                    ListToDictionary();
                }
                else
                {
                    text = "Create your Storytell: No storytell saved";
                }
            }
        }

        if (nodeSet.Count == 0)
        {
            temporalId = 0;
        }

        List <int> keysN = new List <int>(nodeSet.Keys); //We are going to iterate over dictionary keys

        if (GUILayout.Button("Save"))
        {
            if (prenodeSet.Count == 0) //All prenodes assigned
            {
                savedId = temporalId;
                List <StorytellController.StepStruct> stepList = new List <StorytellController.StepStruct>();
                listNode = new List <NodeStruct>(); //Set listNode values, because it's Serilizable

                foreach (int key in keysN)
                {
                    NodeStruct node = nodeSet[key];
                    listNode.Add(node);
                    StorytellController.StepStruct tmpStep = new StorytellController.StepStruct();
                    tmpStep.id              = node.nodeId;
                    tmpStep.nameStep        = node.nodeName;
                    tmpStep.descriptionStep = node.nodeDescription;
                    tmpStep.rectangle       = node.rectangle;
                    tmpStep.heightWindow    = node.heightWindow;
                    tmpStep.parentId        = node.parentId;
                    List <StorytellController.ConsequenceStruct> consList = new List <StorytellController.ConsequenceStruct>();

                    foreach (ConsequenceStructUI cons in node.consequences)
                    {
                        StorytellController.ConsequenceStruct tcons = new StorytellController.ConsequenceStruct();
                        tcons.type    = optionsConsequences[cons.popupPos];
                        tcons.integer = cons.integer;
                        string TobjArt;

                        if (cons.objectAtr == null)
                        {
                            TobjArt = "null";
                        }
                        else
                        {
                            TobjArt = cons.objectAtr.name;
                        }

                        tcons.primaryAtribute   = TobjArt;
                        tcons.secondaryAtribute = cons.primString;
                        //New
                        tcons.popupPos  = cons.popupPos;
                        tcons.objectAtr = cons.objectAtr;

                        consList.Add(tcons);
                    }

                    tmpStep.consequences = consList;
                    List <StorytellController.ConditionStruct> condList = new List <StorytellController.ConditionStruct>();

                    foreach (ConditionStructUI cond in node.conditions)
                    {
                        StorytellController.ConditionStruct tcond = new StorytellController.ConditionStruct();
                        tcond.nextId = cond.nextId;
                        tcond.type   = optionsConditions[cond.popupPos];
                        tcond.time   = cond.time;
                        string target;

                        if (cond.target == null)
                        {
                            target = "null";
                        }
                        else
                        {
                            target = cond.target.name;
                        }

                        tcond.target = target;
                        //New
                        tcond.popupPos  = cond.popupPos;
                        tcond.objTarget = cond.target;
                        tcond.color     = cond.color;

                        condList.Add(tcond);
                    }

                    tmpStep.conditions = condList;
                    stepList.Add(tmpStep);
                }
                StorytellController smg = GameObject.Find("Controller").GetComponent <StorytellController>() as StorytellController;
                smg.listSteps = stepList;
                text          = "Create your Storytell:";
            }
            else   //Still some prenodes without assign
            {
                text = "Create your Storytell: Assign all steps";
            }
        }

        EditorGUILayout.EndHorizontal();
        BeginWindows();

        foreach (int key in keysN)
        {
            NodeStruct node = nodeSet[key];

            foreach (ConditionStructUI cond in node.conditions)
            {
                int chId = cond.nextId;
                if (nodeSet.ContainsKey(chId) || prenodeSet.ContainsKey(chId))
                {
                    DrawLine(chId, node.nodeId, cond.color);
                }
            }

            node.rectangle        = SetRectangle(node.rectangle);
            node.rectangle        = GUI.Window(node.nodeId, node.rectangle, WindowFunction, "" + node.nodeId);
            node.rectangle.height = node.heightWindow;
            nodeSet[key]          = node;
        }

        List <int> keysP = new List <int>(prenodeSet.Keys);

        foreach (int key in keysP)
        {
            PrenodeStruct prenode = prenodeSet[key];
            prenode.rectangle = SetRectangle(prenode.rectangle);
            prenode.rectangle = GUI.Window(prenode.nodeId, prenode.rectangle, WindowFunctionPreNode, "Create Node");
            prenodeSet[key]   = prenode;
        }

        EndWindows();
    }