Exemple #1
0
        /// <summary>
        /// Looks at a particular tile, detecting if NPCs are present as well
        /// Provides string output or special instructions if it is "special"B
        /// </summary>
        /// <param name="xy">positon of tile to look at</param>
        /// <param name="specialLookCommand">Special command such as look at gem or sign</param>
        /// <returns>String to output to user</returns>
        public string Look(Point2D xy, out SpecialLookCommand specialLookCommand)
        {
            specialLookCommand = SpecialLookCommand.None;

            TileReference tileReference = State.TheVirtualMap.GetTileReference(xy);

            // if there is an NPC on the tile, then we assume they want to look at the NPC, not whatever else may be on the tiles
            if (State.TheVirtualMap.IsNPCTile(xy))
            {
                MapCharacter mapCharacter = State.TheVirtualMap.GetNPCOnTile(xy);
                return(DataOvlRef.StringReferences.GetString(DataOvlReference.VISION2_STRINGS.THOU_DOST_SEE).Trim()
                       + " " + (LookRef.GetLookDescription(mapCharacter.NPCRef.NPCKeySprite).Trim()));
            }
            // if we are any one of these signs then we superimpose it on the screen
            else if (SpriteTileReferences.IsSign(tileReference.Index))
            {
                specialLookCommand = SpecialLookCommand.Sign;
                return(String.Empty);
            }
            else if (SpriteTileReferences.GetTileNumberByName("Clock1") == tileReference.Index)
            {
                return(DataOvlRef.StringReferences.GetString(DataOvlReference.VISION2_STRINGS.THOU_DOST_SEE).Trim()
                       + " " + (LookRef.GetLookDescription(tileReference.Index).TrimStart()
                                + State.TheTimeOfDay.FormattedTime));
            }
            else // lets see what we've got here!
            {
                return(DataOvlRef.StringReferences.GetString(DataOvlReference.VISION2_STRINGS.THOU_DOST_SEE).Trim()
                       + " " + (LookRef.GetLookDescription(tileReference.Index).TrimStart()));
            }
        }
Exemple #2
0
        /// <summary>
        /// Looks at a particular tile, detecting if NPCs are present as well
        /// Provides string output or special instructions if it is "special"B
        /// </summary>
        /// <param name="xy">position of tile to look at</param>
        /// <param name="specialLookCommand">Special command such as look at gem or sign</param>
        /// <returns>String to output to user</returns>
        public string Look(Point2D xy, out SpecialLookCommand specialLookCommand)
        {
            specialLookCommand = SpecialLookCommand.None;
            string retStr;

            TileReference tileReference = State.TheVirtualMap.GetTileReference(xy);

            // if there is an NPC on the tile, then we assume they want to look at the NPC, not whatever else may be on the tiles
            if (State.TheVirtualMap.IsNPCTile(xy))
            {
                MapCharacter mapCharacter = State.TheVirtualMap.GetNPCOnTile(xy);
                if (mapCharacter == null)
                {
                    throw new Ultima5ReduxException("Tried to look up NPC, but couldn't find the map character");
                }
                retStr = DataOvlRef.StringReferences.GetString(DataOvlReference.Vision2Strings.THOU_DOST_SEE).Trim()
                         + " " + (LookRef.GetLookDescription(mapCharacter.NPCRef.NPCKeySprite).Trim());
            }
            // if we are any one of these signs then we superimpose it on the screen
            else if (SpriteTileReferences.IsSign(tileReference.Index))
            {
                specialLookCommand = SpecialLookCommand.Sign;
                retStr             = string.Empty;
            }
            else if (SpriteTileReferences.GetTileNumberByName("Clock1") == tileReference.Index)
            {
                retStr = (DataOvlRef.StringReferences.GetString(DataOvlReference.Vision2Strings.THOU_DOST_SEE).Trim()
                          + " " + (LookRef.GetLookDescription(tileReference.Index).TrimStart()
                                   + State.TheTimeOfDay.FormattedTime));
            }
            else // lets see what we've got here!
            {
                retStr = (DataOvlRef.StringReferences.GetString(DataOvlReference.Vision2Strings.THOU_DOST_SEE).Trim()
                          + " " + (LookRef.GetLookDescription(tileReference.Index).TrimStart()));
            }

            // pass time at the end to make sure moving characters are accounted for
            PassTime();
            return(retStr);
        }
Exemple #3
0
        /// <summary>
        /// If an NPC is on a tile, then it will get them
        /// assumes it's on the same floor
        /// </summary>
        /// <param name="xy"></param>
        /// <returns>the NPC or null if one does not exist</returns>
        public MapCharacter GetNPCOnTile(Point2D xy)
        {
            if (IsLargeMap)
            {
                return(null);
            }
            SmallMapReferences.SingleMapReference.Location location = CurrentSingleMapReference.MapLocation;

            MapCharacter mapCharacter = TheMapCharacters.GetMapCharacterByLocation(location, xy, CurrentSingleMapReference.Floor);

            //List<NonPlayerCharacterReference> npcs = nonPlayerCharacters.GetNonPlayerCharactersByLocation(location);

            //MapCharacterAnimationState characterState = characterStates.GetCharacterStateByPosition(xy, CurrentSingleMapReference.Floor);

            // get the NPC on the current tile
            //NonPlayerCharacterReference npc = nonPlayerCharacters.GetNonPlayerCharacter(location, xy, CurrentSingleMapReference.Floor);

            //if (npc == null)
            //throw new Exception("You asked for an NPC on a tile that one does not exist - you should have checked first!");

            return(mapCharacter);

            //foreach (NonPlayerCharacters.NonPlayerCharacter npc in npcs)
            //{

            //    int nIndex = 1;
            //    Point2D npcXy = npc.Schedule.GetHardCoord(nIndex);

            //    // the NPC is a non-NPC, so we keep looking
            //    if (npcXy.X == 0 && npcXy.Y == 0) continue;

            //    // we found the right NPC and are they on the correct floor
            //    if (npcXy == xy && CurrentSingleMapReference.Floor == npc.Schedule.Coords[nIndex].Z)
            //    {
            //        return npc;
            //    }
            //}
            return(null);
        }