Ejemplo n.º 1
0
 private void AddPathes(Chain c, List <Path> newPathes, List <PathEvent> newEvents)
 {
     if (inspectedChains.Contains(c))
     {
         return;
     }
     else
     {
         inspectedChains.Add(c);
     }
     foreach (State s in c.states)
     {
         foreach (Path p in s.pathes)
         {
             if (p.aimState != null && GuidManager.GetChainByState(p.aimState) != c)
             {
                 AddPathes(GuidManager.GetChainByState(p.aimState), newPathes, newEvents);
             }
             if (p.withEvent)
             {
                 newEvents.Add(new PathEvent());
                 newPathes.Add(p);
             }
         }
     }
     inspectedChains.Clear();
 }
Ejemplo n.º 2
0
        public StateLink AddStateLink()
        {
            StateLink sl = CreateInstance <StateLink>();

            sl.Init(this);
            GuidManager.GetGameByChain(this).Dirty = true;
            links.Add(sl);
            return(sl);
        }
Ejemplo n.º 3
0
 private void InvokeEvent(Path p)
 {
     if (!PersonChain.states.Contains(p.aimState))
     {
         PersonChain = GuidManager.GetChainByState(p.aimState);
     }
     if (pathEventsList.ContainsKey(p))
     {
         pathEventsList[p].Invoke();
     }
 }
Ejemplo n.º 4
0
        public void Init(Chain chain)
        {
            Guid        = GuidManager.GetStateGuid();
            this.chain  = chain;
            game        = chain.Game;
            description = "";
            float z = 1;

            z        = game.zoom;
            position = new Rect(300, 300, 208 * z, 30 * z);
        }
Ejemplo n.º 5
0
        public Dictionary <Param, float> GetParamsDictionary()
        {
            Dictionary <Param, float> dict = new Dictionary <Param, float>();

            foreach (KeyValuePair <int, float> kvp in saveInfo.paramsDictionary)
            {
                Param p = GuidManager.GetItemByGuid(kvp.Key);
                dict.Add(p, kvp.Value);
            }
            return(dict);
        }
Ejemplo n.º 6
0
        public Dictionary <Param, float> GetVisibleParams()
        {
            Dictionary <Param, float> result = new Dictionary <Param, float>();

            foreach (KeyValuePair <int, float> pair in saveInfo.paramsDictionary)
            {
                Param p = GuidManager.GetItemByGuid(pair.Key);
                if (p.showing)
                {
                    result.Add(p, pair.Value);
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        public void Load(string fileName)
        {
            saveInfo = new SaveInfo();
            if (!File.Exists(Application.dataPath + "/saves/" + fileName))
            {
                return;
            }

            Debug.Log(Application.dataPath + "/saves/" + fileName);

            Stream          stream     = File.Open(Application.dataPath + "/saves/" + fileName, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();

            bformatter.Binder = new PathGameSaveBinder();
            saveInfo          = (SaveInfo)bformatter.Deserialize(stream);
            foreach (PersonDialog pd in FindObjectsOfType <PersonDialog>())
            {
                //pd.PersonChain = saveInfo.personsChains[pd.gameObject];
            }
            stream.Close();

            DialogPlayer.Instance.PlayState(GuidManager.GetStateByGuid(saveInfo.lastState), FindObjectOfType <PersonDialog>());
        }
Ejemplo n.º 8
0
 public void RemoveStateLink(StateLink link)
 {
     links.Remove(link);
     GuidManager.GetGameByChain(this).Dirty = true;
 }
Ejemplo n.º 9
0
        public override void OnInspectorGUI()
        {
            if (inspectedFlag != dialog.playing)
            {
                if (dialog.playing)
                {
                    qw = QuestWindow.Init(GuidManager.GetGameByChain(dialog.PersonChain));
                    //qw.DebugPathGame(DialogPlayer.Instance.currentState);
                }
                else
                {
                    if (qw)
                    {
                        qw.Close();
                    }
                }
                inspectedFlag = dialog.playing;
            }
            GUILayout.BeginHorizontal();
            GUILayout.Label("Dialogs pack:");
            dialog.game = (PathGame)EditorGUILayout.ObjectField(dialog.game, typeof(PathGame), false);
            GUILayout.EndHorizontal();
            if (dialog.game && dialog.game.chains.Count > 0)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Dialog:");

                if (!dialog.game.chains.Contains(dialog.PersonChain))
                {
                    Debug.Log(dialog.game.chains[0]);
                    dialog.PersonChain = dialog.game.chains[0];
                    if (dialog.PersonChain)
                    {
                        SetEvents();
                    }
                }
                Chain ch = dialog.game.chains[EditorGUILayout.Popup(dialog.game.chains.IndexOf(dialog.PersonChain), dialog.game.chains.Select(x => x.dialogName).ToArray())];
                if (dialog.PersonChain != ch)
                {
                    dialog.PersonChain = ch;

                    if (dialog.PersonChain)
                    {
                        SetEvents();
                    }
                }
                GUILayout.EndHorizontal();
                int i = 0;
                foreach (KeyValuePair <Path, PathEvent> pathEvent in dialog.PathEventsList)
                {
                    string aim = "";

                    if (pathEvent.Key.aimState != null)
                    {
                        aim = pathEvent.Key.aimState.description;
                    }
                    GUILayout.Label(pathEvent.Key.text + "->" + aim);
                    Undo.RecordObject(target, "Changed event");
                    EditorGUILayout.PropertyField(dialogProperty.GetArrayElementAtIndex(i));
                    dialogObject.ApplyModifiedProperties();
                    i++;
                }
            }
        }