Beispiel #1
0
        void SelectNextPath()
        {
            PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;

            if (!playerGPS.HasCurrentLocation)
            {
                DFPosition currMapPixel = playerGPS.CurrentMapPixel;

                byte pathsDataPt     = GetPathsDataPoint(currMapPixel);
                byte playerDirection = GetDirection(GetNormalisedPlayerYaw());
                if (CountSetBits(pathsDataPt) == 2)
                {
                    playerDirection = (byte)(pathsDataPt & playerDirection);
                    if (playerDirection == 0)
                    {
                        byte fromDirection = GetDirection(GetNormalisedPlayerYaw(true));
                        playerDirection = (byte)(pathsDataPt ^ fromDirection);
                    }
#if UNITY_EDITOR
                    Debug.LogFormat("Heading {0}", GetDirectionStr(playerDirection));
#endif
                    byte roadDataPt = GetRoadsDataPoint(currMapPixel);
                    road = (roadDataPt & playerDirection) != 0;
                    BeginPathTravel(GetTargetPixel(playerDirection, currMapPixel));
                    return;
                }
            }
            else
            {
                lastCrossed = GetDirection(GetNormalisedPlayerYaw(true));
            }
            // An intersection, location, or path end then end travel
            travelControlUI.CloseWindow();
        }
Beispiel #2
0
        void Start()
        {
            dfUnity    = DaggerfallUnity.Instance;
            songPlayer = GetComponent <DaggerfallSongPlayer>();

            // Get local player GPS if not set
            if (LocalPlayerGPS == null)
            {
                LocalPlayerGPS = GameManager.Instance.PlayerGPS;
            }

            // Get streaming world if not set
            if (StreamingWorld == null)
            {
                StreamingWorld = GameManager.Instance.StreamingWorld;
            }

            // Get required player components
            if (LocalPlayerGPS)
            {
                playerEnterExit = LocalPlayerGPS.GetComponent <PlayerEnterExit>();
                playerWeather   = LocalPlayerGPS.GetComponent <PlayerWeather>();
            }

            // Shuffle song on load or fast travel
            StreamingWorld.OnInitWorld += StreamingWorld_OnInitWorld;
        }
        /// <summary>
        /// Sets NPC information available at instantiation time.
        /// NPCs are only instantiated when player enters their context and layout places them in world.
        /// So a lot can be derived just from player behaviours.
        /// </summary>
        void SetRuntimeData()
        {
            // Get reference to player objects holding world information
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;
            PlayerGPS       playerGPS       = GameManager.Instance.PlayerGPS;

            // Store map ID
            npcData.mapID = playerGPS.CurrentMapID;

            // Store location ID (if any - not all locations carry a unique ID)
            npcData.locationID = (int)playerGPS.CurrentLocation.Exterior.ExteriorData.LocationId;

            // Store building key if player inside a building
            // This can be gleaned from any exterior door if one is available
            npcData.buildingKey = 0;
            if (playerEnterExit.IsPlayerInsideBuilding)
            {
                if (playerEnterExit.ExteriorDoors != null && playerEnterExit.ExteriorDoors.Length > 0)
                {
                    npcData.buildingKey = playerEnterExit.ExteriorDoors[0].buildingKey;
                }
            }

            // Store name bank
            npcData.nameBank = GameManager.Instance.PlayerGPS.GetNameBankOfCurrentRegion();
        }
        private static string LocalReputation(IMacroContextProvider mcp)
        {   // %ltn
            PlayerGPS gps = GameManager.Instance.PlayerGPS;
            int       rep = GameManager.Instance.PlayerEntity.RegionData[gps.CurrentRegionIndex].LegalRep;

            if (rep > 80)
            {
                return("revered");
            }
            else if (rep > 60)
            {
                return("esteemed");
            }
            else if (rep > 40)
            {
                return("honored");
            }
            else if (rep > 20)
            {
                return("admired");
            }
            else if (rep > 10)
            {
                return("respected");
            }
            else if (rep > 0)
            {
                return("dependable");
            }
            else if (rep == 0)
            {
                return("a common citizen");
            }
            else if (rep < -80)
            {
                return("hated");
            }
            else if (rep < -60)
            {
                return("pond scum");
            }
            else if (rep < -40)
            {
                return("a villain");
            }
            else if (rep < -20)
            {
                return("a criminal");
            }
            else if (rep < -10)
            {
                return("a scoundrel");
            }
            else if (rep < 0)
            {
                return("undependable");
            }

            return("unknown");
        }
