// Use this for initialization void Start() { timer = coolDownTime; currentObjects = 0; photographer = gameManager.GetComponent <Photography>(); objText.text = (objectLimit - currentObjects).ToString(); }
public ActionResult Delete(int id) { try { PhotographyDao photographyDao = new PhotographyDao(); Photography photography = photographyDao.GetById(id); // TomSko: ještě předtím, než vyčistím jméno, je potřeba, abych smazal starý soubor if (photography.IllustrationImageName != null) { System.IO.File.Delete(Server.MapPath("~/uploads/photographyImage/" + photography.IllustrationImageName)); } // TomSko: ještě předtím, než vyčistím jméno, je potřeba, abych smazal starý soubor if (photography.IllustrationThumbImageName != null) { System.IO.File.Delete(Server.MapPath("~/uploads/photographyThumbImage/" + photography.IllustrationThumbImageName)); } photographyDao.Delete(photography); TempData["message-success"] = "Fotografie byla úspěšně smazána."; } catch (Exception) { // mechanismus zachytávání výjimek doporučuje dobře si nastudovat throw; } return(RedirectToAction("Index")); }
protected static void UpdateRecords(Photography skill, Sims3.Gameplay.Objects.HobbiesSkills.Camera camera, SubjectDefinition subject, PaintingStyle style, PhotographSize size, out bool newSubject, out bool firstShotTodayOfSubject, out bool collectionComplete) { newSubject = false; firstShotTodayOfSubject = false; collectionComplete = false; Photography.SubjectRecord record; string str = subject.Key; string str2 = subject.Collection.Key; if (str != "Nothing") { if (!skill.mSubjectRecords.TryGetValue(str, out record)) { record = new Photography.SubjectRecord(); record.SetUIState(Photography.UIState.NewlyDiscovered); skill.OnNewSubjectCaptured(skill.SkillOwner.CreatedSim, subject, camera); skill.mSubjectRecords[str] = record; } firstShotTodayOfSubject = Photography.WouldBeNewToday(record); Photography.UpdateRecord(record, null); newSubject = record.mCaptureCount == 0x1; if (!skill.mCollectionRecords.TryGetValue(str2, out record)) { record = new Photography.SubjectRecord(); skill.mCollectionRecords[str2] = record; } if (record.mCaptureCount == 0x0) { record.SetUIState(Photography.UIState.NewlyDiscovered); skill.OnNewCollectionDiscovered(skill.SkillOwner.CreatedSim, subject.Collection, subject, camera); } Photography.UpdateRecord(record, null); collectionComplete = skill.HasCompletedCollection(str2); if (newSubject && collectionComplete) { record.SetUIState(Photography.UIState.NewlyCompleted); skill.mCollectionsCompleted++; } } if (!skill.mStyleRecords.TryGetValue(style, out record)) { record = new Photography.SubjectRecord(); skill.mStyleRecords[style] = record; } Photography.UpdateRecord(record, null); if (!skill.mSizeRecords.TryGetValue(size, out record)) { record = new Photography.SubjectRecord(); skill.mSizeRecords[size] = record; } Photography.UpdateRecord(record, null); }
public void OnDelayedWorldLoadFinished() { Household house = Household.ActiveHousehold; if (house != null) { foreach (SimDescription desc in house.SimDescriptions) { if (desc == null) { continue; } Photography pho = desc.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (pho != null) { pho.mCollectionsCompleted = uint.MaxValue; } } } }
public void Restore(SimDescription sim) { try { sim.mGenderPreferenceMale = mMalePreference; sim.mGenderPreferenceFemale = mFemalePreference; if (sim.Pregnancy != null) { sim.Pregnancy.mGender = mPregnantGender; } if (sim.CreatedSim != null) { if (mPreviousOutfitCategory != OutfitCategories.None) { SimOutfit outfit = sim.GetOutfit(mPreviousOutfitCategory, mPreviousOutfitIndex); if (outfit != null) { sim.CreatedSim.mPreviousOutfitKey = outfit.Key; } } if (sim.CreatedSim.DreamsAndPromisesManager != null) { ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode; if (node != null) { node.InternalCount = mLifetimeWishTally; } } } foreach (TraitNames trait in mTraits) { if (sim.TraitManager.HasElement(trait)) { continue; } sim.TraitManager.AddElement(trait); } SocialNetworkingSkill networkSkill = sim.SkillManager.GetSkill <SocialNetworkingSkill>(SkillNames.SocialNetworking); if (networkSkill != null) { networkSkill.mNumberOfFollowers = mNumberOfFollowers; networkSkill.mBlogsCreated = mBlogsCreated; } RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand); if (bandSkill != null) { bandSkill.mBandInfo = mBandInfo; } Collecting collecting = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting); if (collecting != null) { collecting.mGlowBugData = mGlowBugData; collecting.mMushroomsCollected = mMushroomsCollected; } NectarSkill nectar = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar); if (nectar != null) { nectar.mHashesMade = mNectarHashesMade; } Photography photography = sim.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (photography != null) { // Forces a recalculation of the completion count // photography.mCollectionsCompleted = uint.MaxValue; photography.mCollectionsCompleted = mCollectionsCompleted; if (mSubjectRecords != null) { photography.mSubjectRecords = mSubjectRecords; } if (mStyleRecords != null) { photography.mStyleRecords = mStyleRecords; } if (mSizeRecords != null) { photography.mSizeRecords = mSizeRecords; } } RidingSkill riding = sim.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding); if (riding != null) { if (mCrossCountryCompetitionsWon != null) { riding.mCrossCountryCompetitionsWon = mCrossCountryCompetitionsWon.ToArray(); } if (mJumpCompetitionsWon != null) { riding.mJumpCompetitionsWon = mJumpCompetitionsWon.ToArray(); } } Bartending mixology = sim.SkillManager.GetSkill <Bartending>(SkillNames.Bartending); if (mixology != null) { if (mCustomDrinks != null) { mixology.mUniqueDrinks = mCustomDrinks; } } if (mOccult != null) { foreach (OccultBaseClass occult in mOccult) { if (OccultTypeHelper.Add(sim, occult.ClassOccultType, false, false)) { OccultTransfer transfer = OccultTransfer.Get(occult.ClassOccultType); if (transfer != null) { transfer.Perform(sim, occult); } } } } mOccult = null; if (mOutfitCache != null) { foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.Outfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, false)) { builder.Builder.SkinTone = mSkinToneKey; builder.Builder.SkinToneIndex = mSkinToneIndex; outfit.Apply(builder, true, null, null); } } foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.AltOutfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, true)) { builder.Builder.SkinTone = mSkinToneKey; builder.Builder.SkinToneIndex = mSkinToneIndex; outfit.Apply(builder, true, null, null); } } int count = 0; int originalCount = mOutfitCache.GetOutfitCount(OutfitCategories.Everyday, false); while ((originalCount > 0) && (originalCount < sim.GetOutfitCount(OutfitCategories.Everyday)) && (count < originalCount)) { CASParts.RemoveOutfit(sim, new CASParts.Key(OutfitCategories.Everyday, sim.GetOutfitCount(OutfitCategories.Everyday) - 1), false); count++; } } } catch (Exception e) { Common.Exception(sim, e); } }
public CrossWorldData(SimDescription sim) { mName = sim.FullName; mOutfitCache = new SavedOutfit.Cache(sim); SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0); if (outfit != null) { mSkinToneKey = outfit.SkinToneKey; mSkinToneIndex = outfit.SkinToneIndex; } else { mSkinToneKey = sim.SkinToneKey; mSkinToneIndex = sim.SkinToneIndex; } mMalePreference = sim.mGenderPreferenceMale; mFemalePreference = sim.mGenderPreferenceFemale; if (sim.CreatedSim != null) { if (sim.CreatedSim.mPreviousOutfitKey != null) { try { mPreviousOutfitCategory = sim.GetOutfitCategoryFromResKey(sim.CreatedSim.mPreviousOutfitKey, out mPreviousOutfitIndex); } catch { } } if (sim.CreatedSim.DreamsAndPromisesManager != null) { ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode; if (node != null) { mLifetimeWishTally = node.InternalCount; } } } if (sim.Pregnancy != null) { mPregnantGender = sim.Pregnancy.mGender; } foreach (Trait trait in sim.TraitManager.List) { if (trait.IsReward) { continue; } mTraits.Add(trait.Guid); } SocialNetworkingSkill networkSkill = sim.SkillManager.GetSkill <SocialNetworkingSkill>(SkillNames.SocialNetworking); if (networkSkill != null) { // This value is set to mNumberOfBlogFollowers for some reason mNumberOfFollowers = networkSkill.mNumberOfFollowers; // Not transitioned at all mBlogsCreated = networkSkill.mBlogsCreated; } RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand); if (bandSkill != null) { mBandInfo = bandSkill.mBandInfo; } Collecting collecting = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting); if (collecting != null) { // Error in CollectingPropertyStreamWriter:Export() requires that mGlowBugData by transfered manually // Exported as two Int64, but Imported as a Int64 and Int32 mGlowBugData = collecting.mGlowBugData; mMushroomsCollected = collecting.mMushroomsCollected; } NectarSkill nectar = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar); if (nectar != null) { mNectarHashesMade = nectar.mHashesMade; } Photography photography = sim.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (photography != null) { mCollectionsCompleted = photography.mCollectionsCompleted; mSubjectRecords = photography.mSubjectRecords; mStyleRecords = photography.mStyleRecords; mSizeRecords = photography.mSizeRecords; } RidingSkill riding = sim.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding); if (riding != null) { // Error in the Import (Copy/Paste fail by the looks of it), where the CrossCountry Wins are imported instead mCrossCountryCompetitionsWon = new List <uint>(riding.mCrossCountryCompetitionsWon); mJumpCompetitionsWon = new List <uint>(riding.mJumpCompetitionsWon); } // EA hosed the color, glass and drink picks Bartending mixology = sim.SkillManager.GetSkill <Bartending>(SkillNames.Bartending); if (mixology != null) { mCustomDrinks = mixology.mUniqueDrinks; } if ((sim.OccultManager != null) && (sim.OccultManager.mOccultList != null)) { mOccult = new List <OccultBaseClass>(sim.OccultManager.mOccultList); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { base.PrivateUpdate(frame); mNet = 0; Camera camera = ManagedBuyProduct <Camera> .Purchase(Sim, 0, this, UnlocalizedName, null, BuildBuyProduct.eBuyCategory.kBuyCategoryElectronics, BuildBuyProduct.eBuySubCategory.kBuySubCategoryHobbiesAndSkills); if (camera == null) { return(false); } Photography skill = Sim.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (skill == null) { skill = Sim.SkillManager.AddElement(SkillNames.Photography) as Photography; } List <PhotographSize> sizes = new List <PhotographSize>(); foreach (PhotographSize size in sSizes) { if (Photography.SizeUnlocked(skill, size)) { sizes.Add(size); } } if (sizes.Count == 0) { IncStat("No Sizes"); return(false); } List <PaintingStyle> styles = new List <PaintingStyle>(); foreach (PaintingStyle style in sStyles) { if (Photography.StyleUnlocked(skill, style)) { styles.Add(style); } } if (styles.Count == 0) { IncStat("No Styles"); return(false); } List <SubjectDefinition> subjects = new List <SubjectDefinition>(); foreach (CollectionDefinition collection in PhotographySubjects.sCollectionDefinitions.Values) { if (!collection.AvailableForSkill(skill)) { continue; } if (collection.Location != WorldName.UserCreated) { continue; } foreach (SubjectDefinition definition in collection.Subjects) { try { if (!definition.AvailableForSkill(skill)) { continue; } } catch { continue; } subjects.Add(definition); } } if (subjects.Count == 0) { IncStat("No Subjects"); return(false); } int additional = AddScoring("AdditionalPhoto", Sim); int total = Sims3.Gameplay.Core.RandomUtil.GetInt(GetValue <Option, int>() + additional); if (total <= 0) { total = 1; } int totalFunds = 0; for (int i = 0; i < total; i++) { PhotographSize size = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(sizes); PaintingStyle style = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(styles); int cost = Photography.GetCostToTakePhoto(skill, camera, size, style); if (Sim.FamilyFunds < cost) { continue; } float x = 0f; float num3 = 1f; float num5 = 0f; float num6 = 1f; SubjectDefinition subject = Sims3.Gameplay.Core.RandomUtil.GetRandomObjectFromList(subjects); skill.ApplyMultiplier(ref num6, camera.CameraTuning.ValueMultiplier, "Value", "CameraTuning"); bool newSubject, firstShotTodayOfSubject, collectionComplete; UpdateRecords(skill, camera, subject, style, size, out newSubject, out firstShotTodayOfSubject, out collectionComplete); if (newSubject) { skill.ApplyBonus(ref x, (float)subject.SkillPoints, "Skill Gain", "Subject Tuning (New Subject)"); skill.ApplyBonus(ref num5, (float)subject.Value, "Value", "Subject Tuning (New Subject)"); } else if (firstShotTodayOfSubject) { skill.ApplyBonus(ref x, subject.SkillPoints * Photography.kFirstShotOfTheDaySkillGainMultiplier, "Skill Gain", "Subject Tuning (First Time Today)"); skill.ApplyBonus(ref num5, subject.Value * Photography.kFirstShotOfTheDayValueMultiplier, "Value", "Subject Tuning (First Time Today)"); } if (Sims3.Gameplay.Core.RandomUtil.RandomChance((skill.MaxSkillLevel - (skill.SkillLevel - 1)) * 10)) { skill.ApplyMultiplier(ref num6, Photography.kBadPhotoValueMultiplier, "Value", "Bad Photo (kBadPhotoValueMultiplier)"); } skill.ApplyMultiplier(ref num6, Photography.sValueMultipliers[skill.SkillLevel], "Value", "Sim's Skill Level"); skill.ApplyMultiplier(ref num6, Photography.sSizeData[size].ValueMultiplier, "Value", "Photo Size"); skill.ApplyMultiplier(ref num6, Photography.sStyleData[style].ValueMultiplier, "Value", "Photo Style"); if (collectionComplete) { skill.ApplyMultiplier(ref num6, subject.Collection.ValueMultiplierWhenComplete, "Value", "Collection Tuning (Complete)"); } else { skill.ApplyMultiplier(ref num6, subject.Collection.ValueMultiplier, "Value", "Collection Tuning"); } if (Sim.TraitManager.HasElement(TraitNames.PhotographersEye)) { skill.ApplyMultiplier(ref num6, TraitTuning.PhotographersEyePhotographValueMultiplier, "Value", "Photographer's Eye (TraitTuning)"); } skill.ApplyMultiplier(ref num3, camera.CameraTuning.SkillGainMultiplier, "Skill Gain", "CameraTuning"); int funds = (int)((Photography.kBaseValuePerPhoto + num5) * num6); if ((funds < cost) && (additional > 0)) { IncStat("Try Again"); total++; additional--; } skill.EarnedMoneyFromPhotography((uint)funds); skill.UpdateXpForEarningMoney(funds); totalFunds += funds; AddStat("Subject: " + subject.Name, funds); AddStat("Funds", funds); Money.AdjustFunds(Sim, "Photography", -cost); AddStat("Cost", cost); skill.SpentMoneyOnPhotography((uint)cost); AddScoring("Net", funds - cost); mNet += (funds - cost); float points = (Photography.kBaseSkillGainPerPhoto + x) * num3; AddStat("Skill", points); skill.AddPoints(points); skill.CheckForCompletedOpportunities(); } Money.AdjustFunds(Sim, "Photography", totalFunds); return(mNet > 0); }
public ActionResult Add(Photography photography, HttpPostedFileBase photographyImage) { if (ModelState.IsValid) { if (photographyImage != null) { if (photographyImage.ContentType == "image/jpeg" || photographyImage.ContentType == "image/png") { Image image = Image.FromStream(photographyImage.InputStream); // Velký náhled if (image.Height > 1080 || image.Width > 1920) { Image smallImage = ImageHelper.ScaleImage(image, 1920, 1080); // zmenšení fotografie Bitmap b = new Bitmap(smallImage); Guid guid = Guid.NewGuid(); // vytvoření jména fotografie string imageName = guid.ToString() + ".jpg"; b.Save(Server.MapPath("~/uploads/photographyImage/" + imageName), ImageFormat.Jpeg); // uložení fotografie; formát jpg smallImage.Dispose(); // vyčištění po e-disposable objektech b.Dispose(); photography.IllustrationImageName = imageName; // vyplnění parametru názvu fotografie } else { photographyImage.SaveAs(Server.MapPath("~/uploads/photographyImage/") + photographyImage.FileName); // uložení v případě, že fotografii není potřeba zmenšovat photography.IllustrationImageName = photographyImage.FileName; // TomSko asi chybělo vyplnění parametru názvu fotografie } // Zmenšený náhled if (image.Height > 310 || image.Width > 560) { Image smallImage = ImageHelper.ScaleImage(image, 560, 310); // zmenšení fotografie Bitmap b = new Bitmap(smallImage); Guid guid = Guid.NewGuid(); // vytvoření jména fotografie string thumbImageName = guid.ToString() + ".jpg"; b.Save(Server.MapPath("~/uploads/photographyThumbImage/" + thumbImageName), ImageFormat.Jpeg); // uložení fotografie; formát jpg smallImage.Dispose(); // vyčištění po e-disposable objektech b.Dispose(); photography.IllustrationThumbImageName = thumbImageName; // vyplnění parametru názvu fotografie } else { photographyImage.SaveAs(Server.MapPath("~/uploads/photographyThumbImage/") + photographyImage.FileName); // uložení v případě, že fotografii není potřeba zmenšovat photography.IllustrationThumbImageName = photographyImage.FileName; // TomSko asi chybělo vyplnění parametru názvu fotografie } } } else { // Pokud nebyl nalinkován nový obrázek, nastav cesty k obrázkům místnosti na null photography.IllustrationImageName = null; photography.IllustrationThumbImageName = null; } PhotographyDao photographyDao = new PhotographyDao(); photographyDao.Create(photography); TempData["message-success"] = "Fotografie byla úspěšně přidána"; } else { TempData["message-error"] = "Fotografie nebyla přidána"; return(View("Create", photography)); } return(RedirectToAction("Index")); }