153 lines
6.0 KiB
C#
153 lines
6.0 KiB
C#
using BitStrap;
|
|
using LE_LevelEditor.Core;
|
|
using LE_LevelEditor.Extensions;
|
|
using UltimateWater;
|
|
using UnityEngine;
|
|
|
|
public class FisheryEditor_Game : MonoBehaviour
|
|
{
|
|
public SkySettings skySettings;
|
|
|
|
public SkySettings skySettingsIce;
|
|
|
|
public WaterSettings waterSettings;
|
|
|
|
public AudioListener fakeAudioListener;
|
|
|
|
[ReadOnly]
|
|
public int fisheryId = -1;
|
|
|
|
[Space(10f)]
|
|
[SerializeField]
|
|
private int TERRAIN_LAYER = 8;
|
|
|
|
[SerializeField]
|
|
private LE_TerrainTextureConfig TERRAIN_TEXTURE_CONFIG;
|
|
|
|
[SerializeField]
|
|
private GameObject PLAYER;
|
|
|
|
public bool m_isLoading = true;
|
|
|
|
private bool m_goBackToEditor;
|
|
|
|
private int m_counter;
|
|
|
|
[HideInInspector]
|
|
public string fisherynameMetaData = string.Empty;
|
|
|
|
[HideInInspector]
|
|
public int temperatureMetaData;
|
|
|
|
[HideInInspector]
|
|
public int pressureMetaData;
|
|
|
|
[HideInInspector]
|
|
public bool isIceFishingMetaData;
|
|
|
|
private void Start()
|
|
{
|
|
}
|
|
|
|
public void Initialize()
|
|
{
|
|
Debug.Log("Editor Level Load - Start");
|
|
FisheryEditor_LoadSave.Init();
|
|
LE_ExtensionInterface.Load.Delegate(this, delegate(byte[][] p_levelData)
|
|
{
|
|
if (p_levelData != null && p_levelData.Length > 0 && p_levelData[0] != null)
|
|
{
|
|
LE_SaveLoadData p_loadedLevel = LE_SaveLoad.LoadLevelDataFromByteArray(p_levelData[0], TERRAIN_LAYER, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURES, TERRAIN_TEXTURE_CONFIG.TERRAIN_NORMALS, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_SIZES, TERRAIN_TEXTURE_CONFIG.TERRAIN_TEXTURE_OFFSETS);
|
|
FixWaterLevel(p_loadedLevel);
|
|
LE_SaveLoad.DisableLevelEditing(p_loadedLevel);
|
|
}
|
|
else
|
|
{
|
|
Debug.LogError("ExampleGame_Game: No saved level found!");
|
|
}
|
|
LoadMetaData(p_levelData[1]);
|
|
m_isLoading = false;
|
|
Debug.Log("Editor Level Load - Finish");
|
|
}, true);
|
|
}
|
|
|
|
public void LoadMetaData(byte[] data)
|
|
{
|
|
LE_SaveLoad.LevelMetaData levelMetaData = LE_SaveLoad.LoadLevelMetaFromByteArray(data, false);
|
|
fisherynameMetaData = ((!levelMetaData.MetaData.ContainsKey("FisheryName")) ? "Fishery Name" : levelMetaData.MetaData["FisheryName"]);
|
|
temperatureMetaData = ((!levelMetaData.MetaData.ContainsKey("AverageTemperature")) ? 22 : int.Parse(levelMetaData.MetaData["AverageTemperature"]));
|
|
pressureMetaData = ((!levelMetaData.MetaData.ContainsKey("AveragePressure")) ? 1000 : int.Parse(levelMetaData.MetaData["AveragePressure"]));
|
|
isIceFishingMetaData = levelMetaData.MetaData.ContainsKey("IsIceFishing") && levelMetaData.MetaData["IsIceFishing"] == "1";
|
|
fisheryId = ((!levelMetaData.MetaData.ContainsKey("FisheryId")) ? (-1) : int.Parse(levelMetaData.MetaData["FisheryId"]));
|
|
Debug.Log("MetaDataLoad FisheryId: " + fisheryId);
|
|
GameObject gameObject = MultiTags.FindWithMultiTag("ICE_EDITOR");
|
|
if ((bool)gameObject)
|
|
{
|
|
IceEditor component = gameObject.GetComponent<IceEditor>();
|
|
GameController.Instance.iceLevel = true;
|
|
GameController.Instance.iceTop = component.iceTop;
|
|
GameController.Instance.iceBottom = component.iceBottom;
|
|
component.iceTop.transform.localPosition = new Vector3(0f, component.transform.position.y, 0f);
|
|
component.transform.localPosition = new Vector3(component.transform.localPosition.x, 0f, component.transform.localPosition.z);
|
|
BoatSimulator[] array = Object.FindObjectsOfType<BoatSimulator>();
|
|
BoatSimulator[] array2 = array;
|
|
foreach (BoatSimulator boatSimulator in array2)
|
|
{
|
|
boatSimulator.gameObject.SetActive(false);
|
|
}
|
|
GameObject gameObject2 = GameObject.Find("TestObjects/Cube");
|
|
if ((bool)gameObject2)
|
|
{
|
|
gameObject2.SetActive(false);
|
|
}
|
|
}
|
|
float altitude = FisheryEditor.LoadFloatMetaData(levelMetaData, "SkySettingsAltitude", 0.05f);
|
|
float colorR = FisheryEditor.LoadFloatMetaData(levelMetaData, "SkySettingsColorR", 650f);
|
|
float colorG = FisheryEditor.LoadFloatMetaData(levelMetaData, "SkySettingsColorG", 570f);
|
|
float colorB = FisheryEditor.LoadFloatMetaData(levelMetaData, "SkySettingsColorB", 475f);
|
|
skySettings.UpdateSkyGame(altitude, colorR, colorG, colorB);
|
|
skySettingsIce.UpdateSkyGame(altitude, colorR, colorG, colorB);
|
|
Color white = Color.white;
|
|
white.r = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterDiffuseColorR", 0.907f);
|
|
white.g = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterDiffuseColorG", 0.944f);
|
|
white.b = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterDiffuseColorB", 0.963f);
|
|
waterSettings.SetColorDiffuse(white);
|
|
Color white2 = Color.white;
|
|
white2.r = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorR", 0.49f);
|
|
white2.g = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorG", 0.694f);
|
|
white2.b = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorB", 0.725f);
|
|
waterSettings.SetColorAbsorption(white2);
|
|
Color white3 = Color.white;
|
|
white3.r = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterR", waterSettings.startAbsorptionColorUnderwater.r);
|
|
white3.g = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterG", waterSettings.startAbsorptionColorUnderwater.g);
|
|
white3.b = FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterTransColorUnderwaterB", waterSettings.startAbsorptionColorUnderwater.b);
|
|
waterSettings.SetColorAbsorptionUnderwater(white3);
|
|
waterSettings.SetDirectionality(FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterDirectionality", 0.35f));
|
|
waterSettings.SetDirection(FisheryEditor.LoadFloatMetaData(levelMetaData, "WaterDirection", 0f));
|
|
}
|
|
|
|
public void LateInitialize()
|
|
{
|
|
waterSettings.water = GameController.Instance.water;
|
|
waterSettings.UpdateWater();
|
|
}
|
|
|
|
public void FixWaterLevel(LE_SaveLoadData p_loadedLevel)
|
|
{
|
|
Water water = Object.FindObjectOfType<Water>();
|
|
float y = water.transform.position.y;
|
|
if ((bool)p_loadedLevel.TerrainObject)
|
|
{
|
|
p_loadedLevel.TerrainObject.transform.position += new Vector3(0f, 0f - y, 0f);
|
|
}
|
|
for (int i = 0; i < p_loadedLevel.LevelObjects.Length; i++)
|
|
{
|
|
LE_SaveLoadData.ObjectData objectData = p_loadedLevel.LevelObjects[i];
|
|
if (objectData.Result == LE_SaveLoadData.ObjectData.EResult.INSTANCE)
|
|
{
|
|
objectData.Instance.transform.position += new Vector3(0f, 0f - y, 0f);
|
|
}
|
|
}
|
|
}
|
|
}
|