示例#1
0
    public override void Save(int index)
    {
        base.Save(index);
        SaveGame.SaveVal("AcreState" + index, (int)this.m_AcreState);
        SaveGame.SaveVal("AcreItemId" + index, (int)this.m_ItemId);
        SaveGame.SaveVal("AcrePlant" + index, this.m_Plant != null);
        SaveGame.SaveVal("AcreTimeToGrow" + index, this.m_TimeToGrow);
        SaveGame.SaveVal("AcreGrownPlant" + index, this.m_GrownPlant != null);
        SaveGame.SaveVal("AcreLastUpdateTime" + index, this.m_LastUpdateTIme);
        if (this.m_GrownPlant)
        {
            AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
            if (component != null)
            {
                SaveGame.SaveVal("AcreGrownPlantRespawn" + index, component.m_TimeToRespawn);
                int num = -1;
                for (int i = 0; i < component.m_ToCollect.Count; i++)
                {
                    num = ((component.m_ToCollect[i] == null) ? (~(1 << i) & num) : (1 << i | num));
                }
                SaveGame.SaveVal("AcreGrownPlantMask" + index, num);
            }
        }
        SaveGame.SaveVal("AcreWaterAmount" + index, this.m_WaterAmount);
        SaveGame.SaveVal("AcreFertilizerAmount" + index, this.m_FertilizerAmount);
        float val = 0f;

        if (this.m_Plant != null)
        {
            val = this.m_Plant.transform.localScale.x;
        }
        SaveGame.SaveVal("AcreScale" + index, val);
    }
示例#2
0
 public void OnTake(ItemReplacer item)
 {
     if (this.m_GrownPlant)
     {
         AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
         if (component != null)
         {
             component.OnTake(item);
         }
     }
 }
示例#3
0
 public void OnEat(PlantFruit item)
 {
     if (this.m_GrownPlant)
     {
         AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
         if (component != null)
         {
             component.OnEat(item);
         }
     }
 }
示例#4
0
    public float GetRespawnProgress()
    {
        if (!this.m_GrownPlant)
        {
            return(0f);
        }
        AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();

        if (!component)
        {
            return(0f);
        }
        return(component.GetRespawnProgress());
    }
示例#5
0
 public void OnDestroyPlant(GameObject obj)
 {
     if (this.m_GrownPlant && SaveGame.m_State == SaveGame.State.None && !this.m_ForceNoRespawn)
     {
         AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
         if (component && this.m_ItemId != ItemID.Cocona_Seeds)
         {
             component.OnDestroyPlant();
         }
     }
     this.m_ForceNoRespawn = false;
     if (this.m_GrownPlant == obj)
     {
         this.SetState(AcreState.NotReady);
     }
 }
示例#6
0
 public override void Load(int index)
 {
     base.Load(index);
     this.m_ItemId = (ItemID)SaveGame.LoadIVal("AcreItemId" + index);
     this.SetState((AcreState)SaveGame.LoadIVal("AcreState" + index));
     if (SaveGame.LoadBVal("AcrePlant" + index))
     {
         this.PlantSeed();
         float   num = SaveGame.LoadFVal("AcreScale" + index);
         Vector3 one = Vector3.one;
         one.Set(num, num, num);
         this.m_Plant.transform.localScale = one;
     }
     this.m_TimeToGrow = SaveGame.LoadFVal("AcreTimeToGrow" + index);
     if (SaveGame.LoadBVal("AcreGrownPlant" + index))
     {
         this.ReplaceToGrown();
         if (this.m_GrownPlant)
         {
             AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
             if (component != null)
             {
                 component.m_TimeToRespawn = SaveGame.LoadFVal("AcreGrownPlantRespawn" + index);
                 int num2 = SaveGame.LoadIVal("AcreGrownPlantMask" + index);
                 for (int i = 0; i < component.m_ToCollect.Count; i++)
                 {
                     if ((num2 & 1 << i) == 0)
                     {
                         UnityEngine.Object.Destroy(component.m_ToCollect[i]);
                         component.m_ToCollect[i] = null;
                     }
                 }
             }
         }
     }
     this.m_LastUpdateTIme   = SaveGame.LoadFVal("AcreLastUpdateTime" + index);
     this.m_WaterAmount      = SaveGame.LoadFVal("AcreWaterAmount" + index);
     this.m_FertilizerAmount = SaveGame.LoadFVal("AcreFertilizerAmount" + index);
 }
示例#7
0
    public void UpdateInternal()
    {
        if (this.m_GrownPlant)
        {
            AcreRespawnFruits component = this.m_GrownPlant.GetComponent <AcreRespawnFruits>();
            if (component)
            {
                component.UpdateInternal();
            }
        }
        float num = Time.deltaTime;

        if (SleepController.Get().IsActive() && !SleepController.Get().IsWakingUp())
        {
            num = Player.GetSleepTimeFactor();
        }
        if (RainManager.Get().IsRain())
        {
            this.m_WaterAmount += this.m_FillSpeed * num;
        }
        else if (this.m_ItemId == ItemID.None)
        {
            this.m_WaterAmount -= this.m_DrySpeed * num;
        }
        else
        {
            this.m_WaterAmount -= ItemsManager.Get().GetInfo(this.m_ItemId).m_AcreDehydration *num;
        }
        this.m_WaterAmount = Mathf.Clamp(this.m_WaterAmount, 0f, this.m_MaxWaterAmount);
        if (this.m_ItemId != ItemID.None)
        {
            this.m_FertilizerAmount -= ItemsManager.Get().GetInfo(this.m_ItemId).m_AcreDefertilization *num;
            this.m_FertilizerAmount  = Mathf.Clamp(this.m_FertilizerAmount, 0f, this.m_MaxFertilizerAmount);
        }
        this.UpdateShaderProperties();
        float currentTimeMinutes = MainLevel.Instance.GetCurrentTimeMinutes();

        if (!this.m_Plant || this.m_AcreState != AcreState.Growing || this.m_WaterAmount <= 0f)
        {
            this.m_LastUpdateTIme = currentTimeMinutes;
            return;
        }
        bool  flag = false;
        float num2 = this.m_Plant.transform.localScale.x;
        float num3 = 1f;

        this.m_NumBuffs = 0;
        if (this.m_WaterAmount > 50f)
        {
            num3 = 1.2f;
            this.m_NumBuffs++;
        }
        float num4 = 1f;

        if (this.m_FertilizerAmount / this.m_MaxFertilizerAmount > 0.5f)
        {
            num4             = 1.4f;
            this.m_NumBuffs += 2;
        }
        else if (this.m_FertilizerAmount / this.m_MaxFertilizerAmount > 0.01f)
        {
            num4 = 1.2f;
            this.m_NumBuffs++;
        }
        if (this.m_WaterAmount > 0f)
        {
            num2 += (currentTimeMinutes - this.m_LastUpdateTIme) / this.m_TimeToGrow * (num4 * num3);
        }
        if (num2 >= 1f)
        {
            flag = true;
        }
        num2 = Mathf.Clamp01(num2);
        Vector3 one = Vector3.one;

        one.Set(num2, num2, num2);
        if (this.m_Plant)
        {
            this.m_Plant.transform.localScale = one;
        }
        if (flag)
        {
            this.SetState(AcreState.Grown);
        }
        this.m_LastUpdateTIme = currentTimeMinutes;
    }