示例#1
0
    Collecting collecting;     //Declare collecting as Collecting type script

    // Use this for initialization
    void Start()
    {
        scoreUI    = GameObject.Find("Score");      //Gets score UI object
        scoreText  = scoreUI.GetComponent <Text>(); //Gets Text proerpty from score UI object
        score      = PlayerPrefs.GetInt("Player Score");
        collecting = GetComponent <Collecting>();   //Gets Collecting script for referencing its variables and functions
    }
示例#2
0
 private void Start()
 {
     runningScript    = this.GetComponent <RunningAndSneaking> ();
     collectingScript = this.GetComponent <Collecting> ();
     minSpeed         = runningScript.speed * runningScript.fraction;
     maxSpeed         = runningScript.speed;
 }
示例#3
0
        public override void OnDelayedWorldLoadFinished()
        {
            new Common.DelayedEventListener(EventTypeId.kSkillLearnedSkill, OnLearnedSkill);

            // Must be immediate
            EventTracker.AddListener(EventTypeId.kGetNCutGems, OnGetNCutGems);

            Overwatch.Log("CleanupCollecting");

            if (SeashellData.sTotalNumberSeashells > 8)
            {
                SeashellData.sTotalNumberSeashells = 8;
                Overwatch.Log("Fixed seashell count");
            }

            foreach (SimDescription sim in Household.AllSimsLivingInWorld())
            {
                Collecting skill = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
                if (skill == null)
                {
                    continue;
                }

                EnactCorrections(skill);
            }
        }