Beispiel #5
0
        private static string CityType(IMacroContextProvider mcp)
        {   // %ct
            PlayerGPS gps = GameManager.Instance.PlayerGPS;

            switch (gps.CurrentLocationType)
            {
            case DFRegion.LocationTypes.TownCity:
                return(HardStrings.city);

            case DFRegion.LocationTypes.TownVillage:
                return(HardStrings.village);

            case DFRegion.LocationTypes.TownHamlet:
                return(HardStrings.hamlet);

            case DFRegion.LocationTypes.HomeFarms:
                return(HardStrings.farm);

            case DFRegion.LocationTypes.HomePoor:
                return(HardStrings.shack);

            case DFRegion.LocationTypes.HomeWealthy:
                return(HardStrings.manor);

            case DFRegion.LocationTypes.Tavern:
                return(HardStrings.community);

            case DFRegion.LocationTypes.ReligionTemple:
                return(HardStrings.shrine);

            default:
                return(gps.CurrentLocationType.ToString());
            }
        }
Beispiel #6
0
        // Create stack of gold pieces
        DaggerfallUnityItem CreateGold(int rangeLow, int rangeHigh)
        {
            // Get amount
            int amount = 0;

            if (rangeLow == -1 || rangeHigh == -1)
            {
                Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;

                int    playerMod  = (playerEntity.Level / 2) + 1;
                int    factionMod = 50;
                IGuild guild      = null;
                if (ParentQuest.FactionId != 0)
                {
                    guild = GameManager.Instance.GuildManager.GetGuild(ParentQuest.FactionId);
                    if (guild != null && !(guild is NonMemberGuild))
                    {
                        // If this is a faction quest, playerMod is (player factionrank + 1) rather than level
                        playerMod = guild.Rank + 1;

                        // If this is a faction quest, factionMod = faction.power rather than 50
                        FactionFile.FactionData factionData;
                        if (playerEntity.FactionData.GetFactionData(ParentQuest.FactionId, out factionData))
                        {
                            factionMod = factionData.power;
                        }
                    }
                }
                if (playerMod > 10)
                {
                    playerMod = 10;
                }

                PlayerGPS gps            = GameManager.Instance.PlayerGPS;
                int       regionPriceMod = playerEntity.RegionData[gps.CurrentRegionIndex].PriceAdjustment / 2;
                amount = UnityEngine.Random.Range(150 * playerMod, (200 * playerMod) + 1) * (regionPriceMod + 500) / 1000 * (factionMod + 50) / 100;

                if (guild != null)
                {
                    amount = guild.AlterReward(amount);
                }
            }
            else
            {
                amount = UnityEngine.Random.Range(rangeLow, rangeHigh + 1);
            }

            if (amount < 1)
            {
                amount = 1;
            }

            // Create item
            DaggerfallUnityItem result = new DaggerfallUnityItem(ItemGroups.Currency, 0);

            result.stackCount = amount;
            result.LinkQuestItem(ParentQuest.UID, Symbol.Clone());

            return(result);
        }
Beispiel #7
0
        void Start()
        {
            dfUnity    = DaggerfallUnity.Instance;
            songPlayer = GetComponent <DaggerfallSongPlayer>();

            // Get local player GPS if not set
            if (LocalPlayerGPS == null)
            {
                LocalPlayerGPS = GameManager.Instance.PlayerGPS;
            }

            // Get player entity
            if (playerEntity == null)
            {
                playerEntity = GameManager.Instance.PlayerEntity;
            }

            // Get streaming world if not set
            if (StreamingWorld == null)
            {
                StreamingWorld = GameManager.Instance.StreamingWorld;
            }

            // Get required player components
            if (LocalPlayerGPS)
            {
                playerEnterExit = LocalPlayerGPS.GetComponent <PlayerEnterExit>();
                playerWeather   = LocalPlayerGPS.GetComponent <PlayerWeather>();
            }
        }
Beispiel #8
0
        private static string LegalReputation(IMacroContextProvider mcp)
        {   // %ltn
            PlayerGPS gps = GameManager.Instance.PlayerGPS;
            int       rep = GameManager.Instance.PlayerEntity.RegionData[gps.CurrentRegionIndex].LegalRep;

            if (rep > 80)
            {
                return(HardStrings.revered);
            }
            else if (rep > 60)
            {
                return(HardStrings.esteemed);
            }
            else if (rep > 40)
            {
                return(HardStrings.honored);
            }
            else if (rep > 20)
            {
                return(HardStrings.admired);
            }
            else if (rep > 10)
            {
                return(HardStrings.respected);
            }
            else if (rep > 0)
            {
                return(HardStrings.dependable);
            }
            else if (rep == 0)
            {
                return(HardStrings.aCommonCitizen);
            }
            else if (rep < -80)
            {
                return(HardStrings.hated);
            }
            else if (rep < -60)
            {
                return(HardStrings.pondScum);
            }
            else if (rep < -40)
            {
                return(HardStrings.aVillain);
            }
            else if (rep < -20)
            {
                return(HardStrings.aCriminal);
            }
            else if (rep < -10)
            {
                return(HardStrings.aScoundrel);
            }
            else if (rep < 0)
            {
                return(HardStrings.undependable);
            }

            return(HardStrings.unknown);
        }
