public override void TickAILogic() { if (!runAI) { return; } if (currentAniState == AniState.Idle || currentAniState == AniState.Move) { if (battleMgr.isPauseGame) { Idle(); return; } float delta = Time.deltaTime; checkCountTime += delta; if (checkCountTime < checkTime) { return; } else { //计算目标方向 Vector2 dir = CalcTargetDir(); //判断目标是否在攻击范围 if (!InAtkRange()) { //不在:设置移动方向,进入一定状态 SetDir(dir); Move(); } else { //在:则停止移动,进行攻击 SetDir(Vector2.zero); //判断攻击间隔 atkCountTime += checkCountTime; if (atkCountTime > atkTime) { //达到攻击时间,转向并攻击 SetAtkRotation(dir); Attack(md.mCfg.skillID); atkCountTime = 0; } else { //未达到攻击时间,Idle等待 Idle(); } } checkCountTime = 0; checkTime = PETools.RDint(1, 5) * 1.0f / 10; } } }
public string GetRDNameData(bool man = true) { string rdName = surnameLst[PETools.RDint(0, surnameLst.Count - 1)]; if (man) { rdName += manLst[PETools.RDint(0, manLst.Count - 1)]; } else { rdName += womanLst[PETools.RDint(0, womanLst.Count - 1)]; } return(rdName); }
private void CalcDamage(EntityBase caster, EntityBase target, SkillCfg skillCfg, int damage) { int dmgSum = damage; if (skillCfg.dmgType == DamageType.AD) { //计算闪避 int dodgeNum = PETools.RDint(1, 100, rd); if (dodgeNum <= target.Props.dodge) { //UI显示闪避 TODO //PECommon.Log("闪避Rate:" + dodgeNum + "/" + target.Props.dodge); target.SetDodge(); return; } //计算属性加成 dmgSum += caster.Props.ad; //计算暴击 int criticalNum = PETools.RDint(1, 100, rd); if (criticalNum <= caster.Props.critical) { float criticalRate = 1 + PETools.RDint(1, 100, rd) / 100.0f; dmgSum += (int)criticalRate * dmgSum; //PECommon.Log("暴击Rate:" + criticalNum + "/" + caster.Props.critical); target.SetCritical(dmgSum); } //计算穿甲 int addef = (int)((1 - caster.Props.pierce / 100.0f) * target.Props.addef); dmgSum -= addef; } else if (skillCfg.dmgType == DamageType.AP) { //计算属性加成 dmgSum += caster.Props.ap; //计算魔法抗性 dmgSum -= target.Props.apdef; } else { } //最终伤害 if (dmgSum < 0) { dmgSum = 0; return; } target.SetHurt(dmgSum); if (target.HP < dmgSum) { target.HP = 0; //目标死亡 target.Die(); if (target.entityType == EntityType.Monster) { target.battleMgr.RemoveMonster(target.Name); } else if (target.entityType == EntityType.Player) { target.battleMgr.EndBattle(false, 0); target.battleMgr.entitySelfPlayer = null; } } else { target.HP -= dmgSum; if (target.entityState == EntityState.None && target.GetBreakState()) { target.Hit(); } } }