public static void OnChangeCurExp(CCreature obj, int newV, int oldV) { // 逻辑层 // 到达满级时,不再执行 if (newV == oldV && newV != 0) { return; } // 通过当前总经验值获取等级。 PlayerExpCsv playerCsv = CsvManager.Inst.GetCsv <PlayerExpCsv>((int)eAllCSV.eAC_PlayerExp); int lv = playerCsv.GetLevelByExp(newV); if (lv >= playerCsv.m_maxLv.Level) // 已满级 { int maxExp = playerCsv.GetMaxExpByLv(lv); obj.SetPropNum(eCreatureProp.CurExp, maxExp); obj.SetPropNum(eCreatureProp.Exp, maxExp); } else { int maxExp = playerCsv.GetMaxExpByLv(lv + 1); // 下一级所需经验 obj.SetPropNum(eCreatureProp.Exp, maxExp); } obj.SetPropNum(eCreatureProp.Lv, lv); // 表现层 obj.UpdateUI_Exp(); }
/// <summary> /// 实际战斗时取的数值 /// 技能为0和4时,取武器攻击 /// 1时,取手雷 /// 2时,取火炮 /// </summary> //public int GetPlayerAp() //{ // PlayerCsvData pCsv = (PlayerCsvData)m_caster.m_csvData; // int lv = m_caster.GetPropNum(eCreatureProp.Lv); // int maxAp = 0; // //int maxAp = m_caster.GetPlayerPropVal(pCsv.BaseAp, pCsv.ApGrow, lv); // //if (m_skillIndex == -1 || m_skillIndex == 0 || m_skillIndex == 4) // // maxAp += m_caster.GetEquipAp(eEquipType.HandRight); // //else if (m_skillIndex == 1) // // maxAp += m_caster.GetEquipAp(eEquipType.Grenade); // //else if (m_skillIndex == 2) // // maxAp += m_caster.GetEquipAp(eEquipType.Back); // maxAp += m_caster.GetBuffAp(maxAp); // return maxAp; //} /// <summary> /// 1.技能伤害数值,是通过普攻*val%计算得出的 /// 1.如果施法者是载具,其实还是用的主人的数值 /// 返回1:需要播放受击动作 /// </summary> public int OnHurt(int skillVal) { if (m_rec == null) { return(0); } if (m_rec.CheckState(eBuffState.God)) { return(0); } // 设置主角保护 //if (m_rec.IsMaster() && m_rec.bMasterProtect()) //{ // return 1; //} //if (m_rec.IsMaster()) //{ // m_rec.SetMasterProtect(); //} // 施法者是载具时,数值结算用主人的 //if (m_caster.GetMaster() != null) //{ // m_caster = m_caster.GetMaster(); //} // 触发施法者的攻击命中BUFF,触发受击者的受击BUFF,在伤害之前 m_caster.OnCreateAtkBuff(m_skillIndex, m_rec); m_rec.OnCreateHitBuff(m_caster); bool bCrit = false; //伤害 = 攻击 * 攻击 /(攻击 + k * 防御)*(0.9 / 1.1) int k = 1; int ap = m_caster.GetPropNum(eCreatureProp.Ap); int dp = m_rec.GetPropNum(eCreatureProp.Dp); // 玩家普攻伤害 int hurtVal = (int)(new FixedPoint(ap * ap) / new FixedPoint((ap + k * dp))).value; // 技能伤害,倍数 hurtVal = (int)(new FixedPoint(hurtVal) * (FixedPoint.N_1 + new FixedPoint(skillVal) * new FixedPoint(0.01f))).value; // 计算暴击 int CritChance = m_caster.GetPropNum(eCreatureProp.CritChance); if (GameManager.Inst.GetRand(0, 100, 1) <= CritChance * 0.1f) { bCrit = true; int CritDamage = m_caster.GetPropNum(eCreatureProp.CritDamage); hurtVal = (int)(new FixedPoint(hurtVal) * (FixedPoint.N_1 + new FixedPoint(CritDamage * 0.001f))).value; } // 连击累加 int comboNum = m_caster.GetComboNum(); if (comboNum > 300) { comboNum = 300; } hurtVal = (int)(new FixedPoint(hurtVal) * (new FixedPoint(comboNum) * new FixedPoint(0.01f) + FixedPoint.N_1)).value; int curHp = m_rec.GetPropNum(eCreatureProp.CurHp); int nextHp = curHp - hurtVal; if (nextHp <= 0) { nextHp = 0; } m_rec.SetPropNum(eCreatureProp.CurHp, nextHp); // 充能 UpdateChargeSkill(m_caster, hurtVal); // 解除受击者睡眠BUFF UpdateBuff(m_rec); // 主角相关 // 经验计算 GetExp(m_rec); // 主角连击 //if (m_caster != null && m_caster.IsMaster()) //{ // m_caster.OnComboAdd(); //} UpdateUI_ShowHpHUD(m_rec, -hurtVal, bCrit); return(1); }