Ejemplo n.º 1
0
        public Enums.ErrorCode TryCook(Player.Instance cOwner, int iCookingID, ref Enums.CookingSuccessType eSuccessType)
        {
            // check Palette
            Palette cPalette = Manager.GetPalette(iCookingID);

            if (null == cPalette)
            {
                return(Enums.ErrorCode.eCooking_InvalidID);
            }

            // check InstanceData
            InstanceData cData = null;

            if (_cDicInstanceData.ContainsKey(iCookingID))
            {
                cData = _cDicInstanceData[iCookingID];
            }
            else
            {
                cData = new InstanceData(iCookingID);
                _cDicInstanceData.Add(iCookingID, cData);
            }

            // check ingredients
            if (!cPalette.CheckIngredientsList(cOwner.IngredientsInstance))
            {
                return(Enums.ErrorCode.eCooking_NotEnoughIngredients);
            }

            // cook - change informations
            eSuccessType = CalcSuccessType(cOwner, iCookingID);

            // exp
            int   iExp        = CookingLevel.Manager.GetCookingData(iCookingID).CookingExp;
            float fScaleSkill = (cOwner.PlayerSkillInstance.GetValue(Enums.PlayerSkillID.eExpCooking) * 0.01f);
            float fScaleGreat = Enums.CookingSuccessType.eGreatSuccess == eSuccessType ? 0.15f : 0.0f;

            float fScaleMedal = 0.0f;

            switch (cData.GreateTypeEnum)
            {
            case Enums.CookingGreatType.eBronze:    fScaleMedal = 0.05f; break;

            case Enums.CookingGreatType.eSilver:    fScaleMedal = 0.1f; break;

            case Enums.CookingGreatType.eGold:              fScaleMedal = 0.15f; break;

            case Enums.CookingGreatType.eNone:
            default:
                fScaleMedal = 0.0f;     break;
            }

            float fExp = (float)iExp;

            fExp *= (1.0f + fScaleSkill + fScaleGreat + fScaleMedal);

            iExp = (int)Math.Round(fExp, 0);

            int iOldLevel = cOwner.PlayerLevelInstance.Level;

            cData.AddAmount(eSuccessType);                                                                      // 요리 갯수 1 올려주고
            //cOwner.MoneysInstance.Pay(Enums.MoneysType.eCoin, cPalette.CookingCost);	// 돈 줄여주고
            cPalette.RemoveIngredientsByCook(cOwner.IngredientsInstance);                                       // 요리재료 줄여주고
            cOwner.PlayerLevelInstance.AddExp(cOwner, iExp);                                                    // 경험치 채워주고
            cOwner.CookingLevelInstance.AddCooking(cData.PaletteID, cOwner);                                    // 요리 레벨 정보 변경해 준다.

            if (iOldLevel < cOwner.PlayerLevelInstance.Level)
            {
                Ranking.Manager.ChangeLevel(cOwner.AccountID, cOwner.PlayerLevelInstance.Level);
            }

            // check mission
            cOwner.MissionInstance.UpCookingAmount(iCookingID);

            if (Enums.CookingSuccessType.eGreatSuccess == eSuccessType)
            {
                cOwner.MissionInstance.UpGreatCookingAmount(iCookingID);
            }

            // write log
            //int iCurCoin = cOwner.MoneysInstance.GetMoney(Enums.MoneysType.eCoin);
            //MySqlUtil.WriteLog(cOwner.AccountID, Enums.LogMainType.Coin_Remove, Enums.LogSubType.Cooking, iCookingID.ToString(), (iCurCoin + cPalette.CookingCost).ToString(), iCurCoin.ToString());

            return(Enums.ErrorCode.eNone);
        }