Beispiel #9
0
 void Awake()
 {
     dfUnity   = DaggerfallUnity.Instance;
     playerGPS = GetComponent <PlayerGPS>();
     world     = FindObjectOfType <StreamingWorld>();
     player    = GameManager.Instance.PlayerEntityBehaviour;
 }
Beispiel #10
0
        /// <summary>
        /// Check if player is allowed to rest at this location.
        /// </summary>
        bool CanRest()
        {
            remainingHoursRented = -1;
            allocatedBed         = Vector3.zero;
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;
            PlayerGPS       playerGPS       = GameManager.Instance.PlayerGPS;

            if (playerGPS.IsPlayerInTown(true, true))
            {
                CloseWindow();
                DaggerfallUI.MessageBox(cityCampingIllegal);

                // Register crime and start spawning guards
                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy;
                playerEntity.SpawnCityGuards(true);

                return(false);
            }
            else if (playerGPS.IsPlayerInTown() && playerEnterExit.IsPlayerInsideBuilding)
            {
                // Check owned locations
                string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey);
                if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName))
                {
                    // Can rest if it's an player owned ship/house.
                    int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey;
                    if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey))
                    {
                        return(true);
                    }

                    // Find room rental record and get remaining time..
                    int           mapId = playerGPS.CurrentLocation.MapTableData.MapId;
                    RoomRental_v1 room  = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey);
                    remainingHoursRented = PlayerEntity.GetRemainingHours(room);

                    // Get allocated bed marker - default to 0 if out of range
                    // We relink marker position by index as building positions are not stable, they can move from terrain mods or floating Y
                    Vector3[] restMarkers = playerEnterExit.Interior.FindMarkers(DaggerfallInterior.InteriorMarkerTypes.Rest);
                    int       bedIndex    = (room.allocatedBedIndex >= 0 && room.allocatedBedIndex < restMarkers.Length) ? room.allocatedBedIndex : 0;
                    allocatedBed = restMarkers[bedIndex];
                    if (remainingHoursRented > 0)
                    {
                        return(true);
                    }
                }
                // Check for guild hall rest privileges (exclude taverns since they are all marked as fighters guilds in data)
                if (playerEnterExit.BuildingDiscoveryData.buildingType != DFLocation.BuildingTypes.Tavern &&
                    GameManager.Instance.GuildManager.GetGuild(playerEnterExit.BuildingDiscoveryData.factionID).CanRest())
                {
                    playerEnterExit.Interior.FindMarker(out allocatedBed, DaggerfallInterior.InteriorMarkerTypes.Rest);
                    return(true);
                }
                CloseWindow();
                DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom);
                return(false);
            }
            return(true);
        }
 void Awake()
 {
     dfUnity = DaggerfallUnity.Instance;
     //mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
     //playerMouseLook = GetComponent<PlayerMouseLook>();
     playerGPS = GetComponent <PlayerGPS>();
     world     = FindObjectOfType <StreamingWorld>();
 }
