Beispiel #1
0
        public ConsumableInfo GetConsumableInfo(ConsumableType CType)
        {
            ConsumableInfo info = null;

            if (this.Consumables != null)
            {
                info = this.Consumables.Find(c => c.Type == CType);
                return(info);
            }
            return(info);
        }
Beispiel #2
0
 public virtual void OnEat(ConsumableInfo info)
 {
     if (info.m_ConsumeEffect == this.m_Type)
     {
         this.m_Level += info.m_ConsumeEffectLevel;
     }
     this.m_Level = Mathf.Clamp(this.m_Level, 0, 100);
     if (this.m_Level == 0)
     {
         this.Deactivate();
     }
 }
Beispiel #3
0
 public void AddConsumable(ConsumableInfo info)
 {
     if (PlacementCollection == null)
     {
         return;
     }
     if (info != null && LastControl <= MAX_CONTROLS)
     {
         AddPicture(info.Type);
         AddInfoText(info);
         LastControl++;
     }
 }
        public ConsumableViewModel()
        {
            Consumable = new ConsumableInfo();

            Categories = new List <ConsumableInfo>();

            SubCategories = new List <ConsumableInfo>();

            Pager = new PaginationInfo();

            Consumables = new List <ConsumableInfo>();

            Friendly_Message = new List <FriendlyMessageInfo>();

            Filter = new Consumable_Filter();
        }
Beispiel #5
0
        private void AddInfoText(ConsumableInfo info)
        {
            if (info.Range > 0)
            {
                Label lbl = (Label)PlacementCollection["lblRange" + LastControl];
                lbl.Text    = "Range: " + info.Range.ToString() + " km";
                lbl.Visible = true;
            }

            if (info.Cooldown > 0)
            {
                Label lbl2 = (Label)PlacementCollection["lblCooldown" + LastControl];
                lbl2.Text    = "Cooldown: " + info.Cooldown.ToString() + " sec.";
                lbl2.Visible = true;
            }

            if (info.Duration > 0)
            {
                Label lbl3 = (Label)PlacementCollection["lblDuration" + LastControl];
                lbl3.Text    = "Duration: " + info.Duration.ToString() + " sec.";
                lbl3.Visible = true;
            }

            if (info.Charges > 0)
            {
                Label lbl4 = (Label)PlacementCollection["lblCharges" + LastControl];
                if (info.Charges == 99)
                {
                    lbl4.Text = "Charges: Unlimited";
                }
                else
                {
                    lbl4.Text = "Charges: " + info.Charges.ToString();
                }
                lbl4.Visible = true;
            }

            if (!info.ExtraInfo.Equals(""))
            {
                Label lbl5 = (Label)PlacementCollection["lblExtra" + LastControl];
                lbl5.Text    = info.ExtraInfo;
                lbl5.Visible = true;
            }
        }
        private List <SqlParameter> Set_Values_In_Consumable_Vendor(ConsumableInfo consumable)
        {
            List <SqlParameter> sqlparam = new List <SqlParameter>();

            if (consumable.Consumable_Vendor.Consumable_Vendor_Id != 0)
            {
                sqlparam.Add(new SqlParameter("@Consumable_Vendor_Id", consumable.Consumable_Vendor.Consumable_Vendor_Id));
            }
            sqlparam.Add(new SqlParameter("@Vendor_Id", consumable.Consumable_Vendor.Vendor_Id));
            sqlparam.Add(new SqlParameter("@Consumable_Id", consumable.Consumable_Id));
            sqlparam.Add(new SqlParameter("@Priority_Order", consumable.Consumable_Vendor.Priority_Order));

            if (consumable.Consumable_Vendor.Consumable_Vendor_Id == 0)
            {
                sqlparam.Add(new SqlParameter("@CreatedBy", consumable.Consumable_Vendor.CreatedBy));
            }
            sqlparam.Add(new SqlParameter("@UpdatedBy", consumable.Consumable_Vendor.UpdatedBy));

            return(sqlparam);
        }
