コード例 #1
0
ファイル: RoomUserManager.cs プロジェクト: bblackv/Yupi
        /// <summary>
        ///     Deploys the bot.
        /// </summary>
        /// <param name="bot">The bot.</param>
        /// <param name="petData">The pet data.</param>
        /// <returns>RoomUser.</returns>
        internal RoomUser DeployBot(RoomBot bot, Pet petData)
        {
            int virtualId = _primaryPrivateUserId++;

            RoomUser roomUser = new RoomUser(0u, _userRoom.RoomId, virtualId, _userRoom, false);

            int num = _secondaryPrivateUserId++;

            roomUser.InternalRoomId = num;
            UserList.TryAdd(num, roomUser);
            OnUserAdd(roomUser);

            DynamicRoomModel model = _userRoom.GetGameMap().Model;
            Point coord = new Point(bot.X, bot.Y);

            if ((bot.X > 0) && (bot.Y >= 0) && (bot.X < model.MapSizeX) && (bot.Y < model.MapSizeY))
            {
                _userRoom.GetGameMap().AddUserToMap(roomUser, coord);
                roomUser.SetPos(bot.X, bot.Y, bot.Z);
                roomUser.SetRot(bot.Rot, false);
            }
            else
            {
                bot.X = model.DoorX;
                bot.Y = model.DoorY;
                roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ);
                roomUser.SetRot(model.DoorOrientation, false);
            }

            bot.RoomUser = roomUser;
            roomUser.BotData = bot;

            roomUser.BotAi = bot.GenerateBotAi(roomUser.VirtualId, (int) bot.BotId);

            if (roomUser.IsPet)
            {
                roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom);
                roomUser.PetData = petData;
                roomUser.PetData.VirtualId = roomUser.VirtualId;
            }
            else
                roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom);

            UpdateUserStatus(roomUser, false);
            roomUser.UpdateNeeded = true;

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

            serverMessage.AppendInteger(1);
            roomUser.Serialize(serverMessage, _userRoom.GetGameMap().GotPublicPool);

            _userRoom.SendMessage(serverMessage);

            roomUser.BotAi.OnSelfEnterRoom();

            if (roomUser.IsPet)
            {
                if (_pets.Contains(roomUser.PetData.PetId))
                    _pets[roomUser.PetData.PetId] = roomUser;
                else
                    _pets.Add(roomUser.PetData.PetId, roomUser);

                PetCount++;
            }

            roomUser.BotAi.Modified();

            if (roomUser.BotData.AiType != AiType.Generic)
                return roomUser;

            if (_bots.Contains(roomUser.BotData.BotId))
                _bots[roomUser.BotData.BotId] = roomUser;
            else
                _bots.Add(roomUser.BotData.BotId, roomUser);

            serverMessage.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer"));
            serverMessage.AppendInteger(roomUser.VirtualId);
            serverMessage.AppendInteger(roomUser.BotData.DanceId);
            _userRoom.SendMessage(serverMessage);
            PetCount++;

            return roomUser;
        }
コード例 #2
0
ファイル: CatalogManager.cs プロジェクト: ImNotSatan/Yupi
        /// <summary>
        ///     Creates the pet.
        /// </summary>
        /// <param name="userId">The user 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="rarity">The rarity.</param>
        /// <returns>Pet.</returns>
        internal static Pet CreatePet(uint userId, string name, string type, string race, string color, int rarity = 0)
        {
            uint trace = Convert.ToUInt32(race);

            uint petId = 404u;

            Pet pet = new Pet(petId, userId, 0u, name, type, trace, 0, 100, 150, 0, Yupi.GetUnixTimeStamp(), 0, 0, 0.0,
                false, 0, 0, -1, rarity, DateTime.Now.AddHours(36.0), DateTime.Now.AddHours(48.0), null, color)
            {
                DbState = DatabaseUpdateState.NeedsUpdate
            };

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery(
                    "INSERT INTO pets_data (user_id, name, ai_type, pet_type, race_id, experience, energy, createstamp, rarity, lasthealth_stamp, untilgrown_stamp, color) " +
                    $"VALUES ('{pet.OwnerId}', @petName, 'pet', @petType, @petRace, 0, 100, UNIX_TIMESTAMP(), '{rarity}', UNIX_TIMESTAMP(now() + INTERVAL 36 HOUR), UNIX_TIMESTAMP(now() + INTERVAL 48 HOUR), @petColor)");

                queryReactor.AddParameter("petName", pet.Name);
                queryReactor.AddParameter("petType", pet.Type);
                queryReactor.AddParameter("petRace", pet.Race);
                queryReactor.AddParameter("petColor", pet.Color);

                petId = (uint)queryReactor.InsertQuery();
            }

            pet.PetId = petId;

            if (pet.Type == "pet_monster")
            {
                pet.MoplaBreed = MoplaBreed.CreateMonsterplantBreed(pet);
                pet.Name = pet.MoplaBreed.Name;
                pet.DbState = DatabaseUpdateState.NeedsUpdate;
            }

            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId != null)
                Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserId, "ACH_PetLover", 1);

            return pet;
        }
