protected virtual void GoToNextScreen() { this.closing = true; if (UFE.gameMode == GameMode.StoryMode) { UFE.DelaySynchronizedAction(this.StartStoryMode, 0.8f); } else { UFE.DelaySynchronizedAction(this.GoToStageSelectionScreen, 0.8f); } }
protected virtual void OnGameEnd(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser) { this.isRunning = false; if (winner == this.player1.character) { this.player1.winner = true; } if (winner == this.player2.character) { this.player2.winner = true; } UFE.DelaySynchronizedAction(this.OpenMenuAfterBattle, 3.5); }
public override void OnShow() { base.OnShow(); if (this.music != null) { UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic); } if (this.sound != null) { UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.sound); }, this.delayBeforePlayingMusic); } UFE.DelaySynchronizedAction(this.GoToNextScreen, this.delayBeforeLoadingNextScreen); }
public virtual void GoToPreviousScreen() { this.closing = true; if (UFE.gameMode == GameMode.VersusMode && UFE.GetVersusModeScreen() != null) { UFE.DelaySynchronizedAction(this.GoToVersusModeScreen, 0.8f); } else if (UFE.gameMode == GameMode.NetworkGame) { UFE.DelaySynchronizedAction(this.GoToNetworkGameScreen, 0.8f); } else { UFE.DelaySynchronizedAction(this.GoToMainMenuScreen, 0.8f); } }
public override void OnShow() { base.OnShow(); if (this.music != null) { UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic); } if (this.stopPreviousSoundEffectsOnLoad) { UFE.StopSounds(); } if (this.onLoadSound != null) { UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic); } UFE.DelaySynchronizedAction(this.GoToNextScreen, delayBeforeLoadingNextScreen); }
//private int opProjectileLayer; //private int opProjectileMask; void Start() { gameObject.AddComponent <SphereCollider>(); /*if (opControlsScript.gameObject.name == "Player1"){ * gameObject.layer = LayerMask.NameToLayer("Projectile1"); * opProjectileLayer = LayerMask.NameToLayer("Projectile2"); * }else{ * gameObject.layer = LayerMask.NameToLayer("Projectile2"); * opProjectileLayer = LayerMask.NameToLayer("Projectile1"); * } * opProjectileMask = 1 << opProjectileLayer;*/ if (mirror == 1) { directionVector = new Vector3(-1, 0, 0); } totalHits = data.totalHits; float angleRad = ((float)data.directionAngle / 180) * Mathf.PI; movement = ((Mathf.Sin(angleRad) * Vector3.up) + (Mathf.Cos(angleRad) * directionVector)) * data.speed; UFE.DelaySynchronizedAction(delegate(){ try{ Destroy(this.gameObject); }catch {} }, data.duration); transform.Translate(new Vector3(data.castingOffSet.x * -mirror, data.castingOffSet.y, data.castingOffSet.z)); // Create Blockable Area blockableArea = new BlockArea(); blockableArea = data.blockableArea; // Create Hurtbox hurtBox = new HurtBox(); hurtBox = data.hurtBox; // Create Hitbox hitBox = new HitBox(); hitBox.shape = hurtBox.shape; hitBox.rect = hurtBox.rect; hitBox.followXBounds = hurtBox.followXBounds; hitBox.followYBounds = hurtBox.followYBounds; hitBox.radius = hurtBox.radius; hitBox.offSet = hurtBox.offSet; hitBox.position = gameObject.transform; UpdateRenderer(); if (data.spaceBetweenHits == Sizes.Small) { spaceBetweenHits = .15f; } else if (data.spaceBetweenHits == Sizes.Medium) { spaceBetweenHits = .2f; } else if (data.spaceBetweenHits == Sizes.High) { spaceBetweenHits = .3f; } // Create Hit data hit = new Hit(); hit.hitType = data.hitType; hit.spaceBetweenHits = data.spaceBetweenHits; hit.hitStrength = data.hitStrength; hit.hitStunType = HitStunType.Frames; hit.hitStunOnHit = data.hitStunOnHit; hit.hitStunOnBlock = data.hitStunOnBlock; hit.damageOnHit = data.damageOnHit; hit.damageOnBlock = data.damageOnBlock; hit.damageScaling = data.damageScaling; hit.damageType = data.damageType; hit.groundHit = data.groundHit; hit.airHit = data.airHit; hit.downHit = data.downHit; hit.overrideHitEffects = data.overrideHitEffects; hit.hitEffects = data.hitEffects; hit.resetPreviousHorizontalPush = true; hit.pushForce = data.pushForce; hit.pullEnemyIn = new PullIn(); hit.pullEnemyIn.enemyBodyPart = BodyPart.none; }
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 void ApplyForces(MoveInfo move) { //if (myControlsScript.debugger != null) myControlsScript.debugger.text = ""; //if (myControlsScript.debugger != null) myControlsScript.debugger.text = "IsGrounded = " + IsGrounded() + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalForce = " + verticalForce + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "verticalTotalForce = " + verticalTotalForce + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "normalizedJumpArc = " + myControlsScript.normalizedJumpArc + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "isTakingOff = " + isTakingOff + "\n"; //if (myControlsScript.debugger != null) myControlsScript.debugger.text += "myControlsScript.currentState = " + myControlsScript.currentState + "\n"; if (freeze) { return; } myControlsScript.normalizedJumpArc = 1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2)); float appliedFriction = (moveDirection != 0 || myControlsScript.myInfo.physics.highMovingFriction) ? UFE.config.selectedStage.groundFriction : myControlsScript.myInfo.physics.friction; if (move != null && move.ignoreFriction) { appliedFriction = 0; } if (myControlsScript.activePullIn != null) { transform.position = Vector3.Lerp(transform.position, myControlsScript.activePullIn.position, Time.fixedDeltaTime * myControlsScript.activePullIn.speed); if (myControlsScript.activePullIn.forceStand && !IsGrounded()) { ForceGrounded(); } if (Vector3.Distance(myControlsScript.activePullIn.position, transform.position) <= myControlsScript.activePullIn.targetDistance || myControlsScript.currentSubState != SubStates.Stunned) { myControlsScript.activePullIn = null; } //if (transform.position.z != 0) transform.Translate(new Vector3(0, 0, -transform.position.z)); } else { if (!IsGrounded()) { appliedFriction = 0; if (verticalForce == 0) { verticalForce = -.1f; } } if (horizontalForce != 0 && !isTakingOff) { if (horizontalForce > 0) { horizontalForce -= appliedFriction * Time.fixedDeltaTime; horizontalForce = Mathf.Max(0, horizontalForce); } else if (horizontalForce < 0) { horizontalForce += appliedFriction * Time.fixedDeltaTime; horizontalForce = Mathf.Min(0, horizontalForce); } transform.Translate(horizontalForce * Time.fixedDeltaTime, 0, 0); } if (move == null || (move != null && !move.ignoreGravity)) { if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0) { verticalForce -= appliedGravity * Time.fixedDeltaTime; transform.Translate(moveDirection * myControlsScript.myInfo.physics.jumpDistance * Time.fixedDeltaTime, verticalForce * Time.fixedDeltaTime, 0); } else if (verticalForce < 0 && IsGrounded()) { currentAirJumps = 0; verticalForce = 0; } } } /*if (myControlsScript.debugger != null) { * myControlsScript.debugger.text = "isBouncing = " + isBouncing + "\n"; * myControlsScript.debugger.text += "controlsScript.stunTime = " + controlsScript.stunTime + "\n"; * myControlsScript.debugger.text += "Animations:\n"; * foreach(AnimationState animState in character.animation){ * if (myMoveSetScript.IsAnimationPlaying(animState.name)){ * myControlsScript.debugger.text += "<color=#003300>"+ animState.name +"</color>\n"; * myControlsScript.debugger.text += "<color=#003300>"+ animState.speed +"</color>\n"; * } * } * }*/ /*if (UFE.normalizedCam) { * Vector3 cameraLeftBounds = Camera.main.ViewportToWorldPoint(new Vector3(0,0,-Camera.main.transform.position.z - 10)); * Vector3 cameraRightBounds = Camera.main.ViewportToWorldPoint(new Vector3(1,0,-Camera.main.transform.position.z - 10)); * * transform.position = new Vector3( * Mathf.Clamp(transform.position.x,cameraLeftBounds.x,cameraRightBounds.x), * transform.position.y, * transform.position.z); * }*/ float minDist = myControlsScript.opponent.transform.position.x - UFE.config.cameraOptions.maxDistance; float maxDist = myControlsScript.opponent.transform.position.x + UFE.config.cameraOptions.maxDistance; transform.position = new Vector3(Mathf.Clamp(transform.position.x, minDist, maxDist), transform.position.y, transform.position.z); transform.position = new Vector3( Mathf.Clamp(transform.position.x, UFE.config.selectedStage.leftBoundary, UFE.config.selectedStage.rightBoundary), transform.position.y, transform.position.z); if (myControlsScript.currentState == PossibleStates.Down) { return; } if (IsGrounded() && myControlsScript.currentState != PossibleStates.Down) { if (verticalTotalForce != 0) { if (bounceTimes < UFE.config.bounceOptions.maximumBounces && myControlsScript.currentSubState == SubStates.Stunned && UFE.config.bounceOptions.bounceForce != Sizes.None && verticalForce <= -UFE.config.bounceOptions.minimumBounceForce) { if (!UFE.config.bounceOptions.bounceHitBoxes) { myHitBoxesScript.HideHitBoxes(true); } if (UFE.config.bounceOptions.bounceForce == Sizes.Small) { AddForce(new Vector2(0, -verticalForce / 2.4f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.Medium) { AddForce(new Vector2(0, -verticalForce / 1.8f), 1); } else if (UFE.config.bounceOptions.bounceForce == Sizes.High) { AddForce(new Vector2(0, -verticalForce / 1.2f), 1); } bounceTimes++; if (!isBouncing) { if (myMoveSetScript.basicMoves.bounce.clip1 == null) { Debug.LogError("Bounce animation not found! Make sure you have it set on Character -> Basic Moves -> Bounce"); } myControlsScript.stunTime += airTime + UFE.config.knockDownOptions.air.knockedOutTime; myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.bounce); if (UFE.config.bounceOptions.bouncePrefab != null) { GameObject pTemp = (GameObject)Instantiate(UFE.config.bounceOptions.bouncePrefab); pTemp.transform.parent = transform; pTemp.transform.localPosition = Vector3.zero; Destroy(pTemp, UFE.config.bounceOptions.bounceKillTime); } if (UFE.config.bounceOptions.shakeCamOnBounce) { myControlsScript.shakeDensity = UFE.config.bounceOptions.shakeDensity; } UFE.PlaySound(UFE.config.bounceOptions.bounceSound); isBouncing = true; } return; } verticalTotalForce = 0; airTime = 0; myMoveSetScript.totalAirMoves = 0; BasicMoveInfo airAnimation = null; isBouncing = false; bounceTimes = 0; float animationSpeed = 0; float delayTime = 0; if (myControlsScript.currentMove != null && myControlsScript.currentMove.hitAnimationOverride) { return; } if (myControlsScript.currentSubState == SubStates.Stunned) { myControlsScript.stunTime = UFE.config.knockDownOptions.air.knockedOutTime + UFE.config.knockDownOptions.air.standUpTime; if (myMoveSetScript.basicMoves.fallDown.clip1 == null) { Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit"); } airAnimation = myMoveSetScript.basicMoves.fallDown; myControlsScript.currentState = PossibleStates.Down; if (!UFE.config.knockDownOptions.air.standUpHitBoxes) { myHitBoxesScript.HideHitBoxes(true); } } else if (myControlsScript.currentState != PossibleStates.Stand) { if (myMoveSetScript.basicMoves.landing.clip1 != null && ((myControlsScript.currentMove != null && myControlsScript.currentMove.cancelMoveWheLanding) || myControlsScript.currentMove == null)) { airAnimation = myMoveSetScript.basicMoves.landing; moveDirection = 0; isLanding = true; myControlsScript.KillCurrentMove(); delayTime = (float)myControlsScript.myInfo.physics.landingDelay / UFE.config.fps; UFE.DelaySynchronizedAction(ResetLanding, delayTime); if (airAnimation.autoSpeed) { animationSpeed = myMoveSetScript.GetAnimationLengh(airAnimation.name) / delayTime; } } if (myControlsScript.currentState != PossibleStates.Crouch) { myControlsScript.currentState = PossibleStates.Stand; } } if (airAnimation != null && !myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (animationSpeed != 0) { myMoveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed); } } } if (myControlsScript.currentSubState != SubStates.Stunned && !myControlsScript.isBlocking && !myControlsScript.blockStunned && move == null && !isTakingOff && !isLanding && myControlsScript.currentState == PossibleStates.Stand) { if (moveDirection > 0 && myControlsScript.mirror == -1 || moveDirection < 0 && myControlsScript.mirror == 1) { if (myMoveSetScript.basicMoves.moveForward.clip1 == null) { Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward"); } if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveForward.name)) { myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveForward); } } else if (moveDirection > 0 && myControlsScript.mirror == 1 || moveDirection < 0 && myControlsScript.mirror == -1) { if (myMoveSetScript.basicMoves.moveBack.clip1 == null) { Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back"); } if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.moveBack.name)) { myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.moveBack); } } } } else if ((verticalForce > 0 || !IsGrounded())) { if (move != null && myControlsScript.currentState == PossibleStates.Stand) { myControlsScript.currentState = PossibleStates.StraightJump; } if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1) { if (isBouncing) { return; } if (moveDirection == 0) { myControlsScript.currentState = PossibleStates.StraightJump; } else { if (moveDirection > 0 && myControlsScript.mirror == -1 || moveDirection < 0 && myControlsScript.mirror == 1) { myControlsScript.currentState = PossibleStates.ForwardJump; } if (moveDirection > 0 && myControlsScript.mirror == 1 || moveDirection < 0 && myControlsScript.mirror == -1) { myControlsScript.currentState = PossibleStates.BackJump; } } BasicMoveInfo airAnimation; if (myControlsScript.currentSubState == SubStates.Stunned) { if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null && Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce && UFE.config.comboOptions.knockBackMinForce > 0) { airAnimation = myMoveSetScript.basicMoves.getHitKnockBack; } else { if (myMoveSetScript.basicMoves.getHitAir.clip1 == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = myMoveSetScript.basicMoves.getHitAir; } } else { if (myMoveSetScript.basicMoves.jumpForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump) { airAnimation = myMoveSetScript.basicMoves.jumpForward; } else if (myMoveSetScript.basicMoves.jumpBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump) { airAnimation = myMoveSetScript.basicMoves.jumpBack; } else { if (myMoveSetScript.basicMoves.jumpStraight.clip1 == null) { Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight"); } airAnimation = myMoveSetScript.basicMoves.jumpStraight; } } if (!myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / (airTime * 2))); } //if (airAnimation.autoSpeed || myControlsScript.currentSubState == SubStates.Stunned) { //myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / airTime)); } } else if (move == null && verticalForce / verticalTotalForce <= 0) { BasicMoveInfo airAnimation; if (isBouncing) { if (myMoveSetScript.basicMoves.fallingFromBounce.clip1 == null) { Debug.LogError("Falling From Bounce animation not found! Make sure you have it set on Character -> Basic Moves -> Falling From Bounce"); } airAnimation = myMoveSetScript.basicMoves.fallingFromBounce; if (myMoveSetScript.basicMoves.fallingFromBounce.invincible) { myHitBoxesScript.HideHitBoxes(true); } } else { if (myControlsScript.currentSubState == SubStates.Stunned) { if (myMoveSetScript.basicMoves.getHitKnockBack.clip1 != null && Mathf.Abs(horizontalForce) > UFE.config.comboOptions.knockBackMinForce && UFE.config.comboOptions.knockBackMinForce > 0) { airAnimation = myMoveSetScript.basicMoves.getHitKnockBack; } else { if (myMoveSetScript.basicMoves.getHitAir.clip1 == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = myMoveSetScript.basicMoves.getHitAir; } } else { if (myMoveSetScript.basicMoves.fallForward.clip1 != null && myControlsScript.currentState == PossibleStates.ForwardJump) { airAnimation = myMoveSetScript.basicMoves.fallForward; } else if (myMoveSetScript.basicMoves.fallBack.clip1 != null && myControlsScript.currentState == PossibleStates.BackJump) { airAnimation = myMoveSetScript.basicMoves.fallBack; } else { if (myMoveSetScript.basicMoves.fallStraight.clip1 == null) { Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight"); } airAnimation = myMoveSetScript.basicMoves.fallStraight; } } } if (!myMoveSetScript.IsAnimationPlaying(airAnimation.name)) { myMoveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { myMoveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (myMoveSetScript.GetAnimationLengh(airAnimation.name) / (airTime * 2))); } } } } if (horizontalForce == 0 && verticalForce == 0) { moveDirection = 0; } }
public override void OnShow() { base.OnShow(); if (this.music != null) { UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforeMusic); } if (this.stopPreviousSoundEffectsOnLoad) { UFE.StopSounds(); } if (this.onLoadSound != null) { UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforeMusic); } if (UFE.config.player1Character != null) { if (this.portraitPlayer1 != null) { this.portraitPlayer1.sprite = Sprite.Create( UFE.config.player1Character.profilePictureBig, new Rect(0f, 0f, UFE.config.player1Character.profilePictureBig.width, UFE.config.player1Character.profilePictureBig.height), new Vector2(0.5f * UFE.config.player1Character.profilePictureBig.width, 0.5f * UFE.config.player1Character.profilePictureBig.height) ); } if (this.namePlayer1 != null) { this.namePlayer1.text = UFE.config.player1Character.characterName; } } if (UFE.config.player2Character != null) { if (this.portraitPlayer2 != null) { this.portraitPlayer2.sprite = Sprite.Create( UFE.config.player2Character.profilePictureBig, new Rect(0f, 0f, UFE.config.player2Character.profilePictureBig.width, UFE.config.player2Character.profilePictureBig.height), new Vector2(0.5f * UFE.config.player2Character.profilePictureBig.width, 0.5f * UFE.config.player2Character.profilePictureBig.height) ); } if (this.namePlayer2 != null) { this.namePlayer2.text = UFE.config.player2Character.characterName; } } if (UFE.config.selectedStage != null) { if (this.screenshotStage != null) { this.screenshotStage.sprite = Sprite.Create( UFE.config.selectedStage.screenshot, new Rect(0f, 0f, UFE.config.selectedStage.screenshot.width, UFE.config.selectedStage.screenshot.height), new Vector2(0.5f * UFE.config.selectedStage.screenshot.width, 0.5f * UFE.config.selectedStage.screenshot.height) ); Animator anim = this.screenshotStage.GetComponent <Animator>(); if (anim != null) { anim.enabled = UFE.gameMode != GameMode.StoryMode; } } /*if (this.nameStage != null){ * this.nameStage.text = UFE.config.selectedStage.stageName; * }*/ } UFE.DelaySynchronizedAction(UFE.PreloadBattle, this.delayBeforePreload); UFE.DelaySynchronizedAction(this.StartBattle, this.delayBeforePreload + UFE.config.preloadingTime + this.delayAfterPreload); }
public void ApplyForces(MoveInfo move) { if (freeze) { return; } controlScript.normalizedJumpArc = (Fix64)1 - ((verticalForce + verticalTotalForce) / (verticalTotalForce * 2)); Fix64 appliedFriction = (moveDirection != 0 || controlScript.myInfo.physics.highMovingFriction) ? UFE.config.selectedStage._groundFriction : controlScript.myInfo.physics._friction; if (move != null && move.ignoreFriction) { appliedFriction = 0; } if (controlScript.activePullIn != null) { worldTransform.position = FPVector.Lerp(worldTransform.position, controlScript.activePullIn.position, UFE.fixedDeltaTime * controlScript.activePullIn.speed); if (controlScript.activePullIn.forceStand && !IsGrounded()) { ForceGrounded(); } if (FPVector.Distance(controlScript.activePullIn.position, worldTransform.position) <= controlScript.activePullIn._targetDistance || controlScript.currentSubState != SubStates.Stunned) { controlScript.activePullIn = null; } } else { if (!IsGrounded()) { appliedFriction = 0; if (verticalForce == 0) { verticalForce = -.1; } } if (horizontalForce != 0 && !isTakingOff) { if (horizontalForce > 0) { horizontalForce -= appliedFriction * UFE.fixedDeltaTime; horizontalForce = FPMath.Max(0, horizontalForce); } else if (horizontalForce < 0) { horizontalForce += appliedFriction * UFE.fixedDeltaTime; horizontalForce = FPMath.Min(0, horizontalForce); } Fix64 leftCameraBounds = opWorldTransform.position.x - (UFE.config.cameraOptions._maxDistance / 2); Fix64 rightCameraBounds = opWorldTransform.position.x + (UFE.config.cameraOptions._maxDistance / 2); bool bouncingOnCamera = false; if (controlScript.currentHit != null && controlScript.currentHit.bounceOnCameraEdge && (worldTransform.position.x <= leftCameraBounds || worldTransform.position.x >= rightCameraBounds)) { bouncingOnCamera = true; } if (wallBounceTimes < UFE.config.wallBounceOptions._maximumBounces && controlScript.currentSubState == SubStates.Stunned && controlScript.currentState != PossibleStates.Down && UFE.config.wallBounceOptions.bounceForce != Sizes.None && FPMath.Abs(horizontalForce) >= UFE.config.wallBounceOptions._minimumBounceForce && (worldTransform.position.x <= UFE.config.selectedStage._leftBoundary || worldTransform.position.x >= UFE.config.selectedStage._rightBoundary || bouncingOnCamera) && controlScript.currentHit != null && controlScript.currentHit.wallBounce && !isWallBouncing) { if (controlScript.currentHit.overrideForcesOnWallBounce) { if (controlScript.currentHit.resetWallBounceHorizontalPush) { horizontalForce = 0; } if (controlScript.currentHit.resetWallBounceVerticalPush) { verticalForce = 0; } Fix64 addedH = -controlScript.currentHit._wallBouncePushForce.x; Fix64 addedV = controlScript.currentHit._wallBouncePushForce.y; AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror); } else { if (UFE.config.wallBounceOptions.bounceForce == Sizes.Small) { horizontalForce /= -1.4; } else if (UFE.config.wallBounceOptions.bounceForce == Sizes.Medium) { horizontalForce /= -1.2; } else if (UFE.config.wallBounceOptions.bounceForce == Sizes.High) { horizontalForce *= -1; } } wallBounceTimes++; if (verticalForce > 0 || !IsGrounded()) { if (moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { controlScript.currentHitAnimation = moveSetScript.basicMoves.airWallBounce.name; } } else { if (controlScript.currentHit.knockOutOnWallBounce) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounceKnockdown); controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown.name; } else { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.standingWallBounce); controlScript.currentHitAnimation = moveSetScript.basicMoves.standingWallBounce.name; } } if (UFE.config.wallBounceOptions.bouncePrefab != null) { GameObject pTemp = UFE.SpawnGameObject(UFE.config.wallBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.wallBounceOptions.bounceKillTime * UFE.config.fps)); pTemp.transform.rotation = UFE.config.wallBounceOptions.bouncePrefab.transform.rotation; if (UFE.config.wallBounceOptions.sticky) { pTemp.transform.parent = transform; } //pTemp.transform.localPosition = Vector3.zero; } if (UFE.config.wallBounceOptions.shakeCamOnBounce) { controlScript.shakeCameraDensity = UFE.config.wallBounceOptions._shakeDensity; } UFE.PlaySound(UFE.config.wallBounceOptions.bounceSound); isWallBouncing = true; } worldTransform.Translate((horizontalForce * UFE.fixedDeltaTime), 0, 0); } if (move == null || (move != null && !move.ignoreGravity)) { if ((verticalForce < 0 && !IsGrounded()) || verticalForce > 0) { verticalForce -= appliedGravity * UFE.fixedDeltaTime; worldTransform.Translate((moveDirection * UFE.fixedDeltaTime) * controlScript.myInfo.physics._jumpDistance, (verticalForce * UFE.fixedDeltaTime), 0); } else if (verticalForce < 0 && IsGrounded() && controlScript.currentSubState != SubStates.Stunned) { verticalForce = 0; } } } Fix64 minDist = opWorldTransform.position.x - UFE.config.cameraOptions._maxDistance; Fix64 maxDist = opWorldTransform.position.x + UFE.config.cameraOptions._maxDistance; worldTransform.position = new FPVector(FPMath.Clamp(worldTransform.position.x, minDist, maxDist), worldTransform.position.y, worldTransform.position.z); worldTransform.position = new FPVector( FPMath.Clamp(worldTransform.position.x, UFE.config.selectedStage._leftBoundary, UFE.config.selectedStage._rightBoundary), FPMath.Max(worldTransform.position.y, UFE.config.selectedStage._groundHeight), worldTransform.position.z); if (controlScript.currentState == PossibleStates.Down) { return; } if (IsGrounded() && controlScript.currentState != PossibleStates.Down) { if (verticalTotalForce != 0) { if (groundBounceTimes < UFE.config.groundBounceOptions._maximumBounces && controlScript.currentSubState == SubStates.Stunned && UFE.config.groundBounceOptions.bounceForce != Sizes.None && verticalForce <= -UFE.config.groundBounceOptions._minimumBounceForce && controlScript.currentHit.groundBounce) { if (controlScript.currentHit.overrideForcesOnGroundBounce) { if (controlScript.currentHit.resetGroundBounceHorizontalPush) { horizontalForce = 0; } if (controlScript.currentHit.resetGroundBounceVerticalPush) { verticalForce = 0; } Fix64 addedH = controlScript.currentHit._groundBouncePushForce.x; Fix64 addedV = controlScript.currentHit._groundBouncePushForce.y; AddForce(new FPVector(addedH, addedV, 0), controlScript.mirror); } else { if (UFE.config.groundBounceOptions.bounceForce == Sizes.Small) { AddForce(new FPVector(0, (-verticalForce / 2.4), 0), 1); } else if (UFE.config.groundBounceOptions.bounceForce == Sizes.Medium) { AddForce(new FPVector(0, (-verticalForce / 1.8), 0), 1); } else if (UFE.config.groundBounceOptions.bounceForce == Sizes.High) { AddForce(new FPVector(0, (-verticalForce / 1.2), 0), 1); } } groundBounceTimes++; if (!isGroundBouncing) { controlScript.stunTime += airTime + UFE.config.knockDownOptions.air._knockedOutTime; if (moveSetScript.basicMoves.groundBounce.animMap[0].clip != null) { controlScript.currentHitAnimation = moveSetScript.basicMoves.groundBounce.name; moveSetScript.PlayBasicMove(moveSetScript.basicMoves.groundBounce); } if (UFE.config.groundBounceOptions.bouncePrefab != null) { GameObject pTemp = UFE.SpawnGameObject(UFE.config.groundBounceOptions.bouncePrefab, transform.position, Quaternion.identity, Mathf.RoundToInt(UFE.config.groundBounceOptions.bounceKillTime * UFE.config.fps)); pTemp.transform.rotation = UFE.config.groundBounceOptions.bouncePrefab.transform.rotation; if (UFE.config.groundBounceOptions.sticky) { pTemp.transform.parent = transform; } //pTemp.transform.localPosition = Vector3.zero; } if (UFE.config.groundBounceOptions.shakeCamOnBounce) { controlScript.shakeCameraDensity = UFE.config.groundBounceOptions._shakeDensity; } UFE.PlaySound(UFE.config.groundBounceOptions.bounceSound); isGroundBouncing = true; } return; } verticalTotalForce = 0; airTime = 0; moveSetScript.totalAirMoves = 0; currentAirJumps = 0; BasicMoveInfo airAnimation = null; string downAnimation = ""; isGroundBouncing = false; groundBounceTimes = 0; Fix64 animationSpeed = 0; Fix64 delayTime = 0; if (controlScript.currentMove != null && controlScript.currentMove.hitAnimationOverride) { return; } if (controlScript.currentSubState == SubStates.Stunned) { if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airRecovery.name)) { controlScript.stunTime = 0; controlScript.currentState = PossibleStates.Stand; } else { controlScript.stunTime = UFE.config.knockDownOptions.air._knockedOutTime + UFE.config.knockDownOptions.air._standUpTime; // Hit Clips if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitKnockBack.name) && moveSetScript.basicMoves.getHitKnockBack.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitHighKnockdown.name) && moveSetScript.basicMoves.getHitHighKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitHighKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.high._knockedOutTime + UFE.config.knockDownOptions.high._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitMidKnockdown.name) && moveSetScript.basicMoves.getHitMidKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitMidKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.highLow._knockedOutTime + UFE.config.knockDownOptions.highLow._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitSweep.name) && moveSetScript.basicMoves.getHitSweep.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitSweep; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.sweep._knockedOutTime + UFE.config.knockDownOptions.sweep._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.getHitCrumple.name) && moveSetScript.basicMoves.getHitCrumple.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.getHitCrumple; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); // Stage Clips } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.standingWallBounceKnockdown.name) && moveSetScript.basicMoves.standingWallBounceKnockdown.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.standingWallBounceKnockdown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime; } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.airWallBounce.name) && moveSetScript.basicMoves.airWallBounce.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); controlScript.stunTime = UFE.config.knockDownOptions.wallbounce._knockedOutTime + UFE.config.knockDownOptions.wallbounce._standUpTime; // Fall Clips } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromAirHit.name) && moveSetScript.basicMoves.fallingFromAirHit.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromAirHit; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else if (moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.fallingFromGroundBounce.name) && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[1].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce; downAnimation = moveSetScript.GetAnimationString(airAnimation, 2); } else { if (moveSetScript.basicMoves.fallDown.animMap[0].clip == null) { Debug.LogError("Fall Down From Air Hit animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Down From Air Hit"); } airAnimation = moveSetScript.basicMoves.fallDown; downAnimation = moveSetScript.GetAnimationString(airAnimation, 1); } controlScript.currentState = PossibleStates.Down; } } else if (controlScript.currentState != PossibleStates.Stand) { if (moveSetScript.basicMoves.landing.animMap[0].clip != null && (controlScript.currentMove == null || (controlScript.currentMove != null && controlScript.currentMove.cancelMoveWheLanding))) { controlScript.isAirRecovering = false; airAnimation = moveSetScript.basicMoves.landing; moveDirection = 0; isLanding = true; controlScript.KillCurrentMove(); delayTime = (Fix64)controlScript.myInfo.physics.landingDelay / (Fix64)UFE.config.fps; UFE.DelaySynchronizedAction(ResetLanding, delayTime); if (airAnimation.autoSpeed) { animationSpeed = moveSetScript.GetAnimationLength(airAnimation.name) / delayTime; } } if (controlScript.currentState != PossibleStates.Crouch) { controlScript.currentState = PossibleStates.Stand; } } if (airAnimation != null) { if (downAnimation != "") { moveSetScript.PlayBasicMove(airAnimation, downAnimation); } else { moveSetScript.PlayBasicMove(airAnimation); } if (animationSpeed != 0) { moveSetScript.SetAnimationSpeed(airAnimation.name, animationSpeed); } } } if (controlScript.currentSubState != SubStates.Stunned && !controlScript.isBlocking && !controlScript.blockStunned && move == null && !isTakingOff && !isLanding && controlScript.currentState == PossibleStates.Stand) { if (moveDirection > 0 && controlScript.mirror == -1 || moveDirection < 0 && controlScript.mirror == 1) { if (moveSetScript.basicMoves.moveForward.animMap[0].clip == null) { Debug.LogError("Move Forward animation not found! Make sure you have it set on Character -> Basic Moves -> Move Forward"); } if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveForward.name)) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveForward); } } else if (moveDirection > 0 && controlScript.mirror == 1 || moveDirection < 0 && controlScript.mirror == -1) { if (moveSetScript.basicMoves.moveBack.animMap[0].clip == null) { Debug.LogError("Move Back animation not found! Make sure you have it set on Character -> Basic Moves -> Move Back"); } if (!moveSetScript.IsAnimationPlaying(moveSetScript.basicMoves.moveBack.name)) { moveSetScript.PlayBasicMove(moveSetScript.basicMoves.moveBack); } } } } else if (verticalForce > 0 || !IsGrounded()) { if (move != null && controlScript.currentState == PossibleStates.Stand) { controlScript.currentState = PossibleStates.NeutralJump; } if (move == null && verticalForce / verticalTotalForce > 0 && verticalForce / verticalTotalForce <= 1) { if (isGroundBouncing) { return; } if (moveDirection == 0) { controlScript.currentState = PossibleStates.NeutralJump; } else { if (moveDirection > 0 && controlScript.mirror == -1 || moveDirection < 0 && controlScript.mirror == 1) { controlScript.currentState = PossibleStates.ForwardJump; } if (moveDirection > 0 && controlScript.mirror == 1 || moveDirection < 0 && controlScript.mirror == -1) { controlScript.currentState = PossibleStates.BackJump; } } BasicMoveInfo airAnimation = moveSetScript.basicMoves.jumpStraight; if (controlScript.currentSubState == SubStates.Stunned) { if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; } else if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null && FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce && UFE.config.comboOptions._knockBackMinForce > 0) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; airTime *= (Fix64)2; } else { if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null) { Debug.LogError("Get Hit Air animation not found! Make sure you have it set on Character -> Basic Moves -> Get Hit Air"); } airAnimation = moveSetScript.basicMoves.getHitAir; } if (overrideStunAnimation != null) { airAnimation = overrideStunAnimation; } } else if (controlScript.isAirRecovering && (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null)) { airAnimation = moveSetScript.basicMoves.airRecovery; } else { if (moveSetScript.basicMoves.jumpForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump) { airAnimation = moveSetScript.basicMoves.jumpForward; } else if (moveSetScript.basicMoves.jumpBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump) { airAnimation = moveSetScript.basicMoves.jumpBack; } else { if (moveSetScript.basicMoves.jumpStraight.animMap[0].clip == null) { Debug.LogError("Jump animation not found! Make sure you have it set on Character -> Basic Moves -> Jump Straight"); } airAnimation = moveSetScript.basicMoves.jumpStraight; } } if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name)) { moveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime)); } } } else if (move == null && verticalForce / verticalTotalForce <= 0) { BasicMoveInfo airAnimation = moveSetScript.basicMoves.fallStraight; if (isGroundBouncing && moveSetScript.basicMoves.fallingFromGroundBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromGroundBounce; } else if (isWallBouncing && moveSetScript.basicMoves.airWallBounce.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.airWallBounce; } else { if (controlScript.currentSubState == SubStates.Stunned) { if (moveSetScript.basicMoves.getHitKnockBack.animMap[0].clip != null && FPMath.Abs(horizontalForce) > UFE.config.comboOptions._knockBackMinForce && UFE.config.comboOptions._knockBackMinForce > 0) { airAnimation = moveSetScript.basicMoves.getHitKnockBack; } else { airAnimation = moveSetScript.basicMoves.getHitAir; if (moveSetScript.basicMoves.fallingFromAirHit.animMap[0].clip != null) { airAnimation = moveSetScript.basicMoves.fallingFromAirHit; } else if (moveSetScript.basicMoves.getHitAir.animMap[0].clip == null) { Debug.LogError("Air Juggle animation not found! Make sure you have it set on Character -> Basic Moves -> Air Juggle"); } } if (overrideStunAnimation != null) { airAnimation = overrideStunAnimation; } } else if (controlScript.isAirRecovering && (moveSetScript.basicMoves.airRecovery.animMap[0].clip != null)) { airAnimation = moveSetScript.basicMoves.airRecovery; } else { if (moveSetScript.basicMoves.fallForward.animMap[0].clip != null && controlScript.currentState == PossibleStates.ForwardJump) { airAnimation = moveSetScript.basicMoves.fallForward; } else if (moveSetScript.basicMoves.fallBack.animMap[0].clip != null && controlScript.currentState == PossibleStates.BackJump) { airAnimation = moveSetScript.basicMoves.fallBack; } else { if (moveSetScript.basicMoves.fallStraight.animMap[0].clip == null) { Debug.LogError("Fall animation not found! Make sure you have it set on Character -> Basic Moves -> Fall Straight"); } airAnimation = moveSetScript.basicMoves.fallStraight; } } } if (!overrideAirAnimation && !moveSetScript.IsAnimationPlaying(airAnimation.name)) { moveSetScript.PlayBasicMove(airAnimation); if (airAnimation.autoSpeed) { moveSetScript.SetAnimationNormalizedSpeed(airAnimation.name, (moveSetScript.GetAnimationLength(airAnimation.name) / airTime)); } } } } if (horizontalForce == 0 && verticalForce == 0) { moveDirection = 0; } }