public void GenerateGrid(int width, int height)
 {
     map        = FindObjectOfType <MapImporter>();
     map.width  = width;
     map.height = height;
     map.Generate();
 }
Example #2
0
File: CoM.cs Project: bsimser/CoM
    /** Loads all the static data, this includes things like monsters, items, etc.  These values do not change as the game progresses */
    public static void LoadGameData()
    {
        DateTime startTime = DateTime.Now;

        Trace.Log("Loading game data:");

        DamageTypes = LoadLibrary <MDRDamageTypeLibrary, MDRDamageType>("DamageTypes", 0, true);
        Skills      = LoadLibrary <MDRSkillLibrary, MDRSkill>("Skills", 0, true);

        SpellClasses = LoadLibrary <MDRSpellClassLibrary, MDRSpellClass>("SpellClasses");
        Spells       = LoadLibrary <MDRSpellLibrary, MDRSpell>("Spells");

        Races  = LoadLibrary <MDRRaceLibrary, MDRRace>("Races");
        Guilds = LoadLibrary <MDRGuildLibrary, MDRGuild>("Guilds");

        ItemClasses = LoadLibrary <MDRItemClassLibrary, MDRItemClass>("ItemClasses");
        ItemTypes   = LoadLibrary <MDRItemTypeLibrary, MDRItemType>("ItemTypes");
        Items       = LoadLibrary <MDRItemLibrary, MDRItem>("Items");

        MonsterClasses = LoadLibrary <MDRMonsterClassLibrary, MDRMonsterClass>("MonsterClasses");
        MonsterTypes   = LoadLibrary <MDRMonsterTypeLibrary, MDRMonsterType>("MonsterTypes");
        Monsters       = LoadLibrary <MDRMonsterLibrary, MDRMonster>("Monsters");

        // stub: import dungeon
        var importer = new MapImporter();

        Dungeon = importer.LoadDungeon(Util.ResourceToStream("Data/MDATA11"));
        //Dungeon = LoadData<MDRDungeon>("Dungeon", 2.0f);

        Trace.Log("Game data loading completed in " + (DateTime.Now - startTime).TotalMilliseconds.ToString("0.0") + "ms.");

        _gameDataLoaded = true;
    }