示例#4
0
        protected static ListenerAction OnGetNCutGems(Event e)
        {
            try
            {
                CutGemEvent gemEvent = e as CutGemEvent;
                if (gemEvent != null)
                {
                    Gem gem = gemEvent.TargetObject as Gem;
                    if (gem != null)
                    {
                        Collecting skill = e.Actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
                        if (skill != null)
                        {
                            if (!skill.mGemData.ContainsKey(gem.Guid))
                            {
                                skill.mGemData.Add(gem.Guid, new Collecting.GemStats(0));
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                Common.Exception(e.Actor, e.TargetObject, exception);
            }

            return(ListenerAction.Keep);
        }
示例#5
0
        public override void MailedSuccesfully(Mailbox box, IGameObject obj)
        {
            try
            {
                Metal      metal      = obj as Metal;
                Collecting collecting = Actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
                if (metal != null)
                {
                    // Custom
                    if (!collecting.mMetalData.ContainsKey(metal.Guid))
                    {
                        collecting.mMetalData.Add(metal.Guid, new Collecting.MetalStats(0));
                    }
                }

                base.MailedSuccesfully(box, obj);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }
        }
示例#6
0
        static void RaiseCollecting(MessageEventArgs eventArgs)
        {
            if (eventArgs == null)
            {
                throw new ArgumentNullException(nameof(eventArgs));
            }

            Collecting?.Invoke(null, eventArgs);
        }
示例#7
0
        protected static void IncreaseIngotsCreatedForMetal(Collecting skill, RockGemMetal metal)
        {
            if (!skill.mMetalData.ContainsKey(metal))
            {
                skill.mMetalData.Add(metal, new Collecting.MetalStats(0));
            }

            skill.IncreaseIngotsCreatedForMetal(metal);
        }
 protected override void Awake()
 {
     base.Awake();
     //ducking = this.GetComponent<DuckingAndCrawling> ();
     collecting = this.GetComponent <Collecting>();
     //throwing = this.GetComponent<Throwing>();
     suffocating = this.GetComponent <Suffocating>();
     anim        = this.GetComponent <Animator>();
 }
    private void AddItem(GameObject item)
    {
        canBePlace = false;
        storeItem  = item;

        storeItem.transform.SetParent(this.gameObject.transform);
        storeItem.transform.position = itemDropPosition.position;
        storeItem.transform.rotation = itemDropPosition.rotation;
        Collecting collect = storeItem.GetComponent <Collecting>();

        collect.Disable();
        StartCoroutine(bufferPlace());
    }
示例#10
0
 // From HarvestPlant
 protected static void UpdateGardeningSkillJournal(HarvestPlant ths, Gardening gardeningSkill, PlantDefinition harvestPlantDef, List <GameObject> objectsHarvested)
 {
     foreach (GameObject obj2 in objectsHarvested)
     {
         gardeningSkill.Harvested(Plant.GetQuality(obj2.Plantable.QualityLevel), harvestPlantDef);
         if (Plant.IsMushroom(ths.Seed))
         {
             Collecting collecting = gardeningSkill.SkillOwner.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
             if (collecting != null)
             {
                 bool flag;
                 collecting.Collected(obj2 as Ingredient, out flag);
             }
         }
     }
 }
    // Update is called once per frame
    void Update()
    {
        Inventory inventory = this.gameObject.GetComponent <Inventory>();

        if (inventory.HasItem())
        {
            if (Input.GetKeyDown(KeyCode.Q))
            {
                GameObject obj = inventory.GetItemGameObject();
                inventory.ClearItem();
                Vector3    vec     = this.gameObject.transform.localPosition;
                Collecting collect = obj.GetComponent <Collecting>();
                collect.beInteractable();
                obj.transform.SetParent(null);
                obj.transform.localPosition = new Vector3(vec.x, 2.0f, vec.z);
                if (this.gameObject.GetComponent <PlayerInfo>().PlayerType == "Student")
                {
                    GameManager.TeacherScore += 20;
                }
            }
            if (this.gameObject.GetComponent <PlayerInfo>()?.PlayerType == "Student")
            {
                Vector3 targetPosition = new Vector3(10f, -1f, -26f);
                targetPosition.y = arrow.transform.position.y;
                arrow.gameObject.SetActive(true);
                arrow.LookAt(targetPosition);
            }
            else
            {
                Vector3 targetPosition = new Vector3(-19f, 0f, 0f);
                targetPosition.y = transform.position.y;
                arrow.gameObject.SetActive(true);
                arrow.LookAt(targetPosition);
            }
        }
        else
        {
            arrow.gameObject.SetActive(false);
        }


        if (Input.GetKeyDown(KeyCode.T))
        {
            Debug.Log(GameManager.StudentScore);
            Debug.Log(GameManager.TeacherScore);
        }
    }
示例#12
0
        protected bool SmeltMetal(Metal metal)
        {
            if (!metal.mCollected)
            {
                return(false);
            }

            if (Sim.FamilyFunds < Metal.GetSmelt.kCostToSmelt)
            {
                IncStat("Smelt Cost");
                return(false);
            }

            Money.AdjustFunds(Sim, "Smelting", -Metal.GetSmelt.kCostToSmelt);

            float chanceOfExtraIngot = Metal.GetSmelt.kChanceOfExtraIngot;

            Collecting skill = Sim.SkillManager.AddElement(SkillNames.Collecting) as Collecting;

            if (skill.IsMetalCollector())
            {
                chanceOfExtraIngot = Metal.GetSmelt.kMetalCollectorExtraIngotChance;
            }

            int num2 = 0x1;

            while ((num2 < Metal.GetSmelt.kMaxNumberOfIngots) && RandomUtil.RandomChance01(chanceOfExtraIngot))
            {
                num2++;
                Metal metal2 = RockGemMetalBase.Make(metal.Guid, true) as Metal;
                MetalEx.SmeltMetal(metal2, Sim);
                IncreaseIngotsCreatedForMetal(skill, metal2.Guid);

                Inventories.TryToMove(metal2, Sim.CreatedSim);
            }

            MetalEx.SmeltMetal(metal, Sim);
            IncreaseIngotsCreatedForMetal(skill, metal.Guid);

            skill.MetalSmelt();

            IncStat("Metal Smelt");

            return(true);
        }
示例#13
0
        private static bool DoHarvest(HarvestPlant ths, Sim actor, bool hasHarvested, BurglarSituation burglarSituation)
        {
            Slot[]            containmentSlots = ths.GetContainmentSlots();
            List <GameObject> objectsHarvested = new List <GameObject>();

            foreach (Slot slot in containmentSlots)
            {
                GameObject containedObject = ths.GetContainedObject(slot) as GameObject;
                if ((containedObject != null) && HarvestHarvestable(ths, containedObject, actor, burglarSituation))
                {
                    objectsHarvested.Add(containedObject);
                }
            }

            if (actor.TraitManager.HasElement(TraitNames.GathererTrait) && RandomUtil.RandomChance01(TraitTuning.GathererTraitExtraHarvestablesChance))
            {
                int gathererTraitNumberOfExtraHarvestables = TraitTuning.GathererTraitNumberOfExtraHarvestables;
                for (int i = 0; i < gathererTraitNumberOfExtraHarvestables; i++)
                {
                    GameObject item = ths.Seed.Copy(false) as GameObject;
                    if (item != null)
                    {
                        objectsHarvested.Add(item);
                    }
                }
            }

            if (objectsHarvested.Count <= 0x0)
            {
                return(false);
            }
            Gardening  skill      = actor.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
            Collecting collecting = actor.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);

            int skillDifficulty = ths.PlantDef.GetSkillDifficulty();

            if (skill != null)
            {
                if (skill.SkillLevel <= skillDifficulty)
                {
                    if (actor.SimDescription.IsFairy && skill.IsFairySkill())
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest * Skill.SkillLevelBumpMultiplierForFairies);
                    }
                    else
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest);
                    }
                }

                if ((ths is MoneyTree) || (ths is OmniPlant))
                {
                    ths.UpdateGardeningSkillJournal(skill, ths.PlantDef, objectsHarvested);
                }
                else
                {
                    // Custom
                    UpdateGardeningSkillJournal(ths, skill, ths.PlantDef, objectsHarvested);
                }
            }
            if (!hasHarvested)
            {
                actor.ShowTNSIfSelectable(Common.LocalizeEAString(actor.IsFemale, "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", new object[] { actor, ths.PlantDef.Name }), StyledNotification.NotificationStyle.kGameMessagePositive, ths.ObjectId, actor.ObjectId);
            }

            if (collecting == null)
            {
                collecting = (Collecting)actor.SkillManager.AddElement(SkillNames.Collecting);
            }
            collecting.CollectedFromHarvest(objectsHarvested);

            ths.PostHarvest();
            return(true);
        }
