Пример #1
0
        public static void Hit(Fighter a, Fighter b)
        {
            FighterState  aframe = a.moves[a.currentState].GetFrame(), bframe = b.moves[b.currentState].GetFrame();
            List <HitBox> aattack = aframe.GetHitbox(HitBox.Type.Attack), battack = bframe.GetHitbox(HitBox.Type.Attack);
            List <HitBox> adef = aframe.GetHitbox(HitBox.Type.Body), bdef = bframe.GetHitbox(HitBox.Type.Body);

            foreach (HitBox h in aattack)
            {
                foreach (HitBox d in bdef)
                {
                    HitBox attack = new HitBox(h, a.transform);
                    HitBox def    = new HitBox(d, b.transform);
                    if (attack.Hit(def))
                    {
                        b.Hit(0);
                    }
                }
            }

            foreach (HitBox h in battack)
            {
                foreach (HitBox d in adef)
                {
                    HitBox attack = new HitBox(h, b.transform);
                    HitBox def    = new HitBox(d, a.transform);
                    if (attack.Hit(def))
                    {
                        a.Hit(0);
                    }
                }
            }
        }
Пример #2
0
        public static void Hit(FighterController a, FighterController b)
        {
            FighterState  aframe = a.fighter.GetFrame(), bframe = b.fighter.GetFrame();
            List <HitBox> aattack = aframe.GetHitbox(HitBox.Type.Attack), battack = bframe.GetHitbox(HitBox.Type.Attack);
            List <HitBox> adef = aframe.GetHitbox(HitBox.Type.Body), bdef = bframe.GetHitbox(HitBox.Type.Body);

            if (!aframe.Computed)
            {
                foreach (HitBox h in aattack)
                {
                    foreach (HitBox d in bdef)
                    {
                        HitBox attack = new HitBox(h, a.transform);
                        HitBox def    = new HitBox(d, b.transform);
                        if (attack.Hit(def))
                        {
                            b.Hit(0, new HitBox(h), a);
                        }
                    }
                }
                if (aattack.Count > 0)
                {
                    b.Block();
                }
            }

            if (!bframe.Computed)
            {
                foreach (HitBox h in battack)
                {
                    foreach (HitBox d in adef)
                    {
                        HitBox attack = new HitBox(h, b.transform);
                        HitBox def    = new HitBox(d, a.transform);
                        if (attack.Hit(def))
                        {
                            a.Hit(0, new HitBox(h), b);
                        }
                    }
                }
                if (battack.Count > 0)
                {
                    a.Block();
                }
            }


            aframe.Consume();
            bframe.Consume();
        }