Beispiel #12
0
        void Start()
        {
            dfUnity    = DaggerfallUnity.Instance;
            songPlayer = GetComponent <DaggerfallSongPlayer>();

            // Get local player GPS if not set
            if (LocalPlayerGPS == null)
            {
                LocalPlayerGPS = GameManager.Instance.PlayerGPS;
            }

            // Get player entity
            if (playerEntity == null)
            {
                playerEntity = GameManager.Instance.PlayerEntity;
            }

            // Get streaming world if not set
            if (StreamingWorld == null)
            {
                StreamingWorld = GameManager.Instance.StreamingWorld;
            }

            // Get required player components
            if (LocalPlayerGPS)
            {
                playerEnterExit = LocalPlayerGPS.GetComponent <PlayerEnterExit>();
                playerWeather   = LocalPlayerGPS.GetComponent <PlayerWeather>();
            }

            // Use alternate music if set
            if (DaggerfallUnity.Settings.AlternateMusic)
            {
                DungeonInteriorSongs = _dungeonSongsFM;
                SunnySongs           = _sunnySongsFM;
                CloudySongs          = _cloudySongsFM;
                OvercastSongs        = _overcastSongsFM;
                RainSongs            = _weatherRainSongsFM;
                SnowSongs            = _weatherSnowSongsFM;
                TempleSongs          = _templeSongsFM;

                TavernSongs = new SongFiles[_tavernSongs.Length + _tavernSongsFM.Length];
                Array.Copy(_tavernSongs, TavernSongs, _tavernSongs.Length);
                Array.Copy(_tavernSongsFM, 0, TavernSongs, _tavernSongs.Length, _tavernSongsFM.Length);

                NightSongs      = _nightSongsFM;
                ShopSongs       = _shopSongsFM;
                MagesGuildSongs = _magesGuildSongsFM;
                InteriorSongs   = _interiorSongsFM;
                PalaceSongs     = _palaceSongsFM;
                CastleSongs     = _castleSongsFM;
                CourtSongs      = _courtSongsFM;
                SneakingSongs   = _sneakingSongsFM;
            }

            PlayerEnterExit.OnTransitionDungeonInterior += PlayerEnterExit_OnTransitionDungeonInterior;
            PlayerEnterExit.OnTransitionInterior        += PlayerEnterExit_OnTransitionInterior;
        }
        /// <summary>
        /// Check if player is allowed to rest at this location.
        /// </summary>
        bool CanRest()
        {
            remainingHoursRented = -1;
            allocatedBed         = Vector3.zero;
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;
            PlayerGPS       playerGPS       = GameManager.Instance.PlayerGPS;

            bool inTown = playerGPS.IsPlayerInTown(true);

            if (inTown && !playerEnterExit.IsPlayerInside)
            {
                CloseWindow();
                DaggerfallUI.MessageBox(cityCampingIllegal);

                // Register crime and start spawning guards
                playerEntity.CrimeCommitted = PlayerEntity.Crimes.Vagrancy;
                playerEntity.SpawnCityGuards(true);

                return(false);
            }
            else if ((inTown || !playerGPS.HasCurrentLocation) && playerEnterExit.IsPlayerInsideBuilding)
            {
                // Check for guild hall rest privileges
                if (GameManager.Instance.GuildManager.GetGuild(playerEnterExit.BuildingDiscoveryData.factionID).CanRest())
                {
                    playerEnterExit.Interior.FindMarker(out allocatedBed, DaggerfallInterior.InteriorMarkerTypes.Rest);
                    return(true);
                }
                // Check owned locations
                string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey);
                if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName))
                {
                    // Can rest if it's an player owned ship/house.
                    int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey;
                    if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey))
                    {
                        return(true);
                    }

                    // Find room rental record and get remaining time..
                    int           mapId = playerGPS.CurrentLocation.MapTableData.MapId;
                    RoomRental_v1 room  = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey);
                    remainingHoursRented = PlayerEntity.GetRemainingHours(room);
                    allocatedBed         = room.allocatedBed;
                    if (remainingHoursRented > 0)
                    {
                        return(true);
                    }
                }
                CloseWindow();
                DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom);
                return(false);
            }
            return(true);
        }
Beispiel #14
0
            public override string LocationDirection()
            {
                Vector2 positionPlayer;
                Vector2 positionLocation = Vector2.zero;

                DFPosition position  = new DFPosition();
                PlayerGPS  playerGPS = GameManager.Instance.PlayerGPS;

                if (playerGPS)
                {
                    position = playerGPS.CurrentMapPixel;
                }

                positionPlayer = new Vector2(position.X, position.Y);

                int region = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetPoliticIndex(position.X, position.Y) - 128;

                if (region < 0 || region >= DaggerfallUnity.Instance.ContentReader.MapFileReader.RegionCount)
                {
                    region = -1;
                }

                DFRegion.RegionMapTable locationInfo = new DFRegion.RegionMapTable();

                DFRegion currentDFRegion = DaggerfallUnity.Instance.ContentReader.MapFileReader.GetRegion(region);

                string name = this.parent.LastPlaceReferenced.SiteDetails.locationName.ToLower();

                string[] locations = currentDFRegion.MapNames;
                for (int i = 0; i < locations.Length; i++)
                {
                    if (locations[i].ToLower() == name) // Valid location found with exact name
                    {
                        if (currentDFRegion.MapNameLookup.ContainsKey(locations[i]))
                        {
                            int index = currentDFRegion.MapNameLookup[locations[i]];
                            locationInfo     = currentDFRegion.MapTable[index];
                            position         = MapsFile.LongitudeLatitudeToMapPixel((int)locationInfo.Longitude, (int)locationInfo.Latitude);
                            positionLocation = new Vector2(position.X, position.Y);
                        }
                    }
                }

                if (positionLocation != Vector2.zero)
                {
                    Vector2 vecDirectionToTarget = positionLocation - positionPlayer;
                    vecDirectionToTarget.y = -vecDirectionToTarget.y; // invert y axis
                    return(GameManager.Instance.TalkManager.DirectionVector2DirectionHintString(vecDirectionToTarget));
                }
                else
                {
                    return("... never mind ...");
                }
            }
