public void LoadEffectPlaceholders(RoMapData mapData, RagnarokWorld worldData)
        {
            data  = mapData;
            world = worldData;

            var findObject = GameObject.Find($"{world.MapName} resources");

            if (findObject != null)
            {
                baseObject = findObject;
            }
            else
            {
                baseObject = new GameObject($"{world.MapName} resources");
                baseObject.transform.position = new Vector3(data.InitialSize.x, 0, data.InitialSize.y);
                baseObject.isStatic           = true;
            }

            var effectContainer = new GameObject("effects");

            effectContainer.transform.SetParent(baseObject.transform, false);

            foreach (var effect in world.Effects)
            {
                var obj = GameObject.CreatePrimitive(PrimitiveType.Sphere);
                //var obj2 = AssetDatabase.LoadAssetAtPath<GameObject>("Assets/Effects/Smoke/SmokeEmitter.prefab");
                //var obj = PrefabUtility.InstantiatePrefab(obj2) as GameObject;
                obj.name = effect.Id + " - " + effect.Name;
                obj.transform.SetParent(effectContainer.transform, false);
                obj.transform.localPosition = new Vector3(effect.Position.x / 5, -effect.Position.y / 5, effect.Position.z / 5);
            }
        }
        public void Load(RoMapData mapData, RagnarokWorld worldData)
        {
            data  = mapData;
            world = worldData;

            modelCache = new Dictionary <string, GameObject>();

            var oldBox = GameObject.Find($"{world.MapName} resources");

            if (oldBox != null)
            {
                GameObject.DestroyImmediate(oldBox);
            }

            baseObject = new GameObject($"{world.MapName} resources");
            baseObject.transform.position = new Vector3(data.InitialSize.x, 0, data.InitialSize.y);
            baseObject.isStatic           = true;

            SetWorldLighting();
            LoadLights();
            LoadModels();
            LoadEffects();
            LoadSounds();
            LoadWater();
            LoadFog();
        }
Exemplo n.º 3
0
        private bool HasSelectedMap()
        {
            if (Selection.activeGameObject != null)
            {
                var selEditor = Selection.activeGameObject.GetComponent <RoMapEditor>();
                if (selEditor != null)
                {
                    if (currentEditor != null && selEditor.gameObject != currentEditor.gameObject)
                    {
                        LeaveEditorMode();
                    }

                    targetGameObject = Selection.activeGameObject;
                    currentEditor    = selEditor;
                    currentData      = currentEditor.MapData;

                    if (currentData != null)
                    {
                        return(true);
                    }
                }
            }

            LeaveEditorMode();

            return(false);
        }
Exemplo n.º 4
0
        public void UnselectedGUI()
        {
            //EditorGUILayout.LabelField("To load an existing map, select a map in scene or use the load button on the map asset in the project folder.");

            currentData = (RoMapData)EditorGUILayout.ObjectField("Map File", currentData, typeof(RoMapData), false);

            if (GUILayout.Button("Load") && currentData != null)
            {
                LoadDataInScene();
            }

            EditorGuiLayoutUtility.HorizontalLine();

            EditorGUILayout.LabelField("Create a new map:");

            const int stepSize = 64;

            createWidth  = stepSize * ((EditorGUILayout.IntSlider("Width", createWidth, stepSize, 512)) / stepSize);
            createHeight = stepSize * ((EditorGUILayout.IntSlider("Height", createHeight, stepSize, 512)) / stepSize);

            if (GUILayout.Button("Create New"))
            {
                var path = EditorUtility.SaveFilePanelInProject("Create New Map", "mapname", "asset", "Map Asset");
                if (!string.IsNullOrEmpty(path))
                {
                    CreateNewMap(path);
                }
            }
        }
Exemplo n.º 5
0
 public virtual void OnDisable()
 {
     //Debug.Log("OnDisable");
     Window = null;
     Editor = null;
     Data   = null;
 }
Exemplo n.º 6
0
        public void CreateNewMap(string savePath)
        {
            currentData = ScriptableObject.CreateInstance <RoMapData>();
            AssetDatabase.CreateAsset(currentData, savePath);

            currentData.CreateNew(createWidth, createHeight);

            LoadDataInScene();
        }
Exemplo n.º 7
0
        public virtual void OnEnable(RoMapEditorWindow window, RoMapEditor editor)
        {
            Window = window;
            Editor = editor;
            Data   = editor.MapData;

            Editor.CurrentBrush = this;

            //Debug.Log("OnEnable");

            OnEnable();
        }