public UrbTile(UrbMap CreatingMap, int CreatedX, int CreatedY, UrbTile[] LinkedTiles) { Constructor(CreatingMap); XAddress = CreatedX; YAddress = CreatedY; Links = LinkedTiles; }
void Start() { if (AtlasX <= 0 && AtlasY <= 0) { return; } Maps = new List <UrbMap>(); GameObject LandObject = new GameObject("LandMap"); LandObject.transform.position = Vector3.forward * (AtlasY + AtlasX); LandMap = LandObject.AddComponent <UrbMap>(); LandMap.SetNewMap(AtlasX, AtlasY, 1, UrbPathTerrain.Land); GameObject SkyObject = new GameObject("SkyMap"); SkyMap = SkyObject.AddComponent <UrbMap>(); SkyMap.SetNewMap(AtlasX / SkySizeFactor, AtlasY / SkySizeFactor, SkySizeFactor, UrbPathTerrain.Air); LinkSkyToLand(); Maps.Add(LandMap); UrbSystemIO.RegisterMap(LandMap); Maps.Add(SkyMap); UrbSystemIO.RegisterMap(SkyMap); RefreshAllMaps(); StartBehaviours(); }
public UrbTile(UrbMap CreatingMap, int CreatedX, int CreatedY) { Constructor(CreatingMap); XAddress = CreatedX; YAddress = CreatedY; Links = new UrbTile[] { null, null, null }; }
public static void UnregisterMap(UrbMap Map) { if (Instance.Maps == null || !Instance.Maps.Contains(Map)) { return; } Instance.Maps.Remove(Map); }
public static int GetMapID(UrbMap input) { if (!HasInstance) { return(-1); } return(Instance.Maps.IndexOf(input)); }
public static void RegisterMap(UrbMap Map) { if (Instance.Maps == null) { Instance.Maps = new List <UrbMap>(); } if (Instance.Maps.Contains(Map)) { return; } Instance.Maps.Add(Map); }
private void OnSceneGUI() { //if (Event.current.type == EventType.Repaint) Vector3 Position = ((UrbMap)target).transform.position; { Handles.color = ((UrbMap)target).Color; float width = ((UrbMap)target).TileSize * ((UrbMap)target).Xsize; float height = ((UrbMap)target).TileSize * ((UrbMap)target).Ysize; Rect MapRect = new Rect(Position, new Vector2(width, height)); Handles.DrawSolidRectangleWithOutline(MapRect, Color.clear, ((UrbMap)target).Color); } if (((UrbMap)target).DebugDisplay) { UrbMap DisplayMap = (UrbMap)target; for (int x = 0; x < DisplayMap.Xsize; x++) { for (int y = 0; y < DisplayMap.Ysize; y++) { UrbTile Tile = DisplayMap.GetTile(x, y); if (Tile == null) { continue; } UrbTile[] LinkedTiles = Tile.GetLinked(); for (int l = 0; l < LinkedTiles.Length; l++) { if (LinkedTiles[l] == null) { continue; } Handles.color = Color.yellow; Handles.DrawLine(Tile.Location, LinkedTiles[l].Location); } } } } }
void Constructor(UrbMap CreatingMap) { Occupants = new List <UrbAgent>(); Contents = new List <UrbAgent>(); OwningMap = CreatingMap; TerrainFilter = new UrbScent[MaxTerrain][]; for (int i = 0; i < MaxTerrain; i++) { TerrainFilter[i] = new UrbScent[MaxSize]; for (int ii = 0; ii < MaxSize; ii++) { TerrainFilter[i][ii] = new UrbScent(); } } Environment = new UrbEnvironment(this); }
public bool LoadTileFromData(UrbTileData input) { LinksDirty = true; if (input.Links.Length > 0) { Links = new UrbTile[input.Links.Length]; for (int i = 0; i < Links.Length; i++) { UrbMap LinkedMap = UrbSystemIO.GetMapFromID(input.Links[i].MapID); if (LinkedMap != null) { UrbTile LinkedTile = LinkedMap.GetTile(input.Links[i].X, input.Links[i].Y); Links[i] = LinkedTile; } } } else { Links = new UrbTile[0]; } ClearTile(); if (input.Contents != null && input.Contents.Length > 0) { for (int c = 0; c < input.Contents.Length; c++) { UrbSystemIO.LoadAgentFromID(input.Contents[c], this, input.Objects[c]); } } Blocked = input.Blocked; Environment.LoadEnvironmentFromData(input.Environment); // This is broken somehow, fix it. /*TerrainTypes = new UrbPathTerrain[input.TerrainTypes.Length]; * * for (int i = 0; i < TerrainTypes.Length; i++) * { * TerrainTypes[i] = input.TerrainTypes[i]; * }*/ return(true); }
public UrbTile(UrbMap CreatingMap, Vector2 MapLocation, UrbTile[] LinkedTiles) { Constructor(CreatingMap); OwningMap.LocationToTileAddress(MapLocation, out XAddress, out YAddress); Links = LinkedTiles; }
public UrbTile(UrbMap CreatingMap, Vector2 MapLocation) { Constructor(CreatingMap); OwningMap.LocationToTileAddress(MapLocation, out XAddress, out YAddress); Links = new UrbTile[] { null, null, null }; }