public static ushort GetVarTile(int tid) { int @base = tid; int @var; if ((StaticData.dbPlaces[@base].Signs.Contains(PlaceFlags.psVarDirect)) && StaticData.dbPlaces[@base].SubsLoaded > 0) { @var = RandomHelper.GetBoundedRnd(0, StaticData.dbPlaces[@base].SubsLoaded); } else { @var = 0; } return(BaseTile.GetVarID((byte)@base, (byte)@var)); }
public static ushort PtTransDoor(BaseTile tile) { ushort result; if (!tile.HasState(BaseTile.TS_SEEN)) { int @base = tile.ForeBase; int @var = tile.ForeVar; int p = (@base); int res; switch (p) { case PlaceID.pid_DoorN_Closed: res = PlaceID.pid_DoorN; break; case PlaceID.pid_DoorS_Closed: res = PlaceID.pid_DoorS; break; case PlaceID.pid_DoorW_Closed: res = PlaceID.pid_DoorW; break; case PlaceID.pid_DoorE_Closed: res = PlaceID.pid_DoorE; break; default: res = p; break; } result = BaseTile.GetVarID((byte)res, (byte)@var); } else { result = tile.Foreground; } return(result); }
private void LoadTemplate() { Data = new FieldData(); int[, ] varTiles = new int[StaticData.FieldHeight, StaticData.FieldWidth]; string varFile = "/fields/" + Sign + ".var"; if (NWResourceManager.HasStream(varFile)) { try { using (StreamReader isr = new StreamReader(NWResourceManager.LoadStream(varFile))) { for (int y = 0; y < StaticData.FieldHeight; y++) { string line = isr.ReadLine().Trim(); string[] parts = line.Split(' '); for (int x = 0; x < StaticData.FieldWidth; x++) { int @var = Convert.ToInt32(parts[x]); varTiles[y, x] = @var; } } } } catch (Exception ex) { Logger.Write("FieldEntry.loadTemplate.2(): " + ex.Message); } } try { string tplFile = "fields/" + Sign + TemplateExt; using (StreamReader isr = new StreamReader(NWResourceManager.LoadStream(tplFile))) { for (int y = 0; y < StaticData.FieldHeight; y++) { string line = isr.ReadLine(); for (int x = 0; x < StaticData.FieldWidth; x++) { char sym = line[x]; FDTile tile = new FDTile(); Data.Tiles[y, x] = tile; int bg = 0; int fg = 0; int bgv = 0; int fgv = 0; switch (sym) { case '.': bg = PlaceID.pid_Grass; break; case ',': bg = PlaceID.pid_Floor; break; case '~': bg = PlaceID.pid_Water; break; case '*': bg = PlaceID.pid_Space; break; case '^': bg = PlaceID.pid_Ground; fg = PlaceID.pid_Mountain; break; case ':': bg = PlaceID.pid_Floor; break; case 'x': bg = PlaceID.pid_Ground; fg = PlaceID.pid_Rock; break; case '+': bg = PlaceID.pid_Bifrost; bgv = varTiles[y, x]; break; case 'o': bg = PlaceID.pid_Grass; fg = PlaceID.pid_Ting; fgv = varTiles[y, x]; break; case '1': bg = PlaceID.pid_cr_y; break; case '2': bg = PlaceID.pid_cr_r; break; case '3': bg = PlaceID.pid_cr_b; break; case '4': bg = PlaceID.pid_cr_a; break; case '5': bg = PlaceID.pid_cr_l; break; case '6': bg = PlaceID.pid_cr_w; break; case '7': bg = PlaceID.pid_cr_k; break; case '8': bg = PlaceID.pid_cr_g; break; case '\\': case '/': bg = PlaceID.pid_Ground; break; } tile.BackGround = BaseTile.GetVarID((byte)bg, (byte)bgv); tile.ForeGround = BaseTile.GetVarID((byte)fg, (byte)fgv); } } } } catch (Exception ex) { Logger.Write("FieldEntry.loadTemplate.1(): " + ex.Message); } }