private Town[] InitializeTowns() { SpawnTowns(NUMBER_OF_TOWNS_TO_SPAWN); townPlayerAt = FindPoorestTown(); Instantiate(MapAssets.GetInstance().RedCircle, new Vector3(townPlayerAt.GetLocation().x, townPlayerAt.GetLocation().y - 1, townPlayerAt.GetLocation().z), Quaternion.identity); return(towns); }
public static void LoadStarPositioners() { MapAssets.PositionersLoader(loadFromDLLs <IStarPositioner>( pluginFolder + MapsFolder, x => x.Initialize(dataFolder + MapsFolder) )); }
public void LoadAsset(MapAssets mapAssets) { foreach (GameObject gameObject in this.sceneAssets) { Destroy(gameObject); } this.sceneAssets.Clear(); foreach (MapAsset mapAsset in mapAssets.Assets) { Vector3 position = new Vector3(mapAsset.X, mapAsset.Y, mapAsset.Z); Quaternion orientation = Quaternion.Euler(0, mapAsset.Orientation, 0); Debug.Log(orientation.eulerAngles); Debug.Log("Asset loaded: " + mapAsset.Orientation); GameObject instantiatedAsset = Instantiate(GetPrefab(mapAsset.AssetId), position, orientation); instantiatedAsset.name = mapAsset.AssetId + assetCounter; sceneAssets.Add(instantiatedAsset); Debug.Log("Asset instantiated: " + instantiatedAsset.transform.rotation.eulerAngles); Animate(instantiatedAsset, "Success"); if (!found) { found = true; Toast("You found the scene!", 2.0f); } } }
public static void LoadStarConnectors() { MapAssets.ConnectorsLoader(loadFromDLLs <IStarConnector>( pluginFolder + MapsFolder, x => x.Initialize(dataFolder + MapsFolder) )); }
private void AssetReloaded(string assetJson) { MapAssets assets = JsonUtility.FromJson <MapAssets>(assetJson); foreach (MapAsset asset in assets.Assets) { AssetLoadedEvent(asset); } }
private void SpawnTowns(int numTowns) { towns = new Town[numTowns]; for (int i = 0; i < numTowns; i++) { towns[i] = SpawnTown(); Vector3 loc = towns[i].GetLocation(); Instantiate(MapAssets.GetInstance().Town, new Vector3(loc.x, loc.y, loc.z), Quaternion.identity); } }
public void SaveAssets(List <MapAsset> assets) { MapAssets mapAssets = new MapAssets() { Assets = assets }; string assetJson = JsonUtility.ToJson(mapAssets); Debug.Log("Asset json: " + assetJson); _SaveAssets(assetJson); }
private void Awake() { //If this is the first time map is loaded, instantiate global values if (GlobalValues.MaxHealth == 0) { Debug.Log("Instantiating Global Values"); GlobalValues.CurrentScene = GlobalValues.Scene.Map; GlobalValues.MaxHealth = 80; GlobalValues.CurrentHealth = GlobalValues.MaxHealth; GlobalValues.Money = 100; GlobalValues.Deck = InitializeDeck(); GlobalValues.Towns = InitializeTowns(); GlobalValues.TownPlayerAt = townPlayerAt; } //If not, we load in our GlobalValues else { GlobalValues.CurrentScene = GlobalValues.Scene.Map; Debug.Log("Loading Global Values"); towns = GlobalValues.Towns; foreach (Town t in towns) { Instantiate(MapAssets.GetInstance().Town, new Vector3(t.GetLocation().x, t.GetLocation().y, t.GetLocation().z), Quaternion.identity); } townPlayerAt = GlobalValues.TownPlayerAt; Instantiate(MapAssets.GetInstance().RedCircle, new Vector3(townPlayerAt.GetLocation().x, townPlayerAt.GetLocation().y - 1, townPlayerAt.GetLocation().z), Quaternion.identity); } /* * SpawnTowns(NUMBER_OF_TOWNS_TO_SPAWN); * foreach (Town t in towns) * t.LogTown(); * * townPlayerAt = FindPoorestTown(); * Instantiate(MapAssets.GetInstance().RedCircle, new Vector3(townPlayerAt.GetLocation().x, townPlayerAt.GetLocation().y-1, townPlayerAt.GetLocation().z), Quaternion.identity); */ }
static void ExportAssets() { Debug.Log("**************init begin*****************"); List <MapNodeEx> lstNode = new List <MapNodeEx>(); GameObject[] gos = GameObject.FindGameObjectsWithTag(EXPORT_TAG); string[] scenePath = EditorApplication.currentScene.Split('/'); string[] sceneNames = scenePath[scenePath.Length - 1].Split('.'); string SceneName = sceneNames[0]; string localdir = PrefabsPath + SceneName + "/Prefabs/"; string buildDIR = EXPORT_PATH + SceneName + "/"; if (!Directory.Exists(localdir)) { Directory.CreateDirectory(localdir); } if (!Directory.Exists(buildDIR)) { Directory.CreateDirectory(buildDIR); } List <MapAssets> lstAsset = MapSerializerTool.JsonToAssetList(EXPORT_PATH + "asset.json"); AssetDatabase.Refresh(ImportAssetOptions.ImportRecursive); Debug.Log("**************init end*****************"); Debug.Log("**************Build Prefab begin*****************"); foreach (GameObject go in gos) { string file = localdir + go.name.Replace("(Clone)", "") + ".prefab"; CreatePrefab(go, file); MapNodeEx node = new MapNodeEx(); node.name = go.name.Replace("(Clone)", ""); node.assetPath = file; node.textureBundle = "none"; node.assetBundle = "none"; node.position = go.transform.position; node.rotation = go.transform.rotation; node.scale = go.transform.localScale; lstNode.Add(node); } Debug.Log("**************Build Prefab End*****************"); Debug.Log("**************AssetBundle Build begin*****************"); int asset_index = 0; List <UnityEngine.Object> lstObj = new List <UnityEngine.Object>(); for (int i = 0; i < lstNode.Count; i++) { MapNodeEx node = lstNode[i]; string assetBundlePath = SceneName + asset_index + ".o"; node.assetBundle = assetBundlePath; UnityEngine.Object asset = AssetDatabase.LoadMainAssetAtPath(node.assetPath); ///// check the resource is not already export //// bool existNode = false; for (int k = 0; k < lstAsset.Count && !existNode; k++) { MapAssets mapAsset = lstAsset[k]; foreach (string objName in mapAsset.Objects) { if (objName == asset.name) { existNode = true; node.assetBundle = mapAsset.Name; break; } } } // if the asset if not already export , then it can export. if (!existNode && !lstObj.Contains(asset)) { lstObj.Add(asset); } if (lstObj.Count >= EXPORT_OBJECT_NUM || i >= (lstNode.Count - 1)) { BuildPipeline.PushAssetDependencies(); BuildPipeline.BuildAssetBundle(null, lstObj.ToArray(), Application.dataPath + "/../" + buildDIR + assetBundlePath, BuildAssetBundleOptions.CompleteAssets | BuildAssetBundleOptions.CollectDependencies); BuildPipeline.PopAssetDependencies(); MapAssets mapAsset = new MapAssets(); mapAsset.Name = assetBundlePath; foreach (UnityEngine.Object item in lstObj) { mapAsset.Objects.Add(item.name); } lstAsset.Add(mapAsset); lstObj.Clear(); asset_index++; } } Debug.Log("**************AssetBundle Build end*****************"); Debug.Log("**************Map infomation Build begin*****************"); Map map = new Map(); map.name = SceneName; map.objects = new List <MapNode>(); foreach (MapNodeEx item in lstNode) { map.objects.Add(item.ToMapNode()); } string mapInfoPath = buildDIR + "map.p"; string mapInfoTxtPath = PrefabsPath + "map.txt"; MapSerializerTool.SerializeObjectAndSave(map, mapInfoTxtPath); AssetDatabase.Refresh(); UnityEngine.Object mapInfoObj = AssetDatabase.LoadAssetAtPath(mapInfoTxtPath, typeof(TextAsset)); BuildPipeline.BuildAssetBundle(mapInfoObj, null, Application.dataPath + "/../" + mapInfoPath); Debug.Log("**************Map infomation Build end*****************"); Debug.Log("**************Ending begin*****************"); Directory.Delete(PrefabsPath, true); MapSerializerTool.SerializeObjectAndSave(lstAsset, EXPORT_PATH + "asset.json"); AssetDatabase.Refresh(); Debug.Log("**************Ending end*****************"); }
private void AssetReloaded(string assetJson) { MapAssets assets = JsonUtility.FromJson <MapAssets>(assetJson); AssetLoadedEvent(assets); }
public static void LoadStartConditions() { MapAssets.StartConditionsLoader(dataStreams(StartConditionsFiles.Select(x => new FileInfo(dataFolder + x)))); }
public static void LoadStarConnectors() { MapAssets.ConnectorsLoader(loadFromDLLs <IStarConnector>(MapsFolder)); }
public static void LoadStarPositioners() { MapAssets.PositionersLoader(loadFromDLLs <IStarPositioner>(MapsFolder)); }
public static void LoadStarPopulators() { MapAssets.PopulatorsLoader(loadFromDLLs <IStarPopulator>(MapsFolder)); }
private void Awake() { instance = this; }