Beispiel #7
0
 public virtual void OnEat(ConsumableInfo info)
 {
     if (info.m_ConsumeEffect == this.m_Type && this.CanApplyConsumeEffect(info))
     {
         this.m_Level += info.m_ConsumeEffectLevel;
         Localization localization = GreenHellGame.Instance.GetLocalization();
         HUDMessages  hudmessages  = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages));
         string       text         = string.Empty;
         if (info.m_ConsumeEffect == ConsumeEffect.ParasiteSickness)
         {
             text = info.m_ConsumeEffectLevel.ToString("F0") + " " + localization.Get("HUD_ParasiteSickness", true);
             hudmessages.AddMessage(text, null, HUDMessageIcon.ParasiteSickness, "", null);
         }
     }
     this.m_Level = Mathf.Clamp(this.m_Level, 0, this.m_MaxLevel);
     if (this.m_Level == 0)
     {
         this.Deactivate();
     }
 }
Beispiel #8
0
    public override void OnEat(ConsumableInfo info)
    {
        base.OnEat(info);
        float   num     = UnityEngine.Random.Range(0f, 1f);
        Disease disease = PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.DirtSickness);

        if (num < (float)disease.m_Level * 0.1f)
        {
            ParasiteSickness parasiteSickness = (ParasiteSickness)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.ParasiteSickness);
            if (parasiteSickness.IsActive())
            {
                parasiteSickness.IncreaseLevel(1);
            }
            else
            {
                PlayerDiseasesModule.Get().RequestDisease(ConsumeEffect.ParasiteSickness, 0f, 1);
            }
            HUDMessages.Get().AddMessage("+1 " + GreenHellGame.Instance.GetLocalization().Get("HUDMessage_ParasiteFromDirt", true), new Color?(Color.white), HUDMessageIcon.ParasiteSickness, string.Empty, this.m_IconIndexesTemp);
        }
    }
Beispiel #9
0
        public List <ConsumableInfo> GetConsumableInfoConfigration()
        {
            List <ConsumableInfo> ret   = new List <ConsumableInfo>();
            string        conString     = WebConfigurationManager.ConnectionStrings["Database1"].ToString();
            SqlConnection sqlConnection = new SqlConnection(conString);

            try
            {
                sqlConnection.Open();

                SqlCommand cmd = new SqlCommand
                {
                    Connection  = sqlConnection,
                    CommandText = "SELECT * FROM ConsumableConfig"
                };
                SqlDataReader reader = cmd.ExecuteReader();

                while (reader.Read())
                {
                    ConsumableInfo info1 = new ConsumableInfo
                    {
                        ID          = (int)reader[0],
                        Name        = (string)reader[1],
                        Information = (string)reader[2],
                        Type        = (int)reader[3],
                        Limit       = (int)reader[4]
                    };

                    ret.Add(info1);
                }
                reader.Close();

                sqlConnection.Close();
            }
            catch (Exception ex)
            {
                sqlConnection.Close();
            }

            return(ret);
        }
        private ConsumableInfo Get_Consumable_Values(DataRow dr)
        {
            ConsumableInfo consumable = new ConsumableInfo();

            consumable.Consumable_Id  = Convert.ToInt32(dr["Consumable_Id"]);
            consumable.Category_Id    = Convert.ToInt32(dr["Category_Id"]);
            consumable.SubCategory_Id = Convert.ToInt32(dr["SubCategory_Id"]);
            consumable.Material_Name  = Convert.ToString(dr["Material_Name"]);
            consumable.Material_Code  = Convert.ToString(dr["Material_Code"]);
            consumable.IsActive       = Convert.ToBoolean(dr["IsActive"]);

            consumable.CreatedDtm = Convert.ToDateTime(dr["CreatedDtm"]);
            consumable.CreatedBy  = Convert.ToInt32(dr["CreatedBy"]);
            consumable.UpdatedDtm = Convert.ToDateTime(dr["UpdatedDtm"]);
            consumable.UpdatedBy  = Convert.ToInt32(dr["UpdatedBy"]);

            consumable.Category_Name    = Convert.ToString(dr["CategoryName"]);
            consumable.SubCategory_Name = Convert.ToString(dr["SubCategoryName"]);

            return(consumable);
        }
        public List <ConsumableInfo> Get_SubCategory_Name(PaginationInfo pager)
        {
            List <ConsumableInfo> consumables = new List <ConsumableInfo>();

            DataTable dt = _sqlRepo.ExecuteDataTable(null, StoredProcedures.Get_SubCategory_Name_sp.ToString(), CommandType.StoredProcedure);

            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dr in CommonMethods.GetRows(dt, ref pager))
                {
                    ConsumableInfo consumable = new ConsumableInfo();

                    consumable.SubCategory_Id   = Convert.ToInt32(dr["SubCategoryId"]);
                    consumable.SubCategory_Name = Convert.ToString(dr["SubCategoryName"]);

                    consumables.Add(consumable);
                }
            }

            return(consumables);
        }