Example #3
0
        internal Task <BoolWithMessage> ImportMapAsync(bool isReimport = false)
        {
            Task <BoolWithMessage> task = Task.Factory.StartNew(() =>
            {
                string sourceFolderToCopy;

                if (IsZipFileImport)
                {
                    if (File.Exists(PathToFileOrFolder) == false)
                    {
                        System.Windows.MessageBox.Show("File does not exist", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(new BoolWithMessage(false, $"{PathToFileOrFolder} does not exist."));
                    }

                    // extract files first before copying
                    Directory.CreateDirectory(PathToTempUnzipFolder);
                    BoolWithMessage didExtract = FileUtils.ExtractZipFile(PathToFileOrFolder, PathToTempUnzipFolder);

                    if (didExtract.Result == false)
                    {
                        UserMessage = $"Failed to extract .zip file: {didExtract.Message}";
                        return(new BoolWithMessage(false, $"Failed to extract zip: {didExtract.Message}."));
                    }

                    sourceFolderToCopy = PathToTempUnzipFolder;
                }
                else
                {
                    if (Directory.Exists(PathToFileOrFolder) == false)
                    {
                        System.Windows.MessageBox.Show("Folder does not exist", "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(new BoolWithMessage(false, $"{PathToFileOrFolder} does not exist."));
                    }

                    sourceFolderToCopy = PathToFileOrFolder;
                }

                FileUtils.CopyDirectoryRecursively(sourceFolderToCopy, PathToSessionContent, FilesToExclude, FoldersToExclude);

                if (IsZipFileImport && Directory.Exists(PathToTempUnzipFolder))
                {
                    // remove unzipped temp files
                    Directory.Delete(PathToTempUnzipFolder, true);
                }
                else if (isReimport == false)
                {
                    // make .meta file to tag where the imported map came from to support the 'Re-import' feature
                    string mapName         = MapImporter.GetMapFileNameFromFolder(sourceFolderToCopy);
                    BoolWithMessage result = MapImporter.TrackMapLocation(mapName, sourceFolderToCopy, PathToSessionContent);
                }

                return(new BoolWithMessage(true));
            });

            return(task);
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        m_MapImporter = gameObject.AddComponent <MapImporter> ();

        if (ApplicationManager.Instance.IsInitialized)
        {
            OnManagersInitlized();
        }
        else
        {
            ApplicationManager.Instance.OnManagersInitialized += OnManagersInitlized;
        }
    }
Example #5
0
        public Product Map(ProductInfoModel source)
        {
            var destination = new Product();

            MapManufacturer?.Invoke(source, destination);
            MapCountryOfOrigin?.Invoke(source, destination);
            MapImporter?.Invoke(source, destination);
            MapImporterCountry?.Invoke(source, destination);
            MapName?.Invoke(source, destination);
            MapQuantityPerPackage?.Invoke(source, destination);
            MapImage?.Invoke(source, destination);
            MapSize?.Invoke(source, destination);
            MapLogoPath?.Invoke(source, destination);

            return(destination);
        }
Example #6
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        MapImporter map = (MapImporter)target;

        if (GUILayout.Button("Import Map"))
        {
            map.Import();
        }
        if (GUILayout.Button("Split Map"))
        {
            map.Split();
        }
        if (GUILayout.Button("Save Map"))
        {
            map.SaveMapTextFile(Application.dataPath + map.saveLocation);
            AssetDatabase.Refresh();
        }
    }
        private void ContextMenu_ContextMenuOpening(object sender, System.Windows.Controls.ContextMenuEventArgs e)
        {
            // disable certain menu items if no map selected
            bool isMapSelected      = (lstMaps.SelectedItem != null);
            bool isSessionPathValid = ViewModel.IsSessionPathValid();

            menuReimporSelectedMap.IsEnabled    = isMapSelected;
            menuOpenSelectedMapFolder.IsEnabled = isMapSelected;

            menuOpenSessionFolder.IsEnabled = isSessionPathValid;
            menuOpenMapsFolder.IsEnabled    = isSessionPathValid;

            if (isMapSelected)
            {
                MapListItem selected          = (lstMaps.SelectedItem as MapListItem);
                bool        hasImportLocation = MapImporter.IsImportLocationStored(ViewModel.SessionContentPath, selected.DisplayName);
                menuReimporSelectedMap.IsEnabled = hasImportLocation;
                menuReimporSelectedMap.ToolTip   = hasImportLocation ? null : "You can only re-import if you imported the map from 'Import Map > From Computer ...' and imported a folder.\n(does not work with .zip files)";
            }
        }
        private static void ImportQ1Map()
        {
            GameObject go = null;

            try
            {
                string path = EditorUtility.OpenFilePanel("Import Quake 1 Map", "", "map");
                if (path.Length != 0)
                {
                    EditorUtility.DisplayProgressBar("RealtimeCSG: Importing Quake 1 Map", "Parsing Quake 1 Map File (*.map)...", 0.0f);
                    var importer = new MapImporter();
                    //importer.adjustTexturesForValve = mapImporter.adjustTexturesForValve;

                    var map = importer.Import(path);

                    // create parent game object to store all of the imported content.
                    go = new GameObject("Q1-" + Path.GetFileNameWithoutExtension(path));
                    go.SetActive(false);

                    // create chisel model and import all of the brushes.
                    EditorUtility.DisplayProgressBar("Chisel: Importing Source Engine Map", "Preparing Material Searcher...", 0.0f);
                    Q1MapWorldConverter.Import(go.transform, map);

                    // begin converting hammer entities to unity objects.
                    //Q1EntityConverter.Import(go.transform, map);
                }
            }
            catch (Exception ex)
            {
                EditorUtility.ClearProgressBar();
                EditorUtility.DisplayDialog("Quake 1 Map Import", "An exception occurred while importing the map:\r\n" + ex.Message, "Ohno!");
            }
            finally
            {
                EditorUtility.ClearProgressBar();
                if (go != null)
                {
                    go.SetActive(true);
                }
            }
        }
Example #9
0
        /// <summary>
        /// Initializes the editor
        /// </summary>
        private void InitializeEditor()
        {
            // events
            Move       += editorViewport.OnEditorMoves;
            Activated  += editorViewport.OnEditorGotFocus;
            Deactivate += editorViewport.OnEditorLostFocus;
            Disposed   += EditorForm_Dispose;

            editorViewport.OnViewportFocus      += OnViewportFocus;
            textureSelector.ApplyButton.Click   += OnApplySelectedTexture;
            textureSelector.ReplaceButton.Click += OnReplaceSelectedTexture;

            creationButtonsPanel.OnCreationButtonPressed = HandleGeometryBarItems;
            solidProperties.OnPropertiesChanged          = OnSolidPropertiesChanged;
            textureProperties.OnPropertiesChanged        = OnTexturePropertiesChanged;
            textureProperties.OnJustify = OnTexturePropertiesJustifyClicked;

            // initialization
            EditorSettings    = new EditorSettings();
            RubberBand        = new RubberBand();
            Selection         = new MapObjectGroup();
            CopyBoard         = new MapObjectGroup();
            CurrentTool       = new SolidManipulationTool();
            defaultMapSaver   = new RuneMapExporter();
            defaultMapLoader  = new RuneMapImporter();
            TextureCollection = new TextureCollection(EditorSettings.TextureFolder);

            if (!DesignMode)
            {
                EditorSettings.Load();
                SetupSolidFactory();
                solidProperties.UpdateProperties(Selection);
                editorViewport.SetController(this);
                textureSelector.TextureCollection = TextureCollection;
                CurrentTool.Initialize(this);

                Rotate = GeneralUtility.CreateCursor(Resources.rotate, 16, 16);
                NewDocument();
            }
        }
Example #10
0
 void Start()
 {
     map = GetComponent <MapImporter>();
 }
Example #11
0
    static void Init()
    {
        MapImporter mapImporter = (MapImporter)EditorWindow.GetWindow(typeof(MapImporter));

        mapImporter.Show();
    }
Example #12
0
    // Use this for initialization
    void Start()
    {
        m_MapImporter = gameObject.AddComponent<MapImporter> ();

        if (ApplicationManager.Instance.IsInitialized) {
            OnManagersInitlized();
        } else {
            ApplicationManager.Instance.OnManagersInitialized += OnManagersInitlized;
        }
    }