Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Pet"/> class.
 /// </summary>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="ownerId">The owner identifier.</param>
 /// <param name="roomId">The room identifier.</param>
 /// <param name="name">The name.</param>
 /// <param name="type">The type.</param>
 /// <param name="race">The race.</param>
 /// <param name="color">The color.</param>
 /// <param name="experience">The experience.</param>
 /// <param name="energy">The energy.</param>
 /// <param name="nutrition">The nutrition.</param>
 /// <param name="respect">The respect.</param>
 /// <param name="creationStamp">The creation stamp.</param>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="z">The z.</param>
 /// <param name="havesaddle">if set to <c>true</c> [havesaddle].</param>
 /// <param name="anyoneCanRide">The anyone can ride.</param>
 /// <param name="dye">The dye.</param>
 /// <param name="petHer">The pet her.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="lastHealth">The last health.</param>
 /// <param name="untilGrown">The until grown.</param>
 /// <param name="moplaBreed">The mopla breed.</param>
 internal Pet(uint petId, uint ownerId, uint roomId, string name, uint type, string race, string color,
              int experience, int energy, int nutrition, int respect, double creationStamp, int x, int y, double z,
              bool havesaddle, int anyoneCanRide, int dye, int petHer, int rarity, DateTime lastHealth,
              DateTime untilGrown, MoplaBreed moplaBreed)
 {
     PetId              = petId;
     OwnerId            = ownerId;
     RoomId             = roomId;
     Name               = name;
     Type               = type;
     Race               = race;
     Color              = color;
     Experience         = experience;
     Energy             = energy;
     Nutrition          = nutrition;
     Respect            = respect;
     CreationStamp      = creationStamp;
     X                  = x;
     Y                  = y;
     Z                  = z;
     PlacedInRoom       = false;
     DbState            = DatabaseUpdateState.Updated;
     HaveSaddle         = havesaddle;
     AnyoneCanRide      = anyoneCanRide;
     PetHair            = petHer;
     HairDye            = dye;
     Rarity             = rarity;
     LastHealth         = lastHealth;
     UntilGrown         = untilGrown;
     MoplaBreed         = moplaBreed;
     PetCommands        = PetCommandHandler.GetPetCommands(this);
     WaitingForBreading = 0;
 }
Пример #2
0
        /// <summary>
        /// Adds the experience.
        /// </summary>
        /// <param name="amount">The amount.</param>
        internal void AddExperience(int amount)
        {
            {
                var oldExperienceGoal = ExperienceGoal;
                Experience += amount;
                if (Experience >= 51900)
                {
                    return;
                }
                if (DbState != DatabaseUpdateState.NeedsInsert)
                {
                    DbState = DatabaseUpdateState.NeedsUpdate;
                }
                if (Room == null)
                {
                    return;
                }
                var serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer"));
                serverMessage.AppendInteger(PetId);
                serverMessage.AppendInteger(VirtualId);
                serverMessage.AppendInteger(amount);
                Room.SendMessage(serverMessage);
                if (Experience < oldExperienceGoal)
                {
                    return;
                }
                var ownerSession = Plus.GetGame().GetClientManager().GetClientByUserId(OwnerId);

                // Reset pet commands
                PetCommands.Clear();
                PetCommands = PetCommandHandler.GetPetCommands(this);

                if (ownerSession == null)
                {
                    return;
                }
                //Console.WriteLine("new level notified##############");
                var levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer"));
                SerializeInventory(levelNotify, true);
                ownerSession.SendMessage(levelNotify);

                var tp = new ServerMessage();
                tp.Init(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer"));
                tp.AppendInteger(PetId);

                var availableCommands = new List <short>();

                tp.AppendInteger(PetCommands.Count);
                foreach (short sh in PetCommands.Keys)
                {
                    tp.AppendInteger(sh);
                    if (PetCommands[sh])
                    {
                        availableCommands.Add(sh);
                    }
                }

                tp.AppendInteger(availableCommands.Count);
                foreach (short sh in availableCommands)
                {
                    tp.AppendInteger(sh);
                }
                ownerSession.SendMessage(tp);
            }
        }