示例#14
0
            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);
                }
            }
示例#15
0
            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);
                }
            }
示例#16
0
        protected bool CutGem(Gem gem)
        {
            if (!gem.mCollected)
            {
                return(false);
            }

            Collecting skill = Sim.SkillManager.AddElement(SkillNames.Collecting) as Collecting;

            List <Gem.CutData> choices = new List <Gem.CutData>();

            int num = 0x0;

            if (skill != null)
            {
                num = skill.GemsCut();

                if (skill.IsGemCollector())
                {
                    choices.Add(Gem.sToughestCut);
                }
            }

            foreach (Gem.CutData data in Gem.sCutData)
            {
                if ((data.NumberOfCuts <= num) && gem.ValidCut(data, Sim.CreatedSim))
                {
                    choices.Add(data);
                }
            }

            List <Gem.CutData> valid = new List <Gem.CutData>();

            foreach (Gem.CutData data in choices)
            {
                if (Sim.FamilyFunds >= data.CostToCut)
                {
                    valid.Add(data);
                }
            }

            if (valid.Count == 0)
            {
                IncStat("No Gem Cut Choices");
                return(false);
            }

            Gem.CutData choice = RandomUtil.GetRandomObjectFromList(valid);

            Money.AdjustFunds(Sim, "GemCut", -choice.CostToCut);

            GemEx.CutGem(gem, choice, Sim);

            IncStat("Gem Cut");

            if (skill != null)
            {
                skill.GemCut();
            }
            ;

            return(true);
        }
    public override void Interact(GameObject player)
    {
        Inventory inventory = player.GetComponent <Inventory>();

        if (inventory)
        {
            if (canBePlace && inventory.HasItem() && player.layer == 6 && ((itemType != Collectibles.None) ? (inventory.GetTypeOfItem() == itemType) : true))
            {
                storeItem = inventory.GetItemGameObject();
                inventory.ClearItem();

                photonView.RPC("AddItem", RpcTarget.All, storeItem.name);

                TextMeshProUGUI Description = player.GetComponent <PlayerInfo>().Display;


                if (player.GetComponent <PlayerInfo>().PlayerType == "Student")
                {
                    Description.SetText("Take");

                    if (hidingSpot)//test
                    {
                        GameManager.StudentScore += 20;
                    }
                    else if (lostAndFound)
                    {
                        GameManager.StudentScore += 100;
                    }
                    else if (!lostAndFound)
                    {
                        GameManager.TeacherScore += 100;
                    }
                }
                else
                {
                    if (lostAndFound)
                    {
                        GameManager.StudentScore += 100;
                    }
                    else if (!lostAndFound)
                    {
                        GameManager.TeacherScore += 100;
                    }
                }
            }
            else if (canBePick)
            {
                Collecting collect = storeItem.GetComponent <Collecting>();
                collect.Enable();
                collect.Interact(player);

                photonView.RPC("RemoveItem", RpcTarget.All);


                if (player.GetComponent <PlayerInfo>().PlayerType == "Student")
                {
                    GameManager.TeacherScore += 20;
                }
                if (hidingSpot)
                {
                    GameManager.StudentScore -= 20;
                }
                else if (lostAndFound)
                {
                    GameManager.StudentScore -= 100;
                }
                else if (!lostAndFound)
                {
                    GameManager.TeacherScore -= 100;
                }
            }
        }
    }
示例#18
0
    Collecting collecting;       //For referencing the collecting script

    // Use this for initialization
    void Start()
    {
        returnedToStart = false;                                            //Default value
        exit            = GameObject.FindGameObjectWithTag("startingArea"); //Assigns gameobject with appropiate tag to exit object. In this case the gameobject will be emply but contains a large box collider covering the exit/ starting area.
        collecting      = GetComponent <Collecting>();                      //To enable use of variables and functions from collecting script
    }