Beispiel #12
0
        /// <summary>
        /// 保存耗材信息
        /// </summary>
        /// <param name="info">耗材信息</param>
        /// <param name="userInfo">操作者</param>
        /// <returns>耗材id</returns>
        public int SaveConsumable(ConsumableInfo info, UserInfo userInfo)
        {
            if (info.ID == 0)
            {
                info.ID = this.consumableDao.AddConsumable(info);
            }
            else
            {
                ConsumableInfo existingInfo = this.consumableDao.GetConsumableByID(info.ID);
                info.FujiClass2.Name = this.fujiClassDao.GetFujiClass2ByID(info.FujiClass2.ID).Name;
                DataTable dtField = existingInfo.GetChangedFields(info);

                if (dtField.Rows.Count > 0)
                {
                    this.consumableDao.UpdateConsumable(info);

                    this.auditManager.AddAuditLog(userInfo.ID, ObjectTypes.Component, info.ID, dtField);
                }
            }

            return(info.ID);
        }
        private List <SqlParameter> Set_Values_In_Consumable(ConsumableInfo consumable)
        {
            List <SqlParameter> sqlParams = new List <SqlParameter>();

            if (consumable.Consumable_Id != 0)
            {
                sqlParams.Add(new SqlParameter("@Consumable_Id", consumable.Consumable_Id));
            }
            sqlParams.Add(new SqlParameter("@Category_Id", consumable.Category_Id));
            sqlParams.Add(new SqlParameter("@SubCategory_Id", consumable.SubCategory_Id));
            sqlParams.Add(new SqlParameter("@Material_Name", consumable.Material_Name));
            sqlParams.Add(new SqlParameter("@Material_Code", consumable.Material_Code));
            sqlParams.Add(new SqlParameter("@IsActive", consumable.IsActive));

            if (consumable.Consumable_Id == 0)
            {
                sqlParams.Add(new SqlParameter("@CreatedBy", consumable.CreatedBy));
            }
            sqlParams.Add(new SqlParameter("@UpdatedBy", consumable.UpdatedBy));

            return(sqlParams);
        }
Beispiel #14
0
        public JsonResult SaveConsumable(ConsumableInfo info)
        {
            ResultModel <int> result = new ResultModel <int>();

            if (CheckSession(false) == false)
            {
                return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet));
            }
            if (CheckSessionID() == false)
            {
                return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet));
            }
            try
            {
                result.Data = this.consumableManager.SaveConsumable(info, GetLoginUser());
            }
            catch (Exception ex)
            {
                NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message);
                result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage);
            }
            return(JsonResult(result));
        }
 public void OnEat(ConsumableInfo info)
 {
     using (Dictionary <int, Disease> .KeyCollection.Enumerator enumerator = this.m_Diseases.Keys.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ConsumeEffect key     = (ConsumeEffect)enumerator.Current;
             Disease       disease = this.m_Diseases[(int)key];
             disease.OnEat(info);
         }
     }
     using (Dictionary <int, global::DiseaseSymptom> .KeyCollection.Enumerator enumerator2 = this.m_Symptoms.Keys.GetEnumerator())
     {
         while (enumerator2.MoveNext())
         {
             Enums.DiseaseSymptom   key2           = (Enums.DiseaseSymptom)enumerator2.Current;
             global::DiseaseSymptom diseaseSymptom = this.m_Symptoms[(int)key2];
             if (diseaseSymptom.IsActive())
             {
                 diseaseSymptom.OnEat(info);
             }
         }
     }
 }
