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(); }
// 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; } }
// Update is called once per frame void Update() { opponent.Hit(hitbox, transform); transform.position += Time.deltaTime * velocity; }