640 lines
22 KiB
C#
640 lines
22 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using BitStrap;
|
|
using LE_LevelEditor;
|
|
using LE_LevelEditor.Commands;
|
|
using LE_LevelEditor.Core;
|
|
using LE_LevelEditor.Events;
|
|
using LE_LevelEditor.Example;
|
|
using LE_LevelEditor.Extensions;
|
|
using LE_LevelEditor.UI;
|
|
using LapinerTools.uMyGUI;
|
|
using PygmyMonkey.AdvancedBuilder;
|
|
using UltimateWater;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
|
|
public class FisheryEditor : MonoBehaviour
|
|
{
|
|
private static FisheryEditor instance;
|
|
|
|
public Shader selectionShader;
|
|
|
|
[HideInInspector]
|
|
public GameObject objectsOrigin;
|
|
|
|
public Camera editorCamera;
|
|
|
|
[Header("Objects")]
|
|
public LE_Object spawnPointPrefab;
|
|
|
|
public Transform spawnPointTransform;
|
|
|
|
public LE_Object waterPrefab;
|
|
|
|
public Transform waterTransform;
|
|
|
|
public LE_Object startStandPrefab;
|
|
|
|
public Transform startStandTransform;
|
|
|
|
[ReadOnly]
|
|
public LE_Object spawnPointObject;
|
|
|
|
[ReadOnly]
|
|
public LE_Object waterObject;
|
|
|
|
[ReadOnly]
|
|
public LE_Object startStandObject;
|
|
|
|
public GameObject fakeDragCollisionObject;
|
|
|
|
[ReadOnly]
|
|
public bool allowKeyboardInput = true;
|
|
|
|
private const string POPUP_LOADING = "loading";
|
|
|
|
private const string POPUP_TEXT = "text";
|
|
|
|
public static bool m_isComingBackFromGame;
|
|
|
|
private int m_lastSaveFrame = -100;
|
|
|
|
public string CURRENT_LEVEL_FILE_NAME = string.Empty;
|
|
|
|
public string CURRENT_LEVEL_FILE_PATH = string.Empty;
|
|
|
|
[Header("UI")]
|
|
public Button saveButton;
|
|
|
|
public Text fisheryNameText;
|
|
|
|
public Text fisheryVersionText;
|
|
|
|
public FisheryEditorParams fisheryEditorParams;
|
|
|
|
public SkySettings skySettings;
|
|
|
|
public WaterSettings waterSettings;
|
|
|
|
public GameObject helpWindow;
|
|
|
|
public FisheryEditorFishDropdown fishDropdown;
|
|
|
|
public GameObject objectEditButtons;
|
|
|
|
public static bool isMultiplayerLM;
|
|
|
|
public static bool multiAnyLanguageLM;
|
|
|
|
public static bool multiPrivateRoomLM;
|
|
|
|
public int fisheryId = -1;
|
|
|
|
[Header("Logic")]
|
|
public LE_LevelEditorMain le_LevelEditorMain;
|
|
|
|
public LE_GUIInterface_uGUIimpl le_GUIInterface_uGUIimpl;
|
|
|
|
public uMyGUI_TabBox rightNavBg;
|
|
|
|
public InputField fisheryNameIF;
|
|
|
|
public GameObject popupTextRoot;
|
|
|
|
public static FisheryEditor Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private FisheryEditor()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
AudioController.PauseMusic(1f);
|
|
if ((bool)RadioManager.Instance)
|
|
{
|
|
RadioManager.Instance.Stop();
|
|
}
|
|
objectsOrigin = MultiTags.FindWithMultiTag("OBJECTS_ORIGIN");
|
|
if ((bool)MenuManager.Instance && MenuManager.Instance.dontDestroyOnLoad)
|
|
{
|
|
MenuManager.Instance.gameObject.SetActive(false);
|
|
}
|
|
if ((bool)GlobalSettings.Instance && !m_isComingBackFromGame)
|
|
{
|
|
isMultiplayerLM = GlobalSettings.Instance.levelsManager.isMultiplayer;
|
|
multiAnyLanguageLM = GlobalSettings.Instance.levelsManager.multiAnyLanguage;
|
|
multiPrivateRoomLM = GlobalSettings.Instance.levelsManager.multiPrivateRoom;
|
|
}
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
le_LevelEditorMain = LE_LevelEditorMain.Instance;
|
|
ExampleGame_LoadSave.Init();
|
|
if (m_isComingBackFromGame)
|
|
{
|
|
LE_ExtensionInterface.Load.Delegate(this, delegate(byte[][] p_levelData)
|
|
{
|
|
if (LE_LevelEditorMain.Instance.IsReady)
|
|
{
|
|
StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), p_levelData));
|
|
}
|
|
else
|
|
{
|
|
LE_LevelEditorMain.Instance.ExecuteWhenReady(delegate
|
|
{
|
|
StartCoroutine(LateLoad(LE_LevelEditorMain.Instance.GetLoadEvent(), p_levelData));
|
|
});
|
|
}
|
|
}, true);
|
|
}
|
|
m_isComingBackFromGame = false;
|
|
LE_EventInterface.OnSave = (EventHandler<LE_SaveEvent>)Delegate.Combine(LE_EventInterface.OnSave, new EventHandler<LE_SaveEvent>(OnSave));
|
|
LE_EventInterface.OnLoad = (EventHandler<LE_LoadEvent>)Delegate.Combine(LE_EventInterface.OnLoad, new EventHandler<LE_LoadEvent>(OnLoad));
|
|
LE_EventInterface.OnCollectMetaDataBeforeSave = (EventHandler<LE_CollectMetaDataEvent>)Delegate.Combine(LE_EventInterface.OnCollectMetaDataBeforeSave, new EventHandler<LE_CollectMetaDataEvent>(OnCollectMetaDataBeforeSave));
|
|
LE_EventInterface.OnObjectPlaced = (EventHandler<LE_ObjectPlacedEvent>)Delegate.Combine(LE_EventInterface.OnObjectPlaced, new EventHandler<LE_ObjectPlacedEvent>(OnObjectPlaced));
|
|
LE_EventInterface.OnObjectSelectedInScene = (EventHandler<LE_ObjectSelectedEvent>)Delegate.Combine(LE_EventInterface.OnObjectSelectedInScene, new EventHandler<LE_ObjectSelectedEvent>(OnObjectSelectedInScene));
|
|
LE_EventInterface.OnTerrainCreated = (EventHandler<LE_TerrainCreatedEvent>)Delegate.Combine(LE_EventInterface.OnTerrainCreated, new EventHandler<LE_TerrainCreatedEvent>(OnTerrainCreated));
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
waterSettings.underwaterEffectToggle.isOn = GlobalSettings.Instance.playerSettings.editorUnderwaterEffect;
|
|
}
|
|
else
|
|
{
|
|
waterSettings.underwaterEffectToggle.isOn = true;
|
|
}
|
|
waterSettings.UpdateUnderwaterEffect();
|
|
fisheryVersionText.text = "Fishery Editor - Alpha Version";
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
Text text = fisheryVersionText;
|
|
string text2 = text.text;
|
|
text.text = text2 + " " + AppParameters.Get.bundleVersion + ":" + AppParameters.Get.buildNumber;
|
|
GlobalSettings.Instance.ShowInfo(false);
|
|
}
|
|
}
|
|
|
|
public IEnumerator Initialize()
|
|
{
|
|
ShowSkySettings(false);
|
|
ShowWaterSettings(false);
|
|
ShowFisheryParams(false);
|
|
ShowFishSpeciesWindow(null);
|
|
SpawnPoint sp = UnityEngine.Object.FindObjectOfType<SpawnPoint>();
|
|
if ((bool)sp)
|
|
{
|
|
spawnPointObject = sp.GetComponent<LE_Object>();
|
|
}
|
|
else
|
|
{
|
|
LE_CmdPlaceObject lE_CmdPlaceObject = new LE_CmdPlaceObject(le_LevelEditorMain.m_GUI3dObject, spawnPointPrefab, spawnPointTransform, "SpawnPoint");
|
|
lE_CmdPlaceObject.Execute();
|
|
LE_CmdPlaceObject lE_CmdPlaceObject2 = new LE_CmdPlaceObject(le_LevelEditorMain.m_GUI3dObject, startStandPrefab, startStandTransform, "TestObjects/Cube");
|
|
lE_CmdPlaceObject2.Execute();
|
|
spawnPointObject = UnityEngine.Object.FindObjectOfType<SpawnPoint>().GetComponent<LE_Object>();
|
|
}
|
|
Water w = UnityEngine.Object.FindObjectOfType<Water>();
|
|
if ((bool)w)
|
|
{
|
|
waterObject = w.GetComponent<LE_Object>();
|
|
}
|
|
else
|
|
{
|
|
LE_CmdPlaceObject lE_CmdPlaceObject3 = new LE_CmdPlaceObject(le_LevelEditorMain.m_GUI3dObject, waterPrefab, waterTransform, "Water/WaterEditor");
|
|
lE_CmdPlaceObject3.Execute();
|
|
waterObject = UnityEngine.Object.FindObjectOfType<Water>().GetComponent<LE_Object>();
|
|
}
|
|
le_LevelEditorMain.OnEditModeBtn(LE_EEditMode.OBJECT);
|
|
if ((bool)spawnPointObject)
|
|
{
|
|
le_LevelEditorMain.m_GUI3dObject.SelectObject(spawnPointObject);
|
|
if (le_LevelEditorMain.m_GUI3dObject.SelectedObject != null)
|
|
{
|
|
le_LevelEditorMain.m_GUI3dObject.Focus();
|
|
}
|
|
}
|
|
yield return null;
|
|
waterSettings.water = waterObject.GetComponent<Water>();
|
|
waterSettings.UpdateWater();
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
LE_EventInterface.OnSave = (EventHandler<LE_SaveEvent>)Delegate.Remove(LE_EventInterface.OnSave, new EventHandler<LE_SaveEvent>(OnSave));
|
|
LE_EventInterface.OnLoad = (EventHandler<LE_LoadEvent>)Delegate.Remove(LE_EventInterface.OnLoad, new EventHandler<LE_LoadEvent>(OnLoad));
|
|
LE_EventInterface.OnCollectMetaDataBeforeSave = (EventHandler<LE_CollectMetaDataEvent>)Delegate.Remove(LE_EventInterface.OnCollectMetaDataBeforeSave, new EventHandler<LE_CollectMetaDataEvent>(OnCollectMetaDataBeforeSave));
|
|
LE_EventInterface.OnObjectPlaced = (EventHandler<LE_ObjectPlacedEvent>)Delegate.Remove(LE_EventInterface.OnObjectPlaced, new EventHandler<LE_ObjectPlacedEvent>(OnObjectPlaced));
|
|
LE_EventInterface.OnObjectSelectedInScene = (EventHandler<LE_ObjectSelectedEvent>)Delegate.Remove(LE_EventInterface.OnObjectSelectedInScene, new EventHandler<LE_ObjectSelectedEvent>(OnObjectSelectedInScene));
|
|
LE_EventInterface.OnTerrainCreated = (EventHandler<LE_TerrainCreatedEvent>)Delegate.Remove(LE_EventInterface.OnTerrainCreated, new EventHandler<LE_TerrainCreatedEvent>(OnTerrainCreated));
|
|
LE_EventInterface.UnregisterAll();
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.ShowInfo(true);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
saveButton.interactable = CURRENT_LEVEL_FILE_NAME != string.Empty;
|
|
fisheryNameText.text = CURRENT_LEVEL_FILE_NAME;
|
|
if (fisheryId != -1)
|
|
{
|
|
Text text = fisheryNameText;
|
|
string text2 = text.text;
|
|
text.text = text2 + " (" + fisheryId + ")";
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
CheckAllowInput();
|
|
}
|
|
|
|
private void OnSave(object p_sender, LE_SaveEvent p_args)
|
|
{
|
|
m_lastSaveFrame = Time.frameCount;
|
|
LE_ExtensionInterface.Save.Delegate(this, p_args.SavedLevelData, p_args.SavedLevelMeta, p_args.RemovedDuplicatesCount);
|
|
}
|
|
|
|
public void OnSaveQuick(object p_sender, LE_SaveEvent p_args)
|
|
{
|
|
m_lastSaveFrame = Time.frameCount;
|
|
string p_levelDataFilePath = Path.Combine(FisheryEditor_LoadSave.GetSaveFolderPath(), CURRENT_LEVEL_FILE_NAME + ".txt");
|
|
string p_levelIconFileName = Path.Combine(FisheryEditor_LoadSave.GetSaveFolderPath(), CURRENT_LEVEL_FILE_NAME + ".png");
|
|
LE_FileSelectionHelpers.SaveLevel(p_levelDataFilePath, p_levelIconFileName, p_args.SavedLevelData, p_args.SavedLevelMeta, p_args.RemovedDuplicatesCount);
|
|
}
|
|
|
|
private void OnLoad(object p_sender, LE_LoadEvent p_args)
|
|
{
|
|
LE_ExtensionInterface.Load.Delegate(this, delegate(byte[][] p_levelData)
|
|
{
|
|
if (p_levelData != null && p_levelData.Length == 2 && p_levelData[0] != null && p_levelData[1] != null)
|
|
{
|
|
StartCoroutine(LateLoad(p_args, p_levelData));
|
|
}
|
|
else
|
|
{
|
|
uMyGUI_PopupManager.Instance.HidePopup("loading");
|
|
((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup("text")).SetText("No saved level found!", "You first need to save a level!\nNo saved level was found!\nIn the webplayer the level must be in the clipboard!").ShowButton("ok");
|
|
}
|
|
}, false);
|
|
}
|
|
|
|
private IEnumerator LateLoad(LE_LoadEvent p_args, byte[][] p_data)
|
|
{
|
|
yield return new WaitForSeconds(0.3f);
|
|
uMyGUI_PopupManager.Instance.HidePopup("loading");
|
|
bool isLevelNotSupported = false;
|
|
if (Application.loadedLevelName == "LE_ExampleEditorTerrainOnly")
|
|
{
|
|
LE_TerrainTextureConfig terrainTextureConfig = UnityEngine.Object.FindObjectOfType<LE_ConfigTerrain>().TerrainTextureConfig;
|
|
LE_SaveLoadDataPeek lE_SaveLoadDataPeek = LE_SaveLoad.PeekLevelDataFromByteArray(p_data[0], terrainTextureConfig.TERRAIN_TEXTURES, terrainTextureConfig.TERRAIN_NORMALS, terrainTextureConfig.TERRAIN_TEXTURE_SIZES, terrainTextureConfig.TERRAIN_TEXTURE_OFFSETS);
|
|
isLevelNotSupported = lE_SaveLoadDataPeek.TerrainDataPreview == null || lE_SaveLoadDataPeek.TerrainDataPreview.size.x != 500f || lE_SaveLoadDataPeek.TerrainDataPreview.size.z != 500f || lE_SaveLoadDataPeek.TerrainDataPreview.heightmapResolution != 257 || lE_SaveLoadDataPeek.LevelObjectsCount > 0;
|
|
UnityEngine.Object.Destroy(lE_SaveLoadDataPeek.TerrainDataPreview);
|
|
if (isLevelNotSupported)
|
|
{
|
|
((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup("text")).SetText("Loading Failed", "It seems that you have a level saved in your clipboard that comes from the full level editor example or from the dungeon game example. However, this is a terrain only editor example that cannot load such levels...").ShowButton("ok");
|
|
}
|
|
}
|
|
if (!isLevelNotSupported)
|
|
{
|
|
p_args.LoadLevelDataFromBytesCallback(p_data[0]);
|
|
p_args.LoadLevelMetaFromBytesCallback(p_data[1]);
|
|
yield return new WaitForEndOfFrame();
|
|
LoadMetaData(p_data[1]);
|
|
GameObject player = GameObject.Find("Objects/PlayerStartPosition");
|
|
if (player != null)
|
|
{
|
|
Camera.main.transform.LookAt(player.transform.position, Vector3.up);
|
|
}
|
|
m_lastSaveFrame = Time.frameCount + 1;
|
|
}
|
|
StartCoroutine(Initialize());
|
|
}
|
|
|
|
private void OnCollectMetaDataBeforeSave(object p_sender, LE_CollectMetaDataEvent p_args)
|
|
{
|
|
p_args.LevelMetaData.Add("FisheryName", fisheryEditorParams.GetFisheryName());
|
|
p_args.LevelMetaData.Add("AverageTemperature", fisheryEditorParams.GetAverageTemperature().ToString());
|
|
p_args.LevelMetaData.Add("AveragePressure", fisheryEditorParams.GetAveragePressure().ToString());
|
|
p_args.LevelMetaData.Add("IsIceFishing", (!(GetIceOnLevel() != null)) ? "0" : "1");
|
|
fisheryId = UnityEngine.Random.Range(10000, 999999);
|
|
p_args.LevelMetaData.Add("FisheryId", fisheryId.ToString());
|
|
Debug.Log("MetaDataSave FisheryId: " + fisheryId);
|
|
p_args.LevelMetaData.Add("SkySettingsAltitude", skySettings.GetSetting(SkySettingsSlider.SettingType.ALTITUDE).ToString("F2"));
|
|
p_args.LevelMetaData.Add("SkySettingsColorR", skySettings.GetSetting(SkySettingsSlider.SettingType.COLOR_R).ToString("F0"));
|
|
p_args.LevelMetaData.Add("SkySettingsColorG", skySettings.GetSetting(SkySettingsSlider.SettingType.COLOR_G).ToString("F0"));
|
|
p_args.LevelMetaData.Add("SkySettingsColorB", skySettings.GetSetting(SkySettingsSlider.SettingType.COLOR_B).ToString("F0"));
|
|
p_args.LevelMetaData.Add("WaterDiffuseColorR", waterSettings.GetColorDiffuse().r.ToString());
|
|
p_args.LevelMetaData.Add("WaterDiffuseColorG", waterSettings.GetColorDiffuse().g.ToString());
|
|
p_args.LevelMetaData.Add("WaterDiffuseColorB", waterSettings.GetColorDiffuse().b.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorR", waterSettings.GetColorAbsorption().r.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorG", waterSettings.GetColorAbsorption().g.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorB", waterSettings.GetColorAbsorption().b.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorUnderwaterR", waterSettings.GetColorAbsorptionUnderwater().r.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorUnderwaterG", waterSettings.GetColorAbsorptionUnderwater().g.ToString());
|
|
p_args.LevelMetaData.Add("WaterTransColorUnderwaterB", waterSettings.GetColorAbsorptionUnderwater().b.ToString());
|
|
p_args.LevelMetaData.Add("WaterDirectionality", waterSettings.GetDirectionality().ToString());
|
|
p_args.LevelMetaData.Add("WaterDirection", waterSettings.GetDirection().ToString());
|
|
}
|
|
|
|
public void LoadMetaData(byte[] data)
|
|
{
|
|
LE_SaveLoad.LevelMetaData levelMetaData = LE_SaveLoad.LoadLevelMetaFromByteArray(data, false);
|
|
fisheryEditorParams.SetFisheryName((!levelMetaData.MetaData.ContainsKey("FisheryName")) ? "Fishery Name" : levelMetaData.MetaData["FisheryName"]);
|
|
fisheryEditorParams.SetAverageTemperature((!levelMetaData.MetaData.ContainsKey("AverageTemperature")) ? 22 : int.Parse(levelMetaData.MetaData["AverageTemperature"]));
|
|
fisheryEditorParams.SetAveragePressure((!levelMetaData.MetaData.ContainsKey("AveragePressure")) ? 1000 : int.Parse(levelMetaData.MetaData["AveragePressure"]));
|
|
fisheryId = ((!levelMetaData.MetaData.ContainsKey("FisheryId")) ? (-1) : int.Parse(levelMetaData.MetaData["FisheryId"]));
|
|
skySettings.SetSetting(SkySettingsSlider.SettingType.ALTITUDE, LoadFloatMetaData(levelMetaData, "SkySettingsAltitude", 0.05f));
|
|
skySettings.SetSetting(SkySettingsSlider.SettingType.COLOR_R, LoadFloatMetaData(levelMetaData, "SkySettingsColorR", 650f));
|
|
skySettings.SetSetting(SkySettingsSlider.SettingType.COLOR_G, LoadFloatMetaData(levelMetaData, "SkySettingsColorG", 570f));
|
|
skySettings.SetSetting(SkySettingsSlider.SettingType.COLOR_B, LoadFloatMetaData(levelMetaData, "SkySettingsColorB", 475f));
|
|
skySettings.UpdateSky();
|
|
Color white = Color.white;
|
|
white.r = LoadFloatMetaData(levelMetaData, "WaterDiffuseColorR", 0.907f);
|
|
white.g = LoadFloatMetaData(levelMetaData, "WaterDiffuseColorG", 0.944f);
|
|
white.b = LoadFloatMetaData(levelMetaData, "WaterDiffuseColorB", 0.963f);
|
|
waterSettings.SetColorDiffuse(white);
|
|
Color white2 = Color.white;
|
|
white2.r = LoadFloatMetaData(levelMetaData, "WaterTransColorR", 0.49f);
|
|
white2.g = LoadFloatMetaData(levelMetaData, "WaterTransColorG", 0.694f);
|
|
white2.b = LoadFloatMetaData(levelMetaData, "WaterTransColorB", 0.725f);
|
|
waterSettings.SetColorAbsorption(white2);
|
|
Color white3 = Color.white;
|
|
white3.r = LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterR", waterSettings.startAbsorptionColorUnderwater.r);
|
|
white3.g = LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterG", waterSettings.startAbsorptionColorUnderwater.g);
|
|
white3.b = LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterB", waterSettings.startAbsorptionColorUnderwater.b);
|
|
waterSettings.SetColorAbsorptionUnderwater(white3);
|
|
waterSettings.SetDirectionality(LoadFloatMetaData(levelMetaData, "WaterDirectionality", 0.35f));
|
|
waterSettings.SetDirection(LoadFloatMetaData(levelMetaData, "WaterDirection", 0f));
|
|
waterSettings.UpdateWater();
|
|
}
|
|
|
|
private IEnumerator LatePlay(string levelName)
|
|
{
|
|
yield return new WaitForSeconds(0.3f);
|
|
Application.LoadLevel(levelName);
|
|
}
|
|
|
|
private bool IsLevelPlayable(out string o_errorMessage)
|
|
{
|
|
GameObject gameObject = GameObject.Find("SpawnPoint");
|
|
if (gameObject == null)
|
|
{
|
|
o_errorMessage = "You must define the\n<b>player start position</b>\nfor this level!\n1. Go to Objects->GameLogic in the right window.\n2. Drag and drop SpawnPoint into the level.";
|
|
return false;
|
|
}
|
|
o_errorMessage = string.Empty;
|
|
return true;
|
|
}
|
|
|
|
private void OnObjectPlaced(object p_sender, LE_ObjectPlacedEvent p_args)
|
|
{
|
|
}
|
|
|
|
private void OnObjectSelectedInScene(object p_sender, LE_ObjectSelectedEvent p_args)
|
|
{
|
|
}
|
|
|
|
private void OnTerrainCreated(object p_sender, LE_TerrainCreatedEvent p_args)
|
|
{
|
|
}
|
|
|
|
public void OnPlayButtonClick()
|
|
{
|
|
if (m_lastSaveFrame > LE_LevelEditorMain.Instance.LastChangeFrame)
|
|
{
|
|
string o_errorMessage;
|
|
if (IsLevelPlayable(out o_errorMessage))
|
|
{
|
|
uMyGUI_PopupManager.Instance.ShowPopup("loading");
|
|
StartCoroutine(LatePlay("FisheryEditor_Game"));
|
|
}
|
|
else
|
|
{
|
|
((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup("text")).SetText("Game logic objects missing!", o_errorMessage).ShowButton("ok");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
((uMyGUI_PopupText)uMyGUI_PopupManager.Instance.ShowPopup("text")).SetText(Utilities.GetTranslation("EDITOR/UNSAVED_CHANGES"), Utilities.GetTranslation("EDITOR/UNSAVED_CHANGES_MSG")).ShowButton("ok");
|
|
}
|
|
}
|
|
|
|
public void OnDocumentationBtn()
|
|
{
|
|
Application.OpenURL("http://www.freebord-game.com/index.php/multiplatform-runtime-level-editor/documentation");
|
|
}
|
|
|
|
public void OnFullLevelEditorExampleBtn()
|
|
{
|
|
uMyGUI_PopupManager.Instance.ShowPopup("loading");
|
|
}
|
|
|
|
public void OnDungeonGameExampleBtn()
|
|
{
|
|
uMyGUI_PopupManager.Instance.ShowPopup("loading");
|
|
}
|
|
|
|
public void OnPureTerrainEditorExampleBtn()
|
|
{
|
|
uMyGUI_PopupManager.Instance.ShowPopup("loading");
|
|
}
|
|
|
|
public void OnExitBtn()
|
|
{
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.isMultiplayer = isMultiplayerLM;
|
|
GlobalSettings.Instance.levelsManager.multiAnyLanguage = multiAnyLanguageLM;
|
|
GlobalSettings.Instance.levelsManager.multiPrivateRoom = multiPrivateRoomLM;
|
|
}
|
|
LoadingManager.LoadScene("MainMenu");
|
|
}
|
|
|
|
public void OnNewBtn()
|
|
{
|
|
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
|
}
|
|
|
|
public void OnSaveBtn()
|
|
{
|
|
le_LevelEditorMain.m_logicLevel.SaveLevel(true);
|
|
}
|
|
|
|
public void ChangeMode()
|
|
{
|
|
rightNavBg.SelectTab(0);
|
|
LE_GUIInterface.Instance.OnEditModeBtn(1);
|
|
le_GUIInterface_uGUIimpl.SelectObjectMode(LE_EObjectEditMode.MOVE);
|
|
ShowWater(true);
|
|
}
|
|
|
|
public void SelectPlayer()
|
|
{
|
|
SelectObject(spawnPointObject);
|
|
}
|
|
|
|
public void SelectWater()
|
|
{
|
|
SelectObject(waterObject);
|
|
}
|
|
|
|
public void SelectObject(LE_Object le_Object)
|
|
{
|
|
if ((bool)le_Object)
|
|
{
|
|
le_LevelEditorMain.m_GUI3dObject.SelectObject(le_Object);
|
|
if (le_LevelEditorMain.m_GUI3dObject.SelectedObject != null)
|
|
{
|
|
le_LevelEditorMain.m_GUI3dObject.Focus();
|
|
}
|
|
}
|
|
le_GUIInterface_uGUIimpl.SelectObjectMode(LE_EObjectEditMode.MOVE);
|
|
}
|
|
|
|
public void ShowFisheryParams(bool show)
|
|
{
|
|
HideWindows();
|
|
fisheryEditorParams.gameObject.SetActive(show);
|
|
}
|
|
|
|
public void ShowFishSpeciesWindow(LE_Object le_Object)
|
|
{
|
|
fishDropdown.Show(le_Object);
|
|
}
|
|
|
|
public void ShowSkySettings(bool show)
|
|
{
|
|
HideWindows();
|
|
skySettings.gameObject.SetActive(show);
|
|
}
|
|
|
|
public void ShowWaterSettings(bool show)
|
|
{
|
|
HideWindows();
|
|
waterSettings.gameObject.SetActive(show);
|
|
}
|
|
|
|
public void HideWindows()
|
|
{
|
|
skySettings.gameObject.SetActive(false);
|
|
waterSettings.gameObject.SetActive(false);
|
|
}
|
|
|
|
public void ShowWater(bool show)
|
|
{
|
|
waterObject.gameObject.SetActive(show);
|
|
}
|
|
|
|
public void ShowUnderwaterCamera(bool show)
|
|
{
|
|
editorCamera.GetComponent<UnderwaterIME>().EffectEnabled = show;
|
|
}
|
|
|
|
public void ShowObjectEditButtons(bool show)
|
|
{
|
|
objectEditButtons.SetActive(show);
|
|
}
|
|
|
|
public void DeleteTerrain()
|
|
{
|
|
le_LevelEditorMain.m_logicTerrain.DestroyOrResetTerrainWithUIUpdate();
|
|
}
|
|
|
|
public GameObject GetIceOnLevel(LE_Object placingIce = null)
|
|
{
|
|
GameObject[] array = MultiTags.FindGameObjectsWithMultiTag("ICE_EDITOR");
|
|
if (array == null)
|
|
{
|
|
Debug.Log("ice null");
|
|
}
|
|
else
|
|
{
|
|
Debug.Log("ice count: " + array.Length);
|
|
}
|
|
if (array == null || array.Length == 0)
|
|
{
|
|
return null;
|
|
}
|
|
if (array.Length == 1)
|
|
{
|
|
return array[0];
|
|
}
|
|
if (array.Length > 2)
|
|
{
|
|
return array[0];
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void CheckAllowInput()
|
|
{
|
|
allowKeyboardInput = true;
|
|
if (fisheryNameIF.isFocused)
|
|
{
|
|
allowKeyboardInput = false;
|
|
}
|
|
else if (popupTextRoot.activeSelf)
|
|
{
|
|
allowKeyboardInput = false;
|
|
}
|
|
else if (helpWindow.activeSelf)
|
|
{
|
|
allowKeyboardInput = false;
|
|
}
|
|
else if (fisheryEditorParams.gameObject.activeSelf)
|
|
{
|
|
allowKeyboardInput = false;
|
|
}
|
|
else if ((bool)le_GUIInterface_uGUIimpl.GetComponentInChildren<LE_PopupFileSelection>(false))
|
|
{
|
|
allowKeyboardInput = false;
|
|
}
|
|
}
|
|
|
|
public static float LoadFloatMetaData(LE_SaveLoad.LevelMetaData meta, string dataName, float defaultValue)
|
|
{
|
|
if (meta.MetaData.ContainsKey(dataName))
|
|
{
|
|
string text = meta.MetaData[dataName];
|
|
Debug.Log("loadedData: " + text);
|
|
CultureInfo provider = CultureInfo.CreateSpecificCulture("en-GB");
|
|
double result = 0.0;
|
|
if (double.TryParse(text, NumberStyles.AllowDecimalPoint, provider, out result))
|
|
{
|
|
return (float)result;
|
|
}
|
|
text = text.Replace(',', '.');
|
|
result = 0.0;
|
|
if (double.TryParse(text, NumberStyles.AllowDecimalPoint, provider, out result))
|
|
{
|
|
return (float)result;
|
|
}
|
|
text = text.Replace('.', ',');
|
|
result = 0.0;
|
|
if (double.TryParse(text, NumberStyles.AllowDecimalPoint, provider, out result))
|
|
{
|
|
return (float)result;
|
|
}
|
|
Debug.Log("ret default");
|
|
return defaultValue;
|
|
}
|
|
return defaultValue;
|
|
}
|
|
}
|