コード例 #1
0
ファイル: CharaOnce.cs プロジェクト: mliuzailin/GitGame
    //----------------------------------------------------------------------------
    /*!
		@brief	キャラ情報セットアップ:マスターデータ指定
		@param	MasterDataParamChara	cMasterData		キャラマスター
		@param	int						nLevel			キャラレベル
		@param	int						lbsLv			リミットブレイクスキルレベル
		@param	int						nPlusPow		プラス値:攻撃
		@param	int						nPlusHP			プラス値:体力
		@param	int						nLOLevel		プラス値:限界突破値
		@note
	*/
    //----------------------------------------------------------------------------
    public bool CharaSetupFromParam(MasterDataParamChara cMasterData, int nLevel, int lbsLv, int nPlusPow, int nPlusHP, int nLOLevel)
    {
        m_CharaMasterDataParam = cMasterData;
        m_bHasCharaMasterDataParam = (null != m_CharaMasterDataParam);

        if (m_CharaMasterDataParam == null)
        {
            Debug.LogError("CharaSetup Error! - InstanceNone!! ");
            return false;
        }

        // @change Developer 2015/09/03 ver300
        #region ==== 通常処理 ====
        int nPlusValuePow = 0;
        int nPlusValueHP = 0;

        m_CharaLevel = nLevel;
        m_CharaLBSLv = lbsLv;

        float fLimitOverHP = 0;
        float fLimitOverATK = 0;

        #region ==== スキルレベルまるめ処理 ====
        MasterDataSkillLimitBreak cSkillLimitBreak = BattleParam.m_MasterDataCache.useSkillLimitBreak(cMasterData.skill_limitbreak);
        if (cSkillLimitBreak != null)
        {
            if (lbsLv > cSkillLimitBreak.level_max)
            {
                m_CharaLBSLv = cSkillLimitBreak.level_max;
            }
        }
        #endregion

        #region ==== リミットオーバーまるめ処理 ====
        MasterDataLimitOver _masterMainLO = MasterFinder<MasterDataLimitOver>.Instance.Find((int)cMasterData.limit_over_type);
        if (_masterMainLO != null)
        {
            if (nLOLevel > _masterMainLO.limit_over_max)
            {
                nLOLevel = _masterMainLO.limit_over_max;
            }
        }
        #endregion

        m_CharaPow = CharaUtil.GetStatusValue(m_CharaMasterDataParam, nLevel, CharaUtil.VALUE.POW);
        m_CharaDef = CharaUtil.GetStatusValue(m_CharaMasterDataParam, nLevel, CharaUtil.VALUE.DEF);
        m_CharaHP = CharaUtil.GetStatusValue(m_CharaMasterDataParam, nLevel, CharaUtil.VALUE.HP);
        m_CharaLimitBreak = 0;
        m_CharaPlusPow = nPlusPow;
        m_CharaPlusDef = 0;
        m_CharaPlusHP = nPlusHP;
        m_CharaLimitOver = nLOLevel;
        m_CharaCharm = CharaLimitOver.GetParamCharm((uint)nLOLevel, cMasterData.limit_over_type);
        // レベルMAXなら限界突破の値を追加

        float fLimitOverAddHp = CharaLimitOver.GetParam((uint)nLOLevel, cMasterData.limit_over_type, (int)CharaLimitOver.EGET.ePARAM_HP);
        float fLimitOverAddAtk = CharaLimitOver.GetParam((uint)nLOLevel, cMasterData.limit_over_type, (int)CharaLimitOver.EGET.ePARAM_ATK);


        fLimitOverHP = m_CharaHP * (fLimitOverAddHp / 100);
        fLimitOverATK = m_CharaPow * (fLimitOverAddAtk / 100);

        // プラス値を算出
        nPlusValuePow = m_CharaPlusPow * GlobalDefine.PLUS_RATE_POW;
        nPlusValueHP = m_CharaPlusHP * GlobalDefine.PLUS_RATE_HP;
        #endregion

        // @add Developer 2015/09/03 ver300
        #region ==== リンクシステム処理 ====
        int nElemValuePow = 0;
        int nElemValueHP = 0;
        int nRaceValuePow = 0;
        int nRaceValueHP = 0;
        int nLinkPlusValuePow = 0;
        int nLinkPlusValueHP = 0;
        double nLinkCharm = 0;
        // リンク中の場合
        //MasterDataParamChara cLinkCharaMaster = BattleParam.m_MasterDataCache.useCharaParam(m_LinkParam.m_CharaID);
        MasterDataParamChara cLinkCharaMaster = m_LinkParam.m_cCharaMasterDataParam;
        if (cLinkCharaMaster != null)
        {
            float fWork = 0.0f;

            // 属性ボーナスを加算
            nElemValuePow = CharaLinkUtil.GetLinkUnitBonusElement(cLinkCharaMaster, m_LinkParam.m_CharaLv, (uint)m_LinkParam.m_CharaLOLevel, CharaUtil.VALUE.POW);
            nElemValueHP = CharaLinkUtil.GetLinkUnitBonusElement(cLinkCharaMaster, m_LinkParam.m_CharaLv, (uint)m_LinkParam.m_CharaLOLevel, CharaUtil.VALUE.HP);

            // 種族ボーナス:攻撃力の+%値を算出
            fWork = CharaLinkUtil.GetLinkUnitBonusRace(cLinkCharaMaster, cLinkCharaMaster.kind, CharaUtil.VALUE.POW);           // %値取得(メイン)
            fWork += CharaLinkUtil.GetLinkUnitBonusRace(cLinkCharaMaster, cLinkCharaMaster.sub_kind, CharaUtil.VALUE.POW);          // %値取得(サブ)
            fWork = InGameUtilBattle.GetDBRevisionValue(fWork);                                                                 // 数値変換
            nRaceValuePow = (int)InGameUtilBattle.AvoidErrorMultiple((float)m_CharaPow, fWork);                                         // 増加量

            // 種族ボーナス:体力の実値を取得
            nRaceValueHP = (int)CharaLinkUtil.GetLinkUnitBonusRace(cLinkCharaMaster, cLinkCharaMaster.kind, CharaUtil.VALUE.HP);        // 実値取得(メイン)
            nRaceValueHP += (int)CharaLinkUtil.GetLinkUnitBonusRace(cLinkCharaMaster, cLinkCharaMaster.sub_kind, CharaUtil.VALUE.HP);       // 実値取得(サブ)

            // +値の算出
            nLinkPlusValuePow = CharaLinkUtil.GetLinkUnitBonusPlus(m_LinkParam.m_CharaPlusPow, CharaUtil.VALUE.POW);
            nLinkPlusValueHP = CharaLinkUtil.GetLinkUnitBonusPlus(m_LinkParam.m_CharaPlusHP, CharaUtil.VALUE.HP);
            nLinkCharm = CharaLimitOver.GetParamCharm((uint)m_LinkParam.m_CharaLOLevel, cLinkCharaMaster.limit_over_type);
        }
        else
        {
            // リンク用変数の初期化
            m_LinkParam.Setup();
        }
        #endregion

#if BUILD_TYPE_DEBUG
        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "キャラ基本情報"
            + "[" + cMasterData.name + "]"
            + " FixID:" + cMasterData.fix_id
            + " DrawID:" + cMasterData.draw_id
            + " LV:" + m_CharaLevel.ToString()
            + " SkillLV:" + m_CharaLBSLv.ToString()
            + " LimOverLv:" + m_CharaLimitOver.ToString()
            + " PlusPow:" + m_CharaPlusPow.ToString()
            + " PlusHp:" + m_CharaPlusHP.ToString()
            + " 属性:" + cMasterData.element.ToString()
            + " 種族1:" + cMasterData.kind.ToString()
            + " 種族2:" + cMasterData.sub_kind.ToString()
        );

        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "  HP(" + (m_CharaHP + nPlusValueHP + nElemValueHP + nRaceValueHP + nLinkPlusValueHP + (int)fLimitOverHP).ToString() + ")"
            + " = LV(" + m_CharaHP.ToString() + ")"
            + " + PlusHP(" + nPlusValueHP.ToString() + ")"
            + " + LinkElem(" + nElemValueHP.ToString() + ")"
            + " + LinkRace(" + nRaceValueHP.ToString() + ")"
            + " + LinkPlus(" + nLinkPlusValueHP.ToString() + ")"
            + " + LimitOver(" + ((int)fLimitOverHP).ToString() + ")"
            );
        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "  POW(" + (m_CharaPow + nPlusValuePow + nElemValuePow + nRaceValuePow + nLinkPlusValuePow + (int)fLimitOverATK).ToString() + ")"
            + " = LV(" + m_CharaPow.ToString() + ")"
            + " + PlusPow(" + nPlusValuePow.ToString() + ")"
            + " + LinkElem(" + nElemValuePow.ToString() + ")"
            + " + LinkRace(" + nRaceValuePow.ToString() + ")"
            + " + LinkPlus(" + nLinkPlusValuePow.ToString() + ")"
            + " + LimitOver(" + ((int)fLimitOverATK).ToString() + ")"
            );

        const int ADD_SKILL_COUNT_LIMIT = 50;	// スキル連結数の上限

        if (cMasterData.skill_leader != 0)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "   リーダースキル(fixid:" + cMasterData.skill_leader.ToString(), false);
            MasterDataSkillLeader master_data = BattleParam.m_MasterDataCache.useSkillLeader(cMasterData.skill_leader);
            if (master_data == null)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
            }
            else
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
            }
        }

        if (cMasterData.skill_limitbreak != 0)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "   リミブレスキル(fixid:" + cMasterData.skill_limitbreak.ToString(), false);
            MasterDataSkillLimitBreak master_data = BattleParam.m_MasterDataCache.useSkillLimitBreak(cMasterData.skill_limitbreak);
            if (master_data == null)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
            }
            else
            {
                int loop_limit = ADD_SKILL_COUNT_LIMIT;
                int add_fix_id = master_data.add_fix_id;
                while (add_fix_id != 0)
                {
                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + "+" + add_fix_id.ToString(), false);
                    MasterDataSkillLimitBreak add_master_data = BattleParam.m_MasterDataCache.useSkillLimitBreak((uint)add_fix_id);
                    if (add_master_data == null)
                    {
                        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
                        break;
                    }

                    add_fix_id = add_master_data.add_fix_id;
                    loop_limit--;
                    if (loop_limit <= 0)
                    {
                        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(無限ループ))");
                    }
                }

                DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
            }
        }

        if (cMasterData.skill_active0 != 0)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "   ノーマルスキル1(fixid:" + cMasterData.skill_active0.ToString(), false);
            MasterDataSkillActive master_data = BattleParam.m_MasterDataCache.useSkillActive(cMasterData.skill_active0);
            if (master_data == null)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
            }
            else
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
            }
        }

        if (cMasterData.skill_active1 != 0)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "   ノーマルスキル2(fixid:" + cMasterData.skill_active1.ToString(), false);
            MasterDataSkillActive master_data = BattleParam.m_MasterDataCache.useSkillActive(cMasterData.skill_active1);
            if (master_data == null)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
            }
            else
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
            }
        }

        if (cMasterData.skill_passive != 0)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "   パッシブスキル(fixid:" + cMasterData.skill_passive.ToString(), false);
            MasterDataSkillPassive master_data = BattleParam.m_MasterDataCache.useSkillPassive(cMasterData.skill_passive);
            if (master_data == null)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
            }
            else
            {
                int loop_limit = ADD_SKILL_COUNT_LIMIT;
                int add_fix_id = master_data.add_fix_id;
                while (add_fix_id != 0)
                {
                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + "+" + add_fix_id.ToString(), false);
                    MasterDataSkillPassive add_master_data = BattleParam.m_MasterDataCache.useSkillPassive((uint)add_fix_id);
                    if (add_master_data == null)
                    {
                        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
                        break;
                    }

                    add_fix_id = add_master_data.add_fix_id;
                    loop_limit--;
                    if (loop_limit <= 0)
                    {
                        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(無限ループ))");
                    }
                }

                DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
            }
        }

        if (cLinkCharaMaster != null)
        {
            DebugBattleLog.writeText(DebugBattleLog.StrOpe + " リンクキャラ"
                + "[" + cLinkCharaMaster.name + "]"
                + " FixID:" + cLinkCharaMaster.fix_id
                + " DrawID:" + cLinkCharaMaster.draw_id
                + " LV:" + m_LinkParam.m_CharaLv.ToString()
                + " LimOverLv:" + m_LinkParam.m_CharaLOLevel.ToString()
                + " PlusPow:" + m_LinkParam.m_CharaPlusPow.ToString()
                + " PlusHp:" + m_LinkParam.m_CharaPlusHP.ToString()
                + " LinkPoint:" + m_LinkParam.m_CharaLinkPoint.ToString()
            );

            if (cLinkCharaMaster.link_skill_active != 0)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "    リンクスキル(fixid:" + cLinkCharaMaster.link_skill_active.ToString(), false);
                MasterDataSkillActive master_data = BattleParam.m_MasterDataCache.useSkillActive(cLinkCharaMaster.link_skill_active);
                if (master_data == null)
                {
                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
                }
                else
                {
                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
                }
            }

            if (cLinkCharaMaster.link_skill_passive != 0)
            {
                DebugBattleLog.writeText(DebugBattleLog.StrOpe + "    リンクパッシブスキル(fixid:" + cLinkCharaMaster.link_skill_passive.ToString(), false);
                MasterDataSkillPassive master_data = BattleParam.m_MasterDataCache.useSkillPassive(cLinkCharaMaster.link_skill_passive);
                if (master_data == null)
                {
                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
                }
                else
                {
                    int loop_limit = ADD_SKILL_COUNT_LIMIT;
                    int add_fix_id = master_data.add_fix_id;
                    while (add_fix_id != 0)
                    {
                        DebugBattleLog.writeText(DebugBattleLog.StrOpe + "+" + add_fix_id.ToString(), false);
                        MasterDataSkillPassive add_master_data = BattleParam.m_MasterDataCache.useSkillPassive((uint)add_fix_id);
                        if (add_master_data == null)
                        {
                            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(存在しないfix_id))");
                            break;
                        }

                        add_fix_id = add_master_data.add_fix_id;
                        loop_limit--;
                        if (loop_limit <= 0)
                        {
                            DebugBattleLog.writeText(DebugBattleLog.StrOpe + "ERROR!(無限ループ))");
                        }
                    }

                    DebugBattleLog.writeText(DebugBattleLog.StrOpe + ")[" + master_data.name + "]" + master_data.detail);
                }
            }
        }
#endif //BUILD_TYPE_DEBUG


        // 攻撃力、体力の増加値を加算
        m_CharaPow += nPlusValuePow + nElemValuePow + nRaceValuePow + nLinkPlusValuePow + (int)fLimitOverATK;
        m_CharaHP += nPlusValueHP + nElemValueHP + nRaceValueHP + nLinkPlusValueHP + (int)fLimitOverHP;
        m_CharaCharm += nLinkCharm;

        if (m_CharaPow > GlobalDefine.VALUE_MAX_POW)
        {
            m_CharaPow = GlobalDefine.VALUE_MAX_POW;
        }

        if (m_CharaHP > GlobalDefine.VALUE_MAX_HP)
        {
            m_CharaHP = GlobalDefine.VALUE_MAX_HP;
        }

        return true;
    }