Exemplo n.º 1
0
        public Hashtable AddRandomPet()
        {
            PetDropper.PetDropSettings settings = new PetDropper.PetDropSettings();
            settings.OnGenerateColor();

            settings.OffGeneratePassiveSkill();
            settings.SetPassiveSkill(-1);

            settings.OnGenerateModel();
            settings.OnGenerateActiveSkills();
            settings.OnGenerateDamageType();

            settings.OffSetMastery();
            settings.SetMastery(0);

            settings.OffGenerateRace();
            settings.SetRace((Race)player.GetComponent <RaceableObject>().race);

            PetDropper dropper = new PetDropper();
            PetInfo    info    = dropper.Drop(player.resource.petParameters, settings, player.resource.petSkills, player.resource.petPassiveBonuses);

            player.GetComponent <PetManager>().AddPet(info);
            return(new Hashtable {
                { (int)SPC.ReturnCode, (int)RPCErrorCode.Ok },
                { (int)SPC.Info, info.GetInfo(player.resource) }
            });
        }
Exemplo n.º 2
0
        public Hashtable TransformPetSchemeToPet(string schemeId)
        {
            var inventory      = player.Station.StationInventory;
            var petManager     = player.GetComponent <PetManager>();
            var playerRaceable = player.GetComponent <RaceableObject>();

            if (false == inventory.HasItem(InventoryObjectType.pet_scheme, schemeId))
            {
                return(CreateResponse(RPCErrorCode.ItemNotFound));
            }
            ServerInventoryItem schemeItem = null;

            if (false == inventory.TryGetItem(InventoryObjectType.pet_scheme, schemeId, out schemeItem))
            {
                return(CreateResponse(RPCErrorCode.ErrorOfGettingInventoryItem));
            }

            PetSchemeObject petSchemeObject = schemeItem.Object as PetSchemeObject;

            if (false == petManager.hasFreeSpace)
            {
                return(CreateResponse(RPCErrorCode.LowPetAngarSpace));
            }

            string model = player.resource.petParameters.defaultModels[(Race)playerRaceable.race];

            if (string.IsNullOrEmpty(model))
            {
                return(CreateResponse(RPCErrorCode.ResourceDataError));
            }

            PetDropper.PetDropSettings settings = new PetDropper.PetDropSettings();

            settings.OffGenerateColor();
            settings.SetColor(petSchemeObject.petColor);

            settings.OffGenerateModel();
            settings.SetModel(model);

            settings.OnGeneratePassiveSkill();
            settings.OnGenerateActiveSkills();
            settings.OnGenerateDamageType();

            settings.OnSetMastery();
            settings.SetMastery(0);

            settings.OffGenerateRace();
            settings.SetRace((Race)playerRaceable.race);

            PetDropper dropper = new PetDropper();
            PetInfo    petInfo = dropper.Drop(player.resource.petParameters, settings, player.resource.petSkills, player.resource.petPassiveBonuses);

            inventory.Remove(InventoryObjectType.pet_scheme, schemeId, 1);

            if (false == petManager.AddPet(petInfo))
            {
                return(CreateResponse(RPCErrorCode.ErrorOfAddingPetToCollection));
            }

            var allowedCount = player.resource.petParameters.GetPlayerPetCount(player.GetComponent <PlayerCharacterObject>().level);

            if (petManager.countOfActivePets < allowedCount)
            {
                bool success = petManager.ActivatePet(petInfo.id);
                if (success)
                {
                    player.GetComponent <MmoMessageComponent>().ReceivePetsUpdate();
                }
            }
            player.EventOnStationHoldUpdated();

            Hashtable hash = CreateResponse(RPCErrorCode.Ok);

            hash.Add((int)SPC.Pet, petInfo.GetInfo(player.resource));

            var achievments = player.GetComponent <AchievmentComponent>();

            achievments.SetVariable("max_pet_color", (int)petInfo.color);

            return(hash);
        }