//------------------------------------------------------------------------------------ // 修改当前属性 //------------------------------------------------------------------------------------ public void ModAttValue(ERoleAttribute nIndex, int nValueMod) { if (nValueMod == 0) { return; } m_nAttr [(int)nIndex] += nValueMod; }
string GetAttName(ERoleAttribute e) { if (e == ERoleAttribute.ERA_Physique) { return("体质: "); } if (e == ERoleAttribute.ERA_Strength) { return("力量: "); } if (e == ERoleAttribute.ERA_Pneuma) { return("精神: "); } if (e == ERoleAttribute.ERA_InnerForce) { return("坚毅: "); } if (e == ERoleAttribute.ERA_Technique) { return("精准: "); } if (e == ERoleAttribute.ERA_ExAttack) { return("物理攻击: "); } if (e == ERoleAttribute.ERA_ExDefense) { return("物理防御: "); } if (e == ERoleAttribute.ERA_InAttack) { return("能量攻击: "); } if (e == ERoleAttribute.ERA_InDefense) { return("能量防御: "); } if (e == ERoleAttribute.ERA_HitRate) { return("命中率: "); } if (e == ERoleAttribute.ERA_Crit_Rate) { return("暴击几率: "); } return(""); }
//-------------------------------------------------------------------------------- // 计算属性加成最终值,并取上下限 //-------------------------------------------------------------------------------- public int CalAttMod(ERoleAttribute nIndex, int nBase) { int nValue = nBase + m_nAttMod [(int)nIndex] + (int)(nBase * (m_nAttModPct[(int)nIndex] / 10000.0f)); return(nValue); }
//-------------------------------------------------------------------------------- // 根据重算标志位进行当前属性重算 //-------------------------------------------------------------------------------- public void RecalAtt( ) { int nHP = m_nAttr [(int)ERoleAttribute.ERA_HP]; int nMP = m_nAttr [(int)ERoleAttribute.ERA_MP]; // 开始计算 for (int i = 0; i < (int)ERoleAttribute.ERA_End; i++) { if (false == GetAttRecalFlag((ERoleAttribute)i)) { continue; } m_nAttr[i] = CalAttMod((ERoleAttribute)i, m_nbaseAttr[i]); } for (int j = (int)ERoleAttribute.ERA_AttA_Start; j <= (int)ERoleAttribute.ERA_AttA_End; j++) { if (GetAttRecalFlag((ERoleAttribute)j) == false) { continue; } ERoleAttribute etype = (ERoleAttribute)j; switch (etype) { // 筋骨,则二级属性的最大体力和外功防御要重新计算 case ERoleAttribute.ERA_Physique: { // 计算最大体力 m_nAttr[(int)ERoleAttribute.ERA_MaxHP] = m_nAttr[(int)ERoleAttribute.ERA_Physique] * 10 + m_nbaseAttr[(int)ERoleAttribute.ERA_MaxHP]; m_nAttr[(int)ERoleAttribute.ERA_MaxHP] = CalAttMod(ERoleAttribute.ERA_MaxHP, m_nAttr[(int)ERoleAttribute.ERA_MaxHP]); // 计算外功防御 m_nAttr[(int)ERoleAttribute.ERA_ExDefense] = m_nAttr[(int)ERoleAttribute.ERA_Physique] * 5 + m_nAttr[(int)ERoleAttribute.ERA_ExDefense]; } break; // 劲力,则二级属性的外功攻击,外功防御和持久力需要重新计算 case ERoleAttribute.ERA_Strength: { // 计算外功攻击 m_nAttr[(int)ERoleAttribute.ERA_ExAttack] = m_nAttr[(int)ERoleAttribute.ERA_Strength] * 5; m_nAttr[(int)ERoleAttribute.ERA_ExAttack] = CalAttMod(ERoleAttribute.ERA_ExAttack, m_nAttr[(int)ERoleAttribute.ERA_ExAttack]); // 计算外功防御 m_nAttr[(int)ERoleAttribute.ERA_ExDefense] = m_nAttr[(int)ERoleAttribute.ERA_Physique] * 5 + m_nAttr[(int)ERoleAttribute.ERA_Strength]; m_nAttr[(int)ERoleAttribute.ERA_ExDefense] = CalAttMod(ERoleAttribute.ERA_ExDefense, m_nAttr[(int)ERoleAttribute.ERA_ExDefense]); } break; // 元气,则二级属性的最大真气和内功防御需要重新计算 case ERoleAttribute.ERA_Pneuma: { // 计算最大体力 m_nAttr[(int)ERoleAttribute.ERA_MaxMP] = m_nAttr[(int)ERoleAttribute.ERA_Pneuma] * 10 + m_nbaseAttr[(int)ERoleAttribute.ERA_MaxMP]; m_nAttr[(int)ERoleAttribute.ERA_MaxMP] = CalAttMod(ERoleAttribute.ERA_MP, m_nAttr[(int)ERoleAttribute.ERA_MaxMP]); // 计算内功防御 m_nAttr[(int)ERoleAttribute.ERA_InDefense] = m_nAttr[(int)ERoleAttribute.ERA_Pneuma] * 5 + m_nAttr[(int)ERoleAttribute.ERA_InnerForce]; m_nAttr[(int)ERoleAttribute.ERA_InDefense] = CalAttMod(ERoleAttribute.ERA_InDefense, m_nAttr[(int)ERoleAttribute.ERA_InDefense]); } break; // 内力,则二级属性的内功攻击,内功防御和持久力要重新计算 case ERoleAttribute.ERA_InnerForce: { // 计算内功攻击 m_nAttr[(int)ERoleAttribute.ERA_InAttack] = m_nAttr[(int)ERoleAttribute.ERA_InnerForce] * 5; m_nAttr[(int)ERoleAttribute.ERA_InAttack] = CalAttMod(ERoleAttribute.ERA_InAttack, m_nAttr[(int)ERoleAttribute.ERA_InAttack]); // 计算内功防御 m_nAttr[(int)ERoleAttribute.ERA_InDefense] = m_nAttr[(int)ERoleAttribute.ERA_Pneuma] * 5 + m_nAttr[(int)ERoleAttribute.ERA_InnerForce]; m_nAttr[(int)ERoleAttribute.ERA_InDefense] = CalAttMod(ERoleAttribute.ERA_InDefense, m_nAttr[(int)ERoleAttribute.ERA_InDefense]); } break; } } // 再判断计算过后是否还有二级属性需要计算 for (int n = (int)ERoleAttribute.ERA_AttB_Start; n < (int)ERoleAttribute.ERA_AttB_End; n++) { if (GetAttRecalFlag((ERoleAttribute)n) == false) { continue; } // 最大体力 if (n == (int)ERoleAttribute.ERA_MaxHP) { m_nAttr[(int)ERoleAttribute.ERA_MaxHP] = m_nAttr[(int)ERoleAttribute.ERA_Physique] * 10 + m_nbaseAttr[(int)ERoleAttribute.ERA_MaxHP]; m_nAttr[(int)ERoleAttribute.ERA_MaxHP] = CalAttMod(ERoleAttribute.ERA_MaxHP, m_nAttr[(int)ERoleAttribute.ERA_MaxHP]); } // 最大真气 else if (n == (int)ERoleAttribute.ERA_MaxMP) { m_nAttr[(int)ERoleAttribute.ERA_MaxMP] = m_nAttr[(int)ERoleAttribute.ERA_Pneuma] * 10 + m_nbaseAttr[(int)ERoleAttribute.ERA_MaxMP]; m_nAttr[(int)ERoleAttribute.ERA_MaxMP] = CalAttMod(ERoleAttribute.ERA_MaxMP, m_nAttr[(int)ERoleAttribute.ERA_MaxMP]); } // 外功攻击 else if (n == (int)ERoleAttribute.ERA_ExAttack) { m_nAttr[(int)ERoleAttribute.ERA_ExAttack] = m_nAttr[(int)ERoleAttribute.ERA_Strength] * 5; m_nAttr[(int)ERoleAttribute.ERA_ExAttack] = CalAttMod(ERoleAttribute.ERA_ExAttack, m_nAttr[(int)ERoleAttribute.ERA_ExAttack]); } // 外功防御 else if (n == (int)ERoleAttribute.ERA_ExDefense) { m_nAttr[(int)ERoleAttribute.ERA_ExDefense] = m_nAttr[(int)ERoleAttribute.ERA_Physique] * 5 + m_nAttr[(int)ERoleAttribute.ERA_Strength]; m_nAttr[(int)ERoleAttribute.ERA_ExDefense] = CalAttMod(ERoleAttribute.ERA_ExDefense, m_nAttr[(int)ERoleAttribute.ERA_ExDefense]); } // 内功攻击 else if (n == (int)ERoleAttribute.ERA_InAttack) { m_nAttr[(int)ERoleAttribute.ERA_InAttack] = m_nAttr[(int)ERoleAttribute.ERA_InnerForce] * 5; m_nAttr[(int)ERoleAttribute.ERA_InAttack] = CalAttMod(ERoleAttribute.ERA_InAttack, m_nAttr[(int)ERoleAttribute.ERA_InAttack]); } // 内功防御 else if (n == (int)ERoleAttribute.ERA_InDefense) { m_nAttr[(int)ERoleAttribute.ERA_InDefense] = m_nAttr[(int)ERoleAttribute.ERA_Pneuma] * 5 + m_nAttr[(int)ERoleAttribute.ERA_InnerForce]; m_nAttr[(int)ERoleAttribute.ERA_InDefense] = CalAttMod(ERoleAttribute.ERA_InDefense, m_nAttr[(int)ERoleAttribute.ERA_InDefense]); } // 命中 else if (n == (int)ERoleAttribute.ERA_HitRate) { m_nAttr[(int)ERoleAttribute.ERA_HitRate] = m_nAttr[(int)ERoleAttribute.ERA_Technique] * 10; m_nAttr[(int)ERoleAttribute.ERA_HitRate] = CalAttMod(ERoleAttribute.ERA_HitRate, m_nAttr[(int)ERoleAttribute.ERA_HitRate]); } // 闪避 else if (n == (int)ERoleAttribute.ERA_Dodge) { m_nAttr[(int)ERoleAttribute.ERA_Dodge] = m_nAttr[(int)ERoleAttribute.ERA_Agility] * 10; m_nAttr[(int)ERoleAttribute.ERA_Dodge] = CalAttMod(ERoleAttribute.ERA_Dodge, m_nAttr[(int)ERoleAttribute.ERA_Dodge]); } // 持久力 else if (n == (int)ERoleAttribute.ERA_MaxEndurance) { m_nAttr[(int)ERoleAttribute.ERA_MaxEndurance] = (m_nAttr[(int)ERoleAttribute.ERA_Technique] + m_nAttr[(int)ERoleAttribute.ERA_Agility]) / 10; m_nAttr[(int)ERoleAttribute.ERA_MaxEndurance] = CalAttMod(ERoleAttribute.ERA_MaxEndurance, m_nAttr[(int)ERoleAttribute.ERA_MaxEndurance]); } } // 附上原先保存的属性 m_nAttr [(int)ERoleAttribute.ERA_HP] = nHP; m_nAttr [(int)ERoleAttribute.ERA_MP] = nMP; // 清空重算标志位 ClearAttRecalFlag(); OnAttChangeEvent(); }
//---------------------------------------------------------------------------------- // 得到某个属性是否需要重算 //---------------------------------------------------------------------------------- public bool GetAttRecalFlag(ERoleAttribute nIndex) { return(m_bAttRecalFlag [(int)nIndex]); }
//---------------------------------------------------------------------------------- // 属性重新计算标识位设置 //---------------------------------------------------------------------------------- public void SetAttRecalFlag(ERoleAttribute nIndex) { m_bAttRecalFlag [(int)nIndex] = true; }
//----------------------------------------------------------------------------------- // 修改属性百分比加成 //----------------------------------------------------------------------------------- public void ModAttModValuePct(ERoleAttribute nIndex, int nValuePctMod) { m_nAttModPct [(int)nIndex] += nValuePctMod; SetAttRecalFlag(nIndex); }
//----------------------------------------------------------------------------------- // 修改基础属性 //----------------------------------------------------------------------------------- public void ModBaseAttValue(ERoleAttribute nIndex, int nValeMod) { m_nbaseAttr [(int)nIndex] += nValeMod; SetAttRecalFlag(nIndex); }
//----------------------------------------------------------------------------------- // 设置属性平直加成 //----------------------------------------------------------------------------------- public void SetAttModValue(ERoleAttribute nIndex, int nValue) { m_nAttMod [(int)nIndex] = nValue; SetAttRecalFlag(nIndex); }
//----------------------------------------------------------------------------------- // 设置基本属性 //----------------------------------------------------------------------------------- public void SetBaseAttValue(ERoleAttribute nIndex, int nValue) { m_nbaseAttr [(int)nIndex] = nValue; SetAttRecalFlag(nIndex); }
//------------------------------------------------------------------------------------ // 设置当前属性 //------------------------------------------------------------------------------------ public void SetAttValue(ERoleAttribute nIndex, int nValue, bool bSend) { m_nAttr [(int)nIndex] = nValue; }
//----------------------------------------------------------------------------------- // 读取属性百分比加成 //----------------------------------------------------------------------------------- public int GetAttModValuePct(ERoleAttribute nIndex) { return(m_nAttModPct [(int)nIndex]); }
//----------------------------------------------------------------------------------- // 读取基础属性 //----------------------------------------------------------------------------------- public int GetBaseAttValue(ERoleAttribute nIndex) { return(m_nbaseAttr [(int)nIndex]); }