public void InitializeVirtualMap(SmallMapReferences smallMapReferences, SmallMaps smallMaps, LargeMapReference largeMapReferences, LargeMap overworldMap, LargeMap underworldMap, NonPlayerCharacterReferences nonPlayerCharacters, TileReferences TileReferences, GameState state, NonPlayerCharacterReferences npcRefs) { TheVirtualMap = new VirtualMap(smallMapReferences, smallMaps, largeMapReferences, overworldMap, underworldMap, nonPlayerCharacters, TileReferences, state, npcRefs, TheTimeOfDay); }
/// <summary> /// Constructor /// </summary> /// <param name="ultima5Directory">ultima 5 data and save game directory</param> public World(string ultima5Directory) : base() { _u5Directory = ultima5Directory; DataOvlRef = new DataOvlReference(_u5Directory); SmallMapRef = new SmallMapReferences(DataOvlRef); // build the overworld map OverworldMap = new LargeMap(_u5Directory, LargeMap.Maps.Overworld, _tileOverrides); // build the underworld map UnderworldMap = new LargeMap(_u5Directory, LargeMap.Maps.Underworld, _tileOverrides); SpriteTileReferences = new TileReferences(DataOvlRef.StringReferences); InvRef = new InventoryReferences(); LargeMapRef = new LargeMapLocationReferences(DataOvlRef); AllSmallMaps = new SmallMaps(SmallMapRef, _u5Directory, SpriteTileReferences, _tileOverrides); MoonPhaseRefs = new MoonPhaseReferences(DataOvlRef); State = new GameState(_u5Directory, DataOvlRef); // build all combat maps from the Combat Map References foreach (CombatMapReference.SingleCombatMapReference combatMapRef in _combatMapRef.MapReferenceList) { CombatMap combatMap = new CombatMap(_u5Directory, combatMapRef, _tileOverrides); } // build a "look" table for all tiles LookRef = new Look(_u5Directory); // build the sign tables SignRef = new Signs(_u5Directory); TalkScriptsRef = new TalkScripts(_u5Directory, DataOvlRef); // build the NPC tables NpcRef = new NonPlayerCharacterReferences(_u5Directory, SmallMapRef, TalkScriptsRef, State); ShoppeKeeperDialogueReference = new ShoppeKeeperDialogueReference(_u5Directory, DataOvlRef, NpcRef, State.PlayerInventory); // sadly I have to initialize this after the NPCs are created because there is a circular dependency State.InitializeVirtualMap(SmallMapRef, AllSmallMaps, LargeMapRef, OverworldMap, UnderworldMap, NpcRef, SpriteTileReferences, State, NpcRef, InvRef); if (State.Location != SmallMapReferences.SingleMapReference.Location.Britannia_Underworld) { State.TheVirtualMap.LoadSmallMap(SmallMapRef.GetSingleMapByLocation(State.Location, State.Floor), State.CharacterRecords, true); } else { State.TheVirtualMap.LoadLargeMap(LargeMap.Maps.Overworld); } }
public MapCharacterState(TileReferences tileReferences, NonPlayerCharacterReference npcRef, int nCharacterAnimationStateIndex, TimeOfDay timeOfDay) { NPCIndex = npcRef.DialogIndex; TileRef = tileReferences.GetTileReference(npcRef.NPCKeySprite); CharacterAnimationStateIndex = nCharacterAnimationStateIndex; // if you are adding by hand then we can assume that the character is active TheCharacterPosition = npcRef.Schedule.GetCharacterDefaultPositionByTime(timeOfDay); Active = true; }
public MapCharacterState(TileReferences tileReferences, UInt16[] stateUInts, int nNPCIndex) { Debug.Assert(stateUInts.Length == 0x8); NPCIndex = nNPCIndex; TheCharacterPosition.X = stateUInts[1]; TheCharacterPosition.Y = stateUInts[2]; TheCharacterPosition.Floor = stateUInts[3]; TileRef = tileReferences.GetTileReference(stateUInts[4] + 0x100); CharacterAnimationStateIndex = stateUInts[6]; Active = stateUInts[7] > 0; }
public MapCharacterStates(DataChunk charStatesDataChunk, TileReferences tileReferences) { DataChunk dataChunk = charStatesDataChunk; List <UInt16> characterStateBytes = dataChunk.GetChunkAsUINT16List(); for (int nIndex = 0; nIndex < MAX_CHARACTER_STATES; nIndex++) { characterStates.Add(new MapCharacterState(tileReferences, characterStateBytes.GetRange(nIndex * MapCharacterAnimationState.NBYTES, MapCharacterAnimationState.NBYTES).ToArray(), nIndex)); } }
public TileReferences(U5StringRef u5StringRef) { this.u5StringRef = u5StringRef; TileReferenceDictionary = TileReferences.Load(); //foreach (TileReference tileRef in TileReferenceDictionary) for (int i = 0; i < TileReferenceDictionary.Count; i++) { TileReference tileRef = TileReferenceDictionary[i]; // this is gross, but I can't seem to get the index number in any other way... tileRef.Index = i; TileReferenceByStringDictionary.Add(tileRef.Name, tileRef); } }
public MapCharacterAnimationState(TileReferences tileReferences, byte[] stateBytes) { Debug.Assert(stateBytes.Length == 0x8); // Tile1 = stateBytes[0] + 0x100; Tile2 = stateBytes[1] + 0x100; Tile1Ref = tileReferences.GetTileReference(Tile1); Tile2Ref = tileReferences.GetTileReference(Tile2); X = stateBytes[2]; Y = stateBytes[3]; Floor = stateBytes[4]; Depends1 = stateBytes[5]; Depends2 = stateBytes[6]; Depends3 = stateBytes[7]; }
public MapCharacters(TileReferences tileRefs, NonPlayerCharacterReferences npcRefs, DataChunk animationStatesDataChunk, DataChunk overworldAnimationStatesDataChunk, DataChunk underworldAnimationStatesDataChunk, DataChunk charStatesDataChunk, DataChunk nonPlayerCharacterMovementLists, DataChunk NonPlayerCharacterMovementOffsets) { this.tileRefs = tileRefs; smallMapAnimationStates = new MapCharacterAnimationStates(animationStatesDataChunk, tileRefs); overworldAnimationState = new MapCharacterAnimationStates(overworldAnimationStatesDataChunk, tileRefs); underworldAnimationState = new MapCharacterAnimationStates(underworldAnimationStatesDataChunk, tileRefs); charStates = new MapCharacterStates(charStatesDataChunk, tileRefs); movements = new NonPlayerCharacterMovements(nonPlayerCharacterMovementLists, NonPlayerCharacterMovementOffsets); this.npcRefs = npcRefs; // we always load the over and underworld from disk immediatley, no need to reload as we will track it in memory // going forward overworldAnimationState.Load(MapCharacterAnimationStates.MapCharacterAnimationStatesFiles.BRIT_OOL, true); underworldAnimationState.Load(MapCharacterAnimationStates.MapCharacterAnimationStatesFiles.UNDER_OOL, true); }
public SmallMaps(SmallMapReferences smallMapRef, string u5Directory, TileReferences SpriteTileReferences) { this.smallMapRef = smallMapRef; foreach (SmallMapReferences.SingleMapReference mapRef in smallMapRef.MapReferenceList) { // now I can go through each and every reference SmallMap smallMap = new SmallMap(u5Directory, mapRef, SpriteTileReferences); smallMaps.Add(smallMap); // we make a map that allows us to map the Location and Floor number to the small map with // details such as the grid if (!mapLocationDictionary.ContainsKey(mapRef.MapLocation)) { mapLocationDictionary.Add(mapRef.MapLocation, new Dictionary <int, SmallMap>()); } mapLocationDictionary[mapRef.MapLocation].Add(mapRef.Floor, smallMap); } }
/// <summary> /// Construct the VirtualMap (requires initalization still) /// </summary> /// <param name="smallMapReferences"></param> /// <param name="smallMaps"></param> /// <param name="largeMapReferences"></param> /// <param name="overworldMap"></param> /// <param name="underworldMap"></param> /// <param name="nonPlayerCharacters"></param> /// <param name="tileReferences"></param> public VirtualMap(SmallMapReferences smallMapReferences, SmallMaps smallMaps, LargeMapReference largeMapReferences, LargeMap overworldMap, LargeMap underworldMap, NonPlayerCharacterReferences nonPlayerCharacters, TileReferences tileReferences, GameState state, NonPlayerCharacterReferences npcRefs, TimeOfDay timeOfDay) { this.SmallMapRefs = smallMapReferences; this.smallMaps = smallMaps; this.nonPlayerCharacters = nonPlayerCharacters; this.largeMapReferences = largeMapReferences; this.tileReferences = tileReferences; this.state = state; this.npcRefs = npcRefs; this.timeOfDay = timeOfDay; //this.characterStates = characterStates; largeMaps.Add(LargeMap.Maps.Overworld, overworldMap); largeMaps.Add(LargeMap.Maps.Underworld, underworldMap); TheMapCharacters = new MapCharacters(tileReferences, npcRefs, state.CharacterAnimationStatesDataChunk, state.OverworldOverlayDataChunks, state.UnderworldOverlayDataChunks, state.CharacterStatesDataChunk, state.NonPlayerCharacterMovementLists, state.NonPlayerCharacterMovementOffsets); }
protected void InitializeAStarMap(TileReferences spriteTileReferences) { Debug.Assert(TheMap != null); Debug.Assert(TheMap.Length > 0); int nXTiles = TheMap[0].Length; int nYTiles = TheMap.Length; // load the A-Star compatible map into memory aStarNodes = Utils.Init2DList <AStarSharp.Node>(nXTiles, nYTiles); for (int x = 0; x < nXTiles; x++) { for (int y = 0; y < nYTiles; y++) { TileReference currentTile = spriteTileReferences.GetTileReference(TheMap[x][y]); bool bIsWalkable = currentTile.IsWalking_Passable || currentTile.Index == 184 || currentTile.Index == 186; AStarSharp.Node node = new AStarSharp.Node(new System.Numerics.Vector2(x, y), bIsWalkable); aStarNodes[x].Add(node); } } astar = new AStarSharp.Astar(aStarNodes); }
public World(string ultima5Directory) : base() { u5Directory = ultima5Directory; // build the overworld map OverworldMap = new LargeMap(u5Directory, LargeMap.Maps.Overworld); // build the underworld map UnderworldMap = new LargeMap(u5Directory, LargeMap.Maps.Underworld); DataOvlRef = new DataOvlReference(u5Directory); SpriteTileReferences = new TileReferences(DataOvlRef.StringReferences); SmallMapRef = new SmallMapReferences(DataOvlRef); LargeMapRef = new LargeMapReference(DataOvlRef, SmallMapRef); AllSmallMaps = new SmallMaps(SmallMapRef, u5Directory, SpriteTileReferences); State = new GameState(u5Directory, DataOvlRef); //CharacterRecord character = State.GetCharacterFromParty(0); //CharacterRecord character3 = State.GetCharacterFromParty(3); //CharacterRecord character4 = State.GetCharacterFromParty(4); //character.Equipped.Amulet = DataOvlReference.EQUIPMENT.Ankh; //CharacterRecord character2 = State.GetCharacterFromParty(0); // build all the small maps from the Small Map reference //foreach (SmallMapReferences.SingleMapReference mapRef in SmallMapRef.MapReferenceList) //{ // // now I can go through each and every reference // SmallMap smallMap = new SmallMap(u5Directory, mapRef); // smallMaps.Add(smallMap); // //U5Map.PrintMapSection(smallMap.RawMap, 0, 0, 32, 32); //} // build all combat maps from the Combat Map References foreach (CombatMapReference.SingleCombatMapReference combatMapRef in combatMapRef.MapReferenceList) { CombatMap combatMap = new CombatMap(u5Directory, combatMapRef); //System.Console.WriteLine("\n"); //System.Console.WriteLine(combatMap.Description); //Map.PrintMapSection(combatMap.RawMap, 0, 0, 11, 11); } // build a "look" table for all tiles LookRef = new Look(ultima5Directory); // build the sign tables SignRef = new Signs(ultima5Directory); //Signs.Sign sign = SignRef.GetSign(SmallMapReferences.SingleMapReference.Location.Yew, 16, 2); Signs.Sign sign = SignRef.GetSign(42); string str = sign.SignText; TalkScriptsRef = new TalkScripts(u5Directory, DataOvlRef); // build the NPC tables NpcRef = new NonPlayerCharacterReferences(ultima5Directory, SmallMapRef, TalkScriptsRef, State); //CharAnimationStates = new MapCharacterAnimationStates(State, SpriteTileReferences); //CharStates = new MapCharacterStates(State, SpriteTileReferences); // sadly I have to initilize this after the Npcs are created because there is a circular dependency State.InitializeVirtualMap(SmallMapRef, AllSmallMaps, LargeMapRef, OverworldMap, UnderworldMap, NpcRef, SpriteTileReferences, State, NpcRef); if (State.Location != SmallMapReferences.SingleMapReference.Location.Britainnia_Underworld) { State.TheVirtualMap.LoadSmallMap(SmallMapRef.GetSingleMapByLocation(State.Location, State.Floor), true); } else { State.TheVirtualMap.LoadLargeMap(LargeMap.Maps.Overworld); } //State.TheVirtualMap.LoadSmallMap() //State.PlayerInventory.MagicSpells.Items[Spell.SpellWords.An_Ex_Por].GetLiteralTranslation(); //State.TheVirtualMap.LoadSmallMap(SmallMapRef.GetSingleMapByLocation(SmallMapReferences.SingleMapReference.Location.Serpents_Hold, 0), false); //int nSpriteGuess = State.TheVirtualMap.GuessTile(new Point2D(15, 15)); //NpcRef.GetNonPlayerCharacter(SmallMapReferences.SingleMapReference.Location.Britain, new Point2D(0, 31), 0); //State.Year = 100; //State.Month = 13; //State.Day = 28; //State.Hour = 22; //State.Minute = 2; //Conversation convo = new Conversation(NpcRef.NPCs[21]); // dunkworth // Conversation convo = new Conversation(NpcRef.NPCs[296], State, DataOvlRef); // Gwenno // 19 = Margarett // NpcRef.NPCs[296].Script.PrintComprehensiveScript(); int count = 0; if (false) { foreach (NonPlayerCharacterReference npc in NpcRef.NPCs) { if (npc.NPCType != 0 && npc.Script != null) { Console.WriteLine(""); Console.WriteLine("---- SCRIPT for " + npc.Name.Trim() + " -----"); //Npc.Script.PrintScript(); npc.Script.PrintComprehensiveScript(); if (npc.Name.Trim() == "Geoffrey") { Console.WriteLine(npc.NPCType.ToString()); } } count++; } } // Scally //Conversation convo = new Conversation(NpcRef.NPCs[0xe6], State, DataOvlRef); // Bidney //Conversation convo = new Conversation(NpcRef.NPCs[0xe8], State); // Lord Dalgrin //Conversation convo = new Conversation(NpcRef.NPCs[0xea], State); // Geoffery //Conversation convo = new Conversation(NpcRef.NPCs[0xec], State, DataOvlRef); // Tierra //Conversation convo = new Conversation(NpcRef.NPCs[0xeb], State, DataOvlRef); // Conversation.EnqueuedScriptItem enqueuedScriptItemDelegate = new Conversation.EnqueuedScriptItem(this.EnqueuedScriptItem); // convo.EnqueuedScriptItemCallback += enqueuedScriptItemDelegate; // convo.BeginConversation(); //0x48 or 0x28 //Console.WriteLine("Shutting down... Hit any key..."); //Console.ReadKey(false); }
/// <summary> /// Creates a small map object using a pre-defined map reference /// </summary> /// <param name="u5Directory"></param> /// <param name="mapRef"></param> public SmallMap(string u5Directory, SmallMapReferences.SingleMapReference mapRef, TileReferences spriteTileReferences) : base(u5Directory) { MapRef = mapRef; // load the map into memory TheMap = LoadSmallMapFile(Path.Combine(u5Directory, mapRef.MapFilename), mapRef.FileOffset); InitializeAStarMap(spriteTileReferences); }
public MapCharacterAnimationStates(DataChunk animationStatesDataChunk, TileReferences tileReferences) { this.tileReferences = tileReferences; this.animationStatesDataChunk = animationStatesDataChunk; }