Beispiel #1
0
    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);
    }
Beispiel #2
0
    private void DealAttackWarningEvent()
    {
        _receiveWarningHeroes.Sort(delegate(XBoxComponent x, XBoxComponent y) {
            return(x.cid - y.cid);
        });
        for (int i = 0; i < _receiveWarningHeroes.Count; i++)
        {
            XBoxComponent hero = _receiveWarningHeroes[i];
            if (hero != null && !_lastReceiveWarningHeroes.Contains(hero))
            {
                hero.AttackWarningEventCallback(true);
            }
        }

        for (int i = 0; i < _lastReceiveWarningHeroes.Count; i++)
        {
            XBoxComponent hero = _lastReceiveWarningHeroes[i];
            if (hero != null && !_receiveWarningHeroes.Contains(hero))
            {
                hero.AttackWarningEventCallback(false);
            }
        }

        if (_receiveWarningHeroes.Count > 0)
        {
            _lastReceiveWarningHeroes = _receiveWarningHeroes;
            _receiveWarningHeroes     = new List <XBoxComponent>();
        }
        else
        {
            _lastReceiveWarningHeroes.Clear();
        }
    }
Beispiel #3
0
    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);
    }
Beispiel #4
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);
                }
            }
        }
    }
Beispiel #5
0
    public void UnRegister(XBoxComponent hero)
    {
        if (hero == null)
        {
            GLog.Log("UNREGISTER a null hero??");
            return;
        }

        if (_heroes.Contains(hero))
        {
            _heroes.Remove(hero);
        }
        else
        {
            GLog.Log("UNREGISTER a ghost hero?? {0}", hero.gameObject.name);
        }

        if (_bloodyHeroes != null)
        {
            XBoxBloody bloodyHero = _bloodyHeroes.Find(delegate(XBoxBloody obj) {
                return(obj.AttackHero == hero);
            });
            GLog.Log("Unregister bloodyHeroes {0}", _bloodyHeroes.Count);
            if (bloodyHero != null)
            {
                _bloodyHeroes.Remove(bloodyHero);
            }
        }
    }
Beispiel #6
0
    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());
                        }
                    }
                }
            }
        }
    }
Beispiel #7
0
    private void InitHitBoxShowStuff()
    {
        _hitBoxMat = new Material(Shader.Find("PostEffect/Effect/QuadColor"));
        _hitBoxMat.SetColor("_Color", new Color(1f, 1f, 1f, 0.4f));

        _warningBoxMat = new Material(Shader.Find("PostEffect/Effect/QuadColor"));
        _warningBoxMat.SetColor("_Color", new Color(1f, 0.5f, 0f, 0.4f));

        _hc = FindObjectOfType <XBoxComponent>();
    }
Beispiel #8
0
    private bool IsWarningAttack(XBulletComponent bc, XBoxComponent hard)
    {
        XBoxRect box = bc.GetBulletWarningBox();

        if (box == null)
        {
            return(false);
        }

        return(_InternalWarningAttack(box, hard));
    }
Beispiel #9
0
    public void GenerateBoneNogPoint()
    {
        XBoxComponent bc = this.GetComponent <XBoxComponent>();

        if (bc)
        {
            nogPoint          = bc.NogPoint;
            camSkillReaction  = bc.CamSkillReaction;
            LinkConfig        = bc.LinkConfig;
            footstepFallAudio = bc.FootstepFallAudio;
            SquatHeight       = bc.SquatHeight;
        }
    }
Beispiel #10
0
    private int LastTransMeet(XBoxComponent hc1, XBoxComponent hc2)
    {
        XBodyMoveRectBox rb1 = hc1.GetTransMoveBox();
        XBodyMoveRectBox rb2 = hc2.GetTransMoveBox();

        if (rb1 == null || rb2 == null)
        {
            return(-1);
        }

        XBoxRect box = XBoxRect.Overlap(rb1, rb2);

        return(box.Width);
    }
Beispiel #11
0
    private void AddBloodyHeroes(XBoxComponent attack, int receiveId, XBoxRect overlap)
    {
        XBoxBloody hero = _bloodyHeroes.Find(delegate(XBoxBloody obj)
        {
            return(obj.AttackHero == attack);
        });

        if (hero == null)
        {
            hero = new XBoxBloody(attack);
            _bloodyHeroes.Add(hero);
        }
        hero.AddBloodyHero(receiveId, overlap);
    }