Beispiel #15
0
        // Gets current player position in map pixels
        DFPosition GetPlayerMapPosition()
        {
            DFPosition position  = new DFPosition();
            PlayerGPS  playerGPS = GameManager.Instance.PlayerGPS;

            if (playerGPS)
            {
                position = playerGPS.CurrentMapPixel;
            }

            return(position);
        }
        public override IQuestAction CreateNew(string source, Quest parentQuest)
        {
            // Source must match pattern
            Match match = Test(source);

            if (!match.Success)
            {
                return(null);
            }

            // Factory new action
            WhenPcEntersExits action = new WhenPcEntersExits(parentQuest);

            action.sourceExteriorType = match.Groups["exteriorType"].Value;
            if (!string.IsNullOrEmpty(match.Groups["enters"].Value))
            {
                action.onEnter = true;
            }
            else if (!string.IsNullOrEmpty(match.Groups["exits"].Value))
            {
                action.onEnter = false;
            }
            else
            {
                throw new Exception("WhenPcEntersExits: Syntax is 'when pc enters exteriorType | when pc exits exteriorType");
            }

            // Get location type index
            Table placesTable = QuestMachine.Instance.PlacesTable;
            int   p1          = placesTable.GetInt("p1", action.sourceExteriorType);

            if (p1 != 2)
            {
                throw new Exception("WhenPcEntersExits: This trigger condition can only be used with exterior types of p1=2 in Quests-Places table.");
            }
            action.indexExteriorType = placesTable.GetInt("p2", action.sourceExteriorType);

            // Set location type (if any) when quest starts
            PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;

            if (playerGPS.IsPlayerInLocationRect)
            {
                if (playerGPS.CurrentLocation.Loaded)
                {
                    action.currentLocationType = playerGPS.CurrentLocation.MapTableData.LocationType;
                }
            }

            // Register events when creating action
            action.RegisterEvents();

            return(action);
        }
 void Start()
 {
     playerGPS       = GetComponent <PlayerGPS>();
     playerEnterExit = GetComponent <PlayerEnterExit>();
     if (RainParticles)
     {
         RainParticles.SetActive(false);
     }
     if (SnowParticles)
     {
         SnowParticles.SetActive(false);
     }
 }
Beispiel #18
0
        //
        // Global macro handlers - not context sensitive. (mcp will be null, and should not be used)
        //
        #region Global macro handlers

        private static string CityName(IMacroContextProvider mcp)
        {   // %cn
            PlayerGPS gps = GameManager.Instance.PlayerGPS;

            if (gps.HasCurrentLocation)
            {
                return(gps.CurrentLocation.Name);
            }
            else
            {
                return(gps.CurrentRegion.Name);
            }
        }
Beispiel #19
0
 void Start()
 {
     PlayerGps       = GetComponent <PlayerGPS>();
     playerEnterExit = GetComponent <PlayerEnterExit>();
     if (RainParticles)
     {
         RainParticles.SetActive(false);
     }
     if (SnowParticles)
     {
         SnowParticles.SetActive(false);
     }
     ClimateWeathers = new byte[6];
 }
        private static string Title(IMacroContextProvider mcp)
        {   // %t
            PlayerGPS gps = GameManager.Instance.PlayerGPS;

            FactionFile.FactionData regionFaction;
            GameManager.Instance.PlayerEntity.FactionData.FindFactionByTypeAndRegion(7, gps.CurrentRegionIndex + 1, out regionFaction);

            switch (regionFaction.ruler)
            {
            case 1:
                return("King");

            case 2:
                return("Queen");

            case 3:
                return("Duke");

            case 4:
                return("Duchess");

            case 5:
                return("Marquis");

            case 6:
                return("Marquise");

            case 7:
                return("Count");

            case 8:
                return("Countess");

            case 9:
                return("Baron");

            case 10:
                return("Baroness");

            case 11:
                return("Lord");

            case 12:
                return("Lady");

            default:
                return("Lord");
            }
        }
