static public void GetWetTarget(ref List <Life> targetlist, SkillInfo skill, Life own) { float radius = ConfigM.GetWetBodyRange() * 0.01f; List <Life> lr = new List <Life>(); LifeMCamp camp = GetSkillCamp(skill, own); CM.SearchLifeMListInBoat(ref lr, LifeMType.SOLDIER, camp); for (int i = 0; i < targetlist.Count; i++) { Life l = targetlist[i]; foreach (Role r in lr) { if (NdUtil.IsSameMapLayer(l.MapPos, r.MapPos)) { if (r.m_thisT.localPosition.x >= (l.m_thisT.localPosition.x - radius) && r.m_thisT.localPosition.x <= (l.m_thisT.localPosition.x + radius)) { if (r.m_Attr.IsWetBody) { if (!targetlist.Contains(r)) { targetlist.Add(r); } } } } } } }
public override void NDUpdate(float deltaTime) { if (CheckCombatIng()) { if (m_timecount > m_info.m_time) { return; } m_timecount += deltaTime; if (m_timecount > m_info.m_time) { GameObject.Destroy(m_thisT.gameObject); } else { if (m_timecount > m_cout * m_info.m_timeinterval) { m_cout++; List <Life> lr = new List <Life>(); LifeMCamp camp = m_Parent.m_Core.m_Camp == LifeMCamp.ATTACK ? LifeMCamp.DEFENSE : LifeMCamp.ATTACK; CM.SearchLifeMListInBoat(ref lr, LifeMType.SOLDIER, camp); for (int i = 0; i < lr.Count; i++) { if (NdUtil.IsSameMapLayer(lr[i].GetMapPos(), m_Pos)) { if (lr[i].m_thisT.localPosition.x > m_MapGrid.pos.x - m_info.m_range && lr[i].m_thisT.localPosition.x < m_MapGrid.pos.x + m_info.m_range) { SkillReleaseInfo sInfo = new SkillReleaseInfo(); sInfo.m_InterruptSkill = false; sInfo.m_MakeStatus = new List <StatusType> (); sInfo.m_bImmunity = false; sInfo.m_Damage = m_info.m_ReduceAttr.GetAttr(EffectType.RecoHp); int fire = m_info.m_ReduceAttr.GetAttr(EffectType.FireAttack); if (fire > 0) { sInfo.m_Damage = Skill.CalcAttributableSkillDamage(AttributeType.Fire, lr[i].m_Attr, sInfo.m_Damage); } sInfo.Result = AttackResult.Normal; lr[i].ApplyDamage(sInfo, null); } } } } } } }
/// <summary> /// 检测攻击目标 /// </summary> /// <param name="target"></param> /// <param name="g"></param> /// <param name="Sort"></param> /// <param name="radus"></param> /// <param name="dir">线性搜索需要方向</param> /// <returns></returns> public bool CheckRangeAttackTarget(Life target, MapGrid g, int Sort, float radus) { Int2 AttackStation2 = target.GetMapPos(); if (!NdUtil.IsSameMapLayer(g.GridPos, AttackStation2)) { return(false); } if (Sort == 3) { if (target.m_thisT.localPosition.x >= (m_parent.m_thisT.localPosition.x - radus * MapGrid.m_width) && target.m_thisT.localPosition.x <= (m_parent.m_thisT.localPosition.x + radus * MapGrid.m_width)) { return(true); } } return(false); }
public override void NDUpdate(float deltaTime) { //base.NDUpdate (deltaTime); List <Life> l = new List <Life>(); CM.SearchLifeMListInBoat(ref l, LifeMType.SOLDIER, LifeMCamp.ATTACK); //Debug.Log("wall: " + l.Count + "," +LifeMType.SOLDIER + "," + LifeMCamp.ATTACK); foreach (Role r in l) { if (NdUtil.IsSameMapLayer(r.GetMapPos(), GetMapPos())) { if (Mathf.Abs(r.m_thisT.position.x - m_thisT.position.x) < 1) { OpenDoor(); return; } } } CloseDoor(null); }
public bool CheckDoAttackTarget(Life target, int Sort, int distant) { if (target == null || target.isDead) { return(false); } //单人 //if (Sort == 1) { Life l = m_Parent; if (m_Parent is Role) { Role parent = l as Role; float radius = distant;//PropSkillInfo.m_distance/MapGrid.m_Pixel; if (radius <= 0) { return(true); } if (!NdUtil.IsSameMapLayer(parent.GetMapPos(), target.GetMapPos())) { return(false); } //radius += parent.m_Attr.Radius; float x1 = parent.m_thisT.localPosition.x; MapGrid g = MapGrid.GetMG(target.GetMapPos()); if (g == null) { //Debug.LogError(target + "," + target.GetMapPos() + "," + target.InBoat); return(false); } float x2 = g.pos.x; if (target is Role) { //radius += (int)(target as Role).m_Attr.Radius; x2 = target.m_thisT.localPosition.x; } if (target is IggWall) { radius += 1; } radius += 0.25f; if (parent.WalkDir == WalkDir.WALKLEFT) { if (x1 >= x2 && (x1 - x2) <= (radius * MapGrid.m_width)) { return(true); } } else if (parent.WalkDir == WalkDir.WALKRIGHT) { if (x1 <= x2 && (x2 - x1) <= (radius * MapGrid.m_width)) { return(true); } } else if (Mathf.Abs(x1 - x2) < radius * MapGrid.m_width) { return(true); } } } return(false); }
/// <summary> /// 检测攻击目标 /// </summary> /// <param name="target"></param> /// <param name="g"></param> /// <param name="Sort"></param> /// <param name="radus"></param> /// <param name="dir">线性搜索需要方向</param> /// <returns></returns> static public bool CheckRangeAttackTarget(Life target, MapGrid g, int Sort, float radus, WalkDir dir) { Building buildlife = target as Building; int startUnit = g.GridPos.Unit; int r = (int)Mathf.Round(radus); if (buildlife != null) { if (Sort == 3) { int nBegine = startUnit - r; int nEnd = startUnit + r; for (int nCnt = nBegine; nCnt <= nEnd; nCnt++) { if (buildlife.CheckInBuildMap(new Int2(nCnt, g.GridPos.Layer))) { return(true); } } } else if (Sort == 2) { int nBegine = g.GridPos.Unit; int nEnd = startUnit + r; if (dir == WalkDir.WALKLEFT) { nBegine = startUnit - r; nEnd = g.GridPos.Unit; } for (int nCnt = nBegine; nCnt <= nEnd; nCnt++) { if (buildlife.CheckInBuildMap(new Int2(nCnt, g.GridPos.Layer))) { return(true); } } } return(false); } MapGrid AttackStation2 = target.GetMapGrid(); if (!NdUtil.IsSameMapLayer(AttackStation2.GridPos, g.GridPos)) { return(false); } if (Sort == 3) { if (AttackStation2.pos.x >= (g.pos.x - radus) && AttackStation2.pos.x <= (g.pos.x + radus)) { return(true); } } else if (Sort == 2) { if (dir == WalkDir.WALKLEFT) { if (AttackStation2.pos.x >= (g.pos.x - radus)) { return(true); } } else { if (AttackStation2.pos.x < (g.pos.x + radus)) { return(true); } } } else if (Sort == 4) { if (dir == WalkDir.WALKLEFT) { if (AttackStation2.pos.x >= (g.pos.x - radus)) { return(true); } } else { if (AttackStation2.pos.x < (g.pos.x + radus)) { return(true); } } } return(false); }