public void AddActor(GameRolePlayActorInformations actor) { if (actor is GameRolePlayCharacterInformations character) { Players.Add(character); Console.WriteLine($@"(Player) {character.Name} en cellid -> {character.Disposition.CellId}"); return; } if (actor is GameRolePlayGroupMonsterInformations monster) { Monsters.Add(monster); var monsterName = FastD2IReader.Instance.GetText(ObjectDataManager.Instance .Get <Monster>(monster.StaticInfos.MainCreatureLightInfos.CreatureGenericId).NameId); Console.WriteLine($@"(Monster) {monsterName} en cellid -> {monster.Disposition.CellId}"); return; } if (actor is GameRolePlayNpcInformations npc) { Npcs.Add(npc); var npcName = FastD2IReader.Instance.GetText(ObjectDataManager.Instance.Get <Npc>(npc.NpcId).NameId); Console.WriteLine($@"(Npc) {npcName} en cellid -> {npc.Disposition.CellId}"); return; } Others.Add(actor); Console.WriteLine($@"(Other) Aucune Idée en cellid -> {actor.Disposition.CellId}"); }
private void AddActors(IEnumerable <GameRolePlayActorInformations> actors) { foreach (var actor in actors) { if (actor is GameRolePlayGroupMonsterInformations monster) { Monsters.Add(new MonsterGroup(monster.StaticInfos, monster.ContextualId, monster.Disposition.CellId)); continue; } if (actor is GameRolePlayNpcInformations npc) { Npcs.Add(new Npc(npc.Disposition.CellId, npc.ContextualId, npc.NpcId)); continue; } if (actor is GameRolePlayCharacterInformations player) { Players.Add(new Player(actor.Disposition.CellId, player.ContextualId, player.Name)); continue; } if (actor is GameRolePlayMerchantInformations merchant) { Merchants.Add(new Merchant(merchant.Disposition.CellId, merchant.ContextualId, merchant.SellType, merchant.Name)); continue; } Entities.Add(new Entity.Entity(actor.ContextualId, actor.Disposition.CellId)); } }
/// <summary> /// Add an NPC /// </summary> /// <param name="npc"></param> public void AddNpc(Npc npc) { if (IsSetupFinalised) { throw new InvalidOperationException("Cannot add NPCs after game state setup is finalised"); } Npcs.Add(npc.Name, npc); }
public void UpdateLocationNpcs() { ObservableCollection <Npc> updateLocationNpcs = new ObservableCollection <Npc>(); foreach (Npc Npc in _npcs) { updateLocationNpcs.Add(Npc); } Npcs.Clear(); foreach (Npc npc in updateLocationNpcs) { Npcs.Add(npc); } }
protected override void Init() { Npcs.Add(new CNpc(2141000) { Y = -236, X = -47, Cy = -47, Foothold = 35, // seems like all the life in this map is on fh 35 ._. Position = new CMovePath() { X = -236, Y = -47 }, }); CreateFieldClock(2 * 60 * 60); // 2 hours base.Init(); }
void NewGame() { var assets = Resolve <IAssetManager>(); PartyMembers.Clear(); foreach (PartyCharacterId charId in Enum.GetValues(typeof(PartyCharacterId))) { PartyMembers.Add(charId, assets.LoadCharacter(AssetType.PartyMember, charId)); } Npcs.Clear(); foreach (NpcCharacterId charId in Enum.GetValues(typeof(NpcCharacterId))) { Npcs.Add(charId, assets.LoadCharacter(AssetType.Npc, charId)); } Chests.Clear(); foreach (ChestId id in Enum.GetValues(typeof(ChestId))) { Chests.Add(id, assets.LoadChest(id)); } Merchants.Clear(); foreach (MerchantId id in Enum.GetValues(typeof(MerchantId))) { Merchants.Add(id, assets.LoadMerchant(id)); } _party.Clear(); Raise(new AddPartyMemberEvent(PartyCharacterId.Tom)); Raise(new AddPartyMemberEvent(PartyCharacterId.Rainer)); Raise(new AddPartyMemberEvent(PartyCharacterId.Drirr)); Raise(new AddPartyMemberEvent(PartyCharacterId.Sira)); Raise(new AddPartyMemberEvent(PartyCharacterId.Mellthas)); Raise(new AddPartyMemberEvent(PartyCharacterId.Khunag)); SetupTestState(); Raise(new ReloadAssetsEvent()); // No need to keep character info cached once we've loaded it. New game is also a good point to clear out state. Raise(new PartyChangedEvent()); Raise(new LoadMapEvent(MapDataId.Toronto2DGesamtkarteSpielbeginn)); Raise(new StartClockEvent()); Loaded = true; }
/// <summary> /// AddObject is called to add a new GameObject to the Objects list. /// </summary> /// public void AddObject(GameObject newObject) { Objects.Add(newObject); // Adds to Drawables if drawable. if (newObject is Drawable drawable) { Drawables.Add(drawable); } // Adds to Collidables if collidable. if (newObject is Collider) { Collidables.Add(newObject); } if (newObject is Player) { Player = (Player)newObject; } if (newObject is Npc) { Npcs.Add((Npc)newObject); } if (newObject is EndObject) { End = (EndObject)newObject; } if (newObject is Event) { Events.Add((Event)newObject); } }
public void LoadAlgorithmSettings() { FloorSettings.Clear(); TileLayers.Clear(); TileData.Clear(); Items.Clear(); Npcs.Clear(); Rooms.Clear(); if (Algorithm > -1) { FloorAlgorithm settingsGuide = GameData.FloorAlgorithmDex[Algorithm]; for (int i = 0; i < settingsGuide.FloorSettings.Count; i++) { FloorSettings.Add(settingsGuide.FloorSettings[i].Item1, 0); } for (int i = 0; i < settingsGuide.LayerSettings.Count; i++) { TileLayers.Add(settingsGuide.LayerSettings[i], new List <Maps.TileAnim>()); } for (int i = 0; i < settingsGuide.TileSettings.Count; i++) { TileData.Add(settingsGuide.TileSettings[i], new List <Maps.TileData>()); } for (int i = 0; i < settingsGuide.ItemGroups.Count; i++) { Items.Add(settingsGuide.ItemGroups[i], new List <Tuple <ItemPreset, int> >()); } for (int i = 0; i < settingsGuide.NpcGroups.Count; i++) { Npcs.Add(settingsGuide.NpcGroups[i], new List <Tuple <NpcPreset, int> >()); } for (int i = 0; i < settingsGuide.RoomGroups.Count; i++) { Rooms.Add(settingsGuide.RoomGroups[i], new List <Tuple <int, int> >()); } } }
private void Awake() { Npcs.Add(this); }
protected override void InitMobs() { var mobcount = 30; const int npc = 1012119; switch (DungeonFieldIndex) { case 1: { var mobs = new int[2] { 9200009, 9500123 }; var y = new int[5] { 295, 206, 46, -55, -249 }; var x = new int[2][] { new int[5] { -20, 275, 290, 310, 310 }, // low range new int[5] { 1250, 1100, 980, 740, 730 }, // high range }; execute(mobs, y, x); makenpc(-340, 298, 21); } break; case 2: { var mobs = new int[2] { 9500123, 9300387 }; var y = new int[5] { 300, 105, 11, -80, -260 }; var x = new int[2][] { new int[5] { -115, 136, 130, 232, 243 }, // low range new int[5] { 1166, 830, 735, 670, 662 }, // high range }; execute(mobs, y, x); makenpc(-340, 298, 4); } break; case 3: { var mobs = new int[2] { 9300387, 9500149 }; var y = new int[5] { 178, 84, -94, -187, -367 }; var x = new int[2][] { new int[5] { 97, 623, 659, 766, 859 }, // low range new int[5] { 1386, 1656, 1465, 1372, 1290 }, // high range }; execute(mobs, y, x); makenpc(-170, -180, 21); } break; case 4: { var mobs = new int[2] { 9500149, 9500150 }; // 3k hp * 10 var y = new int[9] { 175, 76, 48, 34, 0, -97, -127, -240, -368 }; var x = new int[2][] { new int[9] { 380, 498, 1202, 93, 930, 125, 1069, 235, 762 }, // low range new int[9] { 1725, 920, 1590, 480, 1360, 930, 1500, 630, 1130 }, // high range }; execute(mobs, y, x); makenpc(1260, -420, 14); } break; case 5: { MobHpMultiplier = 60; var mobs = new int[3] { 8220009, 8220009, 8220009 }; var y = new int[3] { 1967, 1606, 1373 }; var x = new int[2][] { new int[3] { 0, 113, 210 }, new int[3] { 470, 400, 445 }, }; for (var i = 0; i < mobs.Length; i++) { Mobs.CreateMob(mobs[i], null, Constants.Rand.Next(x[0][i], x[1][i]), y[i], 0, 0, 0, 0, MobType.Normal, null); //var mob = new CMob(mobs[i]) //{ // m_nSummonType = 0xFE, // Position = new CMovePath // { // Y = (short)y[i], // X = (short)Constants.Rand.Next(x[0][i], x[1][i]), // }, //}; //Mobs.CreateMob(mob); } execute( new int[] { 9500106, 9500105, 9400622, 9000002, 9000301 }, new int[] { 1967, 1793, 1652, 1619, 1480, 1379 }, new int[][] { new int[] { -374, -88, 207, -12, 94, 125 }, new int[] { 914, 637, 569, 391, 500, 456, } }); makenpc(-345, 1800, 36); } break; } void execute(int[] mobs, int[] y, int[][] x) { while (mobcount > 0) { var level = Constants.Rand.Next(0, y.Length); var spawnY = y[level]; var spawnX_L = x[0][level]; var spawnX_R = x[1][level]; var spawnX = Constants.Rand.Next(spawnX_L, spawnX_R); Mobs.CreateMob(mobs.Random(), null, spawnX, spawnY, 0, 0, 0, 0, MobType.Normal, null); //var mob = new CMob(mobs.Random()) //{ // m_nSummonType = 0xFE, // Position = new CMovePath // { // Y = (short)spawnY, // X = (short)spawnX, // }, //}; //Mobs.CreateMob(mob); mobcount -= 1; } } void makenpc(short x, short y, short fh) { var entry = new CNpc(npc) { Rx0 = x, Rx1 = y, X = x, Y = y, Cy = y, F = true, Foothold = fh }; Npcs.Add(entry); Broadcast(entry.MakeEnterFieldPacket()); } }
public void CargarMapa(string nombre) { List <string> lineas; int actualX, actualY; try { lineas = new List <string>(File.ReadAllLines(nombre)); } catch (Exception e) { lineas = new List <string>(); } Sprite aux = new Sprite(); for (int i = 0; i < lineas.Count; i++) { string linea = lineas[i]; actualY = i * aux.height; for (int j = 0; j < linea.Length; j++) { actualX = j * aux.width; switch (linea[j]) { case 'A': Arbol a = new Arbol("data/tree.png"); a.MoveTo(actualX, actualY); Arboles.Add(a); break; case 'E': Edificio e = new Edificio("data/casa_amarilla.png"); e.MoveTo(actualX, actualY); Edificios.Add(e); break; case 'H': Hierba h = new Hierba("data/hierba_alta.png"); h.MoveTo(actualX, actualY); Hierbas.Add(h); break; case 'N': Npc n = CargarNpc(); n.MoveTo(actualX, actualY); Npcs.Add(n); break; case 'F': Enfermera ef = new Enfermera( new string[4][] { new string[] { "data/npcs/enfermera/enfermeraRightBase.png" }, new string[] { "data/npcs/enfermera/enfermeraLeftBase.png" }, new string[] { "data/npcs/enfermera/enfermeraUpBase.png" }, new string[] { "data/npcs/enfermera/enfermeraDownBase.png" } }); ef.Dialogo.Add("Tus pokemons han sido curados"); ef.MoveTo(actualX, actualY); Npcs.Add(ef); break; case 'P': Pc p = new Pc("data/pc.png"); p.MoveTo(actualX, actualY); Pcs.Add(p); break; } } } }
public void Load(string filename) { string ext = Path.GetExtension(filename); if (!(string.Equals(ext, ".wld", StringComparison.CurrentCultureIgnoreCase) || string.Equals(ext, ".bak", StringComparison.CurrentCultureIgnoreCase) || string.Equals(ext, ".Tedit", StringComparison.CurrentCultureIgnoreCase))) { throw new ApplicationException("Invalid file"); } IsUsingIo = true; IsValid = false; ClearWorld(); using (var stream = new FileStream(filename, FileMode.Open)) { using (var reader = new BinaryReader(stream)) { int version = reader.ReadInt32(); if (version > CompatableVersion) { // handle version } Header.FileVersion = version; Header.FileName = filename; Header.WorldName = reader.ReadString(); Header.WorldId = reader.ReadInt32(); // WorldBounds (within the file) is measured in frame units (1/2 of a pixel), while MaxTiles is measured in tiles // We force everything into whole tiles, and ditch the redundant MaxTiles // (Also, WorldBounds actually uses W/H, so it is really -1 for right/bottom, in an inclusive-based XY system.) Header.WorldBounds = new RectI(reader.ReadInt32(), reader.ReadInt32() - 1, reader.ReadInt32(), reader.ReadInt32() - 1) / new RectI(16, 16, new SizeInt32(16, 16)); reader.ReadInt32(); // max Y reader.ReadInt32(); // max X var wb = Header.WorldBounds; ClearWorld(); Header.SpawnTile = new PointInt32(reader.ReadInt32(), reader.ReadInt32()); Header.WorldSurface = reader.ReadDouble(); Header.WorldRockLayer = reader.ReadDouble(); Header.Time = reader.ReadDouble(); Header.IsDayTime = reader.ReadBoolean(); Header.MoonPhase = reader.ReadInt32(); Header.IsBloodMoon = reader.ReadBoolean(); Header.DungeonEntrance = new PointInt32(reader.ReadInt32(), reader.ReadInt32()); Header.IsBossDowned1 = reader.ReadBoolean(); Header.IsBossDowned2 = reader.ReadBoolean(); Header.IsBossDowned3 = reader.ReadBoolean(); Header.IsShadowOrbSmashed = reader.ReadBoolean(); Header.IsSpawnMeteor = reader.ReadBoolean(); Header.ShadowOrbCount = reader.ReadByte(); Header.InvasionDelay = reader.ReadInt32(); Header.InvasionSize = reader.ReadInt32(); Header.InvasionType = reader.ReadInt32(); Header.InvasionX = reader.ReadDouble(); for (int x = wb.Left; x <= wb.Right; x++) { OnProgressChanged(this, x, wb.Right, "Loading Tiles..."); for (int y = wb.Top; y <= wb.Bottom; y++) { var tile = new Tile(); tile.IsActive = reader.ReadBoolean(); if (tile.IsActive) { tile.Type = reader.ReadByte(); if (WorldSettings.Tiles[tile.Type].IsFramed) { tile.Frame = new PointShort(reader.ReadInt16(), reader.ReadInt16()); } else { tile.Frame = new PointShort(-1, -1); } } tile.IsLighted = reader.ReadBoolean(); if (reader.ReadBoolean()) { tile.Wall = reader.ReadByte(); } if (reader.ReadBoolean()) { tile.Liquid = reader.ReadByte(); tile.IsLava = reader.ReadBoolean(); } Tiles[x, y] = tile; } } for (int chestIndex = 0; chestIndex < MaxChests; chestIndex++) { OnProgressChanged(this, chestIndex, MaxChests, "Loading Chest Data..."); if (reader.ReadBoolean()) { var chest = new Chest(); chest.Location = new PointInt32(reader.ReadInt32(), reader.ReadInt32()); for (int slot = 0; slot < Chest.MaxItems; slot++) { var item = new Item(); byte stackSize = reader.ReadByte(); if (stackSize > 0) { string itemName = reader.ReadString(); item.ItemName = itemName; item.StackSize = stackSize; } chest.Items.Add(item); } Chests.Add(chest); } } for (int signIndex = 0; signIndex < MaxSigns; signIndex++) { OnProgressChanged(this, signIndex, MaxSigns, "Loading Sign Data..."); if (reader.ReadBoolean()) { string signText = reader.ReadString(); int x = reader.ReadInt32(); int y = reader.ReadInt32(); if (Tiles[x, y].IsActive && (Tiles[x, y].Type == 55 || Tiles[x, y].Type == 85)) // validate tile location { var sign = new Sign(); sign.Location = new PointInt32(x, y); sign.Text = signText; Signs.Add(sign); } } } bool isNpcActive = reader.ReadBoolean(); for (int npcIndex = 0; isNpcActive; npcIndex++) { OnProgressChanged(this, npcIndex, MaxNpcs, "Loading NPCs..."); var npc = new NPC(); npc.Name = reader.ReadString(); npc.Position = new PointFloat(reader.ReadSingle(), reader.ReadSingle()); npc.IsHomeless = reader.ReadBoolean(); npc.HomeTile = new PointInt32(reader.ReadInt32(), reader.ReadInt32()); Npcs.Add(npc); isNpcActive = reader.ReadBoolean(); } if (Header.FileVersion > 7) { OnProgressChanged(this, 100, 100, "Checking format..."); bool test = reader.ReadBoolean(); string worldNameCheck = reader.ReadString(); int worldIdCheck = reader.ReadInt32(); if (!(test && string.Equals(worldNameCheck, Header.WorldName) && worldIdCheck == Header.WorldId)) { // Test FAILED! IsUsingIo = false; reader.Close(); throw new ApplicationException("Invalid World File"); } } reader.Close(); } } IsValid = true; IsUsingIo = false; IsSaved = true; OnProgressChanged(this, 100, 100, "Loading Complete."); }