public BitmapSource GetTileBitmap(SymbolID symbolID, int size) { if (m_symbolSet.Symbols.Contains(symbolID) == false) symbolID = SymbolID.Unknown; var symbol = m_symbolSet.Symbols[symbolID]; var gfx = DecideTileGfx(symbol, size); if (gfx is VectorGfxBase) { var g = (VectorGfxBase)gfx; var drawing = GetVectorGfx(g); return TileSetLoaderHelpers.DrawingToBitmap(drawing, size); } else if (gfx is BitmapGfx) { var g = (BitmapGfx)gfx; return GetBitmapGfx(g, size); } else { throw new Exception(); } }
private SymbolID ConvertElementToObject(SElement sElement) { SymbolID localObject = new SymbolID(); localObject.Location.A = sElement.ObjectId; localObject.Names = sElement.ObjectName; return localObject; }
public BitmapSource GetTile(SymbolID symbolID, GameColor color, int tileSize) { var key = new TileKey(symbolID, color, tileSize); BitmapSource bmp; if (m_cache.TryGet(key, out bmp)) { return(bmp); } int xOffset = GetTileXOffset(tileSize); int yOffset = GetTileYOffset(symbolID); bmp = new CroppedBitmap(this.Atlas, new Int32Rect(xOffset, yOffset, tileSize, tileSize)); if (color != GameColor.None) { var rgb = color.ToGameColorRGB(); var wcolor = Color.FromRgb(rgb.R, rgb.G, rgb.B); bmp = ColorizeBitmap(bmp, wcolor); } bmp.Freeze(); m_cache.Add(key, bmp); return(bmp); }
protected override void OnDropdownClick(Dropdown dpd) { base.OnDropdownClick(dpd); switch (dpd.name) { case "PatternDropdown": case "OperandDropdown": break; case "AmountDropdown": curAmountID = (AmountID)dpd.value; break; case "SymbolDropdown": curSymbolID = (SymbolID)dpd.value; RefreshDigitDropdown(dpd.value); break; case "DigitDropdown": curDigitID = (DigitID)(dpd.value + delta); break; default: MyDebug.LogYellow("Can not find Dropdown: " + dpd.name); break; } }
public BitmapSource GetTileBitmap(SymbolID symbolID, int size) { if (m_symbolSet.Symbols.Contains(symbolID) == false) { symbolID = SymbolID.Unknown; } var symbol = m_symbolSet.Symbols[symbolID]; var gfx = DecideTileGfx(symbol, size); if (gfx is VectorGfxBase) { var g = (VectorGfxBase)gfx; var drawing = GetVectorGfx(g); return(TileSetLoaderHelpers.DrawingToBitmap(drawing, size)); } else if (gfx is BitmapGfx) { var g = (BitmapGfx)gfx; return(GetBitmapGfx(g, size)); } else { throw new Exception(); } }
public static SymbolID GetBorderSymbol(int x, int y) { SymbolID result = SymbolID.sid_None; if (y != -1) { if (y != 18) { if (x != -1) { if (x == 76) { result = SymbolID.sid_Right; } } else { result = SymbolID.sid_Left; } } else { result = SymbolID.sid_Down; } } else { result = SymbolID.sid_Up; } return(result); }
private void RefreshSaveFileList() { saveFileSummary.SetActive(false); SymbolID symbolID = (SymbolID)curSaveFileIndex; ArrayList dataList = new ArrayList(saveFileDict[symbolID]); CommonTool.RefreshScrollContent(saveFileGrid, dataList, GuiItemID.SaveFileItem); }
public CategoryInstance(PatternID patternID, AmountID amountID, SymbolID symbolID, DigitID digitID, OperandID operandID) { this.patternID = patternID; this.amountID = amountID; this.symbolID = symbolID; this.digitID = digitID; this.operandID = operandID; }
/// <summary> /// 用于删除存档时对saveFileDict进行更新,并更新显示 /// 根据成就系统相关函数进行调整 /// </summary> private void RefreshSaveFileDict() { SymbolID symbolID = (SymbolID)curSaveFileIndex; List <SaveFileInstance> saveFileList = RecordController.Instance.ReadAllRecords(); curSaveFileCount = saveFileList.Count; saveFileDict[symbolID] = saveFileList.FindAll(x => x.cInstance.symbolID == symbolID); ArrayList dataList = new ArrayList(saveFileDict[symbolID]); CommonTool.RefreshScrollContent(saveFileGrid, dataList, GuiItemID.SaveFileItem); }
public Drawing GetDetailedDrawing(SymbolID symbolID, GameColor color) { int key = ((int)symbolID << 16) | (int)color; Drawing drawing; if (m_drawingCache.TryGetValue(key, out drawing)) return drawing; drawing = m_tileSet.GetDetailedDrawing(symbolID, color); m_drawingCache[key] = drawing; return drawing; }
public PlaceRec(int name, string imageName, SymbolID symbol, PlaceFlags signs, Movements movements, int subTiles, EffectID effect) { NameRS = name; ImageName = imageName; Symbol = symbol; Signs = signs; Moves = movements; SubTiles = subTiles; Effect = effect; ImageIndex = -1; SubsLoaded = 0; }
public BitmapSource GetBitmap(SymbolID symbolID, Color color, bool dark) { Dictionary <Color, CacheData> map; CacheData data; if (color == Colors.Black) { data = m_blackBitmapList[(int)symbolID]; if (data == null) { data = new CacheData(); m_blackBitmapList[(int)symbolID] = data; } } else { if (!m_bitmapMap.TryGetValue(symbolID, out map)) { map = new Dictionary <Color, CacheData>(); m_bitmapMap[symbolID] = map; } if (!map.TryGetValue(color, out data)) { data = new CacheData(); map[color] = data; } } if (!dark) { if (data.Bitmap == null) { BitmapSource bmp = CreateSymbolBitmap(symbolID, color, dark); data.Bitmap = bmp; } return(data.Bitmap); } else { if (data.BitmapDark == null) { BitmapSource bmp = CreateSymbolBitmap(symbolID, color, dark); data.BitmapDark = bmp; } return(data.BitmapDark); } }
public BitmapSource GetBitmap(SymbolID symbolID, Color color, bool dark) { Dictionary<Color, CacheData> map; CacheData data; if (color == Colors.Black) { data = m_blackBitmapList[(int)symbolID]; if (data == null) { data = new CacheData(); m_blackBitmapList[(int)symbolID] = data; } } else { if (!m_bitmapMap.TryGetValue(symbolID, out map)) { map = new Dictionary<Color, CacheData>(); m_bitmapMap[symbolID] = map; } if (!map.TryGetValue(color, out data)) { data = new CacheData(); map[color] = data; } } if (!dark) { if (data.Bitmap == null) { BitmapSource bmp = CreateSymbolBitmap(symbolID, color, dark); data.Bitmap = bmp; } return data.Bitmap; } else { if (data.BitmapDark == null) { BitmapSource bmp = CreateSymbolBitmap(symbolID, color, dark); data.BitmapDark = bmp; } return data.BitmapDark; } }
public BitmapSource GetBitmap(SymbolID symbolID, GameColor color) { var dv = new DrawingVisual(); var dc = dv.RenderOpen(); dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 2), new Point(m_tileSize / 2, m_tileSize / 2), m_tileSize / 2, m_tileSize / 2); dc.Close(); var bmp = new RenderTargetBitmap(m_tileSize, m_tileSize, 96, 96, PixelFormats.Default); bmp.Render(dv); return(bmp); }
private void RefreshLatestSaveFile(SummarySaveFileItem item, SymbolID symbolID, Text summary) { List <SaveFileInstance> instanceList = saveFileDict[symbolID]; GameObject saveFileDefaultItem = CommonTool.GetGameObjectContainsName(item.gameObject, "SaveFileDefaultItem"); saveFileDefaultItem.SetActive(instanceList.Count <= 0); if (instanceList.Count > 0) { SaveFileInstance latestInstance = instanceList[instanceList.Count - 1]; item.SendMessage("InitPrefabItem", latestInstance); } string content = LanguageController.Instance.GetLanguage(summary.index); summary.text = string.Format(content, instanceList.Count, curSaveFileCount); }
private int GetAchievementCountBySymbol(SymbolID symbol, out int countWithAchievement) { List <AchievementInstance> instanceList = AchievementController.Instance.GetAchievementsBySymbol(symbol); countWithAchievement = 0; for (int i = 0; i < instanceList.Count; i++) { if (string.IsNullOrEmpty(instanceList[i].finishTime)) { continue; } countWithAchievement++; } return(instanceList.Count); }
/// <summary> /// 刷新Dropdown的状态 /// </summary> private void RefreshCategoryContent() { Dropdown[] dropdownArray = GetComponentsInChildren <Dropdown>(true); for (int i = 0; i < dropdownArray.Length; i++) { for (int j = 0; j < dropdownArray[i].options.Count; j++) { dropdownArray[i].options[j].text = LanguageController.Instance.GetLanguage(dropdownArray[i].options[j].text); } dropdownArray[i].value = 0; dropdownArray[i].RefreshShownValue(); } RefreshDigitDropdown(0); curAmountID = 0; curSymbolID = 0; curDigitID = 0; }
public Drawing GetDetailedDrawing(SymbolID symbolID, GameColor color) { if (m_symbolSet.Symbols.Contains(symbolID) == false) symbolID = SymbolID.Unknown; var symbol = m_symbolSet.Symbols[symbolID]; var gfx = DecideGfx(symbol); if (gfx is VectorGfxBase) { var g = (VectorGfxBase)gfx; var drawing = GetVectorGfx(g); if (color != GameColor.None) { drawing = drawing.Clone(); TileSetHelpers.ColorizeDrawing(drawing, color.ToWindowsColor()); } drawing.Freeze(); return drawing; } else if (gfx is BitmapGfx) { var g = (BitmapGfx)gfx; var bmp = GetBitmapGfx(g, 64); if (color != GameColor.None) bmp = TileSetHelpers.ColorizeBitmap(bmp, color.ToWindowsColor()); var drawing = TileSetHelpers.BitmapToDrawing(bmp); drawing.Freeze(); return drawing; } else { throw new Exception(); } }
public Drawing GetDrawing(SymbolID symbolID, GameColor color) { Dictionary <GameColor, Drawing> map; Drawing drawing; if (!m_drawingMap.TryGetValue(symbolID, out map)) { map = new Dictionary <GameColor, Drawing>(); m_drawingMap[symbolID] = map; } if (!map.TryGetValue(color, out drawing)) { drawing = CreateDrawing(symbolID, color); map[color] = drawing; } return(drawing); }
public BitmapSource GetTileBitmap(SymbolID symbolID, GameColor color, int size) { if (m_bitmapCacheTileSize != size) { m_bitmapCacheTileSize = size; m_bitmapCache = new Dictionary<int, BitmapSource>(); } int key = ((int)symbolID << 16) | (int)color; BitmapSource bmp; if (m_bitmapCache.TryGetValue(key, out bmp)) return bmp; bmp = m_tileSet.GetTileBitmap(symbolID, color, size); m_bitmapCache[key] = bmp; return bmp; }
Drawing CreateDrawing(SymbolID symbolID, Color color) { var symbol = m_symbolInfoList.Single(si => si.ID == symbolID); Drawing drawing; if (m_useOnlyChars || symbol.DrawingName == null) { drawing = m_drawingCache.GetCharacterDrawing(symbol.CharSymbol, color, m_useOnlyChars).Clone(); drawing = NormalizeDrawing(drawing, new Point(10, 0), new Size(80, 100), symbol.CharRotation); } else { drawing = m_drawingCache.GetDrawing(symbol.DrawingName, color).Clone(); drawing = NormalizeDrawing(drawing, new Point(symbol.X, symbol.Y), new Size(symbol.Width, symbol.Height), symbol.DrawingRotation); } drawing.Freeze(); return(drawing); }
public Drawing GetDrawing(SymbolID symbolID, Color color) { Dictionary<Color, Drawing> map; Drawing drawing; if (!m_drawingMap.TryGetValue(symbolID, out map)) { map = new Dictionary<Color, Drawing>(); m_drawingMap[symbolID] = map; } if (!map.TryGetValue(color, out drawing)) { drawing = CreateDrawing(symbolID, color); map[color] = drawing; } return drawing; }
protected override void InitPrefabItem(object data) { content = data as AchievementInstance; if (content == null) { MyDebug.LogYellow("SummaryAchievementInstance is null!!"); return; } Init(); try { SymbolID symbol = (SymbolID)System.Enum.Parse(typeof(SymbolID), content.achievementName); if (!System.Enum.IsDefined(typeof(SymbolID), symbol)) { MyDebug.LogYellow("Symbol is not Defined!!"); return; } int countWithAchievement = 0; int countOfSymbol = GetAchievementCountBySymbol(symbol, out countWithAchievement); bool hasFinish = countWithAchievement == countOfSymbol; achievementItem_WithoutAchievement.SetActive(!hasFinish); //achievementCondition.text = GameManager.Instance.GetMutiLanguage(content.condition); //achievementType.text = string.Format(achievementType.text, countWithAchievement, countOfSymbol); achievementName.gameObject.SetActive(hasFinish); //achievementName_WithoutAchievement.gameObject.SetActive(!hasFinish); if (!hasFinish) { //achievementType.color = Color.gray; //achievementCondition.color = Color.gray; //achievementName_WithoutAchievement.color = Color.gray; } else { content.finishTime = "HasFinish"; achievementName.text = LanguageController.Instance.GetLanguage(content.mainTitleIndex); } } catch { MyDebug.LogYellow("Can not get Symbol!!"); } }
Drawing CreateDrawing(SymbolID symbolID, Color color) { var symbol = m_symbolInfoList.Single(si => si.ID == symbolID); Drawing drawing; if (m_useOnlyChars || symbol.DrawingName == null) { drawing = m_drawingCache.GetCharacterDrawing(symbol.CharSymbol, color, m_useOnlyChars).Clone(); drawing = NormalizeDrawing(drawing, new Point(10, 0), new Size(80, 100), symbol.CharRotation); } else { drawing = m_drawingCache.GetDrawing(symbol.DrawingName, color).Clone(); drawing = NormalizeDrawing(drawing, new Point(symbol.X, symbol.Y), new Size(symbol.Width, symbol.Height), symbol.DrawingRotation); } drawing.Freeze(); return drawing; }
public static int GetSymImageIndex(ushort tid) { int result; int @base = AuxUtils.GetShortLo(tid); int @var = AuxUtils.GetShortHi(tid); SymbolID sym = StaticData.dbPlaces[@base].Symbol; SymbolRec symRec = StaticData.dbSymbols[(int)sym]; result = symRec.ImageIndex; if (@var > 0) { if (@var <= symRec.SubCount) { result += @var; } } return(result); }
BitmapSource CreateSymbolBitmap(SymbolID symbolID, Color color, bool dark) { DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); Drawing d = m_symbolDrawingCache.GetDrawing(symbolID, color); drawingContext.PushTransform(new ScaleTransform(Math.Floor(m_size) / 100, Math.Floor(m_size) / 100)); drawingContext.DrawDrawing(d); drawingContext.Pop(); drawingContext.Close(); if (dark) { drawingVisual.Opacity = 0.2; } RenderTargetBitmap bmp = new RenderTargetBitmap((int)m_size, (int)m_size, 96, 96, PixelFormats.Default); bmp.Render(drawingVisual); bmp.Freeze(); return(bmp); }
public int GetTileYOffset(SymbolID symbolID) { return((int)symbolID * MaxTileSize); }
/// <summary> /// 获取法则符号 /// </summary> /// <param name="symbolID"></param> /// <returns></returns> public string GetSymbol(SymbolID symbolID) { return(symbolArray[(int)symbolID]); }
BitmapSource CreateSymbolBitmap(SymbolID symbolID, Color color, bool dark) { DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); Drawing d = m_symbolDrawingCache.GetDrawing(symbolID, color); drawingContext.PushTransform(new ScaleTransform(Math.Floor(m_size) / 100, Math.Floor(m_size) / 100)); drawingContext.DrawDrawing(d); drawingContext.Pop(); drawingContext.Close(); if (dark) drawingVisual.Opacity = 0.2; RenderTargetBitmap bmp = new RenderTargetBitmap((int)m_size, (int)m_size, 96, 96, PixelFormats.Default); bmp.Render(drawingVisual); bmp.Freeze(); return bmp; }
public BitmapSource GetBitmap(SymbolID symbolID, GameColor color) { var dv = new DrawingVisual(); var dc = dv.RenderOpen(); dc.DrawEllipse(Brushes.Red, new Pen(Brushes.Blue, 2), new Point(m_tileSize / 2, m_tileSize / 2), m_tileSize / 2, m_tileSize / 2); dc.Close(); var bmp = new RenderTargetBitmap(m_tileSize, m_tileSize, 96, 96, PixelFormats.Default); bmp.Render(dv); return bmp; }
public static void DrawLocTile(NWGameSpace space, NWField field, int px, int py, BaseScreen screen, Player player, ExtRect mapRect, ExtRect viewRect, ImageList resImages) { NWTile place = (NWTile)field.GetTile(px, py); int xx = viewRect.Left + 32 * (px - mapRect.Left); int yy = viewRect.Top + 30 * (py - mapRect.Top); if (place != null && !place.EmptyStates) { int bg = (int)place.Background; int fg = (int)place.Foreground; int bgExt = (int)place.BackgroundExt; int fgExt = (int)place.ForegroundExt; int fog = place.FogID; int fogExt = place.FogExtID; fg = PtTransDoor(place); short op = space.GetTileBrightness(field, place, false); resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)bg), op); if (bgExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)bgExt), op); } if (fog != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fogExt), op); } else { if (fg != PlaceID.pid_Undefined) { bool trap = field.IsTrap(px, py); if (!trap || (trap && (place.Trap_Discovered || GlobalVars.Debug_Divinity))) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fg), op); if (fgExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fgExt), op); } } } if (fogExt != PlaceID.pid_Undefined) { resImages.DrawImage(screen, xx, yy, GetTileImageIndex((ushort)fogExt), op); } } SymbolID sid = GetBorderSymbol(px, py); if (sid != SymbolID.sid_None && player.CanMove(field, px, py)) { switch (sid) { case SymbolID.sid_Left: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Left].ImageIndex, op); break; case SymbolID.sid_Up: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Up].ImageIndex, op); break; case SymbolID.sid_Right: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Right].ImageIndex, op); break; case SymbolID.sid_Down: resImages.DrawImage(screen, xx, yy, StaticData.dbItfElements[(int)ItfElement.id_Down].ImageIndex, op); break; } } } }
/// <summary> /// sets a general symbol /// use SymbolID enum and SymbolState enum as argument /// </summary> /// <param name="symbolid">symbol ID</param> /// <param name="symbolstate">symbol state</param> public void SetSymbol(SymbolID symbolid, SymbolState symbolstate) { //create handle for datagram Byte[] btDatagram = new Byte[64]; try { //create datagram btDatagram[0x00] = 0x04; //count of successive bytes btDatagram[0x01] = 0x1b; //header (fix value) btDatagram[0x02] = 0x30; //command: set a symbol btDatagram[0x03] = Convert.ToByte(symbolid); //ID of symbol btDatagram[0x04] = Convert.ToByte(symbolstate); //required state of symbol //send command SendCommand(btDatagram); } catch (Exception ex) { throw new Exception("Setting a symbol failed: ", ex); } }
public void GetTileRawBitmap(SymbolID symbolID, int size, byte[] array) { var bmp = GetTileBitmap(symbolID, GameColor.None, size); const int bytesPerPixel = 4; bmp.CopyPixels(array, size * bytesPerPixel, 0); }
Drawing CreateDrawing(SymbolID symbolID, GameColor color) { var symbol = m_symbolSet.Symbols[symbolID]; return CreateDrawing(symbol, color); }
public TileKey(SymbolID symbolID, GameColor color, int size) { this.SymbolID = symbolID; this.Color = color; this.Size = size; }
public List <AchievementInstance> GetAchievementsBySymbol(SymbolID symbol) { return(achievementList.FindAll(x => x.cInstance.symbolID == symbol)); }
public void GetTileRawBitmap(SymbolID symbolID, int size, byte[] array) { m_tileSet.GetTileRawBitmap(symbolID, size, array); }
Drawing CreateDrawing(SymbolID symbolID, GameColor color) { var symbol = m_symbolSet.Symbols[symbolID]; return(CreateDrawing(symbol, color)); }
public BitmapSource GetTileBitmap(SymbolID symbolID, GameColor color, int size) { if (m_symbolSet.Symbols.Contains(symbolID) == false) symbolID = SymbolID.Unknown; var symbol = m_symbolSet.Symbols[symbolID]; var gfx = DecideTileGfx(symbol, size); if (gfx is VectorGfxBase) { var g = (VectorGfxBase)gfx; var drawing = GetVectorGfx(g); var bmp = TileSetHelpers.DrawingToBitmap(drawing, size); if (color != GameColor.None) bmp = TileSetHelpers.ColorizeBitmap(bmp, color.ToWindowsColor()); return bmp; } else if (gfx is BitmapGfx) { var g = (BitmapGfx)gfx; var bmp = GetBitmapGfx(g, size); if (color != GameColor.None) bmp = TileSetHelpers.ColorizeBitmap(bmp, color.ToWindowsColor()); return bmp; } else { throw new Exception(); } }