Beispiel #21
0
        private static string Title(IMacroContextProvider mcp)
        {   // %t
            PlayerGPS gps = GameManager.Instance.PlayerGPS;

            FactionFile.FactionData regionFaction;
            GameManager.Instance.PlayerEntity.FactionData.FindFactionByTypeAndRegion(7, gps.CurrentRegionIndex + 1, out regionFaction);

            switch (regionFaction.ruler)
            {
            case 1:
                return(HardStrings.King);

            case 2:
                return(HardStrings.Queen);

            case 3:
                return(HardStrings.Duke);

            case 4:
                return(HardStrings.Duchess);

            case 5:
                return(HardStrings.Marquis);

            case 6:
                return(HardStrings.Marquise);

            case 7:
                return(HardStrings.Count);

            case 8:
                return(HardStrings.Countess);

            case 9:
                return(HardStrings.Baron);

            case 10:
                return(HardStrings.Baroness);

            case 11:
                return(HardStrings.Lord);

            case 12:
                return(HardStrings.Lady);

            default:
                return(HardStrings.Lord);
            }
        }
        void Start()
        {
            dfUnity         = DaggerfallUnity.Instance;
            streamingWorld  = GameObject.FindObjectOfType <StreamingWorld>();
            playerEnterExit = GetComponent <PlayerEnterExit>();
            playerGPS       = GetComponent <PlayerGPS>();
            playerMotor     = GetComponent <PlayerMotor>();
            playerMouseLook = GameObject.FindObjectOfType <PlayerMouseLook>();
            titleScreen     = GameObject.FindObjectOfType <ShowTitleScreen>();

            // Get starting run speed
            if (playerMotor)
            {
                startRunSpeed = playerMotor.runSpeed;
            }
        }
        /// <summary>Gets current player position in map pixels for purposes of travel</summary>
        public static DFPosition GetPlayerTravelPosition()
        {
            DFPosition       position         = new DFPosition();
            PlayerGPS        playerGPS        = GameManager.Instance.PlayerGPS;
            TransportManager transportManager = GameManager.Instance.TransportManager;

            if (playerGPS && !transportManager.IsOnShip())
            {
                position = playerGPS.CurrentMapPixel;
            }
            else
            {
                position = MapsFile.WorldCoordToMapPixel(transportManager.BoardShipPosition.worldPosX, transportManager.BoardShipPosition.worldPosZ);
            }
            return(position);
        }
        /// <summary>
        /// Sets NPC data from RMB layout.
        /// </summary>
        public void SetLayoutData(DFBlock.RmbBlockPeopleRecord obj, int buildingKey = 0)
        {
            PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;

            SetLayoutData(ref npcData,
                          obj.XPos, obj.YPos, obj.ZPos,
                          obj.Flags,
                          obj.FactionID,
                          obj.TextureArchive,
                          obj.TextureRecord,
                          obj.Position,
                          playerGPS.CurrentMapID,
                          playerGPS.CurrentLocation.LocationIndex,
                          buildingKey);
            npcData.context = Context.Building;
        }
Beispiel #25
0
        private void Start()
        {
            // Cache references
            playerGPS      = GameManager.Instance.PlayerGPS;
            dfLocation     = GetComponent <DaggerfallLocation>();
            cityNavigation = GetComponent <CityNavigation>();

            // Get dominant race in locations climate zone
            populationRace = playerGPS.ClimateSettings.People;

            // Calculate maximum population
            int totalBlocks      = dfLocation.Summary.BlockWidth * dfLocation.Summary.BlockHeight;
            int populationBlocks = Mathf.Clamp(totalBlocks / 16, 1, 4);

            maxPopulation = populationBlocks * populationIndexPer16Blocks;
        }
        /// <summary>
        /// Sets NPC data from RDB layout.
        /// </summary>
        public void SetLayoutData(DFBlock.RdbObject obj)
        {
            PlayerGPS playerGPS = GameManager.Instance.PlayerGPS;

            SetLayoutData(ref npcData,
                          obj.XPos, obj.YPos, obj.ZPos,
                          obj.Resources.FlatResource.Flags,
                          obj.Resources.FlatResource.FactionOrMobileId,
                          obj.Resources.FlatResource.TextureArchive,
                          obj.Resources.FlatResource.TextureRecord,
                          obj.Resources.FlatResource.Position,
                          playerGPS.CurrentMapID,
                          playerGPS.CurrentLocation.LocationIndex,
                          0);
            npcData.context = Context.Dungeon;
        }