Beispiel #16
0
        /// <summary>
        /// 添加耗材
        /// </summary>
        /// <param name="info">耗材信息</param>
        /// <returns>耗材id</returns>
        public int AddConsumable(ConsumableInfo info)
        {
            sqlStr = "INSERT INTO tblConsumable(FujiClass2ID,Name,Description,TypeID,ReplaceTimes, CostPer,StdPrice,IsIncluded,IncludeContract,IsActive,AddDate) " +
                     " VALUES(@FujiClass2ID,@Name,@Description,@TypeID,@ReplaceTimes,@CostPer,@StdPrice,@IsIncluded,@IncludeContract,@IsActive,GetDate()); " +
                     " SELECT @@IDENTITY ";

            using (SqlCommand command = ConnectionUtil.GetCommand(sqlStr))
            {
                command.Parameters.Add("@FujiClass2ID", SqlDbType.Int).Value     = SQLUtil.ConvertInt(info.FujiClass2.ID);
                command.Parameters.Add("@Name", SqlDbType.NVarChar).Value        = SQLUtil.TrimNull(info.Name);
                command.Parameters.Add("@Description", SqlDbType.NVarChar).Value = SQLUtil.TrimNull(info.Description);
                command.Parameters.Add("@TypeID", SqlDbType.Int).Value           = SQLUtil.ConvertInt(info.Type.ID);
                command.Parameters.Add("@ReplaceTimes", SqlDbType.Decimal).Value = info.ReplaceTimes;
                command.Parameters.Add("@CostPer", SqlDbType.Decimal).Value      = info.CostPer;
                command.Parameters.Add("@StdPrice", SqlDbType.Decimal).Value     = info.StdPrice;
                command.Parameters.Add("@IsIncluded", SqlDbType.Bit).Value       = SQLUtil.ConvertBoolean(info.IsIncluded);
                command.Parameters.Add("@IncludeContract", SqlDbType.Bit).Value  = SQLUtil.ConvertBoolean(info.IncludeContract);
                command.Parameters.Add("@IsActive", SqlDbType.Bit).Value         = SQLUtil.ConvertBoolean(info.IsActive);

                info.ID = SQLUtil.ConvertInt(command.ExecuteScalar());

                return(info.ID);
            }
        }