Beispiel #12
0
    public void AddBloodyHero(XBoxComponent receive, XBoxRect box)
    {
        if (_bloodyHeroes == null)
        {
            _bloodyHeroes = new List <int>();
        }

        if (_boxes == null)
        {
            _boxes = new List <XBoxRect>();
        }

        _bloodyHeroes.Add(receive.cid);
        _boxes.Add(box);
    }
Beispiel #13
0
    public void Register(XBoxComponent hero)
    {
        if (hero == null)
        {
            GLog.LogError("REGISTER a null hero??");
            return;
        }

        if (_heroes.Contains(hero))
        {
            GLog.LogError("REGISTER a duplicate hero?? {0}", hero.gameObject.name);
            return;
        }
        _heroes.Add(hero);
    }
Beispiel #14
0
    public void CheckAttackWhenBoxesCome(XBoxComponent hc)
    {
        for (int i = 0; i < _heroes.Count; i++)
        {
            if (_heroes[i] == hc)
            {
                continue;
            }

            IsBloodyAttack(hc, _heroes[i]);
        }
        AddBloodyFlexiableBoxes(hc);

        DealAttackEvent();
    }
Beispiel #15
0
    private void AddBloodyFlexiableBoxes(XBoxComponent attack)
    {
        XBoxRect attackBox = attack.GetAttackBoxRect();

        if (attackBox == null || _flexibleHurtBoxes.Count < 1)
        {
            return;
        }

        for (int i = 0; i < _flexibleHurtBoxes.Count; i++)
        {
            XBoxRect box = XBoxRect.Overlap(attackBox, _flexibleHurtBoxes[i].GetFlexibleHurtBox());
            if (box.Width >= 0)
            {
                AddBloodyHeroes(attack, _flexibleHurtBoxes[i].GetActiveId(), box);
            }
        }
    }
Beispiel #16
0
    public void AddCache(XBoxComponent src, XBoxComponent hc)
    {
        List <XBoxComponent> cacheExis = GetCacheInCache(src);

        if (cacheExis != null)
        {
            if (!cacheExis.Contains(hc))
            {
                cacheExis.Add(hc);
            }
            return;
        }

        List <XBoxComponent> cache = new List <XBoxComponent>();

        cache.Add(src);
        cache.Add(hc);
        _cache.Add(cache);
    }
Beispiel #17
0
 public List <XBoxComponent> GetCacheInCache(XBoxComponent hc)
 {
     if (_cache.Count > 0)
     {
         for (int i = 0; i < _cache.Count; i++)
         {
             if (_cache[i] != null)
             {
                 for (int index = 0; index < _cache[i].Count; index++)
                 {
                     if (hc == _cache[i][index])
                     {
                         return(_cache[i]);
                     }
                 }
             }
         }
     }
     return(null);
 }
Beispiel #18
0
    private void BodyMoveStep(XBoxComponent hc, int x, int y)
    {
        if (Mathf.Abs(hc.GetBodyMoveBox().MoveX) >= Mathf.Abs(x))
        {
            hc.GetBodyMoveBox().MoveX -= x;
        }
        else
        {
            hc.GetBodyMoveBox().MoveX = 0;
        }

        if (Mathf.Abs(hc.GetBodyMoveBox().MoveY) >= Mathf.Abs(y))
        {
            hc.GetBodyMoveBox().MoveY -= y;
        }
        else
        {
            hc.GetBodyMoveBox().MoveY = 0;
        }
    }
Beispiel #19
0
    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);
    }
Beispiel #20
0
    private bool AttackOnBullet(XBoxComponent hero)
    {
        XBoxRect attackBox = hero.GetAttackBoxRect();

        if (attackBox == null)
        {
            return(false);
        }

        if (_bullets.Count > 0)
        {
            for (int i = 0; i < _bullets.Count; i++)
            {
                XBoxRect lapBox = XBoxRect.Overlap(attackBox, _bullets[i].GetBulletHitBox());
                if (lapBox.Width >= 0)
                {
                    AddBloodyHeroes(hero, _bullets[i].gid, lapBox);
                    return(true);
                }
            }
        }
        return(false);
    }
Beispiel #21
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;
            }
        }
    }
Beispiel #22
0
 private void AddBloodyHeroes(XBoxComponent attack, XBoxComponent receive, XBoxRect overlap)
 {
     AddBloodyHeroes(attack, receive.cid, overlap);
 }
Beispiel #23
0
 public XBoxBloody(XBoxComponent attack)
 {
     _attackHero = attack;
 }
Beispiel #24
0
    private bool IsWarningAttack(XBoxComponent cruel, XBoxComponent hard)
    {
        XBoxRect attackBox = cruel.GetAttackWarningBoxRect();

        return(_InternalWarningAttack(attackBox, hard));
    }