コード例 #3
0
ファイル: InventoryComponent.cs プロジェクト: AngelRmz/Yupi
        internal void AddPets(Pet bot)
        {
            _isUpdated = false;

            if (bot == null || _inventoryPets.Contains(bot.PetId))
                return;

            bot.RoomId = 0u;

            _inventoryPets.Add(bot.PetId, bot);
        }
コード例 #4
0
ファイル: RoomItemHandler.cs プロジェクト: ImNotSatan/Yupi
        /// <summary>
        ///     Gets the random breeding terrier.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>Point.</returns>
        internal Point GetRandomBreedingTerrier(Pet pet)
        {
            if (!BreedingTerrier.Any())
                return new Point();
            List<uint> keys = new List<uint>(BreedingTerrier.Keys);
            int size = BreedingTerrier.Count;
            Random rand = new Random();
            uint randomKey = keys[rand.Next(size)];

            BreedingTerrier[randomKey].PetsList.Add(pet);
            pet.WaitingForBreading = BreedingTerrier[randomKey].Id;
            pet.BreadingTile = BreedingTerrier[randomKey].Coordinate;

            return BreedingTerrier[randomKey].Coordinate;
        }
コード例 #5
0
ファイル: InventoryComponent.cs プロジェクト: AngelRmz/Yupi
        /// <summary>
        ///     Adds the pet.
        /// </summary>
        /// <param name="pet">The pet.</param>
        internal void AddPet(Pet pet)
        {
            _isUpdated = false;

            if (pet == null || _inventoryPets.Contains(pet.PetId))
                return;

            pet.PlacedInRoom = false;
            pet.RoomId = 0u;

            _inventoryPets.Add(pet.PetId, pet);

            SerializePetInventory();
        }
コード例 #6
0
ファイル: PetBreeding.cs プロジェクト: sgf/Yupi
        /// <summary>
        ///     Gets the message.
        /// </summary>
        /// <param name="furniId">The furni identifier.</param>
        /// <param name="pet1">The pet1.</param>
        /// <param name="pet2">The pet2.</param>
        /// <returns>ServerMessage.</returns>
        internal static ServerMessage GetMessage(uint furniId, Pet pet1, Pet pet2)
        {
            ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("PetBreedMessageComposer"));

            message.AppendInteger(furniId);
            message.AppendInteger(pet1.PetId);
            message.AppendString(pet1.Name);
            message.AppendInteger(pet1.Level);
            message.AppendString(pet1.Look);
            message.AppendString(pet1.OwnerName);
            message.AppendInteger(pet2.PetId);
            message.AppendString(pet2.Name);
            message.AppendInteger(pet2.Level);
            message.AppendString(pet2.Look);
            message.AppendString(pet2.OwnerName);
            message.AppendInteger(4);

            message.AppendInteger(1);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierEpicRace.Length);

                    foreach (int value in TerrierEpicRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearEpicRace.Length);

                    foreach (int value in BearEpicRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(2);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierRareRace.Length);

                    foreach (int value in TerrierRareRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearRareRace.Length);

                    foreach (int value in BearRareRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(3);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierNoRareRace.Length);

                    foreach (int value in TerrierNoRareRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearNoRareRace.Length);

                    foreach (int value in BearNoRareRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(94);

            switch (pet1.Type)
            {
                case 3:
                    message.AppendInteger(TerrierNormalRace.Length);

                    foreach (int value in TerrierNormalRace)
                        message.AppendInteger(value);

                    break;

                case 4:
                    message.AppendInteger(BearNormalRace.Length);

                    foreach (int value in BearNormalRace)
                        message.AppendInteger(value);

                    break;
            }

            message.AppendInteger(pet1.Type == 3 ? 25 : 24);

            return message;
        }
