/// <summary> /// Search for a given color within a color list, scanning all the client area of BS. Faster then PixelSearch, as it doesn't do a new capture each time. /// </summary> /// <param name="left"></param> /// <param name="top"></param> /// <param name="right"></param> /// <param name="bottom"></param> /// <param name="color1"></param> /// <param name="variation"></param> /// <param name="forceCapture"></param> /// <returns></returns> public static Point FullScreenPixelSearch(ColorList colors, int variation, bool forceCapture = false) { if (!TakeFullScreenCapture(forceCapture)) return Point.Empty; FastFindWrapper.ResetColors(); foreach (Color color in colors) FastFindWrapper.AddColor(color.ToArgb()); int xRef = 0, yRef = 0; if (FastFindWrapper.ColorsPixelSearch(ref xRef, ref yRef, DEFAULT_SNAP) == 0) return Point.Empty; return new Point(xRef, yRef); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.modlEntryList01 = new SpnFenMODLEntryList(this.OnResourceChanged, s); this.modlEntryList02 = new SpnFenMODLEntryList(this.OnResourceChanged, s); this.modlEntryList03 = new SpnFenMODLEntryList(this.OnResourceChanged, s); this.modlEntryList04 = new SpnFenMODLEntryList(this.OnResourceChanged, s); this.refList = new Gp7references(kRecommendedApiVersion, this.OnResourceChanged, s); this.materialVariant = br.ReadUInt32(); this.unkIID01 = br.ReadUInt64(); this.colors = new ColorList(this.OnResourceChanged, s); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.trimRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s); this.materialVariant = br.ReadUInt32(); this.modlRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s); this.swatchGrouping = br.ReadUInt64(); this.colors = new ColorList(this.OnResourceChanged, s); this.unk02 = br.ReadUInt32(); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.refList = new Gp8references(kRecommendedApiVersion,this.OnResourceChanged,s); this.materialVariant = br.ReadUInt32(); this.swatchGrouping = br.ReadUInt64(); this.unk02 = br.ReadUInt32(); this.colors = new ColorList(this.OnResourceChanged, s); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.hashIndicator = br.ReadUInt32(); this.hash01 = br.ReadUInt32(); this.hash02 = br.ReadUInt32(); this.hash03 = br.ReadUInt32(); int count = Convert.ToUInt16(br.ReadUInt32()); this.matdList = new CountedTGIBlockList(this.OnResourceChanged, TGIBlock.Order.ITG, count, s); this.colors = new ColorList(this.OnResourceChanged, s); this.unk02 = br.ReadUInt32(); this.unkIID01 = br.ReadUInt64(); }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.unk01 = br.ReadUInt32(); this.unk02 = br.ReadUInt32(); this.unk03 = br.ReadUInt32(); this.unk04 = br.ReadUInt32(); this.unk05 = br.ReadUInt32(); this.swatchGrouping = br.ReadUInt64(); this.colors = new ColorList(this.OnResourceChanged, s); this.unkRef1 = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s); this.unk06 = br.ReadUInt32(); this.unk07 = br.ReadUInt32(); }
public Rook(int row, int column, ColorList color) : base(row, column, color) { }
private void AddColor(object parameter) { ColorList.Add(new CustomColor(parameter as CustomColor)); }
private void RemoveColor(object parameter) { ColorList.Remove(parameter as CustomColor); }
/// <summary> /// Simple Gaussian Blur /// </summary> /// <param name="image">The image to blur</param> /// <param name="blurSize">The radius in pixels of the blur</param> /// <returns>Bitmap with the result of the blur</returns> public static Bitmap Gaussian(Bitmap image, int blurSize) { int blur = blurSize / 2; int width = image.Width; int height = image.Height; Rectangle bounds = new Rectangle(0, 0, width, height); Bitmap copy = new Bitmap(width, height, PixelFormat.Format32bppArgb); Bitmap output = new Bitmap(width, height, PixelFormat.Format32bppArgb); using(Graphics g = Graphics.FromImage(copy)) { g.PageUnit = GraphicsUnit.Pixel; g.DrawImageUnscaled(image, 0, 0); } BitmapData outData = null; BitmapData srcData = null; try { outData = output.LockBits(bounds, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); srcData = copy.LockBits(bounds, ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); byte* outRow = (byte*)outData.Scan0.ToPointer(); Int32* outPxl; for(int row = 0; row < height; ++row) { outPxl = (Int32*)outRow; for(int col = 0; col < width; ++col, ++outPxl) { ColorList list = new ColorList(); int x1 = col - blur < 0 ? 0 : col - blur; int x2 = col + blur > width ? width : col + blur; int y1 = row - blur < 0 ? 0 : row - blur; int y2 = row + blur > height ? height : row + blur; byte* srcRow = (byte*)srcData.Scan0.ToPointer(); Int32* srcPxl; srcRow += (srcData.Stride * y1); for(int y = y1; y < y2; ++y) { srcPxl = (Int32*)srcRow; srcPxl += x1; for(int x = x1; x < x2; ++x, ++srcPxl) { list.Add(new XColor((Color32*)srcPxl)); } srcRow += srcData.Stride; } ((Color32*)outPxl)->ARGB = list.average().col32.ARGB; } outRow += outData.Stride; } } finally { output.UnlockBits(outData); copy.UnlockBits(srcData); } copy.Dispose(); return output; }
public Knight(int row, int column, ColorList color) : base(row, column, color) { }
/// <summary> /// Формирует описание множественного цвета /// </summary> public static ColorAttribute Multiple(ColorList colorList) { if (null == colorList || 0 == colorList.Count) throw new ArgumentException("items must be given", "colorList"); var result = new ColorAttribute { Mode = ColorAttributeType.Multiple, ColorList = colorList }; return result; }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); bw.Write(this.hashIndicator); bw.Write(this.hash01); bw.Write(this.hash02); bw.Write(this.hash03); bw.Write(this.unk02); bw.Write(this.hash04); bw.Write(this.hash05); bw.Write(this.unkFlags01); bw.Write(this.categoryFlags); bw.Write(this.unkFlags03); bw.Write(this.unkFlags04); bw.Write(this.placementFlags); bw.Write(this.unkIID01); bw.Write(this.unk03); bw.Write(this.unkIID02); bw.Write(this.unk04); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); bw.Write(this.unk05); bw.Write(this.unk06); bw.Write(this.unk07); bw.Write(this.unk08); bw.Write(this.unk09); bw.Write(this.build_buy); if (this.version >= 0x19) { bw.Write(this.unk10); bw.Write(this.unk11); bw.Write(this.unk12); bw.Write(this.unk13); } bw.Write(this.unk14); bw.Write(this.refIndicator); if (refIndicator == 0) { if (this.nullRefs == null) { this.nullRefs = new Gp4references(kRecommendedApiVersion, this.OnResourceChanged); } this.nullRefs.UnParse(s); } else { if (this.modlRefs == null) { this.modlRefs = new Gp9references(kRecommendedApiVersion, this.OnResourceChanged); } this.modlRefs.UnParse(s); if (this.ftptRefs == null) { this.ftptRefs = new Gp9references(kRecommendedApiVersion, this.OnResourceChanged); } this.ftptRefs.UnParse(s); } return s; }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.hashIndicator = br.ReadUInt32(); this.hash01 = br.ReadUInt32(); this.hash02 = br.ReadUInt32(); this.hash03 = br.ReadUInt32(); this.unk02 = br.ReadUInt32(); this.hash04 = br.ReadUInt32(); this.hash05 = br.ReadUInt32(); this.unkFlags01 = br.ReadUInt32(); this.categoryFlags = br.ReadUInt32(); this.unkFlags03 = br.ReadUInt32(); this.unkFlags04 = br.ReadUInt32(); this.placementFlags = br.ReadUInt32(); this.unkIID01 = br.ReadUInt64(); this.unk03 = br.ReadByte(); this.unkIID02 = br.ReadUInt64(); this.unk04 = br.ReadByte(); this.colors = new ColorList(this.OnResourceChanged, s); this.unk05 = br.ReadByte(); this.unk06 = br.ReadByte(); this.unk07 = br.ReadByte(); this.unk08 = br.ReadByte(); this.unk09 = br.ReadByte(); this.build_buy = br.ReadByte(); if (this.version >= 0x19) { this.unk10 = br.ReadUInt32(); this.unk11 = br.ReadUInt32(); this.unk12 = br.ReadUInt32(); this.unk13 = br.ReadUInt32(); } this.unk14 = br.ReadUInt32(); this.refIndicator = br.ReadUInt32(); if (this.refIndicator == 0) { this.nullRefs = new Gp4references(kRecommendedApiVersion, this.OnResourceChanged, s); } else { this.modlRefs = new Gp9references(kRecommendedApiVersion, this.OnResourceChanged, s); this.ftptRefs = new Gp9references(kRecommendedApiVersion, this.OnResourceChanged, s); } }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); bw.Write(this.unk01); if (this.matdRef == null) { this.matdRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); } this.matdRef.UnParse(s); if (this.floorRef == null) { this.floorRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); } this.floorRef.UnParse(s); bw.Write(this.unkIID01); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); return s; }
private async void ExportXLSX() { ExcelPackage.LicenseContext = LicenseContext.NonCommercial; using var p = new ExcelPackage(); // content var ws = p.Workbook.Worksheets.Add(_("Overview")); ws.Cells["A1"].Value = _("Color Usage Overview"); ws.Cells["A1"].Style.Font.Size = 15; var HeaderRow = ProjectColorList.GetDepth(DominoAssembly); // var offset = HeaderRow + 4; ws.Cells[offset - 1, 2].Value = _("Color"); ws.Cells[offset - 1, 3].Value = GetParticularString("Total color count available", "Available"); ColorListWithoutDeleted = ColorList.Where(x => x.GetColorState() != DominoColorState.Deleted).ToList(); var TotalColors = ColorListWithoutDeleted.Count; for (int i = 0; i < TotalColors; i++) { ws.Cells[offset + i, 1].Style.Fill.PatternType = OfficeOpenXml.Style.ExcelFillStyle.Solid; ws.Cells[offset + i, 1].Style.Fill.BackgroundColor.SetColor(ColorListWithoutDeleted[i].DominoColor.mediaColor.ToSD()); ws.Cells[offset + i, 2].Value = ColorListWithoutDeleted[i].DominoColor.name; ws.Cells[offset + i, 3].Value = ColorListWithoutDeleted[i].DominoColor.count; if (ColorListWithoutDeleted[i].GetColorState() == DominoColorState.Inactive) { // mark deleted colors gray ws.Cells[offset + i, 1, offset + i, 3].Style.Font.Color.SetColor(255, 100, 100, 100); } } ws.Cells[offset, 3].Value = ""; // Count of empty domino var length = ExportAssemblyToExcel(ws, DominoAssembly, 0, 0, 0, HeaderRow); int index = length.Item1; // add lines ws.Cells[3, 3, 4 + TotalColors + HeaderRow, 3 + index].Style.Border.Right.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; ws.Cells[2, 1, 3 + TotalColors + HeaderRow, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin; ws.Cells[3 + HeaderRow, 1, 3 + HeaderRow, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick; ws.Cells[3 + HeaderRow + TotalColors, 1, 3 + HeaderRow + TotalColors, 3 + index].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thick; ws.Calculate(); // auto fit unfortunately doesn't work for merged cells (project headers) //ws.Cells.AutoFitColumns(); SaveFileDialog dlg = new SaveFileDialog { InitialFileName = GetParticularString("Default filename for color list", "ColorList"), Filters = new List <FileDialogFilter>() { new FileDialogFilter() { Extensions = new List <string> { "xlsx" }, Name = _("Excel files") }, new FileDialogFilter() { Extensions = new List <string> { "*" }, Name = _("All files") } }, Directory = DialogExtensions.GetCurrentProjectPath() }; var result = await dlg.ShowAsyncWithParent <MainWindow>(); if (!string.IsNullOrEmpty(result)) { try { p.SaveAs(new FileInfo(result)); var process = new Process(); process.StartInfo = new ProcessStartInfo(result) { UseShellExecute = true }; process.Start(); } catch (Exception ex) { await Errorhandler.RaiseMessage(string.Format(_("Save failed: {0}"), ex.Message), _("Error"), Errorhandler.MessageType.Error); } } }
public void SpawnBarrier() { float screenWidthWorldPos = Camera.main.orthographicSize * Screen.width / Screen.height; float distBetweenBlocks = screenWidthWorldPos / 5; for (int i = -2; i < 3; i++) { float x = 2 * i * distBetweenBlocks; float y = 0; if (SM.transform.childCount > 0) { y = (int)SM.transform.GetChild(0).position.y + distBetweenBlocks * 2 + distanceSnakeBarrier; if (Screen.height / Screen.width == 4 / 3) { y *= 4 / 3f; } } Vector3 spawnBarrier = new Vector3(x, y, 0); GameObject boxInstance; if (i == -2 || i == 2 || i == 0) { boxInstance = Instantiate(BlockWithoutBarrierPrefab, spawnBarrier, Quaternion.identity, transform); } else { boxInstance = Instantiate(BlockPrefab, spawnBarrier, Quaternion.identity, transform); } SpawnBlocks(); prevSpawnBarrier = spawnBarrier; string currentScene = SceneManager.GetActiveScene().name; Color32 thisImageColor = boxInstance.GetComponent <SpriteRenderer>().color; if (currentScene.Equals("LEVEL1") || currentScene.Equals("LEVEL2")) { thisImageColor = new Color32(255, 0, 0, 255); } else { for (int k = 0; k < colorsName.Count; k++) { string temp = colorsName[k]; int randomIndex = Random.Range(k, colorsName.Count); colorsName[k] = colorsName[randomIndex]; colorsName[randomIndex] = temp; thisImageColor = ColorList.getColor(colorsName[randomIndex]); boxInstance.name = temp; } } boxInstance.GetComponent <SpriteRenderer>().color = thisImageColor; if (SM.transform.childCount > 0) { previousSnakePos = SM.transform.GetChild(0).position; } } }
public Bishop(int row, int column, ColorList color) : base(row, column, color) { }
/// <summary> /// Beware: do not use this function extensively, at it does a screen shot each time. /// </summary> /// <param name="left"></param> /// <param name="top"></param> /// <param name="right"></param> /// <param name="bottom"></param> /// <param name="color1"></param> /// <param name="variation"></param> /// <param name="forceCapture"></param> /// <returns></returns> public static Point PixelSearch(int left, int top, int right, int bottom, ColorList colors, int variation) { if (!TakeCustomCapture(left, top, right, bottom)) return Point.Empty; FastFindWrapper.ResetColors(); foreach (Color color in colors) FastFindWrapper.AddColor(color.ToArgb()); int xRef = (left + right) / 2, yRef = (top + bottom) / 2; if (FastFindWrapper.ColorsPixelSearch(ref xRef, ref yRef, CUSTOM_SNAP) == 0) return Point.Empty; return new Point(xRef, yRef); }
private int index; // index in the ColorList public ColorListProperty(ColorList ColorList, int Index) { colorList = ColorList; index = Index; base.resourceId = "ColorName"; }
public void AddList(LiteBrite lb) { ColorList.Add(lb); }
// create the page array public void GeneratePageArray() { int[] pixels = MyExtensions.ToArgbArray(BitmapToGenerate); int width = BitmapToGenerate.Width, height = BitmapToGenerate.Height; int black = Color.Black.ToArgb(), white = Color.White.ToArgb(); Dictionary <int, List <byte> > dpages = new Dictionary <int, List <byte> >(); Dictionary <int, bool> backColorListInt = ColorList.ToDictionary <KeyValuePair <Color, bool>, int, bool>(kvp => kvp.Key.ToArgb(), kvp => kvp.Value); bool ColumnMajor = OutConfig.bitLayout == OutputConfiguration.BitLayout.ColumnMajor; // create pages Pages = new byte[0]; Func <int, int, int> getPixel = delegate(int x, int y) { return(pixels[y * width + x]); }; Action <int> ConvertRow = row => { dpages.Add(row, new List <byte>()); // current byte value byte currentValue = 0, bitsRead = 0; // for each column for (int column = 0; column < width; ++column) { // is pixel set? if (!backColorListInt[getPixel(column, row)]) { // set the appropriate bit in the page if (OutConfig.byteOrderMsbFirst) { currentValue |= (byte)(1 << (7 - bitsRead)); } else { currentValue |= (byte)(1 << bitsRead); } } // increment number of bits read // have we filled a page? if (++bitsRead == 8) { // add byte to page array dpages[row].Add(currentValue); // zero out current value currentValue = 0; // zero out bits read bitsRead = 0; } } // if we have bits left, add it as is if (bitsRead != 0) { dpages[row].Add(currentValue); } }; // for each row for (int row = 0; row < height; row++) { ConvertRow(row); } List <byte> tempPages = new List <byte>(); for (int i = 0; i < dpages.Count; i++) { tempPages.AddRange(dpages[i]); } Pages = tempPages.ToArray(); // transpose the pages if column major data is requested if (ColumnMajor) { Pages = Transpose(Pages, BitmapToGenerate.Width, BitmapToGenerate.Height, OutConfig.byteOrderMsbFirst); } }
private static void Main(string[] args) { // Get the startup path, and ensure the necessary folders exist. string path = AppDomain.CurrentDomain.BaseDirectory; Directory.CreateDirectory(path + "input\\"); Directory.CreateDirectory(path + "output\\"); // The wiggle-room size of each sub-section in the RGB scheme. int subSize = 5; // Create the collection for storing the known colors. var KnownColors = new ColorList[156]; for (int i = 0; i < KnownColors.Length; i++) { KnownColors[i] = new ColorList(); } // Loop through all the png files in our input folder. foreach (var file in Directory.GetFiles(path + "input\\").Where(s => s.EndsWith(".png") || s.EndsWith(".jpg"))) { var bmp = (Bitmap)Bitmap.FromFile(file); var fi = new FileInfo(file); Console.WriteLine("Collecting pixel data..."); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { // Collect the pixel color data. var pixel = bmp.GetPixel(x, y); int r = pixel.R / (255 / subSize); int g = pixel.B / (255 / subSize); int b = pixel.B / (255 / subSize); var color = new Color(pixel.R, pixel.G, pixel.B); // Try and add this specific color to the color region. var region = KnownColors[r + subSize * (g + subSize * b)]; region.TryAdd(color); } } // Sort the colors. foreach (var region in KnownColors) { region.Sort(); } Console.WriteLine("Applying blur..."); int blurSize = 2; for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { // Create variables to store average color values. int r = 0; int g = 0; int b = 0; // Loop through a square with a specific size of blurSize. for (int xi = 0; xi < blurSize; xi++) { for (int yi = 0; yi < blurSize; yi++) { // Make sure we're within the boundaries of the images. if (x + xi < bmp.Width) { if (y + yi < bmp.Height) { // If we're on the first pixel, don't divide by 2. // The raw color is the average. var color = bmp.GetPixel(x + xi, y + yi); if (xi + yi == 0) { r = color.R; g = color.G; b = color.B; } else { r = (r + color.R) / 2; g = (color.G + g) / 2; b = (color.B + b) / 2; } } } } } // Replace the current pixel with the average color in the blurSize square space. bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(r, g, b)); } } Console.WriteLine("Applying coloring...."); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { // Get the values for the color region. var pixel = bmp.GetPixel(x, y); int r = pixel.R / (255 / subSize); int g = pixel.B / (255 / subSize); int b = pixel.B / (255 / subSize); // Get the most used color in this color region, and // replace the current pixel with it. var color = KnownColors[r + subSize * (g + subSize * b)].ProminantColor; bmp.SetPixel(x, y, System.Drawing.Color.FromArgb(color.R, color.G, color.B)); } } // Save the image to the output folder. bmp.Save(path + "output\\" + fi.Name); } }
private bool DrawCurrentTile(SKCanvas g, Model model, Dictionary <string, string> dict, string tile, string tileHighlight, SKBitmap wall, SKBitmap floor, string[] wallAndFloorColors, Dictionary <string, string> overrides, float x, float y, float resize, out SKBitmap drawnTile) { if (tile[0] == ' ' && (tileHighlight == Enum.GetName(typeof(ColorListEnum), ColorListEnum.LIGHTGREY) || tileHighlight == Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) || tile.StartsWith("@BL")) { drawnTile = null; return(false); } SKBitmap brandToDraw = null; bool cached = false; if (tile.TryDrawWallOrFloor(tileHighlight, wall, floor, wallAndFloorColors, out drawnTile) || tile.TryDrawMonster(tileHighlight, overrides, _monsterpng, _miscallaneous, floor, out drawnTile, out brandToDraw) ||//first try drawing overrides, that include blue color monsters, and monsters in sight tile.TryDrawCachedTile(tileHighlight, _outOfSightCache, new List <char> { '!', '?', '=', '"', '$', ')', '[', '_', '}', '/', '(', ':', '|', '%', '÷', '†' }, new List <string> { "≈RED" }, out drawnTile, out cached) || tile.TryDrawMonster(tileHighlight, _monsterdata, _monsterpng, _miscallaneous, floor, out drawnTile, out brandToDraw) ||//draw the rest of the monsters tile.TryDrawFeature(tileHighlight, _features, _alldngnpng, _miscallaneous, floor, wall, model.Location, out drawnTile) || tile.TryDrawCloud(_cloudtiles, _alleffects, floor, model.SideData, model.MonsterData, out drawnTile) || tile.TryDrawItem(tileHighlight, _itemdata, _itempng, _miscallaneous, floor, model.Location, out drawnTile)) { var rect = new SKRect(x, y, x + (drawnTile.Width * resize), y + (drawnTile.Height * resize)); g.DrawBitmap(drawnTile, rect); if (brandToDraw != null) { g.DrawBitmap(brandToDraw, new SKRect(x, y, x + (brandToDraw.Width * resize), y + (brandToDraw.Height * resize))); } else if (!tileHighlight.Equals(Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) && (!tile.Substring(1).Equals(Enum.GetName(typeof(ColorListEnum), ColorListEnum.BLACK)) || tile[0] == '.')) { var backgroundPaint = new SKPaint() { Color = ColorList.GetColor(tileHighlight).WithAlpha(100), Style = SKPaintStyle.StrokeAndFill }; g.DrawRect(rect, backgroundPaint); } if (cached)//darken to match out of sight { var backgroundPaint = new SKPaint() { Color = new SKColor(0, 0, 0, 150), Style = SKPaintStyle.StrokeAndFill }; g.DrawRect(rect, backgroundPaint); } return(true); } if (!dict.ContainsKey(tile)) { dict.Add(tile, ""); } var font = new SKPaint { Typeface = SKTypeface.FromFamilyName("Courier New"), TextSize = 24 * resize, }; g.WriteCharacter(tile, font, x, y, tileHighlight);//unhandled tile, write it as a character instead return(false); }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); bw.Write(this.hashIndicator); bw.Write(this.hash01); bw.Write(this.hash02); bw.Write(this.hash03); if (this.matdList == null) { this.matdList = new CountedTGIBlockList(this.OnResourceChanged, TGIBlock.Order.ITG); } bw.Write(Convert.ToUInt32(matdList.Count)); this.matdList.UnParse(s); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); bw.Write(this.unk02); bw.Write(this.unkIID01); return s; }
public ColorSelectionProperty(object go, string propertyName, string resourceId, ColorList clrTable, ColorList.StaticFlags flags) { useFlags = flags; flags = clrTable.Usage; clrTable.Usage = useFlags; base.resourceId = resourceId; colorList = clrTable; choices = clrTable.Names; objectWithProperty = go; propertyInfo = objectWithProperty.GetType().GetProperty(propertyName); MethodInfo mi = propertyInfo.GetGetMethod(); object[] prm = new object[0]; ColorDef selectedColor = (ColorDef)mi.Invoke(objectWithProperty, prm); if (selectedColor != null) { selectedText = selectedColor.Name; } selectedCD = selectedColor; clrTable.Usage = flags; unselectedText = StringTable.GetString("ColorDef.Undefined"); toWatch = go as IGeoObject; // may be null }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); if (this.refList == null) { this.refList = new Gp8references(kRecommendedApiVersion, this.OnResourceChanged); } this.refList.UnParse(s); bw.Write(this.materialVariant); bw.Write(this.swatchGrouping); bw.Write(this.unk02); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); return s; }
/// <param name='type'> /// Required. /// </param> /// <param name='cancellationToken'> /// Cancellation token. /// </param> public async Task <HttpOperationResponse <ColorList> > GetAllByGroupTypeAsyncWithOperationResponseAsync(string type, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // Validate if (type == null) { throw new ArgumentNullException("type"); } // Tracing bool shouldTrace = ServiceClientTracing.IsEnabled; string invocationId = null; if (shouldTrace) { invocationId = ServiceClientTracing.NextInvocationId.ToString(); Dictionary <string, object> tracingParameters = new Dictionary <string, object>(); tracingParameters.Add("type", type); ServiceClientTracing.Enter(invocationId, this, "GetAllByGroupTypeAsyncAsync", tracingParameters); } // Construct URL string url = ""; url = url + "/colors"; List <string> queryParameters = new List <string>(); queryParameters.Add("type=" + Uri.EscapeDataString(type)); if (queryParameters.Count > 0) { url = url + "?" + string.Join("&", queryParameters); } string baseUrl = this.Client.BaseUri.AbsoluteUri; // Trim '/' character from the end of baseUrl and beginning of url. if (baseUrl[baseUrl.Length - 1] == '/') { baseUrl = baseUrl.Substring(0, baseUrl.Length - 1); } if (url[0] == '/') { url = url.Substring(1); } url = baseUrl + "/" + url; url = url.Replace(" ", "%20"); // Create HTTP transport objects HttpRequestMessage httpRequest = new HttpRequestMessage(); httpRequest.Method = HttpMethod.Get; httpRequest.RequestUri = new Uri(url); // Set Credentials if (this.Client.Credentials != null) { cancellationToken.ThrowIfCancellationRequested(); await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); } // Send Request if (shouldTrace) { ServiceClientTracing.SendRequest(invocationId, httpRequest); } cancellationToken.ThrowIfCancellationRequested(); HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); if (shouldTrace) { ServiceClientTracing.ReceiveResponse(invocationId, httpResponse); } HttpStatusCode statusCode = httpResponse.StatusCode; cancellationToken.ThrowIfCancellationRequested(); string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); if (statusCode != HttpStatusCode.OK) { HttpOperationException <object> ex = new HttpOperationException <object>(); ex.Request = httpRequest; ex.Response = httpResponse; ex.Body = null; if (shouldTrace) { ServiceClientTracing.Error(invocationId, ex); } throw ex; } // Create Result HttpOperationResponse <ColorList> result = new HttpOperationResponse <ColorList>(); result.Request = httpRequest; result.Response = httpResponse; // Deserialize Response if (statusCode == HttpStatusCode.OK) { ColorList resultModel = new ColorList(); JToken responseDoc = null; if (string.IsNullOrEmpty(responseContent) == false) { responseDoc = JToken.Parse(responseContent); } if (responseDoc != null) { resultModel.DeserializeJson(responseDoc); } result.Body = resultModel; } if (shouldTrace) { ServiceClientTracing.Exit(invocationId, result); } return(result); }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); if (this.trimRef == null) { this.trimRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); } this.trimRef.UnParse(s); bw.Write(this.materialVariant); if (this.modlRef == null) { this.modlRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG); } this.modlRef.UnParse(s); bw.Write(this.swatchGrouping); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); bw.Write(this.unk02); return s; }
public void SpawnBlocks() { float screenWidthWorldPos = Camera.main.orthographicSize * Screen.width / Screen.height; float distBetweenBlocks = screenWidthWorldPos / 5; int random; random = Random.Range(-2, 3); float x = 2 * random * distBetweenBlocks; float y = 0; if (SM.transform.childCount > 0) { y = (int)SM.transform.GetChild(0).position.y + distBetweenBlocks * 2 + distanceSnakeBarrier; if (Screen.height / Screen.width == 4 / 3) { y *= 2; } } Vector3 SpawnPos = new Vector3(x, y, 0); bool canSpawnBlock = true; if (SimpleBoxPosition.Count == 0) { SimpleBoxPosition.Add(SpawnPos); } else { for (int k = 0; k < SimpleBoxPosition.Count; k++) { if (SpawnPos == SimpleBoxPosition[k] || prevSpawnBarrier == SimpleBoxPosition[k]) { canSpawnBlock = false; } } } GameObject boxInstance; if (canSpawnBlock) { SimpleBoxPosition.Add(SpawnPos); boxInstance = Instantiate(BlockPrefab, SpawnPos, Quaternion.identity, transform); boxInstance.tag = "SimpleBox"; string currentScene = SceneManager.GetActiveScene().name; Color32 thisImageColor = boxInstance.GetComponent <SpriteRenderer>().color; if (currentScene.Equals("LEVEL1") || currentScene.Equals("LEVEL2")) { thisImageColor = new Color32(255, 0, 0, 255); } else { for (int k = 0; k < colorsName.Count; k++) { string temp = colorsName[k]; int randomIndex = Random.Range(k, colorsName.Count); colorsName[k] = colorsName[randomIndex]; colorsName[randomIndex] = temp; thisImageColor = ColorList.getColor(colorsName[randomIndex]); boxInstance.name = temp; } } boxInstance.GetComponent <SpriteRenderer>().color = thisImageColor; boxInstance.layer = LayerMask.NameToLayer("Default"); boxInstance.AddComponent <Rigidbody2D>(); boxInstance.GetComponent <Rigidbody2D> ().constraints = RigidbodyConstraints2D.FreezeAll; } }
protected override Stream UnParse() { var s = new MemoryStream(); var bw = new BinaryWriter(s); bw.Write(this.version); if (this.commonA == null) { this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged); } this.commonA.UnParse(s); if (modlEntryList01 == null) { modlEntryList01 = new SpnFenMODLEntryList(this.OnResourceChanged); } this.modlEntryList01.UnParse(s); if (modlEntryList02 == null) { modlEntryList02 = new SpnFenMODLEntryList(this.OnResourceChanged); } this.modlEntryList02.UnParse(s); if (modlEntryList03 == null) { modlEntryList03 = new SpnFenMODLEntryList(this.OnResourceChanged); } this.modlEntryList03.UnParse(s); if (modlEntryList04 == null) { modlEntryList04 = new SpnFenMODLEntryList(this.OnResourceChanged); } this.modlEntryList04.UnParse(s); if (this.refList == null) { this.refList = new Gp7references(kRecommendedApiVersion, this.OnResourceChanged); } this.refList.UnParse(s); bw.Write(this.materialVariant); bw.Write(this.unkIID01); if (this.colors == null) { this.colors = new ColorList(this.OnResourceChanged); } this.colors.UnParse(s); return s; }
void Parse(Stream s) { var br = new BinaryReader(s); this.version = br.ReadUInt32(); this.commonA = new CatalogCommon(kRecommendedApiVersion, this.OnResourceChanged, s); this.unk01 = br.ReadUInt32(); this.matdRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG,s); this.floorRef = new TGIBlock(kRecommendedApiVersion, this.OnResourceChanged, TGIBlock.Order.ITG, s); this.unkIID01 = br.ReadUInt64(); this.colors = new ColorList(this.OnResourceChanged, s); }