public void AddAttributeObject() { var root = new XmlData("root"); root.AddAttribute("attribute", DayOfWeek.Friday); Assert.AreEqual(1, root.Attributes.Count); Assert.AreEqual(new XmlAttribute("attribute", "Friday"), root.Attributes[0]); }
internal AutoAssign(XmlData dat) : base("autoId") { this.dat = dat; nextSignedId = GetValue<ushort>("nextSigned", "24576"); //0x6000 nextFullId = GetValue<ushort>("nextFull", "32768"); //0x8000 }
public void Constructor() { var root = new XmlData("name"); Assert.AreEqual("name", root.Name); Assert.AreEqual(0, root.Children.Count); Assert.AreEqual(0, root.Attributes.Count); }
private static Stream CreateMockCreepProperties() { var xmlData = new XmlData("CreepProperties"); xmlData.AddChild(CreateTestCottonCreep()); xmlData.AddChild(CreateTestGlassCreep()); return new XmlFile(xmlData).ToMemoryStream(); }
public static void CreateImageAndContentMetaData(string filePath, Size pixelSize, XmlData image) { CreateImage(filePath, pixelSize); image.AddAttribute("FileSize", new FileInfo(filePath).Length); image.AddAttribute("PixelSize", pixelSize.ToString()); }
private static Stream CreateMockGroupProperties() { var xmlData = new XmlData("Groups"); xmlData.AddChild(CreateTestGroup("Paper2", "Paper, Paper")); xmlData.AddChild(CreateTestGroup("Cloth3", "Cloth, Cloth, Cloth")); return new XmlFile(xmlData).ToMemoryStream(); }
private static XmlData CreateTestXmlData() { var root = new XmlData("Root"); AddChild1(root); AddChild2(root); return root; }
private static void AddChild1(XmlData root) { var child1 = new XmlData("Child1"); child1.AddAttribute("Attr1", "Value with space"); child1.AddAttribute("Attr2", "Value2"); root.AddChild(child1); }
protected override void LoadData(Stream fileData) { var glyph1 = new XmlData("Glyph"); glyph1.AddAttribute("Character", ' '); glyph1.AddAttribute("UV", "0 0 1 16"); glyph1.AddAttribute("AdvanceWidth", "7.34875"); glyph1.AddAttribute("LeftBearing", "0"); glyph1.AddAttribute("RightBearing", "4.21875"); var glyph2 = new XmlData("Glyph"); glyph2.AddAttribute("Character", 'a'); glyph2.AddAttribute("UV", "0 0 1 16"); glyph2.AddAttribute("AdvanceWidth", "7.34875"); glyph2.AddAttribute("LeftBearing", "0"); glyph2.AddAttribute("RightBearing", "4.21875"); var glyphs = new XmlData("Glyphs").AddChild(glyph1).AddChild(glyph2); var kerningPair = new XmlData("Kerning"); kerningPair.AddAttribute("First", " "); kerningPair.AddAttribute("Second", "a"); kerningPair.AddAttribute("Distance", "1"); var kernings = new XmlData("Kernings"); kernings.AddChild(kerningPair); var bitmap = new XmlData("Bitmap"); bitmap.AddAttribute("Name", "Verdana12Font"); bitmap.AddAttribute("Width", "128"); bitmap.AddAttribute("Height", "128"); Data = new XmlData("Font"); Data.AddAttribute("Family", "Verdana"); Data.AddAttribute("Size", "12"); Data.AddAttribute("Style", "AddOutline"); Data.AddAttribute("LineHeight", "16"); Data.AddChild(bitmap).AddChild(glyphs).AddChild(kernings); InitializeDescriptionAndMaterial(); }
public FontDescription(XmlData data) { this.data = data; GlyphDictionary = new Dictionary<char, Glyph>(); LoadFromXmlData(); converter = new TextConverter(GlyphDictionary, PixelLineHeight); }
private string GetAppPackageFilePath(XmlData appInfoData) { string fileName = appInfoData.GetAttributeValue(XmlAttributeNameOfFileName); if (String.IsNullOrEmpty(fileName)) throw new AppInfoDataMissing(XmlAttributeNameOfFileName); // ncrunch: no coverage return Path.Combine(StorageDirectory, fileName); }
private static void Main(string[] args) { if (args.Length < 2 || args.Length > 3) { Console.WriteLine("usage: Json2wmapConv.exe jsonfile wmapfile"); Console.WriteLine(" Json2wmapConv.exe wmapfile jsonfile decompile"); return; } try { var dta = new XmlData(); var fi = new FileInfo(args[0]); if (fi.Exists) if (args.Length == 3 && args[2] == "decompile") terrain.Json2Wmap.ConvertReverse(dta, args[0], args[1]); else terrain.Json2Wmap.Convert(dta, args[0], args[1]); else { Console.WriteLine("input file not found: " + fi.FullName); return; } } catch (Exception e) { Console.WriteLine("Exception : " + e); } Console.WriteLine("done"); }
public Chars GetChars(string guid, string password, XmlData data) { using (var db = new Database()) { Account a = db.Verify(guid, password, data); if (a != null) { if (a.Banned) return null; } Chars chrs = new Chars { Characters = new List<Char>(), NextCharId = 2, MaxNumChars = 1, Account = a, }; db.GetCharData(chrs.Account, chrs); db.LoadCharacters(chrs.Account, chrs); chrs.News = db.GetNews(Program.GameData, chrs.Account); chrs.OwnedSkins = Utils.GetCommaSepString(chrs.Account.OwnedSkins.ToArray()); return chrs; } }
private void TryLoadAppFromStorageData(XmlData appInfoData) { AppInfo app = AppInfoExtensions.CreateAppInfo(GetAppPackageFilePath(appInfoData), GetAppPlatform(appInfoData), GetAppGuid(appInfoData), GetAppBuildData(appInfoData)); app.SolutionFilePath = GetAppSolutionFilePath(appInfoData); availableApps.Add(app); }
protected override Stream GetDevicesXmlStream() { var devicesXmlData = new XmlData("Devices"); devicesXmlData.AddChild(EmulatorTestExtensions.CreateDefaultDeviceData()); devicesXmlData.AddChild(EmulatorTestExtensions.CreateWindows8DeviceData()); return new XmlFile(devicesXmlData).ToMemoryStream(); }
public static byte[] Convert(XmlData data, string json) { var obj = JsonConvert.DeserializeObject<json_dat>(json); byte[] dat = ZlibStream.UncompressBuffer(obj.data); var tileDict = new Dictionary<short, TerrainTile>(); for (int i = 0; i < obj.dict.Length; i++) { loc o = obj.dict[i]; tileDict[(short) i] = new TerrainTile { TileId = o.ground == null ? (ushort) 0xff : data.IdToTileType[o.ground], TileObj = o.objs == null ? null : o.objs[0].id, Name = o.objs == null ? "" : o.objs[0].name ?? "", Terrain = TerrainType.None, Region = o.regions == null ? TileRegion.None : (TileRegion) Enum.Parse(typeof (TileRegion), o.regions[0].id.Replace(' ', '_')) }; } var tiles = new TerrainTile[obj.width, obj.height]; using (var rdr = new NReader(new MemoryStream(dat))) for (int y = 0; y < obj.height; y++) for (int x = 0; x < obj.width; x++) { tiles[x, y] = tileDict[rdr.ReadInt16()]; } return WorldMapExporter.Export(tiles); }
protected override AgentData ParseData(XmlData boss) { return new BossData((BossType)Enum.Parse(typeof(BossType), boss.GetAttributeValue("Type")), boss.GetAttributeValue("Name"), boss.GetAttributeValue("MaxHp", 0.0f), boss.GetAttributeValue("Speed", 0.0f), boss.GetAttributeValue("Resistance", 0.0f), boss.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(boss)); }
private static void AssertBasicContentMetaData(XmlData xmlMetaData, ContentMetaData metaData) { AssertMinimumContentMetaData(xmlMetaData, metaData.Name, metaData.Type.ToString(), metaData.LastTimeUpdated); Assert.AreEqual(metaData.LocalFilePath, xmlMetaData.GetAttributeValue("LocalFilePath")); Assert.AreEqual(metaData.FileSize.ToString(), xmlMetaData.GetAttributeValue("FileSize")); }
private static Dictionary<TowerType, float> ParseTypeDamageModifier(XmlData boss) { return boss.GetChild("Modifiers").Attributes.ToDictionary( attribute => (TowerType)Enum.Parse(typeof(TowerType), attribute.Name), attribute => attribute.Value.Convert<float>()); }
private static Guid GetAppGuid(XmlData appInfoData) { string appGuidString = appInfoData.GetAttributeValue(XmlAttributeNameOfAppGuid); if (String.IsNullOrEmpty(appGuidString)) throw new AppInfoDataMissing(XmlAttributeNameOfAppGuid); return new Guid(appGuidString); }
public void GetChild() { var root = new XmlData("root"); new XmlData("child1", root); var child2 = new XmlData("child2", root); Assert.AreEqual(child2, root.GetChild("child2")); }
public void AddAttribute() { var root = new XmlData("root"); root.AddAttribute("attribute", "value"); Assert.AreEqual(1, root.Attributes.Count); Assert.AreEqual(new XmlAttribute("attribute", "value"), root.Attributes[0]); }
private static void Main(string[] args) { XmlConfigurator.ConfigureAndWatch(new FileInfo("log4net.config")); logger.Info("Starting Muledump Item Export"); var sw = new Stopwatch(); sw.Start(); data = new XmlData(); int items = 0; var sb = new StringBuilder("items = {\n"); sb.Append("\t'-1': [\"empty slot\", 0, -1, 0, 0, 0, 0],\n"); foreach (var item in data.Items.Values.OrderBy(i => i.ObjectType)) //foreach (var item in GameData.Items.Values.OrderBy(i => LanguageStrings[i.DisplayId.Replace("{", Empty).Replace("}", Empty)])) //foreach (var item in GameData.Items.Values.OrderBy(i => i.SlotType)) //foreach (var item in GameData.Items.Values.OrderBy(i => i.ObjectId)) //foreach (var item in GameData.Items.Values.OrderBy(i => i.Tier)) // Different sort values, have not tested these //foreach (var item in GameData.Items.Values.OrderBy(i => XY[i.ObjectId].Item1)) //foreach (var item in GameData.Items.Values.OrderBy(i => XY[i.ObjectId].Item2)) //foreach (var item in GameData.Items.Values.OrderBy(i => i.FameBonus)) //foreach (var item in GameData.Items.Values.OrderBy(i => i.FeedPower)) { logger.Info($"Adding item \"{item.ObjectId}\""); sb.Append($"\t{item.ObjectType}: [\"{LanguageStrings[item.DisplayId.Replace("{", Empty).Replace("}", Empty)] ?? item.ObjectId}\", {item.SlotType}, {item.Tier}, {XY[item.ObjectId].Item1}, {XY[item.ObjectId].Item2}, {item.FameBonus}, {item.FeedPower}],\n"); items++; } sb.Append("}"); logger.Info($"Added {items} items"); logger.Info($"Completion time: {sw.ElapsedMilliseconds}"); sw.Stop(); /**var sb2 = new StringBuilder(); foreach (var item in Language) { sb2.Append(" { \"" + item.Key + "\", \"" + item.Value + "\"},\n"); } using (var writer = new StreamWriter("dic.txt", false, Encoding.UTF8)) writer.Write(sb2.ToString()); **/ // Generate new Language dictionary /**var sb3 = new StringBuilder(); foreach (var item in XY.OrderBy(i => i.Value.Item1).ThenBy(j => j.Value.Item2)) { sb3.Append(" { \"" + item.Key + "\", new Tuple<int, int>(" + item.Value.Item1 + ", " + item.Value.Item2 + ") },\n"); } using (var writer = new StreamWriter("dic2.txt", false, Encoding.UTF8)) writer.Write(sb3.ToString());**/ // Generate new XY dictionary // Js function to grab current xy values //$.each(items, function() { ret += (" { \"" + $(this)[0] + "\", new Tuple<int, int>(" + $(this)[3] + ", " + $(this)[4] + ") },\n")}) using (var writer = new StreamWriter("output.js", false, Encoding.UTF8)) writer.Write(sb.ToString()); while (Console.ReadKey(true).Key != ConsoleKey.Escape) ; Console.ReadLine(); }
private static void SetCommand(XmlData root, string command, IEnumerable<Trigger> triggers) { var child = new XmlData("Command"); child.AddAttribute("Name", command); foreach (Trigger trigger in triggers) SetTrigger(trigger, child); root.AddChild(child); }
public static Sprite GetSpriteFromXml(string filename) { List<Monster> ret=new List<Monster>(); XmlData monsterFile=new XmlData(filename); List<XmlNode> sprite=monsterFile.GetElements("sprite"); return new Sprite(sprite[0]); }
private static void AddChild2(XmlData root) { var child2 = new XmlData("Child2"); child2.AddAttribute("Attr3", "Value3"); child2.AddAttribute("Attr4", "Value4"); child2.AddChild(new XmlData("Grandchild")); root.AddChild(child2); }
protected override AgentData ParseData(XmlData creep) { return new CreepData((CreepType)Enum.Parse(typeof(CreepType), creep.GetAttributeValue("Type")), creep.GetAttributeValue("Name"), creep.GetAttributeValue("MaxHp", 0.0f), creep.GetAttributeValue("Speed", 0.0f), creep.GetAttributeValue("Resistance", 0.0f), creep.GetAttributeValue("Gold", 0), ParseTypeDamageModifier(creep)); }
public void AddChildViaNameAndValueWillOnlyAddTheValueIfNotNull() { var node = new XmlData("Root"); Assert.IsNull(node.AddChild("Child").Value); Assert.IsNull(node.AddChild("Child", null).Value); Assert.IsEmpty(node.AddChild("Child", "").Value); Assert.AreEqual(4.ToString(), node.AddChild("Child", 4).Value); }
private static Dictionary<TowerType, float> ParseTypeDamageModifier(XmlData creep) { var typeDamageModifier = new Dictionary<TowerType, float>(); foreach (var attribute in creep.GetChild("Modifiers").Attributes) typeDamageModifier.Add((TowerType)Enum.Parse(typeof(TowerType), attribute.Name), attribute.Value.Convert<float>()); return typeDamageModifier; }
private static XmlData CreateDeepTestXmlData() { XmlData root = CreateShallowTestXmlData(); var grandchild = new XmlData("Grandchild"); grandchild.AddAttribute("Attr5", "Value5"); root.Children[1].AddChild(grandchild); return root; }
//public List<Player> GuildMembersOf(string guild) //{ // return (from i in Worlds where i.Key != 0 from e in i.Value.Players where String.Equals(e.Value.Guild, guild, StringComparison.CurrentCultureIgnoreCase) select e.Value).ToList(); //} public void Initialize() { if (CheckConfig.IsDebugOn()) { Console.WriteLine("Initializing Realm Manager..."); } GameData = new XmlData(); Behaviors = new BehaviorDb(this); GeneratorCache.Init(); MerchantLists.InitMerchatLists(GameData); AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus()); AddWorld(World.MARKET, new ClothBazaar()); AddWorld(World.TUT_ID, new Tutorial(true)); AddWorld(World.FMARKET, new Market()); Monitor = new RealmPortalMonitor(this); Task.Factory.StartNew(() => GameWorld.AutoName(1, true)) .ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default); Chat = new ChatManager(this); Commands = new CommandManager(this); if (CheckConfig.IsDebugOn()) { Console.WriteLine("Realm Manager initialized."); } }
private void InitData() { //if (null != mRuleList) // return; mRuleList = new List <RuleObject>(); XmlData root = XmlTool.GetXmlData(ERuleParam4Editor.RuleConfigUrlForEditor); if (null == root) { return; } foreach (var data in root.Childs) { RuleObject ruleObject = new RuleObject(); if (!ruleObject.XmlDeserilize(data)) { continue; } mRuleList.Add(ruleObject); } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; IntPoint p = new IntPoint { X = pos.X - (Size / 2), Y = pos.Y - (Size / 2) }; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Evil Water"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; } } } }
public void Insert_data_from_xml_into_db() { //OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; OrmLiteConfig.DialectProvider = SqliteOrmLiteDialectProvider.Instance; var element2 = XElement.Parse(xml).AnyElement("Body").AnyElement("Element1").AnyElement("Element2"); using (var db = ":memory:".OpenDbConnection()) { db.CreateTable <XmlData>(true); foreach (var element3 in element2.AllElements("Element3")) { var xmlData = new XmlData { Day = element2.AnyAttribute("day").Value, Name = element3.AnyAttribute("name").Value, Time = int.Parse(element3.FirstElement().AnyAttribute("time").Value), Amount = int.Parse(element3.FirstElement().FirstElement().AnyAttribute("amount").Value), Price = decimal.Parse(element3.FirstElement().FirstElement().AnyAttribute("price").Value), }; db.Insert(xmlData); } db.Select <XmlData>().ForEach(x => Console.WriteLine(TypeSerializer.SerializeToString(x))); } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileBlue]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity dragonwallred = Entity.Resolve(world.Manager, "Dragon Wall Blue"); dragonwallred.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(dragonwallred); } else if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileBlue]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[DragonTileCream]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; IntPoint p = new IntPoint { X = pos.X - (Size / 2), Y = pos.Y - (Size / 2) }; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; } if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + p.X, y + p.Y].Clone(); tile.TileId = dat.IdToTileType["Red Quad"]; tile.ObjType = 0; world.Map[x + p.X, y + p.Y] = tile; Entity en = Entity.Resolve(world.Manager, "Realm Portal"); en.Move(x + p.X + 0.5f, y + p.Y + 0.5f); world.EnterWorld(en); } } } }
//public List<Player> GuildMembersOf(string guild) //{ // return (from i in Worlds where i.Key != 0 from e in i.Value.Players where String.Equals(e.Value.Guild, guild, StringComparison.CurrentCultureIgnoreCase) select e.Value).ToList(); //} public void Initialize() { log.Info("Initializing Realm Manager..."); GameData = new XmlData(); Behaviors = new BehaviorDb(this); GeneratorCache.Init(); MerchantLists.InitMerchatLists(GameData); AddWorld(World.NEXUS_ID, Worlds[0] = new Nexus()); AddWorld(World.MARKET, new ClothBazaar()); AddWorld(World.SKIN_SHOP, new SkinShop()); AddWorld(World.TEST_ID, new Test()); AddWorld(World.TUT_ID, new Tutorial(true)); AddWorld(World.DAILY_QUEST_ID, new DailyQuestRoom()); Monitor = new RealmPortalMonitor(this); Task.Factory.StartNew(() => GameWorld.AutoName(1, true)).ContinueWith(_ => AddWorld(_.Result), TaskScheduler.Default); Chat = new ChatManager(this); Commands = new CommandManager(this); log.Info("Realm Manager initialized."); }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2; if (r <= 10) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity lord = Entity.Resolve(world.Manager, "Phoenix Lord"); lord.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(lord); Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) { container.Inventory[i] = items[i]; } container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
public static byte[] Convert(XmlData data, string json) { var obj = JsonConvert.DeserializeObject <json_dat>(json); byte[] dat = ZlibStream.UncompressBuffer(obj.data); var tileDict = new Dictionary <short, TerrainTile>(); for (int i = 0; i < obj.dict.Length; i++) { loc o = obj.dict[i]; tileDict[(short)i] = new TerrainTile { TileId = o.ground == null ? (ushort)0xff : data.IdToTileType[o.ground], TileObj = o.objs == null ? null : o.objs[0].id, Name = o.objs == null ? "" : o.objs[0].name ?? "", Terrain = TerrainType.None, Region = o.regions == null ? TileRegion.None : (TileRegion)Enum.Parse(typeof(TileRegion), o.regions[0].id.Replace(' ', '_')) }; } var tiles = new TerrainTile[obj.width, obj.height]; using (var rdr = new NReader(new MemoryStream(dat))) for (int y = 0; y < obj.height; y++) { for (int x = 0; x < obj.width; x++) { tiles[x, y] = tileDict[rdr.ReadInt16()]; } } return(WorldMapExporter.Export(tiles)); }
public void RenderSetPiece(World world, IntPoint pos) { var p = new int[Size, Size]; const double SCALE = 5.5; for (int x = 0; x < Size; x++) //Lava { double t = (double)x / Size * Math.PI; double x_ = t / Math.Sqrt(2) - Math.Sin(t) / (SCALE * Math.Sqrt(2)); double y1 = t / Math.Sqrt(2) - 2 * Math.Sin(t) / (SCALE * Math.Sqrt(2)); double y2 = t / Math.Sqrt(2) + Math.Sin(t) / (SCALE * Math.Sqrt(2)); y1 /= Math.PI / Math.Sqrt(2); y2 /= Math.PI / Math.Sqrt(2); var y1_ = (int)Math.Ceiling(y1 * Size); var y2_ = (int)Math.Floor(y2 * Size); for (int i = y1_; i < y2_; i++) { p[x, i] = 1; } } for (int x = 0; x < Size; x++) //Floor { for (int y = 0; y < Size; y++) { if (p[x, y] == 1 && rand.Next() % 5 == 0) { p[x, y] = 2; } } } int r = rand.Next(0, 4); //Rotation for (int i = 0; i < r; i++) { p = SetPieces.rotateCW(p); } p[20, 20] = 2; XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; y++) { if (p[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (p[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = dat.IdToObjectType[Floor]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity demon = Entity.Resolve(world.Manager, "Red Demon"); demon.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(demon); var container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) { container.Inventory[i] = items[i]; } container.Move(pos.X + 20.5f, pos.Y + 20.5f); world.EnterWorld(container); }
public XmlDocumentProvider(IConfiguration configuration, ILogger logger) { logger.Debug("Loading XML data"); XmlData = new XmlData(configuration.XmlDataPath, logger); }
public Wmap(XmlData dat) { this.dat = dat; }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[27, 27]; int[,] q = (int[, ])quarter.Clone(); for (int y = 0; y < 14; y++) //Top left { for (int x = 0; x < 14; x++) { t[x, y] = q[x, y]; } } q = SetPieces.reflectHori(q); //Top right for (int y = 0; y < 14; y++) { for (int x = 0; x < 14; x++) { t[13 + x, y] = q[x, y]; } } q = SetPieces.reflectVert(q); //Bottom right for (int y = 0; y < 14; y++) { for (int x = 0; x < 14; x++) { t[13 + x, 13 + y] = q[x, y]; } } q = SetPieces.reflectHori(q); //Bottom left for (int y = 0; y < 14; y++) { for (int x = 0; x < 14; x++) { t[x, 13 + y] = q[x, y]; } } for (int y = 1; y < 4; y++) //Opening { for (int x = 8; x < 19; x++) { t[x, y] = 2; } } t[12, 0] = t[13, 0] = t[14, 0] = 2; int r = rand.Next(0, 4); //Rotation for (int i = 0; i < r; i++) { t = SetPieces.rotateCW(t); } t[13 + 6, 13] = 3; XmlData dat = world.Manager.Resources.GameData; for (int x = 0; x < 27; x++) //Rendering { for (int y = 0; y < 27; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[Wall]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { Entity cyclops = Entity.Resolve(world.Manager, 0x0928); cyclops.Move(pos.X + x, pos.Y + y); world.EnterWorld(cyclops); } } } }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[33, 33]; for (int x = 0; x < 33; x++) //Grassing { for (int y = 0; y < 33; y++) { if (Math.Abs(x - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95 && Math.Abs(y - Size / 2) / (Size / 2.0) + rand.NextDouble() * 0.3 < 0.95) { t[x, y] = 1; } } } for (int x = 12; x < 21; x++) //Outer { for (int y = 4; y < 29; y++) { t[x, y] = 2; } } t = SetPieces.rotateCW(t); for (int x = 12; x < 21; x++) { for (int y = 4; y < 29; y++) { t[x, y] = 2; } } for (int x = 13; x < 20; x++) //Inner { for (int y = 5; y < 28; y++) { t[x, y] = 4; } } t = SetPieces.rotateCW(t); for (int x = 13; x < 20; x++) { for (int y = 5; y < 28; y++) { t[x, y] = 4; } } for (int i = 0; i < 4; i++) //Ext { for (int x = 13; x < 20; x++) { for (int y = 5; y < 7; y++) { t[x, y] = 3; } } t = SetPieces.rotateCW(t); } for (int i = 0; i < 4; i++) //Pillars { t[13, 7] = rand.Next() % 3 == 0 ? 6 : 5; t[19, 7] = rand.Next() % 3 == 0 ? 6 : 5; t[13, 10] = rand.Next() % 3 == 0 ? 6 : 5; t[19, 10] = rand.Next() % 3 == 0 ? 6 : 5; t = SetPieces.rotateCW(t); } Noise noise = new Noise(Environment.TickCount); //Perlin noise for (int x = 0; x < 33; x++) { for (int y = 0; y < 33; y++) { if (noise.GetNoise(x / 33f * 8, y / 33f * 8, .5f) < 0.2) { t[x, y] = 0; } } } XmlData dat = world.Manager.GameData; for (int x = 0; x < 33; x++) //Rendering { for (int y = 0; y < 33; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Grass]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[TileDark]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Tile]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Stone]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Stone]; tile.ObjType = dat.IdToObjectType[PillarA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Stone]; tile.ObjType = dat.IdToObjectType[PillarB]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity skull = Entity.Resolve(world.Manager, "Skull Shrine"); //Skulls! skull.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(skull); }
public void RenderSetPiece(World world, IntPoint pos) { int[,] t = new int[31, 40]; for (int x = 0; x < 13; x++) //Moats { for (int y = 0; y < 13; y++) { if ((x == 0 && (y < 3 || y > 9)) || (y == 0 && (x < 3 || x > 9)) || (x == 12 && (y < 3 || y > 9)) || (y == 12 && (x < 3 || x > 9))) { continue; } t[x + 0, y + 0] = t[x + 18, y + 0] = 2; t[x + 0, y + 27] = t[x + 18, y + 27] = 2; } } for (int x = 3; x < 28; x++) { for (int y = 3; y < 37; y++) { if (x < 6 || x > 24 || y < 6 || y > 33) { t[x, y] = 2; } } } for (int x = 7; x < 24; x++) //Floor { for (int y = 7; y < 33; y++) { t[x, y] = rand.Next() % 3 == 0 ? 0 : 1; } } for (int x = 0; x < 7; x++) //Perimeter { for (int y = 0; y < 7; y++) { if ((x == 0 && y != 3) || (y == 0 && x != 3) || (x == 6 && y != 3) || (y == 6 && x != 3)) { continue; } t[x + 3, y + 3] = t[x + 21, y + 3] = 4; t[x + 3, y + 30] = t[x + 21, y + 30] = 4; } } for (int x = 6; x < 25; x++) { t[x, 6] = t[x, 33] = 4; } for (int y = 6; y < 34; y++) { t[6, y] = t[24, y] = 4; } for (int x = 13; x < 18; x++) //Bridge { for (int y = 3; y < 7; y++) { t[x, y] = 6; } } for (int x = 0; x < 31; x++) //Corruption { for (int y = 0; y < 40; y++) { if (t[x, y] == 1 || t[x, y] == 0) { continue; } double p = rand.NextDouble(); if (t[x, y] == 6) { if (p < 0.4) { t[x, y] = 0; } continue; } if (p < 0.1) { t[x, y] = 1; } else if (p < 0.4) { t[x, y]++; } } } //Boss & Chest t[15, 27] = 7; t[15, 20] = 8; int r = rand.Next(0, 4); for (int i = 0; i < r; i++) //Rotation { t = SetPieces.rotateCW(t); } int w = t.GetLength(0), h = t.GetLength(1); XmlData dat = world.Manager.GameData; for (int x = 0; x < w; x++) //Rendering { for (int y = 0; y < h; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[WaterA]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[WaterB]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[WallA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; world.Map[x + pos.X, y + pos.Y] = tile; Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Bridge]; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 7) { Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) { container.Inventory[i] = items[i]; } container.Move(pos.X + x + 0.5f, pos.Y + y + 0.5f); world.EnterWorld(container); } else if (t[x, y] == 8) { Entity cyclops = Entity.Resolve(world.Manager, "Cyclops God"); cyclops.Move(pos.X + x, pos.Y + y); world.EnterWorld(cyclops); } } } }
private void SerializeBonus(XmlData data, XmlDocument doc, Account acc, Char chr, int baseFame, bool firstBorn) { double bonus = 0; if (chr.CharacterId < 2) //Ancestor { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Ancestor"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.AncestorDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor(((baseFame + Math.Floor(bonus)) * 0.1) + 20)).ToString(); bonus = Math.Floor(bonus) + ((baseFame + Math.Floor(bonus)) * 0.1) + 20; doc.DocumentElement.AppendChild(x); } //Legacy Builder??? if (ShotsThatDamage == 0) //Pacifist { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Pacifist"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.PacifistDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (PotionsDrunk == 0) //Thirsty { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Thirsty"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.ThirstyDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (SpecialAbilityUses == 0) //Mundane { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Mundane"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.MundaneDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (Teleports == 0) //Boots on the Ground { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.BootsOnGround"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.BootsOnGroundDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.25)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; doc.DocumentElement.AppendChild(x); } if (PirateCavesCompleted > 0 && UndeadLairsCompleted > 0 && AbyssOfDemonsCompleted > 0 && SnakePitsCompleted > 0 && SpiderDensCompleted > 0 && SpriteWorldsCompleted > 0 && TombsCompleted > 0 && TrenchesCompleted > 0 && JunglesCompleted > 0 && ManorsCompleted > 0) //Tunnel Rat { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.TunnelRat"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.TunnelRatDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)GodKills / (GodKills + MonsterKills) > 0.1) //Enemy of the Gods { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.GodEnemy"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.GodEnemyDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)GodKills / (GodKills + MonsterKills) > 0.5) //Slayer of the Gods { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.GodSlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.GodSlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (OryxKills > 0) //Oryx Slayer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.OryxSlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.OryxSlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.25) //Accurate { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Accurate"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.AccurateDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.5) //Sharpshooter { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.SharpShooter"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.SharpShooterDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if ((double)ShotsThatDamage / Shots > 0.75) //Sniper { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Sniper"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.SniperDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (TilesUncovered > 1000000) //Explorer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Explorer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.ExplorerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.05)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; doc.DocumentElement.AppendChild(x); } if (TilesUncovered > 4000000) //Cartographer { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.Cartographer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.CartographerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.05)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; doc.DocumentElement.AppendChild(x); } if (LevelUpAssists > 100) //Team Player { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.TeamPlayer"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.TeamPlayerDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (LevelUpAssists > 1000) //Leader of Men { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.LeaderOfMen"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.LeaderOfMenDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (QuestsCompleted > 1000) //Doer of Deeds { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.DoerOfDeeds"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.DoerOfDeedsDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } if (CubeKills == 0) //Friend of the Cubes { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.CubeFriend"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.CubeFriendDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } double bo = 0; for (int i = 0; i < 4; i++) //Well Equipped { if (chr.Equipment[i] == -1) { continue; } int b; using (Database db = new Database()) b = db.getSerialInfo(chr.Equipment[i], data).FameBonus; if (b > 0) { bo += (baseFame + Math.Floor(bonus)) * b / 100; } } if (bo > 0) { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.WellEquipped"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.WellEquippedDescription"; x.Attributes.Append(descAttr); x.InnerText = ((int)bo).ToString(); bonus = Math.Floor(bonus) + Math.Floor(bo); doc.DocumentElement.AppendChild(x); } if (firstBorn) { XmlElement x = doc.CreateElement("Bonus"); XmlAttribute idAttr = doc.CreateAttribute("id"); idAttr.Value = "FameBonus.FirstBorn"; x.Attributes.Append(idAttr); XmlAttribute descAttr = doc.CreateAttribute("desc"); descAttr.Value = "FameBonus.FirstBornDescription"; x.Attributes.Append(descAttr); x.InnerText = (Math.Floor((baseFame + Math.Floor(bonus)) * 0.1)).ToString(); bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; doc.DocumentElement.AppendChild(x); } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; int DarkGrassradiu = 17; int sandRadius = 17; int waterRadius = 14; List <IntPoint> border = new List <IntPoint>(); int[,] o = new int[Size, Size]; int[,] t = new int[Size, Size]; for (int y = 0; y < Size; y++) //Outer { for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= sandRadius) { t[x, y] = 2; } } } for (int y = 0; y < Size; y++) //Water { for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= waterRadius) { t[x, y] = 3; } } } for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (((x > 5 && x < DarkGrassradiu) || (x < Size - 5 && x > Size - DarkGrassradiu) || (y > 5 && y < DarkGrassradiu) || (y < Size - 5 && y > Size - DarkGrassradiu)) && o[x, y] == 0 && t[x, y] == 1) { t[x, y] = 4; } } } for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjId = dat.IdToObjectType[Tree]; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Sand]; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Water]; world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjId = dat.IdToObjectType[Tree]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Obstacles[x + pos.X, y + pos.Y] = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity gship = Entity.Resolve(world.Manager, "Ghost Ship"); gship.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(gship); Entity gshipanchor = Entity.Resolve(world.Manager, "Ghost Ship Anchor"); gshipanchor.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(gshipanchor); }
public void RenderSetPiece(World world, IntPoint pos) { int outerRadius = 13; int waterRadius = 10; int islandRadius = 3; List <IntPoint> border = new List <IntPoint>(); int[,] t = new int[Size, Size]; for (int y = 0; y < Size; y++) //Outer { for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= outerRadius) { t[x, y] = 1; } } } for (int y = 0; y < Size; y++) //Water { for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= waterRadius) { t[x, y] = 2; if (waterRadius - r < 1) { border.Add(new IntPoint(x, y)); } } } } for (int y = 0; y < Size; y++) //Island { for (int x = 0; x < Size; x++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy); if (r <= islandRadius) { t[x, y] = 1; if (islandRadius - r < 1) { border.Add(new IntPoint(x, y)); } } } } HashSet <IntPoint> trees = new HashSet <IntPoint>(); while (trees.Count < border.Count * 0.5) { trees.Add(border[rand.Next(0, border.Count)]); } foreach (IntPoint i in trees) { t[i.X, i.Y] = 3; } XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Water]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[Tree]; tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140); if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity giant = Entity.Resolve(world.Manager, "Oasis Giant"); giant.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(giant); Container container = new Container(world.Manager, 0x0501, null, false); Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray(); for (int i = 0; i < items.Length; i++) { container.Inventory[i] = items[i]; } container.Move(pos.X + 15.5f, pos.Y + 15.5f); world.EnterWorld(container); }
public int CalculateTotal(XmlData data, Account acc, Char chr, int baseFame, out bool firstBorn) { double bonus = 0; if (chr.CharacterId < 2) //Ancestor { bonus = Math.Floor(bonus) + ((baseFame + Math.Floor(bonus)) * 0.1) + 20; } //Legacy Builder??? if (ShotsThatDamage == 0) //Pacifist { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (PotionsDrunk == 0) //Thirsty { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (SpecialAbilityUses == 0) //Mundane { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (Teleports == 0) //Boots on the Ground { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.25; } if (PirateCavesCompleted > 0 && UndeadLairsCompleted > 0 && AbyssOfDemonsCompleted > 0 && SnakePitsCompleted > 0 && SpiderDensCompleted > 0 && SpriteWorldsCompleted > 0 && TombsCompleted > 0 && TrenchesCompleted > 0 && JunglesCompleted > 0 && ManorsCompleted > 0) //Tunnel Rat { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)GodKills / (GodKills + MonsterKills) > 0.1) //Enemy of the Gods { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)GodKills / (GodKills + MonsterKills) > 0.5) //Slayer of the Gods { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (OryxKills > 0) //Oryx Slayer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.25) //Accurate { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.5) //Sharpshooter { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if ((double)ShotsThatDamage / Shots > 0.75) //Sniper { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (TilesUncovered > 1000000) //Explorer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; } if (TilesUncovered > 4000000) //Cartographer { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.05; } if (LevelUpAssists > 100) //Team Player { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (LevelUpAssists > 1000) //Leader of Men { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (QuestsCompleted > 1000) //Doer of Deeds { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } if (CubeKills == 0) //Friend of the Cubes { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; } double eq = 0; for (int i = 0; i < 4; i++) //Well Equipped { if (chr.Equipment[i] == -1) { continue; } int b; using (Database db = new Database()) b = db.getSerialInfo(chr.Equipment[i], data).FameBonus; if (b > 0) { eq += (baseFame + Math.Floor(bonus)) * b / 100; } } bonus = Math.Floor(bonus) + Math.Floor(eq); if (baseFame + Math.Floor(bonus) > acc.Stats.BestCharFame) //First Born { bonus = Math.Floor(bonus) + (baseFame + Math.Floor(bonus)) * 0.1; firstBorn = true; } else { firstBorn = false; } return((int)(baseFame + Math.Floor(bonus))); }
public Wmap(XmlData data) { this.data = data; }
public void Load(string path, SerializationFormat expectedFormat, bool createBackup) { FileManager.TryRegisterExternalFile(path); var file = new AmfFile(path); var dataVersion = file.GetString("version"); if (file.Error != null) { var box = new ExceptionBox(); box.Title = "Could not read file."; box.Message = "TiTsEd could not read this file correctly. Maybe it was corrupted or generated by an old version of Flash. Continuing may make TiTsEd unstable or cause it to corrupt the file. It is strongly advised that you cancel this operation."; box.Path = file.FilePath; box.ExceptionMessage = file.Error.Mesg; box.IsWarning = true; var result = box.ShowDialog(ExceptionBoxButtons.Continue, ExceptionBoxButtons.Cancel); Logger.Error(file.Error.Mesg); if (result != ExceptionBoxResult.Continue) { return; } } else if (String.IsNullOrEmpty(dataVersion)) { var box = new ExceptionBox(); box.Title = "File version too old."; box.Message = "TiTsEd may not be able to read this file correctly as it was generated by an older version of T**s. Continuing may make TiTsEd unstable or cause it to corrupt the file. It is strongly advised that you cancel this operation."; box.IsWarning = true; var result = box.ShowDialog(ExceptionBoxButtons.Continue, ExceptionBoxButtons.Cancel); Logger.Error(String.Format("{0} T**s data version: {1}.", box.Title, dataVersion)); if (result != ExceptionBoxResult.Continue) { return; } } // I would like to test dataVersion here some day to ensure that it's not too old of a version, // however, as long as Fen keeps occasionally pushing crappy version strings (e.g. 0.8.4.8d), // that can't happen. Ideally, I'd like to see them switch to a segmented version system. // Sanity checks: see if the save can be re-saved as-is OR if any of the top-level property names are invalid as identifiers. if (!file.CanBeSaved(SerializationFormat.Slot) || HasBadPropertyNames(file)) { var box = new ExceptionBox(); box.Title = "File could not be read correctly."; box.Message = "TiTsEd could not read this file correctly, it is likely corrupted. Cancelling this operation."; box.IsWarning = true; box.ShowDialog(ExceptionBoxButtons.OK); Logger.Error(String.Format("{0} T**s data version: {1}.", box.Title, dataVersion)); return; } // Sanity check: ensure the actual format matches the expected format (just a warning to the user about mixing up the formats). if (file.Format != expectedFormat) { var box = new ExceptionBox(); box.Title = "File format different from expected format."; box.Message = "The file is actually a " + (file.Format == SerializationFormat.Slot ? "\"Slot\"" : "\"Save to File\"") + " format save, but it was loaded as though it were a " + (expectedFormat == SerializationFormat.Slot ? "\"Slot\"" : "\"Save to File\"") + " format save.\n\nThe two formats are not compatible, so care should be taken to ensure you do not confuse the two, since T**s can only load each format in a specific way. Attempting to load a \"Slot\" save as though it were a \"Save to File\" save, or vice versa, will cause T**s to think the save is corrupt, at best, or see the save deleted, at worse. Do not mix them up."; box.IsWarning = true; box.ShowDialog(ExceptionBoxButtons.OK); } if (createBackup) { FileManager.CreateBackup(path); } _currentFile = file; XmlData.Select(XmlData.Files.T**s); Data = XmlData.Current; Game = new GameVM(_currentFile, Game); OnPropertyChanged("Data"); OnPropertyChanged("Game"); OnPropertyChanged("HasData"); UpdateAppTitle(); VM.Instance.NotifySaveRequiredChanged(false); if (FileOpened != null) { FileOpened(null, null); } }
public void XmlFileData_WhenMultipleNotTyped_ExpectAllVisibleInTestExplorer(XmlData mySample, string expectedResult) { Assert.Equal(typeof(SampleFakeObject), mySample.Data.GetType()); Assert.Equal(expectedResult, (mySample.Data as SampleFakeObject)?.SampleProp); }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[25, 26]; for (int x = 2; x < 23; x++) //Floor { for (int y = 1; y < 24; y++) { t[x, y] = rand.Next() % 10 == 0 ? 0 : 1; } } for (int y = 1; y < 24; y++) //Perimeters { t[2, y] = t[22, y] = 2; } for (int x = 2; x < 23; x++) { t[x, 23] = 2; } for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { t[x + 1, y] = t[x + 21, y] = 2; } } for (int x = 0; x < 5; x++) { for (int y = 0; y < 5; y++) { if ((x == 0 && y == 0) || (x == 0 && y == 4) || (x == 4 && y == 0) || (x == 4 && y == 4)) { continue; } t[x, y + 21] = t[x + 20, y + 21] = 2; } } for (int y = 0; y < 6; y++) //Pillars { t[9, 4 + 3 * y] = t[15, 4 + 3 * y] = 4; } for (int x = 0; x < 25; x++) //Corruption { for (int y = 0; y < 26; y++) { if (t[x, y] == 1 || t[x, y] == 0) { continue; } double p = rand.NextDouble(); if (p < 0.1) { t[x, y] = 1; } else if (p < 0.4) { t[x, y]++; } } } int r = rand.Next(0, 4); for (int i = 0; i < r; i++) //Rotation { t = SetPieces.rotateCW(t); } int w = t.GetLength(0), h = t.GetLength(1); XmlData dat = world.Manager.GameData; for (int x = 0; x < w; x++) //Rendering { for (int y = 0; y < h; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[WallA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; world.Map[x + pos.X, y + pos.Y] = tile; Entity wall = Entity.Resolve(world.Manager, dat.IdToObjectType[WallB]); wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f); world.EnterWorld(wall); } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[PillarA]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[PillarB]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } //Boss Entity lich = Entity.Resolve(world.Manager, "Lich"); lich.Move(pos.X + Size / 2, pos.Y + Size / 2); world.EnterWorld(lich); }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.Resources.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 1 Light"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Stone Path"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 3) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 2 Dark"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 4) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 3 Dark"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 5) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Dirt"]; tile.ObjType = dat.IdToObjectType["Japanese Prayer Tree"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 6) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 3 Dark"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 7) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 3 Dark"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity statue = Entity.Resolve(world.Manager, "Encounter Altar"); statue.Move(pos.X + x + .5f, pos.Y + y + .5f); world.EnterWorld(statue); } else if (SetPiece[y, x] == 8) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 1 Light"]; tile.ObjType = dat.IdToObjectType["Japanese Trees Pink"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 9) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity statue = Entity.Resolve(world.Manager, "Jade Statue"); statue.Move(pos.X + x + .5f, pos.Y + y + .5f); world.EnterWorld(statue); } else if (SetPiece[y, x] == 10) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity statue = Entity.Resolve(world.Manager, "Garnet Statue"); statue.Move(pos.X + x + .5f, pos.Y + y + .5f); world.EnterWorld(statue); } else if (SetPiece[y, x] == 11) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = dat.IdToObjectType["Japanese Temple Gate 1"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 12) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = dat.IdToObjectType["Japanese Temple Gate 5"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 13) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = dat.IdToObjectType["Japanese Temple Gate 4"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 14) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = dat.IdToObjectType["Japanese Wall Outside 2"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 15) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Hanami Grass 1 Light"]; tile.ObjType = dat.IdToObjectType["Japanese Tree Mini Red"]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 16) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType["Japanese Rock"]; tile.ObjType = dat.IdToObjectType[Gate3]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } }
public void RenderSetPiece(World world, IntPoint pos) { XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) { for (int y = 0; y < Size; y++) { if (SetPiece[y, x] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor1]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor2]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor3]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor4]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 5) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Middle]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 6) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 7) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air2]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 8) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air3]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 9) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Air4]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (SetPiece[y, x] == 10) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Middle]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; Entity elemental = Entity.Resolve(world.Manager, "Maurth the Succubus Queen"); elemental.Move(pos.X + Size / 2f, pos.Y + Size / 2f); world.EnterWorld(elemental); } } } }
public void RenderSetPiece(World world, IntPoint pos) { var t = new int[81, 81]; for (int x = 0; x < Size; x++) //Flooring { for (int y = 0; y < Size; y++) { double dx = x - (Size / 2.0); double dy = y - (Size / 2.0); double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2; if (r <= 35) { t[x, y] = 1; } } } for (int x = 0; x < 17; x++) //Center { for (int y = 0; y < 17; y++) { if (Center[x, y] != 0) { t[32 + x, 32 + y] = 2; } } } t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 4; t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4; t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4; t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4; t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4; XmlData dat = world.Manager.GameData; for (int x = 0; x < Size; x++) //Rendering { for (int y = 0; y < Size; y++) { if (t[x, y] == 1) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Central]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 3) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Central]; tile.ObjType = dat.IdToObjectType[Pillar]; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3); if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 4) { WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = dat.IdToObjectType[Pillar]; tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4); if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } } } Entity sphinx = Entity.Resolve(world.Manager, "Grand Sphinx"); sphinx.Move(pos.X + 40.5f, pos.Y + 40.5f); world.EnterWorld(sphinx); }
public void RenderSetPiece(World world, IntPoint pos) { int w = rand.Next(19, 22), h = rand.Next(19, 22); int[,] t = new int[w, h]; for (int x = 0; x < w; x++) //Perimeter { t[x, 0] = 1; t[x, h - 1] = 1; } for (int y = 0; y < h; y++) { t[0, y] = 1; t[w - 1, y] = 1; } int midPtH = h / 2 + rand.Next(-2, 3); //Mid hori wall int sepH = rand.Next(2, 4); if (rand.Next() % 2 == 0) { for (int x = sepH; x < w; x++) { t[x, midPtH] = 1; } } else { for (int x = 0; x < w - sepH; x++) { t[x, midPtH] = 1; } } int begin, end; if (rand.Next() % 2 == 0) { begin = 0; end = midPtH; } else { begin = midPtH; end = h; } int midPtV = w / 2 + rand.Next(-2, 3); //Mid vert wall int sepW = rand.Next(2, 4); if (rand.Next() % 2 == 0) { for (int y = begin + sepW; y < end; y++) { t[midPtV, y] = 1; } } else { for (int y = begin; y < end - sepW; y++) { t[midPtV, y] = 1; } } for (int x = 0; x < w; x++) //Flooring { for (int y = 0; y < h; y++) { if (t[x, y] == 0) { t[x, y] = 2; } } } for (int x = 0; x < w; x++) //Corruption { for (int y = 0; y < h; y++) { if (rand.Next() % 2 == 0) { t[x, y] = 0; } } } int rotation = rand.Next(0, 4); //Rotation for (int i = 0; i < rotation; i++) { t = SetPieces.rotateCW(t); } w = t.GetLength(0); h = t.GetLength(1); XmlData dat = world.Manager.Resources.GameData; for (int x = 0; x < w; x++) //Rendering { for (int y = 0; y < h; y++) { if (t[x, y] == 1) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.ObjType = dat.IdToObjectType[Wall]; if (tile.ObjId == 0) { tile.ObjId = world.GetNextEntityId(); } world.Map[x + pos.X, y + pos.Y] = tile; } else if (t[x, y] == 2) { var tile = world.Map[x + pos.X, y + pos.Y].Clone(); tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0; world.Map[x + pos.X, y + pos.Y] = tile; } } } }
void Initialize() { ExceptionBox box; foreach (string xmlFile in XmlData.Files.All) { var xmlResult = XmlData.LoadXml(xmlFile); switch (xmlResult) { case XmlLoadingResult.Success: break; case XmlLoadingResult.InvalidFile: box = new ExceptionBox(); box.Title = "Fatal error"; box.Message = "The " + xmlFile + " file is out of date. Did you replace the bundled XML?"; box.Path = Environment.CurrentDirectory; box.ShowDialog(ExceptionBoxButtons.Quit); Shutdown(); return; case XmlLoadingResult.MissingFile: box = new ExceptionBox(); box.Title = "Fatal error"; box.Message = "The " + xmlFile + " file could not be found. Did you try to run the program from the archive without extracting all the files first?"; box.Path = Environment.CurrentDirectory; box.ShowDialog(ExceptionBoxButtons.Quit); Shutdown(); return; case XmlLoadingResult.NoPermission: box = new ExceptionBox(); box.Title = "Fatal error"; box.Message = "The " + xmlFile + " file was already in use or this application does not have permission to read from the folder where it is located."; box.Path = Environment.CurrentDirectory; box.ShowDialog(ExceptionBoxButtons.Quit); Shutdown(); return; default: throw new NotImplementedException(); } } VM.Create(); FileManager.BuildPaths(); var directories = FileManager.GetDirectories().ToArray(); // Load all on startup to check for errors var result = ExceptionBoxResult.Continue; switch (FileManager.Result) { case FileEnumerationResult.NoPermission: box = new ExceptionBox(); box.Title = "Could not scan some folders."; box.Message = "TiTsEd did not get permission to read a folder or file.\nSome files will not be displayed in the Open/Save menus."; box.Path = FileManager.ResultPath; box.IsWarning = true; result = box.ShowDialog(ExceptionBoxButtons.Quit, ExceptionBoxButtons.Continue); break; case FileEnumerationResult.Unreadable: box = new ExceptionBox(); box.Title = "Could not read some folders."; box.Message = "TiTsEd could not read a folder or file.\nSome files will not be displayed in the Open/Save menus."; box.Path = FileManager.ResultPath; box.IsWarning = true; result = box.ShowDialog(ExceptionBoxButtons.Quit, ExceptionBoxButtons.Continue); break; } if (result == ExceptionBoxResult.Quit) { Shutdown(); return; } #if DEBUG var file = AutoLoad(directories); //new AmfFile("e:\\plainObject.sol").TestSerialization(); //new AmfFile("e:\\unicode.sol").TestSerialization(); //DebugStatuses(file); //RunSerializationTest(set); //ParsePerks(); //ImportStatuses(); //ImportFlags(); #endif }
private void ApplyLicense(string licenseKey) { LicenseExists = false; XmlData.Clear(); RaisePropertyChanged(nameof(XmlData)); LicenseInfo.Key = licenseKey; if (string.IsNullOrWhiteSpace(licenseKey)) { FailureOccurred = false; ShowFailure = false; return; } XmlData.Clear(); var xmlList = _licenseService.LoadXmlFromLicense(LicenseInfo.Key); if (xmlList == null) { FailureOccurred = false; ShowFailure = false; return; } xmlList.ForEach(x => { if (string.Equals(x.Name, "Expiration")) { x.Name = "Maintenance End Date"; } XmlData.Add(x); }); var validationContext = _licenseValidationService.ValidateLicense(licenseKey); if (validationContext.HasErrors) { var xmlFirstError = _licenseValidationService.ValidateXml(licenseKey).GetBusinessRuleErrors().FirstOrDefault(); if (xmlFirstError == null) { var normalFirstError = _licenseValidationService.ValidateLicense(LicenseInfo.Key).GetBusinessRuleErrors().FirstOrDefault(); if (normalFirstError != null) { ShowFailure = true; FailureMessage = normalFirstError.Message; } } else { ShowFailure = true; FailureMessage = xmlFirstError.Message; } } else { FailureOccurred = false; ShowFailure = false; } LicenseExists = true; RaisePropertyChanged(nameof(XmlData)); }
protected void Page_Load(object sender, EventArgs e) { // Setup info/error message placeholder if (MessagesPlaceHolder != null) { MessagesPlaceHolder.UseRelativePlaceHolder = false; form.EnsureMessagesPlaceholder(MessagesPlaceHolder); } // Load default properties from XML XmlDocument xml = new XmlDocument(); xml.Load(ResolveUrl(HttpContext.Current.Server.MapPath(PortalFormHelper.BEFOREPROPERTIESDEFINITION))); // Load UI element and element's page template (if any) mUIElementInfo = UIElementInfoProvider.GetUIElementInfo(QueryHelper.GetInteger("elementID", 0)); if (mUIElementInfo != null) { PageTemplateInfo pti = null; if (mUIElementInfo.ElementType == UIElementTypeEnum.PageTemplate) { pti = PageTemplateInfoProvider.GetPageTemplateInfo(mUIElementInfo.ElementPageTemplateID); } form.Enabled = ((SystemContext.DevelopmentMode || mUIElementInfo.ElementIsCustom) && (!UIElementInfoProvider.AllowEditOnlyCurrentModule || (mUIElementInfo.ElementResourceID == QueryHelper.GetInteger("moduleId", 0)))); // Create form info FormInfo fi = (pti != null) ? pti.PageTemplatePropertiesForm : PortalFormHelper.GetUIElementDefaultPropertiesForm(UIElementPropertiesPosition.Both); form.FormInformation = fi; // Load data row from properties DataRow dr = fi.GetDataRow(); fi.LoadDefaultValues(dr); if ((mUIElementInfo == null) || !mUIElementInfo.IsApplication) { fi.RemoveFormField("DescriptionLink"); } XmlData customData = new XmlData(); // Load element properties XmlData data = new XmlData(); data.AllowMacros = true; data.LoadData(mUIElementInfo.ElementProperties); form.MacroTable = data.MacroTable; // Fill template datarow with element's properties. If template does not contain such column, add it to custom foreach (String col in data.ColumnNames) { if (col.StartsWith(UIContextData.CATEGORYNAMEPREFIX, StringComparison.Ordinal)) { if (!RequestHelper.IsPostBack()) { String catName = col.Substring(UIContextData.CATEGORYNAMEPREFIX.Length); FormCategoryInfo fci = fi.GetFormCategory(catName); if (fci != null) { fci.SetPropertyValue(FormCategoryPropertyEnum.CollapsedByDefault, ValidationHelper.GetBoolean(data[col], false).ToString().ToLowerInvariant()); } } } else { if (dr.Table.Columns.Contains(col)) { DataHelper.SetDataRowValue(dr, col, data[col]); } else { customData[col] = data[col]; } } } dr["CustomProperties"] = customData.GetData(); form.DataRow = dr; form.LoadData(dr); form.FormInformation = fi; // Master page style for margin CurrentMaster.PanelContent.CssClass = "WebpartProperties PageContent"; form.OnAfterSave += form_OnAfterSave; } else { EditedObject = null; } }