public override void Launch() { //base.Launch(); //Debug.Log("近战击中,计算伤害"); // 检测,播放受击动作 Vector2d pos = CCreatureMgr.Get(m_curSkillCmd.m_casterUid).GetPos(); Vector2d dir = m_curSkillCmd.m_dir; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (GetCaster().bCamp(creature) || creature.IsDie()) { continue; } Vector2d focusPos = creature.GetPos(); FPSector sec = new FPSector(); sec.pos = pos; sec.dir = dir; sec.angle = new FixedPoint(m_skillInfo.width); sec.r = new FixedPoint(m_skillInfo.length); if (FPCollide.bSectorInside(sec, focusPos)) { //Debug.Log("近战检测:" + item.GetUid()); //OnHit(creature, i++); OnCasterAddBuff(GetCaster(), creature); } } }
public int GetTarget(int lookDis) { int targetUid = 0; FixedPoint m_minDis2 = new FixedPoint(999999); List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature cc = CCreatureMgr.Get(list[i]); FixedPoint abDis2 = FPCollide.GetDis2(GetPos(), cc.GetPos()); if (abDis2 > new FixedPoint(lookDis * lookDis)) { continue; } if (cc.IsDie() || cc.GetUid() == GetUid()) { continue; } if (abDis2 < new FixedPoint(lookDis * lookDis)) // 如果目标在视线范围内 { if (abDis2 < m_minDis2) { m_minDis2 = abDis2; targetUid = (int)cc.GetUid(); } } } return(targetUid); }
public void OnHitTarget() { FixedPoint m_minDis2 = new FixedPoint(999999); CCreature target = null; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_listHited != null && m_listHited.Contains((int)list[i])) { continue; } if (m_caster == creature || m_caster.bCamp(creature) || creature.IsDie() || creature == m_rec) { continue; } FixedPoint abDis2 = FPCollide.GetDis2(m_rec.GetPos(), creature.GetPos()); if (abDis2 < new FixedPoint(m_triggerData.Length * m_triggerData.Length)) { if (abDis2 < m_minDis2) { target = creature; m_minDis2 = abDis2; } } } if (target != null) { if (m_listHited == null) { m_listHited = new List <int>(); } Debug.Log("添加单位:" + target.GetUid()); m_listHited.Add((int)target.GetUid()); OnHitAddBuff(m_caster, target, m_listHited); VTrigger vTri = GetVTrigger(); if (vTri != null && m_rec != null && m_rec.GetVObject() != null) { Vector3 sh = m_rec.GetVObject().GetHitHeight(); Vector3 th = target.GetVObject().GetHitHeight(); vTri.SetLineStartPos(GetPos().ToVector3() + sh); vTri.SetLineTargetPos(target.GetPos().ToVector3() + th); } } else { Destory(); } }
// 矩形检测,获取最近的单位,进行激光链接 public override void Trigger() { FixedPoint minDis = new FixedPoint(999999); CCreature minCC = null; List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_caster.bCamp(creature) || creature.IsDie()) { continue; } FPSphere playerS = new FPSphere(); playerS.c = creature.GetPos(); playerS.r = creature.GetR(); Vector2d pos = m_caster.GetPos() + GetDir().normalized *new FixedPoint((m_triggerData.Length + m_triggerData.vBulletDeltaPos.z) * 0.5f); int angle = (int)FPCollide.GetAngle(GetDir()).value; FPObb obb = new FPObb(pos, new Vector2d(m_triggerData.Width, m_triggerData.Length), angle); if (FPCollide.bSphereOBB(playerS, obb)) { FixedPoint dis = Vector2d.Distance(creature.GetPos(), GetPos()); if (dis < minDis) { minDis = dis; minCC = creature; } } } if (minCC != null) { OnHitAddBuff(m_caster, minCC); Vector2d targetPos = GetPos() + GetDir().normalized *minDis; if (m_vCreature != null) { Vector3 tH = minCC.GetVObject().GetHitHeight(); GetVTrigger().SetLineTargetPos(targetPos.ToVector3() + tH); } } else { _CheckObstacle(); } }
private void GetExp(CCreature m_rec) { if (m_rec.IsMonster() && m_rec.IsDie()) { } }
public void EnterFrame() { if (m_player.IsDie()) { return; } m_curTime += FSPParam.clientFrameMsTime; if (m_curTime >= 40 * FSPParam.clientFrameMsTime) { if (m_tree != null) { m_tree.OnUpdate(); } // AI技能外部CD int curSkillInterval = m_tree.m_dataBase.GetData <int>((int)eAIParam.INT_SKILL_INTERVAL); if (curSkillInterval >= 0) { curSkillInterval -= FSPParam.clientFrameMsTime; m_tree.m_dataBase.SetData <int>((int)eAIParam.INT_SKILL_INTERVAL, curSkillInterval); } if (Client.Inst().m_bDebug) { string state = GetCurState(); if (!string.IsNullOrEmpty(state))// 如果卡主,可以知道最后一个状态 { // 状态显示 VObject mt = m_player.GetVObject(); if (mt == null) { return; } CmdUIHead cmd = new CmdUIHead(); cmd.type = 1; cmd.name = m_player.GetUid() + ":" + state; mt.PushCommand(cmd); } } // 仇恨值 m_curHatredTime += FSPParam.clientFrameMsTime; if (m_curHatredTime >= 30 * FSPParam.clientFrameMsTime) { _UpdateHatredList(); //主角显示测试界面 if (m_player.IsMaster()) { m_hatredList.Sort((x, y) => { if (x.val == y.val) { return(0); } else if (x.val > y.val) { return(-1); } else { return(1); } }); //m_list.Init(m_hatredList.Count, (item, index) => //{ // UIItem.SetText(item, "txt", m_hatredList[index].uid + " 仇恨值:" + m_hatredList[index].val); // UIItem.SetProgress(item, "pct", m_hatredList[index].val, 100); //}); } m_curHatredTime = 0; } } }
public static BuffBase AddBuff(CCreature caster, CCreature receiver, int buffId, Vector2d startPos, Vector2d skillPos, Vector2d dir, int skillIndex = 0, object obj = null) { // 接受者无敌时 if (receiver != null) { if (receiver.IsDie() || receiver.CheckState(eBuffState.WindBlowsUp)) { return(null); } if (caster != receiver && receiver.CheckState(eBuffState.God)) { return(null); } } // 非瞬间伤害的其他所有BUFF,如果是持续的,并且buffid相同时,重置生命时间 SkillBuffCsvData buffData = CsvManager.Inst.GetCsv <SkillBuffCsv>((int)eAllCSV.eAC_SkillBuff).GetData(buffId); if (buffData == null) { Debug.LogError("无buffid,策划检测检查配置表:" + buffId); return(null); } // 状态BUFF的处理 // 接受者霸体时,不再添加其他状态BUFF if (receiver != null && receiver.CheckState(eBuffState.SuperArmor)) { if (buffData.logicId == (int)eBuffType.state || buffData.logicId == (int)eBuffType.repel || buffData.logicId == (int)eBuffType.pullPos ) { return(null); } } // 相同BUFF的叠加处理 if (buffData.IsCont && receiver != null && buffData.logicId != (int)eBuffType.damage) { BuffBase stateBuff = receiver.GetBuffByCsvId(buffId); // 1.相同BUFFID // 2.相同施法者 // 3.相同施法者,相同触发器(暂无) if (stateBuff != null && stateBuff.m_caster == caster) { //Debug.Log("有相同buff。。。" + buffId); // 相同施法者的持续性BUFF,内部可以计算叠加次数和伤害 stateBuff.ResetTime(); return(stateBuff); } } BuffBase buff = CBuffMgr.Create(buffId); //Debug.Log("技能流程:创建BUFF:" + buffId + " " + buff.m_buffData.name + " 类型:" + (eBuffType)buff.m_buffData.logicId); if (buff == null) { Debug.LogError("添加BUFF为空:" + buffId); return(null); } // 最终的接收者,由配表决定 if (buff.m_buffData.targetType == 0) { } else if (buff.m_buffData.targetType == 1) { receiver = caster; } buff.m_caster = caster; buff.m_rec = receiver; buff.m_startPos = startPos; buff.m_skillIndex = skillIndex; buff.m_skillPos = skillPos; buff.m_skillDir = dir; buff.m_extendParam = obj; // 持续性的才加到人物身上,当角色挂掉时,要清除身上的BUFF if (buff.IsCont() && receiver != null) { // 因为BUFF改变的速度,攻击力等都是在初始化时,遍历BUFF增减数值,所以要先add receiver.AddBuff(buff); buff.Init(); } else { buff.Init(); buff.Destroy(); } return(buff); }
public static bool GetAtkTarget(CCreature m_creature, BtDatabase m_dataBase, int lookDis) { // 仇恨值高的优先作为目标 int hTargetUid = m_creature.m_ai.GetHightHatred(); CCreature hTargetCC = CCreatureMgr.Get(hTargetUid); if (hTargetUid != -1 && hTargetCC != null && !hTargetCC.IsDie()) // 有仇恨对象,并且没死 { m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, hTargetUid); } // 如果有目标,判断是否距离足够远,远了就清空目标,继续找附近的 int targetUid = m_dataBase.GetData <int>((int)eAIParam.INT_TARGET_UID); CCreature targetCC = CCreatureMgr.Get(targetUid); if (targetCC == null || FPCollide.GetDis2(targetCC.GetPos(), m_creature.GetPos()) > new FixedPoint(20 * 20) || targetCC.IsDie()) // 隐藏时,不作为目标 { targetUid = 0; } else { return(true); } targetUid = m_creature.GetTarget(lookDis); // 如果没有目标,检测玩家附近的单位,锁定目标 //FixedPoint m_minDis2 = new FixedPoint(999999); //List<long> list = CCreatureMgr.GetCreatureList(); //for (int i = 0; i < list.Count; i++) //{ // CCreature cc = CCreatureMgr.Get(list[i]); // FixedPoint abDis2 = FPCollide.GetDis2(m_creature.GetPos(), cc.GetPos()); // if (abDis2 > new FixedPoint(lookDis * lookDis)) // continue; // if (cc.IsDie() || cc.GetUid() == m_creature.GetUid()) // continue; // //if (m_creature.bCamp(cc)) // // continue; // if (abDis2 < new FixedPoint(lookDis * lookDis)) // 如果目标在视线范围内 // { // if (abDis2 < m_minDis2) // { // targetUid = (int)cc.GetUid(); // m_minDis2 = abDis2; // } // } //} if (targetUid != 0) { m_dataBase.SetData <int>((int)eAIParam.INT_TARGET_UID, targetUid); return(true); } //m_creature.DestoryDownUpSkill(); // 无目标,结束机枪 return(false); }
/// <summary> /// 通过BUFF区域检测触发 /// </summary> public virtual void Trigger() { if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Circle) { FPSphere tSphere = new FPSphere(); tSphere.c = GetPos(); tSphere.r = new FixedPoint(m_triggerData.Length); List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_caster.bCamp(creature) || creature.IsDie()) { continue; } FPSphere playerS = new FPSphere(); playerS.c = creature.GetPos(); playerS.r = creature.GetR(); if (FPCollide.bSphereSphere(tSphere, playerS)) { OnHitAddBuff(m_caster, creature); } } } else if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Sector) { List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_caster.bCamp(creature) || creature.IsDie()) { continue; } FPSphere playerS = new FPSphere(); playerS.c = creature.GetPos(); playerS.r = creature.GetR(); FPSector sec = new FPSector(); sec.pos = GetPos(); sec.dir = GetDir(); sec.angle = new FixedPoint(m_triggerData.Width); sec.r = new FixedPoint(m_triggerData.Length); if (FPCollide.bSectorInside(sec, creature.GetPos())) { OnHitAddBuff(m_caster, creature); } } } else if (m_triggerData.ShapeType == (int)eBuffTriggerShapeType.Rect) { List <long> list = CCreatureMgr.GetCreatureList(); for (int i = 0; i < list.Count; i++) { CCreature creature = CCreatureMgr.Get(list[i]); if (m_caster.bCamp(creature) || creature.IsDie()) { continue; } FPSphere playerS = new FPSphere(); playerS.c = creature.GetPos(); playerS.r = creature.GetR(); Vector2d pos = GetPos(); int angle = (int)FPCollide.GetAngle(GetDir()).value; FPObb obb = new FPObb(pos, new Vector2d(m_triggerData.Width, m_triggerData.Length), angle); if (FPCollide.bSphereOBB(playerS, obb)) { OnHitAddBuff(m_caster, creature); } } } if (m_triggerData.PosType == (int)eBuffTriggerPosType.CasterStartPos_SkillDir) { // 障碍碰撞 if (CMapMgr.m_map.IsblockNotAirWal((int)m_curPos.x.value, (int)m_curPos.y.value)) { Destory(); return; } if (PhysicsManager.Inst.IsblockNotAirWal((int)m_curPos.x, (int)m_curPos.y)) { Destory(); return; } // 子弹碰撞 FPSphere cur = new FPSphere(); cur.c = GetPos(); cur.r = GetR(); foreach (KeyValuePair <long, CBuffTrigger> item in CBuffTriggerMgr.m_dicSkill) { CBuffTrigger tri = item.Value; if (tri.m_triggerData.PosType == (int)eBuffTriggerPosType.CasterStartPos_SkillDir && tri != this && tri.m_caster != m_caster) { FPSphere triItem = new FPSphere(); triItem.c = tri.GetPos(); triItem.r = tri.GetR(); if (FPCollide.bSphereSphere(cur, triItem)) { Destory(); tri.Destory(); } } } } }