public void UpdateSector() { int.TryParse(sectorProps.transform.Find("Beginning X").GetComponentsInChildren <Text>()[1].text, out x); int.TryParse(sectorProps.transform.Find("Beginning Y").GetComponentsInChildren <Text>()[1].text, out y); int.TryParse(sectorProps.transform.Find("Height").GetComponentsInChildren <Text>()[1].text, out height); int.TryParse(sectorProps.transform.Find("Width").GetComponentsInChildren <Text>()[1].text, out width); sctName = sectorProps.transform.Find("Sector Name").GetComponentsInChildren <Text>()[1].text; center = new Vector3 { x = this.x + (width / 2), y = this.y + (height / 2), z = 0 }; var rend = GameObject.Find("SectorBorders").GetComponent <LineRenderer>(); rend.SetPositions(new Vector3[] { new Vector3(x, y, 0), new Vector3(x + width, y, 0), new Vector3(x + width, y + height, 0), new Vector3(x, y + height, 0) }); int secVal = sectorProps.transform.Find("Sector Type").GetComponent <Dropdown>().value; type = (Sector.SectorType)secVal; currentColor = SectorColors.colors[secVal]; UpdateColors(); }
public static Color GetDefaultColor(Sector.SectorType type) { return(new Color( PlayerPrefs.GetFloat($"WCSectorPropertyDisplay_defaultR{(int)type}", SectorColors.colors[(int)type].r), PlayerPrefs.GetFloat($"WCSectorPropertyDisplay_defaultG{(int)type}", SectorColors.colors[(int)type].g), PlayerPrefs.GetFloat($"WCSectorPropertyDisplay_defaultB{(int)type}", SectorColors.colors[(int)type].b) )); }
/// <summary> /// Gets a random adjacent block allowed with the mask. /// </summary> /// <param name='mask'> /// Binary Or together types which you want allowed. /// </param> MapBlock GetAdjBlock(MapBlock block, Sector.SectorType mask) { MapBlock b = null;; int dir = Random.Range(0, 4); int num = 0; do { dir++; if (dir >= 4) { dir = 0; } switch (dir) { case 0: b = WorldToBlock(block.transform.position + new Vector3(1f, 0f, 0f)); break; case 1: b = WorldToBlock(block.transform.position + new Vector3(-1f, 0f, 0f)); break; case 2: b = WorldToBlock(block.transform.position + new Vector3(0f, 0f, 1f)); break; case 3: b = WorldToBlock(block.transform.position + new Vector3(0f, 0f, -1f)); break; } num++; }while ((b == null || (b.SectorType & mask) == 0) && num < 4); if (b == null || (b.SectorType & mask) == 0) { return(null); } return(b); }
public static string GetDefaultMusic(Sector.SectorType type) { switch (type) { case Sector.SectorType.BattleZone: return(PlayerPrefs.GetString($"WCSectorPropertyDisplay_defaultMusic{(int)type}", "music_fast")); case Sector.SectorType.Capitol: return(PlayerPrefs.GetString($"WCSectorPropertyDisplay_defaultMusic{(int)type}", "music_funktify")); // Funktify made by Mr Spastic, website - http://www.mrspastic.com case Sector.SectorType.SiegeZone: return(PlayerPrefs.GetString($"WCSectorPropertyDisplay_defaultMusic{(int)type}", "music_siege_1")); default: return(PlayerPrefs.GetString($"WCSectorPropertyDisplay_defaultMusic{(int)type}", "music_overworld")); } }
public void FromJSON() { string path = GameObject.Find("JSONPath").GetComponentInChildren <InputField>().text; if (System.IO.File.Exists(path)) { SectorData data = JsonUtility.FromJson <SectorData>(System.IO.File.ReadAllText(path)); Sector sectorDataWrapper = ScriptableObject.CreateInstance <Sector>(); JsonUtility.FromJsonOverwrite(data.sectorjson, sectorDataWrapper); LandPlatform platformDataWrapper = ScriptableObject.CreateInstance <LandPlatform>(); JsonUtility.FromJsonOverwrite(data.platformjson, platformDataWrapper); type = sectorDataWrapper.type; currentColor = sectorDataWrapper.backgroundColor; sctName = sectorDataWrapper.sectorName; UpdateColors(); int cols = platformDataWrapper.columns; int rows = platformDataWrapper.rows; x = sectorDataWrapper.bounds.x; y = sectorDataWrapper.bounds.y; width = sectorDataWrapper.bounds.w; height = sectorDataWrapper.bounds.h; sectorProps.ToggleActive(); sectorProps.transform.Find("Beginning X").GetComponentInChildren <InputField>().text = x.ToString(); sectorProps.transform.Find("Beginning Y").GetComponentInChildren <InputField>().text = y.ToString(); sectorProps.transform.Find("Height").GetComponentInChildren <InputField>().text = height.ToString(); sectorProps.transform.Find("Width").GetComponentInChildren <InputField>().text = width.ToString(); sectorProps.transform.Find("Sector Name").GetComponentInChildren <InputField>().text = sctName; sectorProps.transform.Find("Sector Type").GetComponent <Dropdown>().value = (int)sectorDataWrapper.type; sectorProps.ToggleActive(); var rend = GameObject.Find("SectorBorders").GetComponent <LineRenderer>(); rend.SetPositions(new Vector3[] { new Vector3(x, y, 0), new Vector3(x + width, y, 0), new Vector3(x + width, y + height, 0), new Vector3(x, y + height, 0) }); center = new Vector3 { x = this.x + width / 2F, y = this.y + height / 2F }; Vector2 offset = new Vector2 { x = center.x - tileSize * (cols - 1) / 2, y = center.y + tileSize * (rows - 1) / 2 }; for (int i = 0; i < platformDataWrapper.tilemap.Length; i++) { switch (platformDataWrapper.tilemap[i]) { case -1: break; default: PlaceableObject obj = new PlaceableObject(); obj.type = ObjectTypes.Platform; obj.placeablesIndex = platformDataWrapper.tilemap[i]; obj.rotation = platformDataWrapper.rotations[i]; Vector3 pos = new Vector3 { x = offset.x + (i % cols) * tileSize, y = offset.y - (i / cols) * tileSize, z = 0 }; obj.pos = pos; obj.obj = Instantiate(placeables[platformDataWrapper.tilemap[i]].obj, pos, Quaternion.identity); obj.obj.transform.localEulerAngles = new Vector3(0, 0, 90 * platformDataWrapper.rotations[i]); objects.Add(obj); break; } } foreach (Sector.LevelEntity ent in sectorDataWrapper.entities) { PlaceableObject obj = new PlaceableObject(); obj.pos = ent.position; obj.faction = ent.faction; obj.shellcoreJSON = ent.blueprintJSON; obj.ID = ent.ID; obj.assetID = ent.assetID; obj.type = ObjectTypes.Other; obj.vendingID = ent.vendingID; for (int i = 0; i < placeables.Length; i++) { if (placeables[i].assetID == obj.assetID) { obj.placeablesIndex = i; break; } } obj.obj = Instantiate(placeables[obj.placeablesIndex].obj, obj.pos, Quaternion.identity); obj.obj.name = ent.name; if (GetIsFactable(obj)) { foreach (SpriteRenderer renderer in obj.obj.GetComponentsInChildren <SpriteRenderer>()) { renderer.color = FactionManager.GetFactionColor(obj.faction); } if (obj.obj.GetComponentsInChildren <SpriteRenderer>().Length > 1) { obj.obj.GetComponent <SpriteRenderer>().color = Color.white; } } objects.Add(obj); } } else { Debug.Log($"File {path} doesn't exist."); } }