public static int getNextEventID(string sceneName, int mapID) { if (idDictionary == null) { IDHandler.LoadIDs(); } if (IDHandler.idDictionary.ContainsKey(sceneName)) { if (IDHandler.idDictionary[sceneName].Exists(id => id.mapID == mapID)) { int tempInt = 1; while (IDHandler.idDictionary[sceneName][mapID].eventIDs.Contains(tempInt)) { ++tempInt; } IDHandler.idDictionary[sceneName][mapID].eventIDs.Add(tempInt); return(tempInt); } else { IDHandler.idDictionary[sceneName].Add(new MapIDInfo(mapID)); IDHandler.idDictionary[sceneName][mapID].eventIDs.Add(1); return(1); } } else { IDHandler.idDictionary.Add(sceneName, new List <MapIDInfo>()); IDHandler.idDictionary[sceneName].Add(new MapIDInfo(mapID)); IDHandler.idDictionary[sceneName][mapID].eventIDs.Add(1); return(1); } }
private void HandleTiledAttributes(GameObject gameObject, XElement goXml, int previousMapID, MetadataSettings previousMetadata) { // Add the TiledMap component TiledMap map = gameObject.AddComponent <TiledMap>(); try { map.NumTilesWide = ImportUtils.GetAttributeAsInt(goXml, "numTilesWide"); map.NumTilesHigh = ImportUtils.GetAttributeAsInt(goXml, "numTilesHigh"); map.TileWidth = ImportUtils.GetAttributeAsInt(goXml, "tileWidth"); map.TileHeight = ImportUtils.GetAttributeAsInt(goXml, "tileHeight"); map.ExportScale = ImportUtils.GetAttributeAsFloat(goXml, "exportScale"); map.MapWidthInPixels = ImportUtils.GetAttributeAsInt(goXml, "mapWidthInPixels"); map.MapHeightInPixels = ImportUtils.GetAttributeAsInt(goXml, "mapHeightInPixels"); if (previousMapID == 0) { map.MapID = IDHandler.getNextMapID(EditorApplication.currentScene); } else { map.MapID = previousMapID; } map.gameObject.AddComponent <MetadataSettings>(); if (previousMetadata != null) { map.gameObject.GetComponent <MetadataSettings>().Copy(previousMetadata); } } catch { Debug.LogWarning(String.Format("Error adding TiledMap component. Are you using an old version of Tiled2Unity in your Unity project?")); GameObject.DestroyImmediate(map); } }
public static void SaveIDs() { if (idDictionary == null) { IDHandler.LoadIDs(); } FileInfo idFile; if ((new FileInfo(idHandlerPath)).Exists) { // Get file info idFile = new FileInfo(idHandlerPath); // Remove the hidden attribute of the file idFile.Attributes &= ~FileAttributes.Hidden; } using (Stream stream = File.Open(idHandlerPath, FileMode.Create)) { var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); binaryFormatter.Serialize(stream, idDictionary); } // Hide the file. idFile = new FileInfo(idHandlerPath); idFile.Attributes |= FileAttributes.Hidden; }
public void OnDestroy() { if (Application.isEditor && !EditorApplication.isPlaying) { IDHandler.removeMapID(EditorApplication.currentScene, this.MapID); } }
public Account(SocketAppUser user, Server.LogIn server) { InitializeComponent(); scorpServer = server; pictureBox1.Image = user.Avatar; metroLabel2.Text = $"{user.UserName}#{IDHandler.VerifyUserTag(user.Tag)}"; }
public UserInfo(SocketAppUser user) { InitializeComponent(); User = user; pictureBox1.Image = user.Avatar; label1.Text = user.UserName; label2.Text = $"#{IDHandler.VerifyUserTag(user.Tag)}"; }
public static void addScene(string sceneName) { if (idDictionary == null) { IDHandler.LoadIDs(); } if (idDictionary.ContainsKey(sceneName)) { idDictionary.Add(sceneName, new List <MapIDInfo>()); } }
public static void removeEventID(string sceneName, int mapId, int targetEventID) { if (idDictionary == null) { IDHandler.LoadIDs(); } if (IDHandler.idDictionary.ContainsKey(sceneName) && IDHandler.idDictionary[sceneName].Exists(x => x.mapID == mapId)) { IDHandler.idDictionary[sceneName][mapId].eventIDs.RemoveAll(x => x.Equals(targetEventID)); } }
public static void removeMapID(string sceneName, int targetMapID) { if (idDictionary == null) { IDHandler.LoadIDs(); } if (IDHandler.idDictionary.ContainsKey(sceneName)) { IDHandler.idDictionary[sceneName].RemoveAll(x => x.mapID == targetMapID); } }
private MedianCut(Bitmap bmp, WiiPixelFormat texFormat, WiiPaletteFormat palFormat) { //Set output format if (texFormat == WiiPixelFormat.CI4) { _outFormat = PixelFormat.Format4bppIndexed; } else if (texFormat == WiiPixelFormat.CI8) { _outFormat = PixelFormat.Format8bppIndexed; } else { throw new ArgumentException("Invalid pixel format."); } //Set conversion functions if (palFormat == WiiPaletteFormat.IA8) { _idFunc = IA8Handler; _idConv = IA8Converter; } else if (palFormat == WiiPaletteFormat.RGB565) { _idFunc = RGB565Handler; _idConv = RGB565Converter; } else { _idFunc = RGB5A3Handler; _idConv = RGB5A3Converter; } //Lock/set source data _srcBmp = bmp; _width = bmp.Width; _height = bmp.Height; _size = _width * _height; _srcData = bmp.LockBits(new Rectangle(0, 0, _width, _height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); _srcPixels = (ARGBPixel *)_srcData.Scan0; //Create buffers _boxes = (ColorBox *)Marshal.AllocHGlobal(256 * sizeof(ColorBox)); _groupTable = (ColorEntry **)Marshal.AllocHGlobal(65536 * sizeof(void *)); }
private MedianCut(Bitmap bmp, WiiPixelFormat texFormat, WiiPaletteFormat palFormat) { //Set output format if (texFormat == WiiPixelFormat.CI4) _outFormat = PixelFormat.Format4bppIndexed; else if (texFormat == WiiPixelFormat.CI8) _outFormat = PixelFormat.Format8bppIndexed; else throw new ArgumentException("Invalid pixel format."); //Set conversion functions if (palFormat == WiiPaletteFormat.IA8) { _idFunc = IA8Handler; _idConv = IA8Converter; } else if (palFormat == WiiPaletteFormat.RGB565) { _idFunc = RGB565Handler; _idConv = RGB565Converter; } else { _idFunc = RGB5A3Handler; _idConv = RGB5A3Converter; } //Lock/set source data _srcBmp = bmp; _width = bmp.Width; _height = bmp.Height; _size = _width * _height; _srcData = bmp.LockBits(new Rectangle(0, 0, _width, _height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); _srcPixels = (ARGBPixel*)_srcData.Scan0; //Create buffers _boxes = (ColorBox*)Marshal.AllocHGlobal(256 * sizeof(ColorBox)); _groupTable = (ColorEntry**)Marshal.AllocHGlobal(65536 * 4); }
public static int getNextMapID(string sceneName) { if (idDictionary == null) { IDHandler.LoadIDs(); } if (IDHandler.idDictionary.ContainsKey(sceneName)) { int tempInt = 1; while (IDHandler.idDictionary[sceneName].Exists(id => id.mapID == tempInt)) { ++tempInt; } IDHandler.idDictionary[sceneName].Add(new MapIDInfo(tempInt)); Debug.Log(sceneName + " " + tempInt); return(tempInt); } else { IDHandler.idDictionary.Add(sceneName, new List <MapIDInfo>()); IDHandler.idDictionary[sceneName].Add(new MapIDInfo(1)); return(1); } }
public FieldIndexKeyHandler(IIndexable4 delegate_) { _parentIdHandler = new IDHandler(); _valueHandler = delegate_; }
//Saving scene in Unity will save this info to file static string[] OnWillSaveAssets(string[] paths) { IDHandler.SaveIDs(); return(paths); }