Beispiel #17
0
        // While hovering over a food, show food's consumable effects
        // Code below is mostly copy&pasted from original implementation
        protected override void SetupConsumableEffects()
        {
            if (!m_ConsumableEffects)
            {
                return;
            }

            if (IsExpanded())
            {
                m_ConsumableEffects.gameObject.SetActive(false);
            }
            else
            {
                Trigger  trigger = GetTrigger();
                ItemInfo m_Info  = null;
                if (trigger)
                {
                    if (trigger.IsItem())
                    {
                        m_Info = ((Item)trigger).m_Info;
                    }
                    else if (trigger is PlantFruit)
                    {
                        m_Info = ((PlantFruit)trigger).m_ItemInfo;
                    }
                    else if (trigger is ItemReplacer)
                    {
                        m_Info = ((ItemReplacer)trigger).m_ReplaceInfo;
                    }
                }

                if (m_Info == null)
                {
                    m_ConsumableEffects.gameObject.SetActive(false);
                }
                else
                {
                    if (!m_Info.IsConsumable() && !m_Info.IsLiquidContainer())
                    {
                        m_ConsumableEffects.gameObject.SetActive(false);
                    }
                    else
                    {
                        int index1 = 0;
                        if (m_Info.IsConsumable())
                        {
                            if (!ItemsManager.Get().WasConsumed(m_Info.m_ID))
                            {
                                m_UnknownEffect.SetActive(true);
                            }
                            else
                            {
                                m_UnknownEffect.SetActive(false);
                                ConsumableInfo info = (ConsumableInfo)m_Info;
                                if (info.m_Proteins > 0.0)
                                {
                                    SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), info.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f);
                                }
                                if (info.m_Fat > 0.0)
                                {
                                    SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), info.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f);
                                }
                                if (info.m_Carbohydrates > 0.0)
                                {
                                    SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), info.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f);
                                }
                                if (info.m_Water > 0.0)
                                {
                                    SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Water, "HUD_Hydration", ref index1, -1f);
                                }
                                if (info.m_Dehydration > 0.0)
                                {
                                    SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * info.m_Dehydration, "HUD_Hydration", ref index1, -1f);
                                }
                                if (info.m_AddEnergy > 0.0)
                                {
                                    SetupEffect("Energy_icon", Color.white, info.m_AddEnergy, "HUD_Energy", ref index1, -1f);
                                }
                                if (info.m_SanityChange != 0.0)
                                {
                                    SetupEffect("sanity_icon_H", Color.white, info.m_SanityChange, "HUD_Sanity", ref index1, -1f);
                                }
                                if (info.m_ConsumeEffect == ConsumeEffect.Fever)
                                {
                                    SetupEffect("Fever_icon_T", Color.white, info.m_ConsumeEffectLevel, "Fever", ref index1, -1f);
                                }
                                if (info.m_ConsumeEffect == ConsumeEffect.FoodPoisoning)
                                {
                                    SetupEffect("Vomit_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f);
                                }
                                else if (info.m_ConsumeEffect == ConsumeEffect.ParasiteSickness)
                                {
                                    SetupEffect("ParasiteSichness_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_ParasiteSickness", ref index1, -1f);
                                }
                            }
                        }
                        else if (m_Info.IsLiquidContainer())
                        {
                            LiquidContainerInfo info = (LiquidContainerInfo)m_Info;
                            if (info.m_Amount > 0.0)
                            {
                                LiquidData liquidData = LiquidManager.Get().GetLiquidData(info.m_LiquidType);
                                if (info.m_Amount >= 1.0)
                                {
                                    SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Amount, "HUD_Hydration", ref index1, info.m_Capacity);
                                }
                                if (liquidData.m_Energy > 0.0)
                                {
                                    SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref index1, -1f);
                                }
                                for (int index2 = 0; index2 < liquidData.m_ConsumeEffects.Count; ++index2)
                                {
                                    if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.FoodPoisoning)
                                    {
                                        SetupEffect("Vomit_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f);
                                    }
                                    else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.Fever)
                                    {
                                        SetupEffect("Fever_icon_T", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Fever", ref index1, -1f);
                                    }
                                    else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.ParasiteSickness)
                                    {
                                        SetupEffect("ParasiteSichness_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Parasite Sickness", ref index1, -1f);
                                    }
                                }
                                if (info.IsBowl())
                                {
                                    if (liquidData.m_Proteins > 0.0)
                                    {
                                        SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), liquidData.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f);
                                    }
                                    if (liquidData.m_Fat > 0.0)
                                    {
                                        SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), liquidData.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f);
                                    }
                                    if (liquidData.m_Carbohydrates > 0.0)
                                    {
                                        SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), liquidData.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f);
                                    }
                                    if (liquidData.m_Dehydration > 0.0)
                                    {
                                        SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * liquidData.m_Dehydration, "HUD_Hydration", ref index1, -1f);
                                    }
                                    if (liquidData.m_SanityChange != 0)
                                    {
                                        SetupEffect("sanity_icon_H", Color.white, liquidData.m_SanityChange, "HUD_Sanity", ref index1, -1f);
                                    }
                                }
                            }
                            m_UnknownEffect.SetActive(index1 == 0);
                        }
                        for (int index2 = index1; index2 < m_EffectsData.Count; ++index2)
                        {
                            m_EffectsData[index2].m_Parent.SetActive(false);
                        }
                        m_ConsumableEffects.gameObject.SetActive(true);
                    }
                }
            }
        }
Beispiel #18
0
 public void Update_Consumable(ConsumableInfo consumable)
 {
     _cRepo.Update_Consumable(consumable);
 }
Beispiel #19
0
 public void Update_Consumable_Vendors(ConsumableInfo consumable)
 {
     _cRepo.Update_Consumable_Vendors(consumable);
 }
Beispiel #20
0
 public virtual void OnEat(ConsumableInfo info)
 {
 }