Beispiel #27
0
        protected void FollowPath()
        {
            PlayerGPS  playerGPS    = GameManager.Instance.PlayerGPS;
            DFPosition currMapPixel = playerGPS.CurrentMapPixel;

            bool inLoc = locationRect.Contains(new Vector2(playerGPS.WorldX, playerGPS.WorldZ));

            // Start following a path
            byte pathsDataPt = GetPathsDataPoint(currMapPixel);
            byte onPath      = IsPlayerOnPath(playerGPS, pathsDataPt);

            if (onPath != 0)
            {
                byte playerDirection = GetDirection(GetNormalisedPlayerYaw());
                byte roadDataPt      = GetRoadsDataPoint(currMapPixel);
#if UNITY_EDITOR
                Debug.LogFormat("Begun following path {0}", GetDirectionStr(playerDirection));
#endif
                if ((inLoc && (pathsDataPt & playerDirection) != 0) || (pathsDataPt & playerDirection & onPath) != 0)
                {
                    road            = (roadDataPt & playerDirection) != 0;
                    DestinationName = null;     // Remove any specified destination
                    BeginPathTravel(GetTargetPixel(playerDirection, currMapPixel));
                    return;
                }
                else
                {
                    byte fromDirection = GetDirection(GetNormalisedPlayerYaw(true));
                    if ((inLoc && (pathsDataPt & fromDirection) != 0) || (pathsDataPt & fromDirection & onPath) != 0)
                    {
                        road            = (roadDataPt & fromDirection) != 0;
                        DestinationName = null;     // Remove any specified destination
                        BeginPathTravel(GetTargetPixel(0, currMapPixel));
                        return;
                    }
                }
            }
            if (!inLoc && locationBorderRect.Contains(new Vector2(playerGPS.WorldX, playerGPS.WorldZ)))
            {
                // Player in location border, initiate location circumnavigation
                SetupLocBorderCornerRects();
                CircumnavigateLocation();
                return;
            }

            DaggerfallUI.AddHUDText(MsgNoPath);
        }
Beispiel #28
0
        byte IsPlayerOnPath(PlayerGPS playerGPS, byte pathsDataPt)
        {
            if (pathsDataPt == 0)
            {
                return(0);
            }

            byte       onPath        = 0;
            DFPosition worldOriginMP = MapsFile.MapPixelToWorldCoord(playerGPS.CurrentMapPixel.X, playerGPS.CurrentMapPixel.Y);
            DFPosition posInMp       = new DFPosition(playerGPS.WorldX - worldOriginMP.X, playerGPS.WorldZ - worldOriginMP.Y);

            if ((pathsDataPt & N) != 0 && posInMp.X > MidLo && posInMp.X < MidHi && posInMp.Y > MidLo)
            {
                onPath = (byte)(onPath | N);
            }
            if ((pathsDataPt & E) != 0 && posInMp.Y > MidLo && posInMp.Y < MidHi && posInMp.X > MidLo)
            {
                onPath = (byte)(onPath | E);
            }
            if ((pathsDataPt & S) != 0 && posInMp.X > MidLo && posInMp.X < MidHi && posInMp.Y < MidHi)
            {
                onPath = (byte)(onPath | S);
            }
            if ((pathsDataPt & W) != 0 && posInMp.Y > MidLo && posInMp.Y < MidHi && posInMp.X < MidHi)
            {
                onPath = (byte)(onPath | W);
            }
            if ((pathsDataPt & NE) != 0 && (Mathf.Abs(posInMp.X - posInMp.Y) < PSize) && posInMp.X > MidLo)
            {
                onPath = (byte)(onPath | NE);
            }
            if ((pathsDataPt & SW) != 0 && (Mathf.Abs(posInMp.X - posInMp.Y) < PSize) && posInMp.X < MidHi)
            {
                onPath = (byte)(onPath | SW);
            }
            if ((pathsDataPt & NW) != 0 && (Mathf.Abs(posInMp.X - (MPworldUnits - posInMp.Y)) < PSize) && posInMp.X < MidHi)
            {
                onPath = (byte)(onPath | NW);
            }
            if ((pathsDataPt & SE) != 0 && (Mathf.Abs(posInMp.X - (MPworldUnits - posInMp.Y)) < PSize) && posInMp.X > MidLo)
            {
                onPath = (byte)(onPath | SE);
            }

            return(onPath);
        }
        //PlayerMotor playerMotor;
        //PlayerMouseLook playerMouseLook;
        //ShowTitleScreen titleScreen;

        //int timeScaleControl = 1;
        //int minTimeScaleControl = 1;
        //int maxTimeScaleControl = 150;
        //int timeScaleStep = 25;
        //float timeScaleMultiplier = 10f;
        //float startRunSpeed;
        //float startTorchRange;
        //bool showDebugStrings = false;
        //bool invertMouse = false;
        //bool hiRunSpeed = false;
        //bool hiTorchRange = false;

        void Start()
        {
            dfUnity         = DaggerfallUnity.Instance;
            streamingWorld  = GameObject.FindObjectOfType <StreamingWorld>();
            playerEnterExit = GetComponent <PlayerEnterExit>();
            playerGPS       = GetComponent <PlayerGPS>();
            //playerMotor = GetComponent<PlayerMotor>();
            //playerMouseLook = GameObject.FindObjectOfType<PlayerMouseLook>();
            //titleScreen = GameObject.FindObjectOfType<ShowTitleScreen>();

            //// Get starting run speed
            //if (playerMotor)
            //    startRunSpeed = playerMotor.runSpeed;

            //// Get starting torch range
            //if (PlayerTorch != null)
            //    startTorchRange = PlayerTorch.range;
        }
