/// <summary> /// Begins opening a new map with a given default terrain or null if the terrain will be loaded from a map-file. /// </summary> /// <param name="tileset">The tileset of the map.</param> /// <param name="size">The size of the map.</param> /// <param name="defaultTerrain"> /// The name of the default terrain of the map or null if the terrain will be loaded from a map-file. /// </param> public void BeginOpen(ITileSet tileset, RCIntVector size, string defaultTerrain) { if (this.status != MapStatus.Closed) { throw new InvalidOperationException(string.Format("Invalid operation! Map status: {0}", this.status)); } if (tileset == null) { throw new ArgumentNullException("tileset"); } if (size == RCIntVector.Undefined) { throw new ArgumentNullException("size"); } if (size.X % QUAD_PER_ISO_VERT != 0 || size.Y % QUAD_PER_ISO_HORZ != 0) { throw new ArgumentException(string.Format("Horizontal size of the map must be a multiple of {0}, vertical size of the map must be a multiple of {1}!", QUAD_PER_ISO_VERT, QUAD_PER_ISO_HORZ), "size"); } if (size.X <= 0 || size.X > MAX_MAPSIZE || size.Y <= 0 || size.Y > MAX_MAPSIZE) { throw new ArgumentOutOfRangeException("size"); } this.status = MapStatus.Opening; this.tileset = tileset; this.defaultTileType = defaultTerrain != null?this.tileset.GetIsoTileType(defaultTerrain) : null; this.size = size; this.DetachAtSize(); }
/// <see cref="IComponent.Start"/> public void Start() { this.tilesetLoader = ComponentManager.GetInterface <ITileSetLoader>(); /// Load the tilesets from the configured directory DirectoryInfo rootDir = new DirectoryInfo(BizLogicConstants.TILESET_DIR); FileInfo[] tilesetFiles = rootDir.GetFiles("*.xml", SearchOption.AllDirectories); foreach (FileInfo tilesetFile in tilesetFiles) { /// TODO: this is a hack! Later we will have binary tileset format. string xmlStr = File.ReadAllText(tilesetFile.FullName); string imageDir = tilesetFile.DirectoryName; RCPackage tilesetPackage = RCPackage.CreateCustomDataPackage(PackageFormats.TILESET_FORMAT); tilesetPackage.WriteString(0, xmlStr); tilesetPackage.WriteString(1, imageDir); byte[] buffer = new byte[tilesetPackage.PackageLength]; tilesetPackage.WritePackageToBuffer(buffer, 0); ITileSet tileset = this.tilesetLoader.LoadTileSet(buffer); if (this.loadedTilesets.ContainsKey(tileset.Name)) { throw new InvalidOperationException(string.Format("Tileset with name '{0}' already loaded!", tileset.Name)); } this.loadedTilesets.Add(tileset.Name, tileset); } }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { tabsImageElements = new IImage[10] { iconsTileSet.ExtractImage(new RectangleF(74.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(90.0f * 4, 1.0f * 4, 1.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(95.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(111.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(128.0f * 4, 1.0f * 4, 1.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(132.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(150.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(204.0f * 4, 1.0f * 4, 1.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(166.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(187.0f * 4, 1.0f * 4, 16.0f * 4, 26.0f * 4)) }; terrainModeIcon = iconsTileSet.ExtractImage(new RectangleF(38.0f * 4, 55.0f * 4, 27.0f * 4, 19.0f * 4)); handIcon = iconsTileSet.ExtractImage(new RectangleF(19.0f * 4, 55.0f * 4, 17.0f * 4, 18.0f * 4)); undoIcon = iconsTileSet.ExtractImage(new RectangleF(1.0f * 4, 60.0f * 4, 16.0f * 4, 16.0f * 4)); redoIcon = iconsTileSet.ExtractImage(new RectangleF(2.0f * 4, 77.0f * 4, 16.0f * 4, 16.0f * 4)); stackingEnabledIcon = iconsTileSet.ExtractImage(new RectangleF(232.0f * 4, 42.0f * 4, 21.0f * 4, 18.0f * 4)); stackingDisabledIcon = iconsTileSet.ExtractImage(new RectangleF(232.0f * 4, 61.0f * 4, 21.0f * 4, 18.0f * 4)); hideRevealIcon = iconsTileSet.ExtractImage(new RectangleF(232.0f * 4, 152.0f * 4, 21.0f * 4, 17.0f * 4)); hiddenIcon = iconsTileSet.ExtractImage(new RectangleF(232.0f * 4, 80.0f * 4, 17.0f * 4, 11.0f * 4)); tabScrollers = new IImage[4] { iconsTileSet.ExtractImage(new RectangleF(215.0f * 4, 30.0f * 4, 15.0f * 4, 15.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(215.0f * 4, 46.0f * 4, 15.0f * 4, 15.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(215.0f * 4, 62.0f * 4, 15.0f * 4, 15.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(215.0f * 4, 78.0f * 4, 15.0f * 4, 15.0f * 4)) }; }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { //mainForm.Controls.Remove(textBox); OnGameDisplayAreaResized(); textBox.Visible = false; //mainForm.Controls.Add(textBox); }
/// <see cref="IMapLoader.NewMap"/> public IMapAccess NewMap(string mapName, ITileSet tileset, string defaultTerrain, RCIntVector size) { if (!this.initThreadStarted) { throw new InvalidOperationException("Component has not yet been started!"); } this.initThread.Join(); if (mapName == null) { throw new ArgumentNullException("mapName"); } if (tileset == null) { throw new ArgumentNullException("tileset"); } if (defaultTerrain == null) { throw new ArgumentNullException("defaultTerrain"); } if (size == RCIntVector.Undefined) { throw new ArgumentNullException("size"); } MapAccess retObj = new MapAccess(mapName, this.mapStructure); this.mapStructure.BeginOpen(tileset, size, defaultTerrain); this.mapStructure.EndOpen(); return(retObj); }
public WindowUpdater() { tsr = new TileSetRepo(); tsr.Discover(); TileSet = null; update_targets = new List <MainWindow>(); }
protected RenderingFactoryBase(GameRenderingConfig renderConfig, ITileSet <TTile> tileSet) { RenderingConfig = renderConfig; this.RenderControl = new RendererControl(tileSet.TileSize, RenderingConfig.RenderType); this.Tiles = tileSet.LoadTexturePack(); }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { buttonImageElements = new IImage[5] { iconsTileSet.ExtractImage(new RectangleF(32.0f * 4, 25.0f * 4, 18.0f * 4, 28.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(50.0f * 4, 25.0f * 4, 18.0f * 4, 28.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(49.0f * 4, 25.0f * 4, 1.0f * 4, 28.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(59.0f * 4, 1.0f * 4, 13.0f * 4, 14.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(1.0f * 4, 48.0f * 4, 13.0f * 4, 11.0f * 4)) }; }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { //rotationMarkImage = iconsTileSet.ExtractImage(new RectangleF(13.0f * 4, 0.0f * 4, 16.0f * 4, 21.0f * 4)); frameImageElements = new IImage[2] { iconsTileSet.ExtractImage(new RectangleF(205.0f * 4, 2.0f * 4, 1.0f * 4, 6.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(205.0f * 4, 8.0f * 4, 1.0f * 4, 1.0f * 4)) }; pinIcon = iconsTileSet.ExtractImage(new RectangleF(20.0f * 4, 76.0f * 4, 22.0f * 4, 10.0f * 4)); unpinIcon = iconsTileSet.ExtractImage(new RectangleF(44.0f * 4, 76.0f * 4, 10.0f * 4, 10.0f * 4)); }
/// <summary> /// Notifies the WindowUpdater that the tileset selection changed. /// </summary> /// <param name="new_selection">New selection.</param> public void TilesetSelectionChanged(String new_selection) { var tsets = tsr.ByName(new_selection); if (tsets.Count == 1) { TileSet = tsets[0]; this.NeedsUpdate = true; } LazyUpdate(); }
void RemapTilingToPrefabs() { ITileSet newTileSet = tileSetBuilder.UnityTileSet; TilingRemapper remapper = new TilingRemapper(tiling, newTileSet); foreach (var tile in newTileSet) { for (int i = 0; i < 16; i++) { remapper.AddMapping(i, tile.ID); } } ITiling2D newTiling = remapper.Remap(new RandomTilingEnumerator()); tiling = newTiling; }
public GameState() { InputManager = new ManageInput(); tileSet = new TileSet(); OutputManager = new ManageOutput(tileSet); droidGroup = new DroidGroup(new IDroidState[] { new ReadyState(new int[] { 0, 0 }, new int[] { 1, 0 }), new ReadyState(new int[] { 2, 3 }, new int[] { 0, 1 }) }); InputManager.InputParsed += droidGroup.OnInputParsed; foreach (IDroidState droid in droidGroup.Droids) { droid.DroidReportedStatus += OutputManager.OnDroidReportedStatus; droid.TileWithNeighboursRequested += tileSet.OnTileInfoRequested; droid.MoveRequested += tileSet.OnTileInfoRequested; } }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { //rotationMarkImage = iconsTileSet.ExtractImage(new RectangleF(13.0f * 4, 0.0f * 4, 16.0f * 4, 21.0f * 4)); frameImageElements = new IImage[9] { iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 172.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 172.0f * 4, 1.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 172.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 182.0f * 4, 11.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 182.0f * 4, 1.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 182.0f * 4, 11.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 220.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 220.0f * 4, 1.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 220.0f * 4, 11.0f * 4, 10.0f * 4)) }; closeIcon = iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 2.0f * 4, 13.0f * 4, 12.0f * 4)); recycleIcon = iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 15.0f * 4, 13.0f * 4, 12.0f * 4)); shuffleIcon = iconsTileSet.ExtractImage(new RectangleF(233.0f * 4, 28.0f * 4, 16.0f * 4, 13.0f * 4)); invertIcon = iconsTileSet.ExtractImage(new RectangleF(209.0f * 4, 16.0f * 4, 11.0f * 4, 12.0f * 4)); }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { loudspeakerIcon = iconsTileSet.ExtractImage(new RectangleF(208.0f * 4, 1.0f * 4, 10.0f * 4, 15.0f * 4)); soundWavesIcon = iconsTileSet.ExtractImage(new RectangleF(218.0f * 4, 1.0f * 4, 10.0f * 4, 15.0f * 4)); frameIcon = iconsTileSet.ExtractImage(new RectangleF(1.0f * 4, 163.0f * 4, 195.0f * 4, 76.0f * 4)); playerIcon = iconsTileSet.ExtractImage(new RectangleF(1.0f * 4, 98.0f * 4, 64.0f * 4, 64.0f * 4)); microphoneLevelIcon = iconsTileSet.ExtractImage(new RectangleF(198.0f * 4, 171.0f * 4, 19.0f * 4, 59.0f * 4)); microphoneThresholdIcon = iconsTileSet.ExtractImage(new RectangleF(221.0f * 4, 208.0f * 4, 9.0f * 4, 11.0f * 4)); handIcon = iconsTileSet.ExtractImage(new RectangleF(19.0f * 4, 55.0f * 4, 17.0f * 4, 18.0f * 4)); videoTexture = graphics.CreateVideoTexture(new Size(256, 256)); for (int y = 0; y < 4; ++y) { for (int x = 0; x < 4; ++x) { playerVideoFrames[y * 4 + x] = videoTexture.ExtractImage(new RectangleF(x * 64.0f, y * 64.0f, 64.0f, 64.0f)); } } }
private void Form1_Load(object sender, EventArgs e) { ComponentManager.RegisterComponents("RC.Engine.Maps, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", new string[3] { "RC.Engine.Maps.TileSetLoader", "RC.Engine.Maps.MapLoader", "RC.Engine.Maps.MapEditor" }); ComponentManager.StartComponents(); this.tilesetLoader = ComponentManager.GetInterface <ITileSetLoader>(); this.mapLoader = ComponentManager.GetInterface <IMapLoader>(); this.mapEditor = ComponentManager.GetInterface <IMapEditor>(); /// TODO: this is a hack! FileInfo tilesetFile = new FileInfo("../../../../tilesets/test/test.xml"); string xmlStr = File.ReadAllText(tilesetFile.FullName); string imageDir = tilesetFile.DirectoryName; RCPackage tilesetPackage = RCPackage.CreateCustomDataPackage(PackageFormats.TILESET_FORMAT); tilesetPackage.WriteString(0, xmlStr); tilesetPackage.WriteString(1, imageDir); byte[] buffer = new byte[tilesetPackage.PackageLength]; tilesetPackage.WritePackageToBuffer(buffer, 0); ITileSet tileset = this.tilesetLoader.LoadTileSet(buffer); this.map = this.mapLoader.NewMap("TestMap", tileset, "Yellow", new RCIntVector(64, 32)); this.draw = new IsoDraw(); this.replacedTiles = new RCSet <IIsoTile>(); this.terrainTypes = new List <string>(); foreach (ITerrainType terrainType in tileset.TerrainTypes) { this.terrainTypes.Add(terrainType.Name); } this.selectedTerrain = 0; this.Text = this.terrainTypes[this.selectedTerrain]; }
/// <summary> /// Adds a tile set to the repo. /// </summary> /// <param name="tset">Tset to add.</param> public void AddTileSet(ITileSet tset) { found.Add(tset); }
/// <see cref="IMapLoader.LoadMap"/> public IMapAccess LoadMap(ITileSet tileset, byte[] data) { if (!this.initThreadStarted) { throw new InvalidOperationException("Component has not yet been started!"); } this.initThread.Join(); if (tileset == null) { throw new ArgumentNullException("tileset"); } if (data == null) { throw new ArgumentNullException("data"); } /// Load the packages from the byte array. RCPackage mapHeaderPackage = null; RCPackage isotileListPackage = null; RCPackage terrainObjListPackage = null; int offset = 0; while (offset < data.Length) { int parsedBytes; RCPackage package = RCPackage.Parse(data, offset, data.Length - offset, out parsedBytes); if (package == null || !package.IsCommitted) { throw new MapException("Syntax error!"); } offset += parsedBytes; if (package.PackageFormat.ID == MapFileFormat.MAP_HEADER) { mapHeaderPackage = package; } else if (package.PackageFormat.ID == MapFileFormat.ISOTILE_LIST) { isotileListPackage = package; } else if (package.PackageFormat.ID == MapFileFormat.TERRAINOBJ_LIST) { terrainObjListPackage = package; } } /// Validate the packages. if (mapHeaderPackage == null) { throw new MapException("Syntax error: map header is missing!"); } if (isotileListPackage == null) { throw new MapException("Syntax error: isometric-tile-list is missing!"); } if (terrainObjListPackage == null) { throw new MapException("Syntax error: terrain-object-list is missing!"); } /// Validate the map header. MapHeader mapHeader = MapHeader.FromPackage(mapHeaderPackage); if (mapHeader.AppVersion > new Version(ConstantsTable.Get <string>("RC.App.Version"))) { throw new MapException(string.Format("Incompatible map version: {0}!", mapHeader.AppVersion)); } if (mapHeader.TilesetName != tileset.Name) { throw new ArgumentException(string.Format("The given tileset '{0}' has to equal with the map tileset '{1}'!", tileset.Name, mapHeader.TilesetName), "tileset"); } if (mapHeader.MapSize.X > MapStructure.MAX_MAPSIZE || mapHeader.MapSize.Y > MapStructure.MAX_MAPSIZE) { throw new MapException(string.Format("Map size exceeds the limits: {0}x{0}!", MapStructure.MAX_MAPSIZE)); } MapAccess retObj = new MapAccess(mapHeader.MapName, this.mapStructure); this.mapStructure.BeginOpen(tileset, mapHeader.MapSize); this.LoadIsoTiles(isotileListPackage); this.mapStructure.EndOpen(); this.LoadTerrainObjects(terrainObjListPackage, retObj); // TODO: validate MapHeader.MaxPlayers! // TODO: validate the MapHeader checksums! return(retObj); }
/// <summary> /// Create a Texture2D array which contains mipmapped versions of all symbol drawings /// </summary> public static Texture2D CreateTextures11(Device device, ITileSet tileSet) { var numDistinctBitmaps = EnumHelpers.GetEnumMax<SymbolID>() + 1; int maxTileSize = 64; int mipLevels = 4; // 64, 32, 16, 8 var atlasTexture = new Texture2D(device, new Texture2DDescription() { Usage = ResourceUsage.Default, BindFlags = BindFlags.ShaderResource, CpuAccessFlags = CpuAccessFlags.None, Format = Format.B8G8R8A8_UNorm, Width = maxTileSize, Height = maxTileSize, SampleDescription = new SampleDescription(1, 0), ArraySize = numDistinctBitmaps, MipLevels = mipLevels, }); for (int mipLevel = 0; mipLevel < mipLevels; ++mipLevel) { int tileSize = maxTileSize >> mipLevel; const int bytesPerPixel = 4; var pixelArray = new byte[tileSize * tileSize * bytesPerPixel]; for (int i = 0; i < numDistinctBitmaps; ++i) { tileSet.GetTileRawBitmap((SymbolID)i, tileSize, pixelArray); #if COLORMIPMAPS byte r, g, b; switch (mipLevel) { case 0: r = 255; g = 0; b = 0; break; case 1: r = 0; g = 255; b = 0; break; case 2: r = 0; g = 0; b = 255; break; case 3: r = 255; g = 255; b = 0; break; case 4: r = 255; g = 0; b = 255; break; case 5: r = 0; g = 255; b = 255; break; default: throw new Exception(); } for (int y = 0; y < tileSize; ++y) { for (int x = 0; x < tileSize; ++x) { pixelArray[y * tileSize * 4 + x * 4 + 0] = b; pixelArray[y * tileSize * 4 + x * 4 + 1] = g; pixelArray[y * tileSize * 4 + x * 4 + 2] = r; pixelArray[y * tileSize * 4 + x * 4 + 3] = 255; } } #endif #if TEST for (int y = 0; y < tileSize; ++y) { for (int x = 0; x < tileSize; ++x) { if (x == y) { pixelArray[y * tileSize * 4 + x * 4 + 0] = 255; pixelArray[y * tileSize * 4 + x * 4 + 1] = (byte)y; pixelArray[y * tileSize * 4 + x * 4 + 2] = (byte)(x + y); pixelArray[y * tileSize * 4 + x * 4 + 3] = 255; } } } #endif using (var dataStream = DataStream.Create(pixelArray, true, false)) { var box = new DataBox(dataStream.DataPointer, tileSize * 4, 0); device.ImmediateContext.UpdateSubresource(box, atlasTexture, Texture2D.CalculateSubResourceIndex(mipLevel, i, mipLevels)); } } } return atlasTexture; }
public ManageOutput(ITileSet tileSet) { CurrentDroidReports = new List <DroidReportStatusEventArgs>(); DisplayedTiles = new string[tileSet.Tiles.GetLength(0), tileSet.Tiles.GetLength(1)]; }
/// <summary> /// Begins opening a new map. /// </summary> /// <param name="tileset">The tileset of the map.</param> /// <param name="size">The size of the map.</param> public void BeginOpen(ITileSet tileset, RCIntVector size) { this.BeginOpen(tileset, size, null); }
public DungeonGameRenderingFactory(GameRenderingConfig renderConfig, DungeonGameData gameData, ITileSet <TTile> tileSet) : base(renderConfig, tileSet) { this.GameData = gameData; }
/// <summary>Reloads all graphics resource.</summary> /// <remarks>Called for instance after a game box has just been loaded.</remarks> public override void ResetGraphicsElements(IGraphics graphics, ITileSet iconsTileSet) { // recalculate area dimensions OnGameDisplayAreaResized(); if (model.CurrentGameBox.Reference == model.GameLibrary.DefaultGameBox) { // load ZunTzu logo 3D model IFile diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.ZunTzuDiceTexture.png"); logoMesh = graphics.LoadDieMesh(Dice.D6ComplexModel.Vertice, Dice.D6ComplexModel.Triangles, Dice.D6ComplexModel.Inradius, diceTextureFile, false); } else { logoMesh = null; // load 3D models of dice DiceHand[] diceHands = model.CurrentGameBox.CurrentGame.DiceHands; for (int i = 0; i < diceHands.Length; ++i) { DiceType diceType = diceHands[i].DiceType; Die[] dice = diceHands[i].Dice; for (int j = 0; j < dice.Length; ++j) { string textureFileName = dice[j].TextureFileName; // have we loaded a model for this die already? for (int k = 0; k <= i; ++k) { if (diceHands[k].DiceType == diceType) { Die[] diceAlreadyLoaded = diceHands[k].Dice; for (int l = 0; l < (k < i ? diceAlreadyLoaded.Length : j); ++l) { if (diceAlreadyLoaded[l].TextureFileName == textureFileName) { // already loaded --> reuse mesh dice[j].DieMesh = diceAlreadyLoaded[l].DieMesh; goto nextDie; } } } } // not loaded yet --> create new mesh IFile diceTextureFile = null; bool custom = (dice[j].TextureFileName != null); if (custom) { IArchive archive = new Archive(model.CurrentGameBox.Reference.FileName); diceTextureFile = archive.GetFile(dice[j].TextureFileName); } switch (diceType) { case DiceType.D4: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D4Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D4ComplexModel.Vertice, Dice.D4ComplexModel.Triangles, Dice.D4ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D4SimpleModel.Vertice, Dice.D4SimpleModel.Triangles, Dice.D4SimpleModel.Inradius, diceTextureFile, custom)); break; case DiceType.D6: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D6Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D6ComplexModel.Vertice, Dice.D6ComplexModel.Triangles, Dice.D6ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D6SimpleModel.Vertice, Dice.D6SimpleModel.Triangles, Dice.D6SimpleModel.Inradius, diceTextureFile, custom)); break; case DiceType.D8: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D8Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D8ComplexModel.Vertice, Dice.D8ComplexModel.Triangles, Dice.D8ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D8SimpleModel.Vertice, Dice.D8SimpleModel.Triangles, Dice.D8SimpleModel.Inradius, diceTextureFile, custom)); break; case DiceType.D10: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D10Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D10ComplexModel.Vertice, Dice.D10ComplexModel.Triangles, Dice.D10ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D10SimpleModel.Vertice, Dice.D10SimpleModel.Triangles, Dice.D10SimpleModel.Inradius, diceTextureFile, custom)); break; case DiceType.D12: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D12Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D12ComplexModel.Vertice, Dice.D12ComplexModel.Triangles, Dice.D12ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D12SimpleModel.Vertice, Dice.D12SimpleModel.Triangles, Dice.D12SimpleModel.Inradius, diceTextureFile, custom)); break; case DiceType.D20: if (!custom) { diceTextureFile = FileSystem.FileSystem.GetResource("ZunTzu.ResourceFiles.D20Texture.png"); } dice[j].DieMesh = (view.DisplayProperties.DiceModelsDetailLevel == ModelDetailType.Complex ? graphics.LoadDieMesh(Dice.D20ComplexModel.Vertice, Dice.D20ComplexModel.Triangles, Dice.D20ComplexModel.Inradius, diceTextureFile, custom) : graphics.LoadDieMesh(Dice.D20SimpleModel.Vertice, Dice.D20SimpleModel.Triangles, Dice.D20SimpleModel.Inradius, diceTextureFile, custom)); break; } nextDie: ; } } // initialize orientation of each die (if first time) for (int i = 0; i < diceHands.Length; ++i) { DiceType diceType = diceHands[i].DiceType; for (int j = 0; j < diceHands[i].Dice.Length; ++j) { if (diceHands[i].Dice[j].Orientation == null) { diceHands[i].Dice[j].Orientation = faceOrientations[(int)diceType][faceOrientations[(int)diceType].Length - 1]; } } } frameImageElements = new IImage[9] { iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 172.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 172.0f * 4, 1.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 172.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 182.0f * 4, 11.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 182.0f * 4, 1.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 182.0f * 4, 11.0f * 4, 38.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(231.0f * 4, 220.0f * 4, 11.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(241.0f * 4, 220.0f * 4, 1.0f * 4, 10.0f * 4)), iconsTileSet.ExtractImage(new RectangleF(242.0f * 4, 220.0f * 4, 11.0f * 4, 10.0f * 4)) }; } }