Exemple #1
0
        /// <summary>
        /// Adds a player-owned house to the rent queue
        /// </summary>
        private static void AddRentQueue(IPlayer player, House house)
        {
            var playerHouse = new PlayerHouse(player, house);

            RentQueue.Add(playerHouse);
        }
Exemple #2
0
 /// <summary>
 /// Handles the eviction process for a player house
 /// </summary>
 private static void HandleEviction(PlayerHouse playerHouse, bool force = false)
 {
     HandleEviction(playerHouse.House, playerHouse.PlayerGuid, false, force);
 }
Exemple #3
0
        public static async void HandleEviction(PlayerHouse playerHouse)
        {
            // todo: copied from Player_House.HandleActionAbandonHouse, move to House.Abandon()
            // todo: get online copy of house
            var house = playerHouse.House;

            // clear out slumlord inventory
            // todo: get online copy of house
            var slumlord = house.SlumLord;

            slumlord.ClearInventory(true);

            var player = PlayerManager.FindByGuid(playerHouse.PlayerGuid, out bool isOnline);

            if (!PropertyManager.GetBool("house_rent_enabled", true).Item)
            {
                // rent disabled, push forward
                var purchaseTime = (uint)(player.HousePurchaseTimestamp ?? 0);
                var nextRentTime = house.GetRentDue(purchaseTime);
                player.HouseRentTimestamp = (int)nextRentTime;

                log.Info($"HouseManager.HandleRentPaid({playerHouse.PlayerName}): house rent disabled via config");

                BuildRentQueue();
                return;
            }

            house.HouseOwner     = null;
            house.MonarchId      = null;
            house.HouseOwnerName = null;

            house.ClearPermissions();

            house.SaveBiotaToDatabase();

            // relink
            house.UpdateLinks();

            // player slumlord 'off' animation
            var off = new Motion(MotionStance.Invalid, MotionCommand.Off);

            slumlord.CurrentMotionState = off;
            slumlord.EnqueueBroadcastMotion(off);

            // reset slumlord name
            var weenie = DatabaseManager.World.GetCachedWeenie(slumlord.WeenieClassId);
            var wo     = WorldObjectFactory.CreateWorldObject(weenie, ObjectGuid.Invalid);

            slumlord.Name = wo.Name;

            slumlord.EnqueueBroadcast(new GameMessagePublicUpdatePropertyString(slumlord, PropertyString.Name, wo.Name));
            slumlord.SaveBiotaToDatabase();

            player.HouseId       = null;
            player.HouseInstance = null;
            //player.HousePurchaseTimestamp = null;
            player.HouseRentTimestamp = null;

            house.ClearRestrictions();

            log.Info($"HouseManager.HandleRentEviction({playerHouse.PlayerName})");

            BuildRentQueue();

            if (!isOnline)
            {
                // inform player of eviction when they log in
                var offlinePlayer = PlayerManager.GetOfflinePlayer(playerHouse.PlayerGuid);
                if (offlinePlayer == null)
                {
                    log.Warn($"{playerHouse.PlayerName}.HandleEviction(): couldn't find offline player");
                    return;
                }
                offlinePlayer.SetProperty(PropertyBool.HouseEvicted, true);
                offlinePlayer.SaveBiotaToDatabase();
                return;
            }

            var onlinePlayer = PlayerManager.GetOnlinePlayer(playerHouse.PlayerGuid);

            onlinePlayer.House = null;

            // send text message
            onlinePlayer.Session.Network.EnqueueSend(new GameMessageSystemChat("You abandon your house!", ChatMessageType.Broadcast));
            onlinePlayer.RemoveDeed();

            await Task.Delay(3000);     // wait for slumlord inventory biotas above to save

            onlinePlayer.HandleActionQueryHouse();
        }
Exemple #4
0
        private string GetHouseSummary(PlayerHouse house, int index)
        {
            var houseName = index >= Players.Count ? $"House {index}" : $"{Players[index].Personal.PlayerName}'s House";

            return($"{houseName} (lv {house.HouseLevel})");
        }
Exemple #5
0
 private void ChangeRoom(PlayerHouse house)
 {
     RoomIndex = (int)NUD_Room.Value - 1;
     ReloadManager(house);
     DrawLayer();
 }
Exemple #6
0
        public static string GetHouseSummary(IReadOnlyList <Player> players, PlayerHouse house, int index)
        {
            var houseName = index >= players.Count ? $"House {index}" : $"{players[index].Personal.PlayerName}'s House";

            return($"{houseName} (lv {house.HouseLevel})");
        }
Exemple #7
0
        /// <summary>
        /// Removes a house from the collection.
        /// </summary>
        /// <param name="house">The house to remove.</param>
        public void Remove(PlayerHouse house)
        {
            PlayerHouse removedHouse;

            _houses.TryRemove(house.DbPlayerHouse.MapId, out removedHouse);
        }
