Пример #1
0
    private void HugEach(XBoxComponent human, XBoxComponent orc)
    {
        XBoxHugRect humanBox = human.GetHugBoxRect();
        XBoxHugRect orcBox   = orc.GetHugBoxRect();

        if (humanBox == null || orcBox == null)
        {
            return;
        }

        XBoxRect overlap = XBoxRect.Overlap(humanBox, orcBox);

        if (overlap != null && overlap.Width >= 0)
        {
            if (humanBox.HugType == orcBox.HugType || (humanBox.HugType != XHugType.Normal && orcBox.HugType != XHugType.Normal))
            {
                if (!_hugEachList.Contains(human))
                {
                    _hugEachList.Add(human);
                }
                if (!_hugEachList.Contains(orc))
                {
                    _hugEachList.Add(orc);
                }
            }
            else
            {
                XBoxComponent hc = humanBox.HugType > orcBox.HugType ? orc : human;
                if (!_hugBeEatenList.Contains(hc))
                {
                    _hugBeEatenList.Add(hc);
                }
            }
        }
    }
Пример #2
0
    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;
            }
        }
    }