Beispiel #21
0
    public void Unload()
    {
        if (currentLevel == gameObject)
        {
            GameObject[] Monsters = GameObject.FindGameObjectsWithTag("Monster");

            foreach (GameObject monster in Monsters)
            {
                MonsterList.Add(new MonsterData
                {
                    position = ConvertToArray(monster.transform.position),
                    rotation = ConvertToArray(monster.transform.rotation.eulerAngles),

                    Level       = monster.GetComponent <MonsterScript>().MonsterLevel,
                    MonsterType = monster.GetComponent <MonsterScript>().monsterType
                });
                Destroy(monster);
            }

            GameObject[] droppedStuffs = GameObject.FindGameObjectsWithTag("Shiny");

            List <WeaponData> droppedWeaponData = new List <WeaponData>();

            List <Array> droppedWeaponPositions = new List <Array>();
            List <Array> droppedWeaponRotations = new List <Array>();

            List <Array> droppedConsumablePositions = new List <Array>();
            List <Array> droppedConsumableRotations = new List <Array>();

            List <ConsumableInfo> droppedConsumableInfo = new List <ConsumableInfo>();

            foreach (GameObject droppedItem in droppedStuffs)
            {
                if (droppedItem.GetComponent <DroppedConsumableScript>())
                {
                    ConsumableInfo consumable = new ConsumableInfo()
                    {
                        amountCarried  = droppedItem.GetComponent <DroppedConsumableScript>().amount,
                        consumableType = droppedItem.GetComponent <DroppedConsumableScript>().ConsumableType
                    };

                    droppedConsumableInfo.Add(consumable);
                    droppedConsumablePositions.Add(ConvertToArray(droppedItem.transform.position));
                    droppedConsumableRotations.Add(ConvertToArray(droppedItem.transform.rotation.eulerAngles));
                }
                else if (droppedItem.GetComponent <DroppedWeaponScript>())
                {
                    DroppedWeaponScript currentWeapon = droppedItem.gameObject.GetComponent <DroppedWeaponScript>();


                    // setting these up so that we can turn them into arrays then save the inventory as an array
                    List <EnchantmentType> currentEnchants         = new List <EnchantmentType>();
                    List <int>             currentEnchantStrengths = new List <int>();


                    List <int> currentEnchantCosts     = new List <int>();
                    List <int> currentEnchantPenalties = new List <int>();


                    foreach (EnchantmentScript enchant in currentWeapon.gameObject.GetComponents <EnchantmentScript>())
                    {
                        currentEnchants.Add(enchant.EnchantType);
                        currentEnchantStrengths.Add(enchant.Strength);

                        currentEnchantCosts.Add(enchant.ManaCost);
                        currentEnchantPenalties.Add(enchant.ManaPenalty);
                    }
                    WeaponData currentData = new WeaponData()
                    {
                        reactionCount = 0,
                        weaponType    = currentWeapon.WeaponCategory,

                        weaponVariant = currentWeapon.WeaponVariation,
                        enchants      = currentEnchants.ToArray(),

                        enchantmentStrengths = currentEnchantStrengths.ToArray(),
                        enchantmentCosts     = currentEnchantCosts.ToArray(),
                        enchantmentPenalties = currentEnchantPenalties.ToArray()
                    };
                    droppedWeaponData.Add(currentData);
                    droppedWeaponPositions.Add(ConvertToArray(droppedItem.transform.position));
                    droppedWeaponRotations.Add(ConvertToArray(droppedItem.transform.rotation.eulerAngles));
                }
            }
            // converting the lists we filled to something we can use
            float[][] consumablePos = new float[droppedConsumablePositions.Count][];
            for (int i = 0; i < consumablePos.Length; i++)
            {
                consumablePos[i] = (float[])droppedConsumablePositions[i];
            }
            float[][] consumableRot = new float[droppedConsumableRotations.Count][];
            for (int i = 0; i < consumableRot.Length; i++)
            {
                consumableRot[i] = (float[])droppedConsumableRotations[i];
            }

            float[][] droppedWeaponPos = new float[droppedWeaponPositions.Count][];
            for (int i = 0; i < droppedWeaponPos.Length; i++)
            {
                droppedWeaponPos[i] = (float[])droppedWeaponPositions[i];
            }
            float[][] droppedWeaponRot = new float[droppedWeaponRotations.Count][];
            for (int i = 0; i < droppedWeaponRot.Length; i++)
            {
                droppedWeaponRot[i] = (float[])droppedWeaponRotations[i];
            }

            // putting it all into contents so that we can reload it later.
            myContents = new LevelContents()
            {
                AllMonsters = MonsterList.ToArray(),

                myConsumableLoot      = droppedConsumableInfo.ToArray(),
                myConsumablePositions = consumablePos,
                myConsumableRotations = consumableRot,

                myWeaponLoot          = droppedWeaponData.ToArray(),
                myWeaponLootPositions = droppedWeaponPos,
                myWeaponRotations     = droppedWeaponRot,


                eF = exitFound,

                map = map
            };
        }
    }
