void LoadSkillConfig() { m_curSkillID = Convert.ToUInt32(SkillID.text); m_SkillInfo = CSVManager.GetSkillCfg(m_curSkillID); if (m_SkillInfo == null) { Debug.LogError("不存在技能id " + m_curSkillID); return; } SkillType.text = m_SkillInfo.type.ToString(); AttackType.text = m_SkillInfo.attackType.ToString(); //MagicType.text = m_SkillInfo.magicType.ToString(); AttackDistance.text = m_SkillInfo.attackDistance.ToString(); HitTime.text = m_SkillInfo.hitTime.ToString(); FlySpeed.text = m_SkillInfo.flySpeed.ToString(); CastEffect.text = m_SkillInfo.castEffect == null ? "" : m_SkillInfo.castEffect; CastEffectBeginTime.text = m_SkillInfo.castEffectBeginTime.ToString(); CastEffectDuration.text = m_SkillInfo.castEffectDuration.ToString(); CastEffectBindBone.text = m_SkillInfo.castEffectBindBone == null ? "" : m_SkillInfo.castEffectBindBone; BulletEffect.text = m_SkillInfo.BulletEffect == null ? "" : m_SkillInfo.BulletEffect; BulletEffectBeginTime.text = m_SkillInfo.BulletBeginTime.ToString(); BulletEffectBindBone.text = m_SkillInfo.BulletBindBone == null ? "" : m_SkillInfo.BulletBindBone; BeAttackEffect.text = m_SkillInfo.beattackEffect == null ? "" : m_SkillInfo.beattackEffect; CastAction.text = m_SkillInfo.castAction == null ? "" : m_SkillInfo.castAction; CastActionBeginTime.text = m_SkillInfo.castActionBeginTime.ToString(); BeAttackAction.text = m_SkillInfo.beattackAction == null ? "" : m_SkillInfo.beattackAction; }
public static void BulletHit(Entity caster, Entity target, CSVSkill skillInfo) { if (target.IsDead || target.invincible) { return; } //受击动作 if (!string.IsNullOrEmpty(skillInfo.beattackAction)) { target.Anim.SyncAction(skillInfo.beattackAction); } //受击特效 if (!string.IsNullOrEmpty(skillInfo.beattackEffect)) { EffectEntity effect = EffectManager.Instance.GetEffect(skillInfo.beattackEffect); effect.Init(eDestroyType.Time, skillInfo.beattackActionDuration); effect.Pos = target.Pos; effect.Forward = target.Forward; } CalcBlood(caster, target, skillInfo); }
public static CSVSkill GetSkillCfg(uint ID) { CSVSkill data = null; m_SkillData.TryGetValue(ID, out data); return(data); }
public SkillBase(CSVSkill si, Entity caster) { m_caster = caster; m_skillInfo = si; m_fCDTotalTime = si.coolTime; m_fCDLeftTime = 0; m_targets = new List <Entity>(); }
void PlayAction(uint skillID, List <Entity> targets = null) { CSVSkill skillInfo = CSVManager.GetSkillCfg(skillID); if (!string.IsNullOrEmpty(skillInfo.castAction)) { m_entity.Anim.SyncAction(skillInfo.castAction); } }
void CastBullet(uint skillID, List <Entity> targets = null) { CSVSkill skillInfo = CSVManager.GetSkillCfg(skillID); Bullet bu = BulletManager.Instance.Get(); if (bu != null) { bu.Init(m_entity, skillInfo, SkillProcesser.BulletHit, m_entity.SelectTarget); } }
//由时间控制的击中事件,一般是近战类攻击击中目标 public void SkillHit(uint skillID, List <Entity> targets = null) { if (targets == null) { Log.Info("技能id = " + skillID + " 没有目标"); return; } CSVSkill skillInfo = CSVManager.GetSkillCfg(skillID); //技能类型(1.普攻 2.物理 3.法术 4.保护 5.治疗 6.辅助 7.召唤 8.被动) if (skillInfo.type <= 3) { for (int i = 0; i < targets.Count; i++) { Entity target = targets[i]; if (target.IsDead || target.invincible) { continue; } //受击动作 if (!string.IsNullOrEmpty(skillInfo.beattackAction)) { target.Anim.SyncAction(skillInfo.beattackAction); } //受击特效 if (!string.IsNullOrEmpty(skillInfo.beattackEffect)) { EffectEntity effect = EffectManager.Instance.GetEffect(skillInfo.beattackEffect); effect.Init(eDestroyType.Time, skillInfo.beattackActionDuration); effect.Pos = target.Pos; effect.Forward = target.Forward; } SkillProcesser.CalcBlood(m_entity, target, skillInfo); } } else if (skillInfo.type <= 6) { //添加增益buff for (int i = 0; i < targets.Count; i++) { } } }
public void SetSpecialSkills(string str) { string[] s = str.Split(new char[] { '|' }); m_skillList.Clear(); for (int i = 0; i < s.Length; i++) { uint SkillID = System.Convert.ToUInt32(s[i]); CSVSkill sk = CSVManager.GetSkillCfg(SkillID); if (sk == null) { Log.Error("不存在技能id " + SkillID); continue; } m_skillList.Add(new SkillBase(sk, m_entity)); } }
public static void ProcessSkill(ReqCastSkill msg) { Entity caster = EntityManager.Instance.Find(msg.caster); if (caster == null) { Log.Error("找不到技能释放者! id = " + msg.caster); return; } CSVSkill skillInfo = CSVManager.GetSkillCfg(msg.skillID); if (skillInfo == null) { Log.Error("找不到技能配置 skillid = " + msg.skillID); return; } List <Entity> targets = GetTargets(msg, skillInfo); if (targets == null) { return; } List <SkillResult> result = null; for (int i = 0; i < targets.Count; i++) { SkillResult sr = new SkillResult(); sr.target = msg.target; if (skillInfo.type == 1) //普攻 { sr.damage = caster.Property.PhysicDamage - targets[i].Property.PhysicDefence; } else if (skillInfo.type == 2) //物理技能攻击 { } else if (skillInfo.type == 3) //法术技能攻击 { } result.Add(sr); } OnCastSkill rsp = new OnCastSkill(); rsp.result = result; caster.OnEvent(eEntityEvent.OnSkillResult, rsp); }
public void SetNormalSkills(string str) { string[] s = str.Split(new char[] { '|' }); m_normalAttackList.Clear(); for (int i = 0; i < s.Length; i++) { uint SkillID = System.Convert.ToUInt32(s[i]); CSVSkill sk = CSVManager.GetSkillCfg(SkillID); if (sk == null) { Log.Error("不存在技能id " + SkillID); continue; } m_normalAttackList.Add(new SkillBase(sk, m_entity)); } //攻击距离以普攻的攻击距离为准 AttackDistance = m_normalAttackList[0].m_skillInfo.attackDistance; }
public static Entity GetTargetInSkillDistance(Entity caster, CSVSkill skillInfo) { Entity ent = null; var e = EntityManager.Instance.m_dicObject.GetEnumerator(); while (e.MoveNext()) { ent = e.Current.Value; if (caster.IsEnemy(ent) == false || ent.IsDead) { continue; } if ((ent.Pos - caster.Pos).sqrMagnitude <= skillInfo.attackDistance * skillInfo.attackDistance) { return(ent); } } return(null); }
//得到这个技能作用的目标 private static List <Entity> GetTargets(ReqCastSkill msg, CSVSkill skillInfo) { List <Entity> targets = null; if (skillInfo.type == 1) //普攻 { Entity target = EntityManager.Instance.Find(msg.target); if (targets == null) { Log.Error("找不到普通攻击的目标 target = " + msg.target); return(null); } targets = new List <Entity>(); targets.Add(target); } else //技能 { } return(targets); }
public void Init(Entity caster, CSVSkill skillInfo, BulletHitCallback notify = null, Entity target = null) { m_effect = EffectManager.Instance.GetEffect(skillInfo.BulletEffect); if (m_effect == null) { Log.Error("不存在特效 " + skillInfo.BulletEffect); return; } m_caster = caster; m_target = target; if (target == null) { bulletType = eBulletType.Dir; m_dir = m_caster.Forward; } else { bulletType = eBulletType.Target; m_dir = (m_target.Pos - m_caster.Pos).normalized; } m_skillInfo = skillInfo; m_hitNotify = notify; //子弹存在的时间 = 子弹的攻击距离 / 子弹的飞行速度 小学物理知识 呵呵哒 duration = m_skillInfo.attackDistance / m_skillInfo.flySpeed; m_effect.Init(eDestroyType.Time, duration); m_fSpeed = m_skillInfo.flySpeed; if (!string.IsNullOrEmpty(m_skillInfo.BulletBindBone)) { m_effect.Pos = GetBonePos(m_caster, m_skillInfo.BulletBindBone); } else { m_effect.Pos = new Vector3(m_caster.Pos.x, m_caster.Pos.y + 0.5f, m_caster.Pos.z); } IsUsing = true; }
void PlayEffect(uint skillID, List <Entity> targets = null) { CSVSkill skillInfo = CSVManager.GetSkillCfg(skillID); if (string.IsNullOrEmpty(skillInfo.castEffect)) { return; } EffectEntity effect = EffectManager.Instance.GetEffect(skillInfo.castEffect); effect.Init(eDestroyType.Time, skillInfo.castEffectDuration); //特效绑定的骨骼 if (!string.IsNullOrEmpty(skillInfo.castEffectBindBone)) { Transform bone = null; if (skillInfo.castEffectBindBone.CompareTo("self") == 0) { bone = m_object.transform; } else { bone = m_entity.GetBone(skillInfo.castEffectBindBone); } if (bone != null) { effect.Bind(bone); } } //如果特效没有绑定位置,则默认位置为释放者的位置 else { effect.Pos = m_entity.Pos; effect.Forward = m_entity.Forward; } }
//计算伤害 public static void CalcBlood(Entity caster, Entity target, CSVSkill skillInfo) { if (target == null) { return; } if (skillInfo.attackBuff != 0) { target.Buff.AddBuff((int)skillInfo.attackBuff); } bool isCrit = false; int damage = GetDamage(caster, target, skillInfo, out isCrit); if (damage != 0) { target.Property.HP -= damage; if (target.IsDead) { target.Die(); } } }
static int GetDamage(Entity caster, Entity target, CSVSkill skillInfo, out bool isCrit) { float damage = 0; int randomValue = UnityEngine.Random.Range(20, 40); float realCritRate = Mathf.Min(caster.Property.CritRate - target.Property.AvoidCritRate, 0.8f); isCrit = GetProResult(realCritRate); switch (skillInfo.type) { case 1: //普攻 damage = Mathf.RoundToInt((Mathf.Max(caster.Property.PhysicDamage + caster.Property.MagicDamage - target.Property.PhysicDefence - target.Property.MagicDefence, 0)) + randomValue); break; case 2: //物攻 damage = Mathf.RoundToInt(Mathf.Max(caster.Property.PhysicDamage - target.Property.PhysicDefence, 0) + randomValue); break; case 3: //法攻 damage = Mathf.RoundToInt(Mathf.Max(caster.Property.MagicDamage - target.Property.MagicDefence, 0) + randomValue); break; default: break; } if (isCrit) { float f = UnityEngine.Random.Range(1.5f, 2); damage *= 2; if (caster.IsMainPlayer) { CameraController.Instance.Shake(); } } return(Mathf.RoundToInt(damage)); }