コード例 #1
0
 void Hit(int dmg, HitBox hitting, FighterController opponent)
 {
     if (fighter.Parrying()) //Perfect Parry
     {
         if (perfectParryEvent != null)
         {
             perfectParryEvent.Invoke();
         }
         particleLaunch(parryPerfect, Vector3.up * 2f + new Vector3(sens.x, 0, 0));
         float t = FightManager.timeModifier;
         FightManager.timeModifier = 0.0f;
         StartCoroutine(freezeTime(hitFreezeTime, t));
         return;
     }
     if (fighter.Parrying()) //Parry
     {
         if (parryEvent != null)
         {
             parryEvent.Invoke();
         }
         particleLaunch(parry, Vector3.up * 2f + new Vector3(sens.x, 0, 0));
         float t = FightManager.timeModifier;
         FightManager.timeModifier = 0.0f;
         StartCoroutine(freezeTime(hitFreezeTime, t));
         return;
     }
     if (controller.GetKeyDown(VirtualController.Keys.Block) && fighter.CanBlock())//(controller.GetHorizontal() < -0.3f && sens.x > 0.1f) || (controller.GetHorizontal() > 0.3f && sens.x < -0.1f))
     {
         if (blockEvent != null)
         {
             blockEvent.Invoke();
         }
         if (fighter.ReceiveGuardDamage(hitting.guardDmg))
         {
             particleLaunch(guardBreak, Vector3.up * 2f + Vector3.right);
         }
         else
         {
             particleLaunch(hitBlock, Vector3.up * 2f + Vector3.right);
         }
         StartCoroutine(blockPush());
         blocked = true;
     }
     else
     {
         opponent.particleLaunch(hit, (Vector3)(hitting._position + hitting._size / 2f));
         float t = FightManager.timeModifier;
         FightManager.timeModifier = 0.0f;
         StartCoroutine(freezeTime(hitFreezeTime, t));
         fighter.Damage(hitting);
         StartCoroutine(blockPush());
         if (CameraController.controller != null)
         {
             CameraController.controller.Shake(0.25f);
         }
     }
 }
コード例 #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();
        }
コード例 #3
0
 // Update is called once per frame
 void Update()
 {
     FighterController.Hit(player1, player2);
     if (!bReset && (player1.Life <= 0 || player2.Life <= 0 || time > matchTime))
     {
         if (player1.Life < player2.Life)
         {
             p2victory++;
             addVictory(player2);
             if (roundEnd != null)
             {
                 roundEnd.Invoke(1);
             }
         }
         if (player2.Life < player1.Life)
         {
             p1victory++;
             addVictory(player1);
             if (roundEnd != null)
             {
                 roundEnd.Invoke(0);
             }
         }
         Debug.Log("Match End");
         bReset     = true;
         resetTimer = 0.0f;
     }
     else if (bReset)
     {
         resetTimer += Time.deltaTime;
         if (resetTimer > 2.0f)
         {
             if (!OnMatchEnd())
             {
                 ResetMatch();
                 if (fightBegin != null)
                 {
                     Block();
                     fightBegin.Invoke(UnBlock);
                 }
             }
         }
     }
     if (running)
     {
         time += Time.deltaTime;
     }
 }
コード例 #4
0
 // Use this for initialization
 void Start()
 {
     controller            = GetComponent <FighterController>();
     opponent              = controller.opponent;
     controller.controller = this;
 }
コード例 #5
0
 public void SetFighter(FighterController controller)
 {
     fighter = controller;
 }