Beispiel #22
0
    public void QueueEffects(ConsumableInfo consumableInfo)
    {
        if (!consumableInfo.Stackable && _activeEffects.ContainsKey(consumableInfo.ConsumableType))
        {
            for (var i = 0; i < _activeEffects[consumableInfo.ConsumableType].Length; i++)
            {
                var effect = _activeEffects[consumableInfo.ConsumableType][i];
                if (effect == null)
                {
                    continue;
                }

                var tup = _queuedMinuteEffects.Find(j => j.Item2 == effect);
                if (tup != null)
                {
                    _queuedMinuteEffects.Remove(tup);
                }

                tup = _queuedHourEffects.Find(j => j.Item2 == effect);
                if (tup != null)
                {
                    _queuedHourEffects.Remove(tup);
                }

                ApplyEffect(effect.EffectDetailsArray);
            }

            _activeEffects.Remove(consumableInfo.ConsumableType);
        }

        _activeEffects[consumableInfo.ConsumableType] = Effect.GetNewEffects(consumableInfo.Effects);

        for (var i = 0; i < _activeEffects[consumableInfo.ConsumableType].Length; i++)
        {
            var effect = _activeEffects[consumableInfo.ConsumableType][i];

            if (effect.EffectDelay == 0)
            {
                ApplyEffect(effect.EffectDetailsArray);
                continue;
            }

            var targetList = effect.DelayLengthType switch
            {
                Effect.DelayLength.Minute => _queuedMinuteEffects,
                Effect.DelayLength.Hour => _queuedHourEffects,
                _ => throw new System.ArgumentOutOfRangeException()
            };

            var index = 0;
            while (index < targetList.Count && targetList[index].Item2.EffectDelay < effect.EffectDelay)
            {
                index++;
            }

            targetList.Insert(index,
                              new System.Tuple <ConsumableInfo.Type, Effect>(consumableInfo.ConsumableType, effect));
        }

        if (_creature is Player player && consumableInfo.AddictionType != Addiction.Type.None)
        {
            var indexOfExisting = _activeAddictions.FindIndex(i => i.AddictionType == consumableInfo.AddictionType);
            if (indexOfExisting >= 0)
            {
                ResetAddiction(_activeAddictions[indexOfExisting], consumableInfo.Addiction);
            }
            else
            {
                var addictionChance = Random.Range(0, 100);
                if (addictionChance <= consumableInfo.Addiction.AddictionChance * player.AddictionResistMod())
                {
                    TriggerAddiction(consumableInfo.Addiction);
                }
            }
        }

        if (!_listeningForMinutes && (_queuedMinuteEffects.Count > 0 ||
                                      _activeAddictions.Exists(i =>
                                                               AddictionMatchesType(i, Effect.DelayLength.Minute))))
        {
            WorldClock.Instance.minuteTick += MinutePassedHandler;
            _listeningForMinutes            = true;
        }

        if (!_listeningForHours && (_queuedHourEffects.Count > 0 ||
                                    _activeAddictions.Exists(i => AddictionMatchesType(i, Effect.DelayLength.Hour))))
        {
            WorldClock.Instance.hourTick += HourPassedHandler;
            _listeningForHours            = true;
        }
    }
