Exemple #1
0
        public void LoadSaveData(Save data)
        {
            saveData = data;

            if (data.LoadableId != -1)
            {
                DefaultMission = loadables.GetLoadableById(data.LoadableId);
            }
            LoadScene(DefaultMission);
        }
Exemple #2
0
        public static void LoadScene(Loadable MissionToBeLoaded)
        {
            if (Application.isPlaying)
            {
                TurnManager.TurnNumber       = 0;
                TurnManager.currentTeam      = 0;
                missionToBeLoaded            = Instantiate(MissionToBeLoaded);
                GameManager._intance.current = missionToBeLoaded;


                missionToBeLoaded.original           = MissionToBeLoaded;
                CameraTransitionHandlerer.fadeEnded += UnloadLastScene;
                _intance.StartCoroutine(CameraTransitionHandlerer._intance.BeginFadeIn());
            }
        }
Exemple #3
0
        private static void OnMissionLoaded(Scene scene, LoadSceneMode mode)
        {
            SceneManager.sceneLoaded -= OnMissionLoaded;
            Loadable.CurrentlyLoaded  = missionToBeLoaded;
            if (saveData != null && saveData.LoadableId == missionToBeLoaded.ID)
            {
                missionToBeLoaded.LoadData(saveData);
            }
            else
            {
                missionToBeLoaded.LoadDefaultData();
            }
            missionToBeLoaded = null;

            UIManager._instance.InitNewMission();
            Loadable.CurrentlyLoaded.Init();
            CameraTransitionHandlerer.fadeEnded += Loadable.CurrentlyLoaded.Begin;

            _intance.StartCoroutine(CameraTransitionHandlerer._intance.BeginFadeOut());
        }
Exemple #4
0
        public override void OnInspectorGUI()
        {
            Mission selectedMission = target as Mission;

            if (auxWindow == null)
            {
                TeamEditor teamEdit = Editor.CreateInstance <TeamEditor>();
                if (selectedMission.Teams.Count > SessionState.GetInt("MissionEditor_LastTeamIndex", 0))
                {
                    teamEdit.Do(selectedMission.Teams[SessionState.GetInt("MissionEditor_LastTeamIndex", 0)], selectedMission);
                    teamEdit.SetParent(this);
                    auxWindow = teamEdit;
                }
            }

            EditorGUI.BeginChangeCheck();
            Loadable next = EditorGUILayout.ObjectField("Next Mission", selectedMission.NextLoadable, typeof(Loadable), false) as Loadable;

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(selectedMission, "Modify Mission");
                selectedMission.NextLoadable = next;
            }
            List <Team> teams = selectedMission.Teams;

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Teams", EditorStyles.boldLabel, GUILayout.Width(50));

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(20)))
            {
                Undo.RecordObject(selectedMission, "Add Team");
                teams.Add(new Team());
            }
            EditorGUILayout.EndHorizontal();
            int i = 0;

            for (i = 0; i < teams.Count; i++)
            {
                int  _i   = i;
                Team team = teams[_i];


                EditorGUILayout.BeginHorizontal();
                GUILayout.Space(10);
                if (GUILayout.Button("Team: " + _i + "    Members: " + team.members.Count.ToString(), EditorStyles.miniButtonLeft))
                {
                    TeamEditor teamEdit = Editor.CreateInstance <TeamEditor>();
                    teamEdit.Do(team, selectedMission);
                    teamEdit.SetParent(this);
                    auxWindow = teamEdit;
                    SessionState.SetInt("MissionEditor_LastTeamIndex", _i);
                }
                if (GUILayout.Button("Pop", EditorStyles.miniButtonRight, GUILayout.Width(35)))
                {
                    TeamEditor teamEdit = Editor.CreateInstance <TeamEditor>();
                    teamEdit.Do(team, selectedMission);
                    teamEdit.Show();
                    auxWindow = null;
                }

                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(10);
            EditorGUILayout.LabelField("End Conditions", EditorStyles.boldLabel);
            selectedMission.ConditionSelector("Victory", ref ShowdCondition[0], ref selectedMission.WinDondition, ref ConditionTypes[0]);
            selectedMission.ConditionSelector("Defeat", ref ShowdCondition[1], ref selectedMission.LoseCondition, ref ConditionTypes[1]);
            GUILayout.Space(10);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.LabelField("Intro Text", EditorStyles.boldLabel);

            string introText = EditorGUILayout.TextArea(selectedMission.MissionIntroText);

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(selectedMission, "Modify Mission");
                selectedMission.MissionIntroText = introText;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Events", EditorStyles.boldLabel);
            if (GUILayout.Button("+"))
            {
                Undo.RegisterCompleteObjectUndo(selectedMission, "Add Event Group");
                selectedMission.events.Add(new MissionEventContainer());
            }
            EditorGUILayout.EndHorizontal();
            EditorGUI.indentLevel++;

            for (int q = 0; q < selectedMission.events.Count; q++)
            {
                for (int z = 0; z < selectedMission.events[q].allEvents.Count; z++)
                {
                    if (!eventEditors.ContainsKey(selectedMission.events[q].allEvents[z]))
                    {
                        UpdateDictionaries();
                        break;
                    }
                }
            }

            int deleteindex = -1;

            for (int q = 0; q < selectedMission.events.Count; q++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                selectedMission.events[q].OnGUI(eventEditors, selectedMission);
                EditorGUILayout.EndVertical();
                if (GUILayout.Button("X", GUILayout.Width(20)))
                {
                    deleteindex = q;
                }

                EditorGUILayout.EndHorizontal();
            }
            if (deleteindex != -1)
            {
                MissionEventContainer cont = selectedMission.events[deleteindex];
                selectedMission.events.RemoveAt(deleteindex);

                if (cont.cond != null && AssetDatabase.GetAssetPath(cont.cond) == AssetDatabase.GetAssetPath(selectedMission))
                {
                    DestroyImmediate(cont.cond, true);
                }
            }
            EditorGUI.indentLevel--;

            GUILayout.Space(10);
            if (auxWindow != null)
            {
                if (auxWindow.Render())
                {
                    Editor.DestroyImmediate(auxWindow as EditorWindow);
                    auxWindow = null;
                }
            }

            if (GUI.changed && !Application.isPlaying && selectedMission != null)
            {
                EditorUtility.SetDirty(selectedMission);
            }
        }
 public virtual Loadable Clone()
 {
     return(Loadable.Instantiate <Loadable>(this));
 }