protected virtual string ProcessMessage(string msg, ControlsScript controlsScript) { if (msg == UFE.config.selectedLanguage.combo) { if (this.announcer != null && !this.muteAnnouncer) { foreach (ComboAnnouncer comboAnnouncer in this.announcer.combos) { if (controlsScript.opControlsScript.comboHits >= comboAnnouncer.hits) { UFE.PlaySound(comboAnnouncer.audio); break; } } } } else if (msg == UFE.config.selectedLanguage.parry) { if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.parry); } UFE.PlaySound(UFE.config.blockOptions.parrySound); } else if (msg == UFE.config.selectedLanguage.counterHit) { if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.counterHit); } UFE.PlaySound(UFE.config.counterHitOptions.sound); } else if (msg == UFE.config.selectedLanguage.firstHit) { if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.firstHit); } } else if (msg == UFE.config.selectedLanguage.fight) { if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.fight); } } else if (msg == UFE.config.selectedLanguage.ko) { if (this.announcer != null && !this.muteAnnouncer && this.announcer.ko != null) { UFE.PlaySound(this.announcer.ko); } } else { return(this.SetStringValues(msg, null)); } return(this.SetStringValues(msg, controlsScript)); }
public static void MoveCursor(this UFEScreen screen, Vector3 direction, AudioClip moveCursorSound = null) { GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject; GameObject nextGameObject = null; if (currentGameObject != null && currentGameObject.activeInHierarchy) { Selectable currentSelectableObject = currentGameObject.GetComponent <Selectable>(); if (currentSelectableObject != null && currentSelectableObject.IsInteractable()) { Selectable nextSelectableObject = currentSelectableObject.FindSelectable(direction); if (nextSelectableObject != null) { nextGameObject = nextSelectableObject.gameObject; } } } if (nextGameObject == null) { nextGameObject = screen.FindFirstSelectableGameObject(); } if (currentGameObject != nextGameObject) { if (moveCursorSound != null) { UFE.PlaySound(moveCursorSound); } screen.HighlightOption(nextGameObject); } }
public override void OnShow() { base.OnShow(); this.HighlightOption(this.FindFirstSelectable()); 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); } if (buttonNetwork != null) { buttonNetwork.interactable = UFE.isNetworkAddonInstalled; } if (buttonBluetooth != null) { buttonBluetooth.interactable = UFE.isNetworkAddonInstalled && Application.isMobilePlatform; } }
protected virtual void MoveCursor(int characterIndex) { if (this.moveCursorSound != null) { UFE.PlaySound(this.moveCursorSound); } this.stageHoverIndex = characterIndex; }
public virtual void NextStage() { if (this.moveCursorSound != null) { UFE.PlaySound(this.moveCursorSound); } this.SetHoverIndex((this.stageHoverIndex + 1) % UFE.config.stages.Length); }
public virtual void PreviousStage() { int length = UFE.config.stages.Length; if (this.moveCursorSound != null) { UFE.PlaySound(this.moveCursorSound); } this.SetHoverIndex((this.stageHoverIndex + length - 1) % length); }
protected override void OnTimeOver() { base.OnTimeOver(); this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.timeOver, null), null); if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.timeOver); } }
/// <summary> /// Moves to target selection. Used for mouse support. /// Always does thing, so no need for boolean to verify. /// </summary> /// <param name="targetButton">A valid number between 0 and @MAX_BUTTONS - 1</param> public void _SelectTarget(int targetButton) { if (targetButton > MAX_BUTTONS - 1 || targetButton < 0) { CBUG.Error("TARGET BUTTON EXCEEDS MAXIMUM BUTTONS OF: " + MAX_BUTTONS); return; } currentPage.SelectTarget(targetButton); UFE.PlaySound(moveCursorSound); }
private static void DefaultCancelAction(this Action action, AudioClip sound) { if (sound != null) { UFE.PlaySound(sound); } if (action != null) { action(); } }
protected virtual void MoveCursor(int player, int characterIndex) { int previousIndex = this.GetHoverIndex(player); this.SetHoverIndex(player, characterIndex); int newIndex = this.GetHoverIndex(player); if (previousIndex != newIndex && this.moveCursorSound != null) { UFE.PlaySound(this.moveCursorSound); } }
public override void OnShow() { base.OnShow(); this.HighlightOption(this.FindFirstSelectable()); if (this.music != null) { UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic); } if (this.onLoadSound != null) { UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic); } }
protected override void OnRoundBegin(int roundNumber) { base.OnRoundBegin(roundNumber); if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null) { this.player1GUI.alert.text.text = string.Empty; } if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null) { this.player2GUI.alert.text.text = string.Empty; } if (roundNumber < UFE.config.roundOptions.totalRounds) { this.OnNewAlert(UFE.config.selectedLanguage.round, null); if (this.announcer != null && !this.muteAnnouncer) { if (roundNumber == 1) { UFE.PlaySound(this.announcer.round1); } if (roundNumber == 2) { UFE.PlaySound(this.announcer.round2); } if (roundNumber == 3) { UFE.PlaySound(this.announcer.round3); } if (roundNumber > 3) { UFE.PlaySound(this.announcer.otherRounds); } } } else { this.OnNewAlert(UFE.config.selectedLanguage.finalRound, null); if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.finalRound); } } }
public void _NextPage() { UFE.PlaySound(selectSound); Page nextPage = currentPage.OnSelect(); if (nextPage != null) { nextPage.PrevPage = currentPage; currentPage = nextPage; currentPageName = currentPage.Name; if (DEBUG_ON) { Debug.Log("Previous page has been set to: " + currentPage.PrevPage.Name); } } }
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 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); } }
public static void SelectOption(this UFEScreen screen, AudioClip selectSound = null) { // Retrieve the current selected object... GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject; if (currentGameObject != null) { // Check if it's a button... Button currentButton = currentGameObject.GetComponent <Button>(); if (currentButton != null) { // In that case, raise the "On Click" event if (currentButton.onClick != null) { if (selectSound != null) { UFE.PlaySound(selectSound); } currentButton.onClick.Invoke(); } } else { // Otherwise, check if it's a toggle... Toggle currentToggle = currentGameObject.GetComponent <Toggle>(); if (currentToggle != null) { // In that case, change the state of the toggle... currentToggle.isOn = !currentToggle.isOn; } } } else { currentGameObject = screen.FindFirstSelectableGameObject(); if (selectSound != null) { UFE.PlaySound(selectSound); } screen.HighlightOption(currentGameObject); } }
public static void MoveCursor(this UFEScreen screen, Vector3 direction, AudioClip moveCursorSound = null) { GameObject currentGameObject = UFE.eventSystem.currentSelectedGameObject; GameObject nextGameObject = screen.FindSelectableGameObject(direction); if (nextGameObject == null) { nextGameObject = currentGameObject; } if (currentGameObject != nextGameObject) { if (moveCursorSound != null) { UFE.PlaySound(moveCursorSound); } screen.HighlightOption(nextGameObject); } }
public override void OnShow() { base.OnShow(); this.HighlightOption(this.FindFirstSelectable()); if (this.music != null) { UFE.DelayLocalAction(delegate(){ UFE.PlayMusic(this.music); }, this.delayBeforePlayingMusic); } if (this.onLoadSound != null) { UFE.DelayLocalAction(delegate(){ UFE.PlaySound(this.onLoadSound); }, this.delayBeforePlayingMusic); } if (myInfoText != null) { myInfoText.text = "IP: " + GetIp() + "\nPort: " + UFE.config.networkOptions.port; } }
private static void DefaultConfirmAction(this GameObject gameObject, AudioClip sound) { // Check if the GameObject is defined... if (gameObject != null) { // Check if it's a button... Button currentButton = gameObject.GetComponent <Button>(); if (currentButton != null) { // In that case, raise the "On Click" event if (sound != null) { UFE.PlaySound(sound); } if (currentButton.onClick != null) { currentButton.onClick.Invoke(); } } else { // Otherwise, check if it's a toggle... Toggle currentToggle = gameObject.GetComponent <Toggle>(); if (currentToggle != null) { // In that case, change the state of the toggle... if (sound != null) { UFE.PlaySound(sound); } currentToggle.isOn = !currentToggle.isOn; } } } }
public void OnStageSelectionAllowed(int stageIndex) { if (!this.closing) { if (stageIndex >= 0 && stageIndex < UFE.config.stages.Length) { if (this.selectSound != null) { UFE.PlaySound(this.selectSound); } this.SetHoverIndex(stageIndex); UFE.config.selectedStage = UFE.config.stages[stageIndex]; this.StartLoadingBattleScreen(); } else if (stageIndex < 0) { if (UFE.config.selectedStage != null) { if (this.cancelSound != null) { UFE.PlaySound(this.cancelSound); } UFE.config.selectedStage = null; } else { if (this.cancelSound != null) { UFE.PlaySound(this.cancelSound); } this.StartLoadingCharacterSelectionScreen(); } } } }
public override void OnShow() { base.OnShow(); this.visible = true; 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); } if (this.musicToggle != null) { this.musicToggle.isOn = UFE.config.music; } if (this.musicSlider != null) { this.musicSlider.value = UFE.config.musicVolume; } if (this.soundToggle != null) { this.soundToggle.isOn = UFE.config.soundfx; } if (this.soundSlider != null) { this.soundSlider.value = UFE.config.soundfxVolume; } int difficultySettingsLength = UFE.config.aiOptions.difficultySettings.Length; AIDifficultySettings difficulty = UFE.GetAIDifficulty(); if (this.difficultySlider != null) { this.difficultySlider.minValue = 0; this.difficultySlider.maxValue = difficultySettingsLength - 1; this.difficultySlider.wholeNumbers = true; this.difficultySlider.value = this.GetDifficultyIndex(difficulty); } if (this.difficultyName != null) { this.difficultyName.text = difficulty.difficultyLevel.ToString(); } if (this.aiEngineName != null) { AIEngine aiEngine = UFE.GetAIEngine(); if (aiEngine == AIEngine.RandomAI) { this.aiEngineName.text = "Random"; } else { this.aiEngineName.text = "Fuzzy"; } } if (this.debugModeToggle != null) { this.debugModeToggle.isOn = UFE.config.debugOptions.debugMode; } if (this.diagnosticModeToggle != null) { GameObject nameObj = GameObject.Find("Name"); if (nameObj != null) { NameHolder name = nameObj.GetComponent <NameHolder>(); if (name != null) { this.diagnosticModeToggle.isOn = name.diagnosticMode; } else { Debug.Log("Could not find nameholder script"); } } else { Debug.Log("Could not find name object"); } } if (this.changeControlsButton != null) { this.changeControlsButton.gameObject.SetActive( UFE.isCInputInstalled && UFE.config.inputOptions.inputManagerType == InputManagerType.cInput ); } this.HighlightOption(this.FindFirstSelectable()); }
public override void OnShow() { // Set the portraits of the characters if (this.characters != null) { // First, update the portraits of the characters until we run out of characters or portrait slots.... CharacterInfo[] selectableCharacters = this.GetSelectableCharacters(); for (int i = 0; i < selectableCharacters.Length && i < this.characters.Length; ++i) { this.characters[i].gameObject.SetActive(true); this.characters[i].sprite = Sprite.Create( selectableCharacters[i].profilePictureSmall, new Rect(0f, 0f, selectableCharacters[i].profilePictureSmall.width, selectableCharacters[i].profilePictureSmall.height), new Vector2(0.5f * selectableCharacters[i].profilePictureSmall.width, 0.5f * selectableCharacters[i].profilePictureSmall.height) ); } // If there are more slots than characters, fill the remaining slots with the "No Character" sprite... // If the "No Character" sprite is undefined, hide the image instead. for (int i = selectableCharacters.Length; i < this.characters.Length; ++i) { if (this.noCharacterSprite != null) { this.characters[i].gameObject.SetActive(true); this.characters[i].sprite = this.noCharacterSprite; } else { this.characters[i].gameObject.SetActive(false); } } } 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); } if (UFE.gameMode == GameMode.StoryMode) { if (this.namePlayer2 != null) { this.namePlayer2.text = "???"; } if (this.portraitPlayer2 != null) { this.portraitPlayer2.gameObject.SetActive(false); } this.UpdateHud(); } else { this.SetHoverIndex(2, Mathf.Min(this.GetHoverIndex(2), this.charactersPerRow - 1)); if (this.portraitPlayer2 != null) { this.portraitPlayer2.gameObject.SetActive(true); } } }
// Update is called once per frame void Update() { #region UI Input if (canMove) { if (cInput.GetAxis("P1KeyboardVertical") > UpWeight) { //Goes "down" the list, visually downward on buttons. if (currentPage.SelectDown()) { UFE.PlaySound(moveCursorSound); if (DEBUG_ON) { Debug.Log("Moved Down a Button."); } } canMove = false; } if (cInput.GetAxis("P1KeyboardVertical") < DownWeight) { if (currentPage.SelectUp()) { UFE.PlaySound(moveCursorSound); if (DEBUG_ON) { Debug.Log("Moved Up a Button."); } } canMove = false; } } if (!canMove) { if (cInput.GetAxis("P1KeyboardVertical") < UpWeight && cInput.GetAxis("P1KeyboardVertical") > DownWeight) { canMove = true; } } if (cInput.GetButtonDown("P1Button1")) // CONFIRM OR SUBMIT BUTTON { if (DEBUG_ON) { Debug.Log("Confirm Button pressed!"); } _NextPage(); } if (cInput.GetButtonDown("P1Button2")) // BACK OR CANCEL BUTTON { if (DEBUG_ON) { Debug.Log("Back Button pressed!"); } if (currentPage.PrevPage != null) { UFE.PlaySound(cancelSound); if (DEBUG_ON) { Debug.Log("Going back a Page to: " + currentPage.PrevPage.Name); } currentPage = currentPage.PrevPage; currentPageName = currentPage.Name; } } #endregion }
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() { // We add these lines before base.OnShow() because they will affect how will the engine display // characters selected by default Camera.main.transform.position = UFE.config.cameraOptions.initialDistance; Camera.main.transform.eulerAngles = UFE.config.cameraOptions.initialRotation; Camera.main.fieldOfView = UFE.config.cameraOptions.initialFieldOfView; if (this.displayMode == DisplayMode.CharacterGameObject) { if (background3dPrefab != null) { this.background = GameObject.Instantiate(background3dPrefab); } UFE.canvas.planeDistance = 0.1f; UFE.canvas.worldCamera = Camera.main; UFE.canvas.renderMode = RenderMode.ScreenSpaceCamera; } base.OnShow(); this.characterButtonsWhiteList.Clear(); // Set the portraits of the characters if (this.characters != null) { // First, update the portraits of the characters until we run out of characters or portrait slots.... for (int i = 0; i < this.selectableCharacters.Length && i < this.characters.Length; ++i) { Image character = this.characters[i]; CharacterInfo selectableCharacter = this.selectableCharacters[i]; if (character != null) { character.gameObject.SetActive(true); character.sprite = Sprite.Create( selectableCharacter.profilePictureSmall, new Rect(0f, 0f, selectableCharacter.profilePictureSmall.width, selectableCharacter.profilePictureSmall.height), new Vector2(0.5f * selectableCharacter.profilePictureSmall.width, 0.5f * selectableCharacter.profilePictureSmall.height) ); Button button = character.GetComponent <Button>(); if (button == null) { button = character.gameObject.AddComponent <Button>(); } int index = i; button.onClick.AddListener(() => { this.TrySelectCharacter(index); }); button.targetGraphic = character; this.characterButtonsWhiteList.Add(button); } } // If there are more slots than characters, fill the remaining slots with the "No Character" sprite... // If the "No Character" sprite is undefined, hide the image instead. for (int i = this.selectableCharacters.Length; i < this.characters.Length; ++i) { Image character = this.characters[i]; if (character != null) { if (this.noCharacterSprite != null) { this.characters[i].gameObject.SetActive(true); this.characters[i].sprite = this.noCharacterSprite; } else { this.characters[i].gameObject.SetActive(false); } } } } 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); } this.SetHoverIndex(1, Mathf.Clamp(this.defaultCharacterPlayer1, 0, this.selectableCharacters.Length - 1)); if (UFE.gameMode == GameMode.StoryMode) { if (this.namePlayer2 != null) { this.namePlayer2.text = "???"; } if (this.portraitPlayer2 != null) { this.portraitPlayer2.gameObject.SetActive(false); } this.UpdateHud(); } else { this.SetHoverIndex(2, Mathf.Clamp(this.defaultCharacterPlayer2, 0, this.selectableCharacters.Length - 1)); if (this.portraitPlayer2 != null) { this.portraitPlayer2.gameObject.SetActive(true); } } }
protected override void OnRoundEnd(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser) { base.OnRoundEnd(winner, loser); // Find out who is the winner and who is the loser... int winnerPlayer = winner == this.player1.character ? 1 : 2; int loserPlayer = loser == this.player1.character ? 1 : 2; PlayerGUI winnerGUI = winnerPlayer == 1 ? this.player1GUI : this.player2GUI; PlayerGUI loserGUI = loserPlayer == 1 ? this.player1GUI : this.player2GUI; ControlsScript winnerControlsScript = UFE.GetControlsScript(winnerPlayer); // Then update the "Won Rounds" sprites... if (this.wonRounds.NotFinishedRounds == null) { Debug.LogError("\"Not Finished Rounds\" Sprite not found! Make sure you have set the sprite correctly in the Editor"); } else if (this.wonRounds.WonRounds == null) { Debug.LogError("\"Won Rounds\" Sprite not found! Make sure you have set the sprite correctly in the Editor"); } else if (this.wonRounds.LostRounds == null && this.wonRounds.VisibleImages == DefaultBattleGUI.VisibleImages.AllRounds) { Debug.LogError("\"Lost Rounds\" Sprite not found! If you want to display Lost Rounds, make sure you have set the sprite correctly in the Editor"); } else { // To calculate the target number of images, check if the "Lost Rounds" Sprite is defined or not int targetNumberOfImages = this.wonRounds.GetNumberOfRoundsImages(); if (this.wonRounds.VisibleImages == DefaultBattleGUI.VisibleImages.AllRounds) { // If the "Lost Rounds" sprite is defined, that means that we must display all won and lost rounds... if ( winnerGUI != null && winnerGUI.wonRoundsImages != null && winnerGUI.wonRoundsImages.Length >= targetNumberOfImages ) { winnerGUI.wonRoundsImages[UFE.config.currentRound - 1].sprite = this.wonRounds.WonRounds; } else { Debug.LogError( "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " + "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length + "\nMake sure you have set the images correctly in the Editor" ); } if ( loserGUI != null && loserGUI.wonRoundsImages != null && loserGUI.wonRoundsImages.Length >= targetNumberOfImages ) { loserGUI.wonRoundsImages[UFE.config.currentRound - 1].sprite = this.wonRounds.LostRounds; } else { Debug.LogError( "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " + "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length + "\nMake sure you have set the images correctly in the Editor" ); } } else { // If the "Lost Rounds" sprite is not defined, that means that we must only display won rounds... if ( winnerGUI != null && winnerGUI.wonRoundsImages != null && winnerGUI.wonRoundsImages.Length >= winnerControlsScript.roundsWon ) { winnerGUI.wonRoundsImages[winnerControlsScript.roundsWon - 1].sprite = this.wonRounds.WonRounds; } else if (UFE.gameMode != GameMode.ChallengeMode) { Debug.LogError( "Player " + winnerPlayer + ": not enough \"Won Rounds\" Images not found! " + "Expected:" + targetNumberOfImages + " / Found: " + winnerGUI.wonRoundsImages.Length + "\nMake sure you have set the images correctly in the Editor" ); } } } if (this.announcer != null && !this.muteAnnouncer) { // Check if it was the last round if (winnerControlsScript.roundsWon > Mathf.Ceil(UFE.config.roundOptions.totalRounds / 2)) { if (winnerPlayer == 1) { UFE.PlaySound(this.announcer.player1Wins); } else { UFE.PlaySound(this.announcer.player2Wins); } } // Finally, check if we should play any AudioClip if (winnerControlsScript.myInfo.currentLifePoints == winnerControlsScript.myInfo.lifePoints) { UFE.PlaySound(this.announcer.perfect); } } if (winnerControlsScript.myInfo.currentLifePoints == winnerControlsScript.myInfo.lifePoints) { this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.perfect, winnerControlsScript), null); } if (UFE.gameMode != GameMode.ChallengeMode && winnerControlsScript.roundsWon > Mathf.Ceil(UFE.config.roundOptions.totalRounds / 2)) { this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.victory, winnerControlsScript), null); UFE.PlayMusic(UFE.config.roundOptions.victoryMusic); } else if (UFE.gameMode == GameMode.ChallengeMode) { this.OnNewAlert(this.SetStringValues(UFE.config.selectedLanguage.challengeEnds, winnerControlsScript), null); UFE.PlayMusic(UFE.config.roundOptions.victoryMusic); } }
protected override void OnRoundBegin(int roundNumber) { base.OnRoundBegin(roundNumber); if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null) { this.player1GUI.alert.text.text = string.Empty; } if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null) { this.player2GUI.alert.text.text = string.Empty; } if (UFE.gameMode == GameMode.ChallengeMode) { this.OnNewAlert(UFE.config.selectedLanguage.challengeBegins, null); } else if (roundNumber < UFE.config.roundOptions.totalRounds) { this.OnNewAlert(UFE.config.selectedLanguage.round, null); if (this.announcer != null && !this.muteAnnouncer) { if (roundNumber == 1) { UFE.PlaySound(this.announcer.round1); } if (roundNumber == 2) { UFE.PlaySound(this.announcer.round2); } if (roundNumber == 3) { UFE.PlaySound(this.announcer.round3); } if (roundNumber > 3) { UFE.PlaySound(this.announcer.otherRounds); } } } else { this.OnNewAlert(UFE.config.selectedLanguage.finalRound, null); if (this.announcer != null && !this.muteAnnouncer) { UFE.PlaySound(this.announcer.finalRound); } // If network game, point which character the local player is if ((UFE.gameMode == GameMode.NetworkGame || UFE.config.debugOptions.emulateNetwork) && networkPlayerPointer != null) { int localPlayer = 1; if (UFE.isConnected) { localPlayer = UFE.localPlayerController.player; } GameObject pointer = new GameObject("Local Pointer"); pointer.transform.SetParent(UFE.GetControlsScript(localPlayer).transform); pointer.transform.localPosition = new Vector3(0, 7, 0); SpriteRenderer spriteRenderer = pointer.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = networkPlayerPointer; Destroy(pointer, pointerTimer); } } // If network game, point which character the local player is if ((UFE.gameMode == GameMode.NetworkGame || UFE.config.debugOptions.emulateNetwork) && networkPlayerPointer != null) { int localPlayer = 1; if (UFE.isConnected) { localPlayer = UFE.localPlayerController.player; } GameObject pointer = new GameObject("Local Pointer"); pointer.transform.SetParent(UFE.GetControlsScript(localPlayer).transform); pointer.transform.localPosition = new Vector3(0, 7, 0); SpriteRenderer spriteRenderer = pointer.AddComponent <SpriteRenderer>(); spriteRenderer.sprite = networkPlayerPointer; Destroy(pointer, pointerTimer); } }
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); } 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; } } this.stageHoverIndex = 0; StageOptions stage = UFE.config.stages[this.stageHoverIndex]; if (stage != null) { if (this.screenshotStage != null) { this.screenshotStage.sprite = Sprite.Create( stage.screenshot, new Rect(0f, 0f, stage.screenshot.width, stage.screenshot.height), new Vector2(0.5f * stage.screenshot.width, 0.5f * stage.screenshot.height) ); } if (this.nameStage != null) { this.nameStage.text = stage.stageName; } } }
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 static void DefaultNavigationSystem( this UFEScreen screen, AudioClip selectSound = null, AudioClip moveCursorSound = null, Action cancelAction = null, AudioClip cancelSound = null ) { // Retrieve the controller assigned to each player AbstractInputController p1InputController = UFE.GetPlayer1Controller(); AbstractInputController p2InputController = UFE.GetPlayer2Controller(); // Retrieve the values of the horizontal and vertical axis float p1HorizontalAxis = p1InputController.GetAxisRaw(p1InputController.horizontalAxis); float p1VerticalAxis = p1InputController.GetAxisRaw(p1InputController.verticalAxis); bool p1AxisDown = p1InputController.GetButtonDown(p1InputController.horizontalAxis) || p1InputController.GetButtonDown(p1InputController.verticalAxis); float p2HorizontalAxis = p2InputController.GetAxisRaw(p2InputController.horizontalAxis); float p2VerticalAxis = p2InputController.GetAxisRaw(p2InputController.verticalAxis); bool p2AxisDown = p2InputController.GetButtonDown(p2InputController.horizontalAxis) || p2InputController.GetButtonDown(p2InputController.verticalAxis); // Check if we should change the selected option if (p1AxisDown) { screen.MoveCursor(new Vector3(p1HorizontalAxis, p1VerticalAxis), moveCursorSound); } if (p1InputController.GetButtonDown(UFE.config.inputOptions.confirmButton)) { screen.SelectOption(selectSound); } else if (p1InputController.GetButtonDown(UFE.config.inputOptions.cancelButton)) { if (cancelSound != null) { UFE.PlaySound(cancelSound); } if (cancelAction != null) { cancelAction(); } } else { if (p2AxisDown) { screen.MoveCursor(new Vector3(p2HorizontalAxis, p2VerticalAxis), moveCursorSound); } if (p2InputController.GetButtonDown(UFE.config.inputOptions.confirmButton)) { screen.SelectOption(selectSound); } else if (p2InputController.GetButtonDown(UFE.config.inputOptions.cancelButton)) { if (cancelSound != null) { UFE.PlaySound(cancelSound); } if (cancelAction != null) { cancelAction(); } } } }