Beispiel #30
0
        /// <summary>
        /// Check if player is allowed to rest at this location.
        /// </summary>
        bool CanRest()
        {
            remainingHoursRented = -1;
            allocatedBed         = Vector3.zero;
            PlayerEnterExit playerEnterExit = GameManager.Instance.PlayerEnterExit;
            PlayerGPS       playerGPS       = GameManager.Instance.PlayerGPS;

            bool inTown = playerGPS.IsPlayerInTown(true);

            if (inTown && !playerEnterExit.IsPlayerInside)
            {
                CloseWindow();
                DaggerfallUI.MessageBox(cityCampingIllegal);
                return(false);
            }
            else if ((inTown || !playerGPS.HasCurrentLocation) && playerEnterExit.IsPlayerInsideBuilding)
            {
                string sceneName = DaggerfallInterior.GetSceneName(playerGPS.CurrentLocation.MapTableData.MapId, playerEnterExit.BuildingDiscoveryData.buildingKey);
                if (SaveLoadManager.StateManager.ContainsPermanentScene(sceneName))
                {
                    // Can rest if it's an player owned ship/house.
                    int buildingKey = playerEnterExit.BuildingDiscoveryData.buildingKey;
                    if (playerEnterExit.BuildingType == DFLocation.BuildingTypes.Ship || DaggerfallBankManager.IsHouseOwned(buildingKey))
                    {
                        return(true);
                    }

                    // Find room rental record and get remaining time..
                    int           mapId = playerGPS.CurrentLocation.MapTableData.MapId;
                    RoomRental_v1 room  = GameManager.Instance.PlayerEntity.GetRentedRoom(mapId, buildingKey);
                    remainingHoursRented = PlayerEntity.GetRemainingHours(room);
                    allocatedBed         = room.allocatedBed;
                    if (remainingHoursRented > 0)
                    {
                        return(true);
                    }
                }
                CloseWindow();
                DaggerfallUI.MessageBox(HardStrings.haveNotRentedRoom);
                return(false);
            }
            return(true);
        }
 void Start()
 {
     playerGPS = GetComponent<PlayerGPS>();
     playerEnterExit = GetComponent<PlayerEnterExit>();
     if (RainParticles) RainParticles.SetActive(false);
     if (SnowParticles) SnowParticles.SetActive(false);
 }
 void Awake()
 {
     dfUnity = DaggerfallUnity.Instance;
     //mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
     //playerMouseLook = GetComponent<PlayerMouseLook>();
     playerGPS = GetComponent<PlayerGPS>();
     world = FindObjectOfType<StreamingWorld>();
 }
 void Start()
 {
     dfUnity = DaggerfallUnity.Instance;
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
     playerGPS = GetComponent<PlayerGPS>();
 }
 void Start()
 {
     playerGPS = GetComponent<PlayerGPS>();
     playerEnterExit = GetComponent<PlayerEnterExit>();
     mainCamera = GameObject.FindGameObjectWithTag("MainCamera");
 }
 void Start()
 {
     playerGPS = GetComponent<PlayerGPS>();
     ResetText();
 }
        void Start()
        {
            dfUnity = DaggerfallUnity.Instance;
            streamingWorld = GameObject.FindObjectOfType<StreamingWorld>();
            playerEnterExit = GetComponent<PlayerEnterExit>();
            playerGPS = GetComponent<PlayerGPS>();
            playerMotor = GetComponent<PlayerMotor>();
            playerMouseLook = GameObject.FindObjectOfType<PlayerMouseLook>();
            titleScreen = GameObject.FindObjectOfType<ShowTitleScreen>();

            // Get starting run speed
            if (playerMotor)
                startRunSpeed = playerMotor.runSpeed;

            // Get starting torch range
            if (PlayerTorch != null)
                startTorchRange = PlayerTorch.range;
        }