public string GetRDNameData(bool man = true) { System.Random rd = new System.Random(); string rdName = surnameLst[PETools.RDInit(0, surnameLst.Count - 1)]; if (man) { rdName += mannLst[PETools.RDInit(0, mannLst.Count - 1)]; } else { rdName += womanLst[PETools.RDInit(0, womanLst.Count - 1)]; } return(rdName); }
public override void TickAILogic() { if (runAI == false) { return; } if (currentAnimState == AniState.Idle || currentAnimState == AniState.Move) { float delta = Time.deltaTime; checkCountTime += delta; if (checkCountTime < checkTime) { return; } Vector2 dir = CalcTargetDir(); //判断是否在攻击范围内 if (InAttackRange()) { SetDir(Vector2.zero); atkCheckTime += delta; if (atkCheckTime > atkTime) { //攻击 SetAtkDir(dir, false); Attack(msd.mCfg.skillID); atkCheckTime = 0; } else { //休息 Idle(); } } else { //移动 SetDir(dir); Move(); } checkCountTime = 0; checkTime = PETools.RDInit(1, 5) * 0.1f / 10; } }
//计算伤害 public void CalcDamge(EntityBase self, EntityBase target, SkillCfg skillCfg, int damage) { int damageSum = damage; if (skillCfg.dmgType == DamageType.AD) { //物理伤害 //计算目标闪避 int dodgeNum = PETools.RDInit(1, 100, rd); if (dodgeNum <= target.battleProps.dodge) { PECommon.Log("闪避:" + target.battleProps.dodge + "/" + dodgeNum); target.Dodge(); return; } //计算属性加成伤害 damageSum += self.battleProps.ad; //计算暴击 int criticalNum = PETools.RDInit(1, 100, rd); if (criticalNum < self.battleProps.critical) { //计算暴击伤害倍率 1.5f~2.0f float hitDoubly = 1.0f + PETools.RDInit(50, 100, rd) / 100f; damageSum = (int)(damageSum * hitDoubly); target.Critical(damageSum); PECommon.Log("闪避:" + target.battleProps.critical + "/" + criticalNum); } //计算穿甲 int adPierce = (int)((1 - self.battleProps.pierce / 100f) * target.battleProps.addef); damageSum -= adPierce; } else if (skillCfg.dmgType == DamageType.AP) { //魔法伤害 //计算属性加成伤害 damageSum += self.battleProps.ap; //计算魔法抗性 damageSum -= self.battleProps.apdef; } //最终伤害 if (damageSum < 0) { damageSum = 0; } if (target.HP <= damageSum) { //死亡 target.HP = 0; target.Die(); target.Remove(); } else { //受伤 扣血 target.HP -= damageSum; if (target.entityState != EntityState.BtState && target.GetBreakState()) { target.Hit(); } if (target.enitityType == EnitityType.Player) { AudioSource audioSource = target.GetAudioSource(); AudioSvc.PlayAudio(Constants.AssasinHit, audioSource); } target.Hurt(damageSum); } PECommon.Log("Damage:" + damageSum, LogType.Warn); }