Пример #1
0
    public void DoFixedUpdate()
    {
        if (isHit > 0)
        {
            isHit -= Time.fixedDeltaTime;
            return;
        }

        // Check if both controllers are ready
        AbstractInputController p1InputController = UFE.GetPlayer1Controller();
        AbstractInputController p2InputController = UFE.GetPlayer2Controller();

        if (p1InputController == null || !p1InputController.isReady || p2InputController == null || !p2InputController.isReady)
        {
            return;
        }

        if (UFE.freeCamera)
        {
            return;
        }

        transform.position += (movement * Time.fixedDeltaTime);

        hurtBox.position = gameObject.transform.position;
        if (projectileRenderer != null && (hurtBox.followXBounds || hurtBox.followYBounds))
        {
            hurtBox.rendererBounds = GetBounds();
            hitBox.rendererBounds  = GetBounds();
        }

        blockableArea.position = transform.position;
        if (!opControlsScript.isBlocking &&
            !opControlsScript.blockStunned &&
            opControlsScript.currentSubState != SubStates.Stunned &&
            opHitBoxesScript.TestCollision(blockableArea) != Vector3.zero)
        {
            opControlsScript.CheckBlocking(true);
        }

        if (data.projectileCollision)
        {
            if (opControlsScript.projectiles.Count > 0)
            {
                foreach (ProjectileMoveScript projectile in opControlsScript.projectiles)
                {
                    if (projectile == null)
                    {
                        continue;
                    }
                    if (projectile.hitBox == null)
                    {
                        continue;
                    }
                    if (projectile.hurtBox == null)
                    {
                        continue;
                    }

                    if (HitBoxesScript.TestCollision(new HitBox[] { projectile.hitBox }, new HurtBox[] { hurtBox }, HitConfirmType.Hit, mirror) != Vector3.zero)
                    {
                        if (data.impactPrefab != null)
                        {
                            GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                            UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration);
                        }
                        totalHits--;
                        if (totalHits <= 0)
                        {
                            destroyMe = true;
                        }
                        isHit = spaceBetweenHits;
                        transform.Translate(movement * -1 * Time.fixedDeltaTime);
                        break;
                    }
                }
            }
        }

        if (opHitBoxesScript.TestCollision(new HurtBox[] { hurtBox }, HitConfirmType.Hit) != Vector3.zero &&
            opControlsScript.ValidateHit(hit))
        {
            if (data.impactPrefab != null)
            {
                GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(hitEffect); }catch {} }, data.impactDuration);
            }
            totalHits--;
            if (totalHits <= 0)
            {
                UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(gameObject); }catch {} }, (float)(2 / UFE.config.fps));
            }


            if (opControlsScript.currentSubState != SubStates.Stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType))
            {
                myControlsScript.AddGauge(data.gaugeGainOnBlock);
                opControlsScript.AddGauge(data.opGaugeGainOnBlock);
                opControlsScript.GetHitBlocking(hit, 20, transform.position);

                if (data.moveLinkOnBlock != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnBlock, true, data.forceGrounded);
                }
            }
            else if (opControlsScript.potentialParry > 0 && opControlsScript.TestParryStances(hit.hitType))
            {
                opControlsScript.AddGauge(data.opGaugeGainOnParry);
                opControlsScript.GetHitParry(hit, 20, transform.position);

                if (data.moveLinkOnParry != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnParry, true, data.forceGrounded);
                }
            }
            else
            {
                myControlsScript.AddGauge(data.gaugeGainOnHit);
                opControlsScript.AddGauge(data.opGaugeGainOnHit);
                opControlsScript.GetHit(hit, 30, Vector3.zero);

                if (data.moveLinkOnStrike != null)
                {
                    myControlsScript.CastMove(data.moveLinkOnStrike, true, data.forceGrounded);
                }
            }

            isHit = opControlsScript.GetHitFreezingTime(data.hitStrength) * 1.2f;
            opControlsScript.CheckBlocking(false);
        }
    }