Beispiel #1
0
        /// <summary>
        ///     Adds the experience.
        /// </summary>
        /// <param name="amount">The amount.</param>
        internal void AddExperience(uint amount)
        {
            int oldExperienceGoal = ExperienceGoal;

            Experience += amount;

            if (Experience >= 51900)
            {
                return;
            }

            if (DbState != DatabaseUpdateState.NeedsInsert)
            {
                DbState = DatabaseUpdateState.NeedsUpdate;
            }

            if (Room == null)
            {
                return;
            }

            PetExperienceComposer.GenerateMessage(this, amount);

            if (Experience < oldExperienceGoal)
            {
                return;
            }

            GameClient ownerSession = Yupi.GetGame().GetClientManager().GetClientByUserId(OwnerId);

            Dictionary <uint, PetCommand> totalPetCommands = PetCommandHandler.GetAllPetCommands();

            Dictionary <uint, PetCommand> petCommands = PetCommandHandler.GetPetCommandByPetType(Type);

            if (ownerSession == null)
            {
                return;
            }

            ServerMessage levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer"));

            SerializeInventory(levelNotify, true);

            ownerSession.SendMessage(levelNotify);

            PetCommandPanelComposer.GenerateMessage(this, totalPetCommands, petCommands, ownerSession);
        }
Beispiel #2
0
Datei: Pet.cs Projekt: sgf/Yupi
        /// <summary>
        ///     Adds the experience.
        /// </summary>
        /// <param name="amount">The amount.</param>
        internal void AddExperience(int amount)
        {
            int oldExperienceGoal = ExperienceGoal;

            Experience += amount;

            if (Experience >= 51900)
            {
                return;
            }

            if (DbState != DatabaseUpdateState.NeedsInsert)
            {
                DbState = DatabaseUpdateState.NeedsUpdate;
            }

            if (Room == null)
            {
                return;
            }

            ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("AddPetExperienceMessageComposer"));

            serverMessage.AppendInteger(PetId);
            serverMessage.AppendInteger(VirtualId);
            serverMessage.AppendInteger(amount);
            Room.SendMessage(serverMessage);

            if (Experience < oldExperienceGoal)
            {
                return;
            }

            GameClient ownerSession = Yupi.GetGame().GetClientManager().GetClientByUserId(OwnerId);

            Dictionary <uint, PetCommand> totalPetCommands = PetCommandHandler.GetAllPetCommands();

            Dictionary <uint, PetCommand> petCommands = PetCommandHandler.GetPetCommandByPetType(Type);

            if (ownerSession == null)
            {
                return;
            }

            ServerMessage levelNotify = new ServerMessage(LibraryParser.OutgoingRequest("NotifyNewPetLevelMessageComposer"));

            SerializeInventory(levelNotify, true);

            ownerSession.SendMessage(levelNotify);

            ServerMessage tp = new ServerMessage();

            tp.Init(LibraryParser.OutgoingRequest("PetTrainerPanelMessageComposer"));

            tp.AppendInteger(PetId);

            tp.AppendInteger(totalPetCommands.Count);

            foreach (uint sh in totalPetCommands.Keys)
            {
                tp.AppendInteger(sh);
            }

            tp.AppendInteger(petCommands.Count);

            foreach (uint sh in petCommands.Keys)
            {
                tp.AppendInteger(sh);
            }

            ownerSession.SendMessage(tp);
        }