private bool IsBloodyAttack(XBoxComponent cruel, XBoxComponent hard) { XBoxRect attackBox = cruel.GetAttackBoxRect(); List <XBoxRect> receiveBoxes = hard.GetReceiveDamageBoxesRect(); if (attackBox == null || receiveBoxes == null) { return(false); } XBoxRect box = new XBoxRect(); for (int i = 0; i < receiveBoxes.Count; i++) { XBoxRect lapBox = XBoxRect.Overlap(attackBox, receiveBoxes[i]); if (lapBox.Width >= 0) { if (box.Height < lapBox.Height) { box.Copy(lapBox); } } } if (box.Width >= 0) { AddBloodyHeroes(cruel, hard, box); return(true); } return(false); }
private bool _InternalWarningAttack(XBoxRect rectBox, XBoxComponent hard) { List <XBoxRect> receiveBoxes = hard.GetReceiveDamageBoxesRect(); if (rectBox == null || receiveBoxes == null) { return(false); } for (int i = 0; i < receiveBoxes.Count; i++) { XBoxRect box = XBoxRect.Overlap(rectBox, receiveBoxes[i]); if (box.Width >= 0) { if (!_receiveWarningHeroes.Contains(hard)) { _receiveWarningHeroes.Add(hard); } return(true); } } return(false); }
private void CalBulletHit(XBoxComponent hero) { if (_bullets.Count > 0) { bool isHeroWarning = false; for (int i = 0; i < _bullets.Count; i++) { bool addI = false; List <XBoxRect> boxes = hero.GetReceiveDamageBoxesRect(); for (int hurtBoxIndex = 0; hurtBoxIndex < boxes.Count; hurtBoxIndex++) { if (XBoxRect.Overlap(boxes[hurtBoxIndex], _bullets[i].GetBulletHitBox()).Width >= 0) { AddBulletHero(_bullets[i], hero.Trans); addI = true; break; } } if (!isHeroWarning) { isHeroWarning = IsWarningAttack(_bullets[i], hero); } if (addI) { continue; } for (int flexiHurtIndex = 0; flexiHurtIndex < _flexibleHurtBoxes.Count; flexiHurtIndex++) { if (XBoxRect.Overlap(_flexibleHurtBoxes[flexiHurtIndex].GetFlexibleHurtBox(), _bullets[i].GetBulletHitBox()).Width >= 0) { AddBulletHero(_bullets[i], _flexibleHurtBoxes[flexiHurtIndex].Trans); addI = true; break; } } if (addI) { continue; } for (int index = 0; index < _bullets.Count; index++) { if (index != i) { if (XBoxRect.Overlap(_bullets[i].GetBulletHitBox(), _bullets[index].GetBulletHitBox()).Width >= 0) { AddBulletHero(_bullets[i], _bullets[index].GetFlyEffectTrans()); } } } } } }
protected bool IsIntersect(Transform trans) { bool hit = false; XBoxComponent hc = trans.GetComponent <XBoxComponent>(); if (hc != null && collider_ != null) { List <XBoxRect> hurtBoxes = hc.GetReceiveDamageBoxesRect(); XBoxRect bulletRect = GetBoundingRect(transform, collider_); if (hurtBoxes != null && hurtBoxes.Count > 0 && bulletRect != null) { for (int i = 0; i < hurtBoxes.Count; i++) { if (bulletRect.Overlap(hurtBoxes[i]) >= 0) { hit = true; break; } } } } else { Collider colid = trans.GetComponent <Collider>(); if (colid != null) { if (collider_ != null) { hit = colid.bounds.Intersects(collider_.bounds); } else { hit = colid.bounds.Contains(transform.position); } } } return(hit); }
private void HugYou(XBoxComponent me, XBoxComponent you) { if (_hugBeEatenList.Contains(me)) { return; } XBoxRect hugBox = me.GetHugBoxRect(); if (hugBox == null) { return; } List <XBoxRect> hurtBoxes = you.GetReceiveDamageBoxesRect(); if (hurtBoxes == null) { return; } for (int i = 0; i < hurtBoxes.Count; i++) { XBoxRect overlap = XBoxRect.Overlap(hugBox, hurtBoxes[i]); if (overlap != null && overlap.Width >= 0) { if ((_hugHeroesDic.ContainsKey(me) && overlap.Width < _hugHeroesDic[me].Overlap) || !_hugHeroesDic.ContainsKey(me)) { XBoxOverlap lap = new XBoxOverlap(); lap.Hero = you; lap.Overlap = overlap.Width; _hugHeroesDic[me] = lap; } return; } } }