Exemple #8
0
 /// <summary>
 /// Attempts to get a house from the collection.
 /// </summary>
 /// <param name="mapId">The map id.</param>
 /// <param name="house">The house.</param>
 /// <returns>True if the house was found, false otherwise.</returns>
 public bool TryGetHouse(int mapId, out PlayerHouse house)
 {
     return(_houses.TryGetValue(mapId, out house));
 }
Exemple #9
0
 /// <summary>
 /// Adds a new house to the collection.
 /// </summary>
 /// <param name="house">The house.</param>
 public void Add(PlayerHouse house)
 {
     _houses.TryAdd(house.DbPlayerHouse.MapId, house);
 }
Exemple #10
0
        /// <summary>
        /// Places the player and all NPCs on the map.
        /// </summary>
        private void CreateHumans()
        {
            // place player near top left edge of the screen
            Vector2 coords   = new Vector2(-randomGridForHumans.screenBounds.x + 0.2f, randomGridForHumans.screenBounds.y - 0.2f);
            Vector3 coords3D = new Vector3(coords[0], coords[1], 0);

            //  Place the player
            Player = Instantiate(playerPrefab.GetComponent <Player>(),
                                 coords3D,
                                 Quaternion.identity);
            // give the player a unique id
            Player.myID = npcNumber;

            // player has no hand and no sign at the beginning
            Player.transform.GetChild(1).GetComponent <SpriteRenderer>().enabled = false;
            Player.transform.GetChild(2).GetComponent <SpriteRenderer>().enabled = false;

            // Set the player var of the house
            PlayerHouse playerHouseScript = playerHouse.GetComponent <PlayerHouse>();

            playerHouseScript.setPlayer(Player.gameObject);


            //  Place the NPCs in the grid
            for (int i = 1; i <= npcNumber; i++)
            {
                NPCs.Add(Instantiate(npcPrefab.GetComponent <NPC>(),
                                     randomGridForHumans.RandomCoords[i],
                                     Quaternion.identity));
                // we want to place the npcs in the middle of the screen
                float sby  = randomGridForHumans.screenBounds.y;
                float posy = NPCs[i - 1].transform.position.y;
                // if npcs are too low or to high
                if (Mathf.Abs(NPCs[i - 1].transform.position.y) > 0.33 * sby)
                {
                    // we randomly transform their positition to be more in the middle
                    // we don't care that they touch each other since this is a demo anyway
                    posy = UnityEngine.Random.Range(-sby * 0.5f, sby * 0.45f);
                    NPCs[i - 1].transform.position = new Vector2(NPCs[i - 1].transform.position.x, posy);
                }
                // assign velocity to npcs
                NPCs[i - 1].MinVelocity        = 1.0f;
                NPCs[i - 1].MaxVelocity        = 2.0f;
                NPCs[i - 1].AccelerationFactor = 0.3f;

                // give all npcs a unique id
                NPCs[i - 1].myID = i - 1;

                // these NPCs have a sign
                if (i < 20)
                {
                    // all of them have a hand
                    // we also assign them their own sorting order in the layer
                    // normal NPCs live in sorting order 1
                    // those with a sign live in 2 .. 22
                    // otherwise weird overlaps with the signs happen
                    NPCs[i - 1].transform.GetChild(1).GetComponent <SpriteRenderer>().enabled      = true;
                    NPCs[i - 1].transform.GetChild(1).GetComponent <SpriteRenderer>().sortingOrder = 1 + i;
                    NPCs[i - 1].transform.GetComponent <SpriteRenderer>().sortingOrder             = 1 + i;
                    // we have 7 different signs, one of them is the default one
                    // the other 6 are loaded here since they are called sign1, sign2, etc.
                    string whichSign = (i % 7).ToString();
                    // default sign is the 0th which is already loaded
                    if (i != 0)
                    {
                        string Loader = string.Concat("SmileyPictures/symbols/sign", whichSign);
                        Sprite sign   = Resources.Load <Sprite>(Loader);
                        NPCs[i - 1].transform.GetChild(2).GetComponent <SpriteRenderer>().enabled      = true;
                        NPCs[i - 1].transform.GetChild(2).GetComponent <SpriteRenderer>().sprite       = sign;
                        NPCs[i - 1].transform.GetChild(2).GetComponent <SpriteRenderer>().sortingOrder = 1 + i;
                    }
                }
                else
                {
                    // the other have no hand and no sign
                    NPCs[i - 1].transform.GetChild(1).GetComponent <SpriteRenderer>().enabled = false;
                    NPCs[i - 1].transform.GetChild(2).GetComponent <SpriteRenderer>().enabled = false;
                }
            }

            // infect 20
            for (int i = 0; i < 12; i++)
            {
                NPCs[UnityEngine.Random.Range(0, npcNumber)].SetInitialCondition(NPC.EXPOSED);
            }
        }
Exemple #11
0
 /// <summary>
 /// Handles the eviction process for a player house
 /// </summary>
 private static void HandleEviction(PlayerHouse playerHouse)
 {
     HandleEviction(playerHouse.House, playerHouse.PlayerGuid);
 }