Beispiel #23
0
    private void SetupConsumableEffects()
    {
        if (!this.m_ConsumableEffects)
        {
            return;
        }
        if (!Inventory3DManager.Get().gameObject.activeSelf || this.IsExpanded())
        {
            this.m_ConsumableEffects.gameObject.SetActive(false);
            return;
        }
        Trigger trigger = this.GetTrigger();

        if (trigger == null || !trigger.IsItem())
        {
            this.m_ConsumableEffects.gameObject.SetActive(false);
            return;
        }
        Item item = (Item)trigger;

        if (!item.m_Info.IsConsumable() && !item.m_Info.IsLiquidContainer())
        {
            this.m_ConsumableEffects.gameObject.SetActive(false);
            return;
        }
        int num = 0;

        if (item.m_Info.IsConsumable())
        {
            if (!ItemsManager.Get().WasConsumed(item.m_Info.m_ID))
            {
                this.m_UnknownEffect.SetActive(true);
            }
            else
            {
                this.m_UnknownEffect.SetActive(false);
                ConsumableInfo consumableInfo = (ConsumableInfo)item.m_Info;
                if (consumableInfo.m_Proteins > 0f)
                {
                    this.SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), consumableInfo.m_Proteins, "HUD_Nutrition_Protein", ref num, -1f);
                }
                if (consumableInfo.m_Fat > 0f)
                {
                    this.SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), consumableInfo.m_Fat, "HUD_Nutrition_Fat", ref num, -1f);
                }
                if (consumableInfo.m_Carbohydrates > 0f)
                {
                    this.SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), consumableInfo.m_Carbohydrates, "HUD_Nutrition_Carbo", ref num, -1f);
                }
                if (consumableInfo.m_Water > 0f)
                {
                    this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), consumableInfo.m_Water, "HUD_Hydration", ref num, -1f);
                }
                if (consumableInfo.m_AddEnergy > 0f)
                {
                    this.SetupEffect("Energy_icon", Color.white, consumableInfo.m_AddEnergy, "HUD_Energy", ref num, -1f);
                }
                if ((float)consumableInfo.m_SanityChange > 0f)
                {
                    this.SetupEffect("Default_Pickup", Color.white, (float)consumableInfo.m_SanityChange, "HUD_Sanity", ref num, -1f);
                }
                if (consumableInfo.m_ConsumeEffect == ConsumeEffect.FoodPoisoning)
                {
                    this.SetupEffect("Vomit_icon_H", Color.white, (float)consumableInfo.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f);
                }
            }
        }
        else if (item.m_Info.IsLiquidContainer())
        {
            LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info;
            if (liquidContainerInfo.m_Amount > 0f)
            {
                LiquidData liquidData = LiquidManager.Get().GetLiquidData(liquidContainerInfo.m_LiquidType);
                if (liquidContainerInfo.m_Amount > 0f)
                {
                    this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), liquidContainerInfo.m_Amount, "HUD_Hydration", ref num, liquidContainerInfo.m_Capacity);
                }
                if (liquidData.m_Energy > 0f)
                {
                    this.SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref num, -1f);
                }
                if (liquidData.m_ConsumeEffect == ConsumeEffect.FoodPoisoning)
                {
                    this.SetupEffect("Vomit_icon_H", Color.white, (float)liquidData.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f);
                }
            }
            this.m_UnknownEffect.SetActive(num == 0);
        }
        for (int i = num; i < this.m_EffectsData.Count; i++)
        {
            this.m_EffectsData[i].m_Parent.SetActive(false);
        }
        this.m_ConsumableEffects.gameObject.SetActive(true);
    }
Beispiel #24
0
 protected override bool CanApplyConsumeEffect(ConsumableInfo info)
 {
     return(true);
 }
Beispiel #25
0
 protected virtual bool CanApplyConsumeEffect(ConsumableInfo info)
 {
     return(true);
 }
 public void Update_Consumable_Vendors(ConsumableInfo consumable)
 {
     _sqlRepo.ExecuteNonQuery(Set_Values_In_Consumable_Vendor(consumable), StoredProcedures.Update_Consumable_Vendors_Sp.ToString(), CommandType.StoredProcedure);
 }
Beispiel #27
0
 public int Insert_Consumable_Vendor(ConsumableInfo consumable)
 {
     return(_cRepo.Insert_Consumable_Vendor(consumable));
 }