示例#19
0
        protected static void EnactCorrections(Collecting skill)
        {
            Overwatch.Log(" Correcting: " + skill.SkillOwner.FullName);

            if (skill.mGlowBugData == null)
            {
                skill.mGlowBugData = new Dictionary <Sims3.Gameplay.Objects.Insect.InsectType, Collecting.GlowBugStats>();

                Overwatch.Log("  GlowBugData Fixed");
            }

            if (skill.mMushroomData == null)
            {
                skill.mMushroomData = new Dictionary <string, Collecting.MushroomStats>();

                Overwatch.Log("  MushroomData Fixed");
            }

            if (skill.mHarvestData == null)
            {
                skill.mHarvestData = new Dictionary <string, Collecting.HarvestStats>();

                Overwatch.Log("  HarvestData Fixed");
            }

            if (skill.mMetalData != null)
            {
                List <RockGemMetal> remove = new List <RockGemMetal>();

                foreach (KeyValuePair <RockGemMetal, Collecting.MetalStats> data in skill.mMetalData)
                {
                    if (data.Value.count == 0)
                    {
                        remove.Add(data.Key);
                    }
                }

                foreach (RockGemMetal metal in remove)
                {
                    skill.mMetalData.Remove(metal);
                }
            }

            Gardening gardening = skill.SkillOwner.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);

            if ((gardening != null) && (gardening.mHarvestCounts.Count != 0))
            {
                bool success = false;

                foreach (KeyValuePair <string, Gardening.PlantInfo> plants in gardening.mHarvestCounts)
                {
                    string ingredient = null;
                    foreach (IngredientData choice in IngredientData.IngredientDataList)
                    {
                        if (choice.PlantName == plants.Key)
                        {
                            ingredient = choice.mStringKey;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(ingredient))
                    {
                        continue;
                    }

                    Collecting.HarvestStats data = null;
                    if (!skill.mHarvestData.TryGetValue(ingredient, out data))
                    {
                        data = new Collecting.HarvestStats();
                        skill.mHarvestData.Add(ingredient, data);

                        data.quality = (int)plants.Value.BestQuality;
                        if (data.quality <= 0)
                        {
                            data.quality = (int)Quality.Bad;
                        }
                    }
                    else
                    {
                        if (data.quality < (int)plants.Value.BestQuality)
                        {
                            data.quality = (int)plants.Value.BestQuality;
                        }

                        if (data.count >= plants.Value.HarvestablesCount)
                        {
                            continue;
                        }
                    }

                    if (data.mostExpensive < plants.Value.MostExpensive)
                    {
                        data.mostExpensive = plants.Value.MostExpensive;
                    }

                    if (data.count < plants.Value.HarvestablesCount)
                    {
                        data.count = plants.Value.HarvestablesCount;
                    }

                    success = true;
                }

                if (success)
                {
                    Overwatch.Log("  HarvestData Reconciled");
                }
            }
        }
