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); } }
public override void UFEFixedUpdate() { if (!this.gameObject.activeInHierarchy || destroyMe) { return; } if (isHit > 0) { isHit -= UFE.fixedDeltaTime; return; } // Check if both controllers are ready if (UFE.freezePhysics) { return; } // Update Fixed Point Transform fpTransform.position += (movement * UFE.fixedDeltaTime); // Test Outbounds if (fpTransform.position.x > UFE.config.selectedStage._rightBoundary + 5 || fpTransform.position.x < UFE.config.selectedStage._leftBoundary - 5) { destroyMe = true; return; } // Get Auto Bounds hurtBox.position = fpTransform.position; if (projectileRenderer != null && (hurtBox.followXBounds || hurtBox.followYBounds)) { hurtBox.rendererBounds = GetBounds(); hitBox.rendererBounds = GetBounds(); } // Check Block Area Contact blockableArea.position = fpTransform.position; if (!opControlsScript.isBlocking && !opControlsScript.blockStunned && opControlsScript.currentSubState != SubStates.Stunned && opHitBoxesScript.TestCollision(blockableArea).Length > 0) { opControlsScript.CheckBlocking(true); } // Test Collision with Opponent's Projectiles 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(projectile.fpTransform.position, new HitBox[] { projectile.hitBox }, new HurtBox[] { hurtBox }, HitConfirmType.Hit, mirror).Length > 0) { ProjectileHit(); projectile.ProjectileHit(); break; } } } } // Test Collision with Opponent FPVector[] collisionVectors = (opHitBoxesScript.TestCollision(new HurtBox[] { hurtBox }, HitConfirmType.Hit)); if (collisionVectors.Length > 0 && opControlsScript.ValidateHit(hit)) { ProjectileHit(); //if (data.impactPrefab != null){ // GameObject hitEffect = UFE.SpawnGameObject(data.impactPrefab, fpTransform.position.ToVector(), Quaternion.Euler(0, 0, data.directionAngle), Mathf.RoundToInt(data.impactDuration * UFE.config.fps)); //} //totalHits --; //if (totalHits <= 0){ // this.destroyMe = true; //} //isHit = opControlsScript.GetHitFreezingTime(data.hitStrength) * 1.2f; if (opControlsScript.currentSubState != SubStates.Stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType)) { myControlsScript.AddGauge(data.gaugeGainOnBlock); opControlsScript.AddGauge(data.opGaugeGainOnBlock); opControlsScript.GetHitBlocking(hit, 20, collisionVectors); 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, collisionVectors); if (data.moveLinkOnParry != null) { myControlsScript.CastMove(data.moveLinkOnParry, true, data.forceGrounded); } } else { myControlsScript.AddGauge(data.gaugeGainOnHit); opControlsScript.AddGauge(data.opGaugeGainOnHit); /*if (data.obeyDirectionalHit){ * hit._pushForce.x *= directionVector.x; * }*/ if (data.hitEffectsOnHit) { opControlsScript.GetHit(hit, 30, collisionVectors, data.obeyDirectionalHit); } else { opControlsScript.GetHit(hit, 30, new FPVector[0], data.obeyDirectionalHit); } if (data.moveLinkOnStrike != null) { myControlsScript.CastMove(data.moveLinkOnStrike, true, data.forceGrounded); } } opControlsScript.CheckBlocking(false); } // Update Unity Transform transform.position = fpTransform.position.ToVector(); }