コード例 #7
0
ファイル: CatalogManager.cs プロジェクト: sgf/Yupi
        /// <summary>
        ///     Creates the pet.
        /// </summary>
        /// <param name="userId">The user 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="rarity">The rarity.</param>
        /// <returns>Pet.</returns>
        internal static Pet CreatePet(uint userId, string name, int type, string race, string color, int rarity = 0)
        {
            Pet pet = new Pet(404u, userId, 0u, name, (uint) type, race, color, 0, 100, 150, 0, Yupi.GetUnixTimeStamp(), 0, 0, 0.0, false, 0, 0, -1, rarity, DateTime.Now.AddHours(36.0), DateTime.Now.AddHours(48.0), null)
            {
                DbState = DatabaseUpdateState.NeedsUpdate
            };

            using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                queryReactor.SetQuery($"INSERT INTO bots_data (user_id, name, ai_type) VALUES ('{pet.OwnerId}', @{$"{pet.PetId}name"}, 'pet')");

                queryReactor.AddParameter($"{pet.PetId}name", pet.Name);

                pet.PetId = (uint)queryReactor.InsertQuery();

                queryReactor.SetQuery(string.Concat("INSERT INTO pets_data (id,type,race,color,experience,energy,createstamp,rarity,lasthealth_stamp,untilgrown_stamp) VALUES (", pet.PetId, ", ", pet.Type, ",@", pet.PetId, "race,@", pet.PetId, "color,0,100,UNIX_TIMESTAMP(), ", rarity, ", UNIX_TIMESTAMP(now() + INTERVAL 36 HOUR), UNIX_TIMESTAMP(now() + INTERVAL 48 HOUR))"));

                queryReactor.AddParameter($"{pet.PetId}race", pet.Race);
                queryReactor.AddParameter($"{pet.PetId}color", pet.Color);
                queryReactor.RunQuery();
            }

            if (pet.Type == 16u)
            {
                pet.MoplaBreed = MoplaBreed.CreateMonsterplantBreed(pet);
                pet.Name = pet.MoplaBreed.Name;
                pet.DbState = DatabaseUpdateState.NeedsUpdate;
            }

            GameClient clientByUserId = Yupi.GetGame().GetClientManager().GetClientByUserId(userId);

            if (clientByUserId != null)
                Yupi.GetGame().GetAchievementManager().ProgressUserAchievement(clientByUserId, "ACH_PetLover", 1);

            return pet;
        }
コード例 #8
0
ファイル: MoplaBreed.cs プロジェクト: weslley17w/Yupi
 /// <summary>
 ///     Initializes a new instance of the <see cref="MoplaBreed" /> class.
 /// </summary>
 /// <param name="pet">The pet.</param>
 /// <param name="petId">The pet identifier.</param>
 /// <param name="rarity">The rarity.</param>
 /// <param name="moplaName">Name of the mopla.</param>
 /// <param name="breedData">The breed data.</param>
 /// <param name="liveState">State of the live.</param>
 /// <param name="growingStatus">The growing status.</param>
 internal MoplaBreed(Pet pet, uint petId, int rarity, string moplaName, string breedData, int liveState,
     int growingStatus)
 {
     _pet = pet;
     _petId = petId;
     _rarity = rarity;
     Name = moplaName;
     PlantData = breedData;
     LiveState = (MoplaState) liveState;
     GrowingStatus = growingStatus;
 }
コード例 #9
0
ファイル: MoplaBreed.cs プロジェクト: weslley17w/Yupi
        /// <summary>
        ///     Creates the monsterplant breed.
        /// </summary>
        /// <param name="pet">The pet.</param>
        /// <returns>MoplaBreed.</returns>
        internal static MoplaBreed CreateMonsterplantBreed(Pet pet)
        {
            if (pet.Type != "pet_monster")
                return null;

            Tuple<string, string> tuple = GeneratePlantData(pet.Rarity);
            MoplaBreed breed = new MoplaBreed(pet, pet.PetId, pet.Rarity, tuple.Item1, tuple.Item2, 0, 1);

            using (IQueryAdapter adapter = Yupi.GetDatabaseManager().GetQueryReactor())
            {
                adapter.SetQuery(
                    "INSERT INTO pets_plants (pet_id, rarity, plant_name, plant_data) VALUES (@petid , @rarity , @plantname , @plantdata)");
                adapter.AddParameter("petid", pet.PetId);
                adapter.AddParameter("rarity", pet.Rarity);
                adapter.AddParameter("plantname", tuple.Item1);
                adapter.AddParameter("plantdata", tuple.Item2);
                adapter.RunQuery();
            }

            return breed;
        }