示例#20
0
        public static void NotifySell(SimDescription sim, GameObject obj, int value)
        {
            try
            {
                obj.SoldFor(value);

                if (obj.CanBeSold())
                {
                    if (IsCollectable(obj))
                    {
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            Collecting skill = member.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj.HasFlags(GameObject.FlagField.WasHarvested))
                    {
                        Gardening gardening = sim.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                        if (gardening != null)
                        {
                            gardening.HarvestableSold(value);
                        }
                        foreach (SimDescription member in sim.Household.AllSimDescriptions)
                        {
                            gardening = member.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                            if (gardening != null)
                            {
                                gardening.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is INectarBottle)
                    {
                        INectarBottle bottle = obj as INectarBottle;

                        NectarSkill skill = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                        if (skill != null)
                        {
                            skill.SellNectarBottle(value);
                        }

                        if ((bottle.Creator != null) && (bottle.Creator.IsValid))
                        {
                            skill = bottle.Creator.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar);
                            if (skill != null)
                            {
                                skill.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IInvention)
                    {
                        IInvention invention = obj as IInvention;

                        SimDescription inventor = invention.Inventor;

                        if ((inventor != null) && (inventor.IsValid))
                        {
                            InventingSkill skill2 = inventor.SkillManager.GetSkill <InventingSkill>(SkillNames.Inventing);
                            if (skill2 != null)
                            {
                                skill2.UpdateXpForEarningMoney(value);
                            }
                        }
                    }

                    if (obj is IScubaCollectible)
                    {
                        ScubaDivingSkill skill3 = sim.SkillManager.AddElement(SkillNames.ScubaDiving) as ScubaDivingSkill;
                        if (skill3 != null)
                        {
                            skill3.SimoleonsFromSellingCollectibles += value;
                            skill3.UpdateXpForEarningMoney(value);
                        }
                    }

                    if (sim.CreatedSim != null)
                    {
                        obj.SendObjectSoldEvent(sim.CreatedSim);
                    }
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim.CreatedSim, obj, e);
            }
        }
示例#21
0
 protected override void Awake()
 {
     base.Awake();
     collecting = this.GetComponent <Collecting> ();
 }
示例#22
0
        public async Task <IActionResult> FinalCalc(decimal fathallah, decimal Cash, string MerchantName, string Price, string ToMerchantName, string ToPrice, string BoatName, string HalekPrice,
                                                    string HalekName, string Adding, string AddingPrice, string BoatNameExpenses, string ExpensePricee, string Cause)
        {
            Collecting c = new Collecting()
            {
                Date             = TimeNow(),
                TotalForFahAllah = fathallah,
                TotalOfCashes    = Cash
            };



            if (MerchantName != null && Price != null)
            {
                var       MerchantNameCookie = MerchantName.TrimEnd(MerchantName[MerchantName.Length - 1]);
                var       PriceCookie        = Price.TrimEnd(Price[Price.Length - 1]);
                string[]  MerchantNames      = MerchantNameCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                decimal[] prices             = PriceCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray();

                for (int i = 0; i < MerchantNames.Length; i++)
                {
                    var             merchant = _context.Merchants.FirstOrDefault(c => c.MerchantName == MerchantNames[i]);
                    PaidForMerchant m;
                    if (merchant.IsOwner == true)
                    {
                        m = new PaidForMerchant()
                        {
                            IsPaidForUs = true,
                            MerchantID  = merchant.MerchantID,
                            Payment     = prices[i],
                            PreviousDebtsForMerchant = merchant.PreviousDebts - prices[i],
                            Date     = TimeNow(),
                            IsCash   = true,
                            PersonID = 3
                        };
                    }
                    else
                    {
                        m = new PaidForMerchant()
                        {
                            IsPaidForUs = true,
                            MerchantID  = merchant.MerchantID,
                            Payment     = prices[i],
                            PreviousDebtsForMerchant = merchant.PreviousDebts - prices[i],
                            Date     = TimeNow(),
                            IsCash   = true,
                            PersonID = 3
                        };
                    }
                    Person pppp = _context.People.Find(3);
                    pppp.credit           += prices[i];
                    merchant.PreviousDebts = merchant.PreviousDebts - prices[i];
                    _context.PaidForMerchant.Add(m);
                    _context.SaveChanges();
                    c.TotalPaidFromMerchants = prices.Sum();
                }
            }

            if (ToMerchantName != null && ToPrice != null)
            {
                var       ToMerchantNameCookie = ToMerchantName.TrimEnd(ToMerchantName[ToMerchantName.Length - 1]);
                var       ToPriceCookie        = ToPrice.TrimEnd(ToPrice[ToPrice.Length - 1]);
                string[]  ToMerchantNames      = ToMerchantNameCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                decimal[] Toprices             = ToPriceCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray();


                for (int i = 0; i < ToMerchantNames.Length; i++)
                {
                    var merchant = _context.Merchants.FirstOrDefault(c => c.MerchantName == ToMerchantNames[i]);

                    PaidForMerchant m = new PaidForMerchant()
                    {
                        IsPaidForUs = false,
                        MerchantID  = merchant.MerchantID,
                        Payment     = Toprices[i],
                        PreviousDebtsForMerchant = merchant.PreviousDebtsForMerchant - Toprices[i],
                        Date     = TimeNow(),
                        IsCash   = true,
                        PersonID = 3
                    };
                    Person person = _context.People.Find(3);
                    person.credit -= Toprices[i];
                    merchant.PreviousDebtsForMerchant = merchant.PreviousDebtsForMerchant - Toprices[i];
                    _context.PaidForMerchant.Add(m);
                    _context.SaveChanges();
                }
                c.TotalPaidForMerchants = Toprices.Sum();
            }

            if (HalekName != null)
            {
                var       BoatNameCookie   = BoatName.TrimEnd(BoatName[BoatName.Length - 1]);
                var       HalekPriceCookie = HalekPrice.TrimEnd(HalekPrice[HalekPrice.Length - 1]);
                var       HalekNameCookie  = HalekName.TrimEnd(HalekName[HalekName.Length - 1]);
                string[]  BoatNames        = BoatNameCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                decimal[] HalekPrices      = HalekPriceCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray();
                string[]  HalekNames       = HalekNameCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();

                for (int i = 0; i < HalekNames.Length; i++)
                {
                    var boat        = _context.Boats.FirstOrDefault(c => c.BoatName == BoatNames[i]);
                    var lastSarhaID = _context.Sarhas.Where(c => c.BoatID == boat.BoatID && c.IsFinished == false).FirstOrDefault().SarhaID;
                    var lastSarha   = _context.Sarhas.Find(lastSarhaID);

                    var debt_sarha = _context.Debts_Sarhas.Include(c => c.Debt).ToList().
                                     Where(c => c.SarhaID == lastSarhaID && c.Debt.DebtName == HalekNames[i] && c.PersonID == 3 && c.Date.ToShortDateString() == TimeNow().ToShortDateString()).FirstOrDefault();
                    boat.DebtsOfHalek += HalekPrices[i];
                    if (debt_sarha != null)
                    {
                        debt_sarha.Price += HalekPrices[i];
                    }
                    else
                    {
                        var         debt = _context.Debts.Where(c => c.DebtName == HalekNames[i]).FirstOrDefault();
                        Debts_Sarha ds   = new Debts_Sarha()
                        {
                            Price = HalekPrices[i], DebtID = debt.DebtID, SarhaID = lastSarhaID, PersonID = 3, Date = TimeNow()
                        };
                        _context.Debts_Sarhas.Add(ds);
                        _context.SaveChanges();
                    }
                    Person person1 = _context.People.Find(3);
                    person1.credit -= HalekPrices[i];

                    _context.SaveChanges();
                }
                c.TotalHalek = HalekPrices.Sum();
            }

            if (BoatNameExpenses != null)
            {
                var       BoatNameExpensesCookie = BoatNameExpenses.TrimEnd(BoatNameExpenses[BoatNameExpenses.Length - 1]);
                var       ExpensePriceCookie     = ExpensePricee.TrimEnd(ExpensePricee[ExpensePricee.Length - 1]);
                var       CauseCookie            = Cause.TrimEnd(Cause[Cause.Length - 1]);
                string[]  BoatNamesExpenses      = BoatNameExpensesCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                decimal[] ExpensePrice           = ExpensePriceCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray();
                string[]  Causes = CauseCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                for (int i = 0; i < BoatNamesExpenses.Length; i++)
                {
                    var     boat = _context.Boats.FirstOrDefault(c => c.BoatName == BoatNamesExpenses[i]);
                    Expense ex   = new Expense()
                    {
                        BoatID   = boat.BoatID,
                        Cause    = Causes[i],
                        Date     = TimeNow(),
                        PersonID = 3,
                        Price    = ExpensePrice[i]
                    };
                    _context.Expenses.Add(ex);
                    await _context.SaveChangesAsync();

                    Person person1 = _context.People.Find(3);
                    person1.credit -= ExpensePrice[i];

                    await _context.SaveChangesAsync();
                }
                c.TotalOfExpenses = ExpensePrice.Sum();
            }

            var           p = _context.People.Find(4);
            FathAllahGift g = new FathAllahGift()
            {
                charge = fathallah, CreditBefore = p.credit, CreditAfter = fathallah + p.credit, Date = TimeNow(), PersonID = 3
            };

            p.credit += fathallah;
            Person pp = _context.People.Find(3);

            pp.credit -= fathallah;
            _context.FathAllahGifts.Add(g);
            _context.Collectings.Add(c);
            await _context.SaveChangesAsync();

            if (Adding != null)
            {
                var       AddingCookie      = Adding.TrimEnd(Adding[Adding.Length - 1]);
                var       AddingPriceCookie = AddingPrice.TrimEnd(AddingPrice[AddingPrice.Length - 1]);
                string[]  AddingNames       = AddingCookie.Split(",").Select(c => Convert.ToString(c)).ToArray();
                decimal[] AddingPrices      = AddingPriceCookie.Split(",").Select(c => Convert.ToDecimal(c)).ToArray();
                var       collecting        = _context.Collectings.ToList().Where(x => x.Date.ToShortDateString() == TimeNow().ToShortDateString()).FirstOrDefault();
                collecting.TotalOfAdditionalPayment = AddingPrices.Sum();

                for (int i = 0; i < AddingNames.Length; i++)
                {
                    AdditionalPayment ad = new AdditionalPayment()
                    {
                        Name  = AddingNames[i],
                        Value = AddingPrices[i],
                        ID    = collecting.ID,
                        Date  = TimeNow()
                    };

                    _context.AdditionalPayments.Add(ad);
                    Person ppp = _context.People.Find(3);
                    ppp.credit -= AddingPrices[i];
                    _context.SaveChanges();
                }
            }

            var FinalCredit = c.TotalPaidFromMerchants - (c.TotalPaidForMerchants + c.TotalHalek + c.TotalOfAdditionalPayment + fathallah + c.TotalOfExpenses);

            //Person halaka = _context.People.Find(1);
            //halaka.credit += FinalCredit;
            pp.credit = 0.0m;
            await _context.SaveChangesAsync();

            return(Json(new { message = "success" }));
        }
示例#23
0
        public static bool DoHarvest(HarvestPlant ths, Sim actor, bool hasHarvested, BurglarSituation burglarSituation)
        {
            Slot[]            containmentSlots = ths.GetContainmentSlots();
            List <GameObject> objectsHarvested = new List <GameObject>();

            foreach (Slot slot in containmentSlots)
            {
                GameObject containedObject = ths.GetContainedObject(slot) as GameObject;
                if ((containedObject != null) && ths.HarvestHarvestable(containedObject, actor, burglarSituation))
                {
                    objectsHarvested.Add(containedObject);
                }
            }

            if (actor.TraitManager.HasElement(TraitNames.GathererTrait) && RandomUtil.RandomChance01(TraitTuning.GathererTraitExtraHarvestablesChance))
            {
                int gathererTraitNumberOfExtraHarvestables = TraitTuning.GathererTraitNumberOfExtraHarvestables;
                for (int i = 0; i < gathererTraitNumberOfExtraHarvestables; i++)
                {
                    GameObject item = ths.Seed.Copy(false) as GameObject;
                    if (item != null)
                    {
                        objectsHarvested.Add(item);
                    }
                }
            }

            ScienceSkill element = actor.SkillManager.GetSkill <ScienceSkill>(SkillNames.Science);

            if ((element != null) && RandomUtil.RandomChance01(ScienceSkill.kSuccessRateBonusesGardening[element.SkillLevel]))
            {
                int num3 = ScienceSkill.kNumExtraHarvestables[element.SkillLevel];
                for (int j = 0; j < num3; j++)
                {
                    GameObject obj6 = ths.Seed.Copy(false) as GameObject;
                    if (obj6 != null)
                    {
                        objectsHarvested.Add(obj6);
                    }
                }
            }

            if (objectsHarvested.Count <= 0)
            {
                return(false);
            }

            foreach (GameObject obj7 in objectsHarvested)
            {
                ths.ManipulateHarvestable(actor, obj7);
            }

            Gardening  skill           = actor.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
            Collecting collecting      = actor.SkillManager.GetSkill <Collecting>(SkillNames.Collecting);
            int        skillDifficulty = ths.PlantDef.GetSkillDifficulty();

            if (skill != null)
            {
                if (skill.SkillLevel <= skillDifficulty)
                {
                    if (actor.SimDescription.IsFairy && skill.IsFairySkill())
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest * Skill.SkillLevelBumpMultiplierForFairies);
                    }
                    else
                    {
                        skill.AddPoints(ths.PlantDef.SkillPointsHarvest);
                    }
                }

                if (ths is MoneyTree)
                {
                    MoneyTreeEx.UpdateGardeningSkillJournal(ths as MoneyTree, skill, ths.PlantDef, objectsHarvested);
                }
                else
                {
                    ths.UpdateGardeningSkillJournal(skill, ths.PlantDef, objectsHarvested);
                }
            }

            if (!hasHarvested)
            {
                actor.ShowTNSIfSelectable(Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/Gardening/HarvestPlant/Harvest:FirstHarvest", new object[] { actor, ths.PlantDef.Name }), StyledNotification.NotificationStyle.kGameMessagePositive, ths.ObjectId, actor.ObjectId);
            }

            if (collecting == null)
            {
                collecting = actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
            }

            collecting.CollectedFromHarvest(objectsHarvested);
            ths.PostHarvest();
            return(true);
        }
示例#24
0
        protected static void EnactCorrections(Collecting skill)
        {
            Overwatch.Log(" Correcting: " + skill.SkillOwner.FullName);

            if (skill.mGlowBugData == null)
            {
                skill.mGlowBugData = new Dictionary<Sims3.Gameplay.Objects.Insect.InsectType, Collecting.GlowBugStats>();

                Overwatch.Log("  GlowBugData Fixed");
            }

            if (skill.mMushroomData == null)
            {
                skill.mMushroomData = new Dictionary<string, Collecting.MushroomStats>();

                Overwatch.Log("  MushroomData Fixed");
            }

            if (skill.mHarvestData == null)
            {
                skill.mHarvestData = new Dictionary<string, Collecting.HarvestStats>();

                Overwatch.Log("  HarvestData Fixed");
            }

            if (skill.mMetalData != null)
            {
                List<RockGemMetal> remove = new List<RockGemMetal>();

                foreach (KeyValuePair<RockGemMetal, Collecting.MetalStats> data in skill.mMetalData)
                {
                    if (data.Value.count == 0)
                    {
                        remove.Add(data.Key);
                    }
                }

                foreach (RockGemMetal metal in remove)
                {
                    skill.mMetalData.Remove(metal);
                }
            }

            Gardening gardening = skill.SkillOwner.SkillManager.GetSkill<Gardening>(SkillNames.Gardening);
            if ((gardening != null) && (gardening.mHarvestCounts.Count != 0))
            {
                bool success = false;

                foreach (KeyValuePair<string, Gardening.PlantInfo> plants in gardening.mHarvestCounts)
                {
                    string ingredient = null;
                    foreach (IngredientData choice in IngredientData.IngredientDataList)
                    {
                        if (choice.PlantName == plants.Key)
                        {
                            ingredient = choice.mStringKey;
                            break;
                        }
                    }

                    if (string.IsNullOrEmpty(ingredient)) continue;

                    Collecting.HarvestStats data = null;
                    if (!skill.mHarvestData.TryGetValue(ingredient, out data))
                    {
                        data = new Collecting.HarvestStats();
                        skill.mHarvestData.Add(ingredient, data);

                        data.quality = (int)plants.Value.BestQuality;
                        if (data.quality <= 0)
                        {
                            data.quality = (int)Quality.Bad;
                        }
                    }
                    else
                    {
                        if (data.quality < (int)plants.Value.BestQuality)
                        {
                            data.quality = (int)plants.Value.BestQuality;
                        }

                        if (data.count >= plants.Value.HarvestablesCount) continue;
                    }

                    if (data.mostExpensive < plants.Value.MostExpensive)
                    {
                        data.mostExpensive = plants.Value.MostExpensive;
                    }

                    if (data.count < plants.Value.HarvestablesCount)
                    {
                        data.count = plants.Value.HarvestablesCount;
                    }

                    success = true;
                }

                if (success)
                {
                    Overwatch.Log("  HarvestData Reconciled");
                }
            }
        }
示例#25
0
        public override bool Run()
        {
            try
            {
                InsectData data;
                Route      r = Actor.RoutingComponent.CreateRoute();
                r.PlanToPointRadialRange(Target.Position, 0f, InsectJig.sMaxCatchRange, RouteDistancePreference.PreferNearestToRouteDestination, RouteOrientationPreference.TowardsObject, Target.LotCurrent.LotId, null);

                try
                {
                    if (!Actor.RoutingComponent.DoRoute(r) || Target.InUse)
                    {
                        return(false);
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.DebugException(Actor, Target, e);
                    return(false);
                }

                mDummyIkJig = GlobalFunctions.CreateObjectOutOfWorld("SocialJigOnePerson") as SocialJigOnePerson;
                mDummyIkJig.SetForward(Actor.ForwardVector);
                mDummyIkJig.SetPosition(Actor.Position);
                mDummyIkJig.SetHiddenFlags(~HiddenFlags.Nothing);
                mDummyIkJig.AddToWorld();

                StandardEntry();

                BeginCommodityUpdates();
                bool succeeded = false;

                try
                {
                    if (InsectData.sData.TryGetValue(Target.InsectType, out data))
                    {
                        mTempInsect = Sims3.Gameplay.Objects.Insect.Insect.Create(Target.InsectType);
                        string       jazzInsectParameterName = data.GetJazzInsectParameterName();
                        string       jazzEnterStateName      = data.GetJazzEnterStateName();
                        float        catchChance             = data.CatchChance;
                        InsectRarity rarity = data.Rarity;
                        data = null;
                        mCurrentStateMachine = InsectData.AcquireInitAndEnterStateMachine(Actor, mTempInsect, mDummyIkJig, jazzInsectParameterName, jazzEnterStateName);
                        if (mCurrentStateMachine != null)
                        {
                            Collecting collecting = Actor.SkillManager.AddElement(SkillNames.Collecting) as Collecting;
                            if (collecting.IsBeetleCollector())
                            {
                                succeeded = true;
                            }
                            else
                            {
                                succeeded = RandomUtil.RandomChance01(catchChance);
                            }
                            AnimateSim(succeeded ? "ExitSuccess" : "ExitFailure");
                            if (succeeded)
                            {
                                InsectTerrarium.Create(Target, Actor);
                            }
                            else
                            {
                                ReactionTypes reactionType = RandomUtil.CoinFlip() ? ReactionTypes.Annoyed : (RandomUtil.CoinFlip() ? ReactionTypes.Shrug : ReactionTypes.Angry);
                                Actor.PlayReaction(reactionType, ReactionSpeed.NowOrLater);
                            }
                        }
                    }
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                StandardExit();
                DestroyObject(Target);
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }