void Update() { if (!isRunning) { return; } // Animate the alert message if it exists if (player1AlertGO != null) { GOTween(player1AlertGO, player1AlertLocation, 15); } if (player2AlertGO != null) { GOTween(player2AlertGO, player2AlertLocation, 15); } // Animate life points when it goes down (P1) if (player1TargetLife > UFE.config.player1Character.currentLifePoints) { player1TargetLife -= 5; // The speed the life moves down } if (player1TargetLife < UFE.config.player1Character.currentLifePoints) { player1TargetLife = UFE.config.player1Character.currentLifePoints; } // Animate life points when it goes down (P2) if (player2TargetLife > UFE.config.player2Character.currentLifePoints) { player2TargetLife -= 5; // The speed the life moves down } if (player2TargetLife < UFE.config.player2Character.currentLifePoints) { player2TargetLife = UFE.config.player2Character.currentLifePoints; } if (Input.GetKeyDown(KeyCode.Escape) && !UFE.isPaused()) { UFE.PauseGame(true); } else if (Input.GetKeyDown(KeyCode.Escape)) { UFE.PauseGame(false); } }
public override void DoFixedUpdate( IDictionary <InputReferences, InputEvents> player1PreviousInputs, IDictionary <InputReferences, InputEvents> player1CurrentInputs, IDictionary <InputReferences, InputEvents> player2PreviousInputs, IDictionary <InputReferences, InputEvents> player2CurrentInputs ) { base.DoFixedUpdate(player1PreviousInputs, player1CurrentInputs, player2PreviousInputs, player2CurrentInputs); if (this.isRunning) { float deltaTime = (float)UFE.fixedDeltaTime; // Animate the alert messages if they exist if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null) { this.player1GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp( this.player1GUI.alert.text.rectTransform.anchoredPosition, this.player1GUI.alert.finalPosition, this.player1GUI.alert.movementSpeed * deltaTime ); if (this.player1AlertTimer > 0f) { this.player1AlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.player1GUI.alert.text.text)) { this.player1GUI.alert.text.text = string.Empty; } } if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null) { this.player2GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp( this.player2GUI.alert.text.rectTransform.anchoredPosition, this.player2GUI.alert.finalPosition, this.player2GUI.alert.movementSpeed * deltaTime ); if (this.player2AlertTimer > 0f) { this.player2AlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.player2GUI.alert.text.text)) { this.player2GUI.alert.text.text = string.Empty; } } if (this.mainAlert != null && this.mainAlert.text != null) { if (this.mainAlertTimer > 0f) { this.mainAlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.mainAlert.text.text)) { this.mainAlert.text.text = string.Empty; } } // Animate life points when it goes down (P1) if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints) { this.player1.targetLife -= this.lifeDownSpeed * deltaTime; if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints) { this.player1.targetLife = (float)UFE.config.player1Character.currentLifePoints; } } if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints) { this.player1.targetLife += this.lifeUpSpeed * deltaTime; if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints) { this.player1.targetLife = (float)UFE.config.player1Character.currentLifePoints; } } // Animate life points when it goes down (P2) if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints) { this.player2.targetLife -= this.lifeDownSpeed * deltaTime; if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints) { this.player2.targetLife = (float)UFE.config.player2Character.currentLifePoints; } } if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints) { this.player2.targetLife += this.lifeUpSpeed * deltaTime; if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints) { this.player2.targetLife = (float)UFE.config.player2Character.currentLifePoints; } } bool player1CurrentStartButton = false; foreach (KeyValuePair <InputReferences, InputEvents> pair in player1CurrentInputs) { if (pair.Key.inputType == InputType.Button && pair.Key.engineRelatedButton == ButtonPress.Start) { player1CurrentStartButton = pair.Value.button; break; } } bool player1PreviousStartButton = false; foreach (KeyValuePair <InputReferences, InputEvents> pair in player1PreviousInputs) { if (pair.Key.inputType == InputType.Button && pair.Key.engineRelatedButton == ButtonPress.Start) { player1PreviousStartButton = pair.Value.button; break; } } bool player2CurrentStartButton = false; foreach (KeyValuePair <InputReferences, InputEvents> pair in player2CurrentInputs) { if (pair.Key.inputType == InputType.Button && pair.Key.engineRelatedButton == ButtonPress.Start) { player2CurrentStartButton = pair.Value.button; break; } } bool player2PreviousStartButton = false; foreach (KeyValuePair <InputReferences, InputEvents> pair in player2PreviousInputs) { if (pair.Key.inputType == InputType.Button && pair.Key.engineRelatedButton == ButtonPress.Start) { player2PreviousStartButton = pair.Value.button; break; } } if ( // Check if both players have their life points above zero... UFE.config.player1Character.currentLifePoints > 0 && UFE.config.player2Character.currentLifePoints > 0 && UFE.gameMode != GameMode.NetworkGame && ( // and at least one of the players have pressed the Start button... player1CurrentStartButton && !player1PreviousStartButton || player2CurrentStartButton && !player2PreviousStartButton ) ) { // In that case, we can process pause menu events UFE.PauseGame(!UFE.isPaused()); } // Draw the Life Bars and Gauge Meters using the data stored in UFE.config.guiOptions if (this.player1GUI != null && this.player1GUI.lifeBar != null) { this.player1GUI.lifeBar.fillAmount = this.player1.targetLife / this.player1.totalLife; } if (this.player2GUI != null && this.player2GUI.lifeBar != null) { this.player2GUI.lifeBar.fillAmount = this.player2.targetLife / this.player2.totalLife; } if (UFE.config.gameGUI.hasGauge) { if (this.player1GUI != null && this.player1GUI.gaugeMeter != null) { this.player1GUI.gaugeMeter.fillAmount = (float)UFE.config.player1Character.currentGaugePoints / UFE.config.player1Character.maxGaugePoints; } if (this.player2GUI != null && this.player2GUI.gaugeMeter != null) { this.player2GUI.gaugeMeter.fillAmount = (float)UFE.config.player2Character.currentGaugePoints / UFE.config.player2Character.maxGaugePoints; } } if (this.pause != null) { this.pause.DoFixedUpdate(player1PreviousInputs, player1CurrentInputs, player2PreviousInputs, player2CurrentInputs); } /* * if (Debug.isDebugBuild){ * player1NameGO.guiText.text = string.Format( * "{0}\t\t({1},\t{2},\t{3})", * this.player1.characterName, * UFE.GetPlayer1ControlsScript().transform.position.x, * UFE.GetPlayer1ControlsScript().transform.position.y, * UFE.GetPlayer1ControlsScript().transform.position.z * ); * * player2NameGO.guiText.text = string.Format( * "{0}\t\t({1},\t{2},\t{3})", * this.player2.characterName, * UFE.GetPlayer2ControlsScript().transform.position.x, * UFE.GetPlayer2ControlsScript().transform.position.y, * UFE.GetPlayer2ControlsScript().transform.position.z * ); * } */ } }
public override void DoFixedUpdate() { base.DoFixedUpdate(); if (this.isRunning) { AbstractInputController p1InputController = UFE.GetPlayer1Controller(); AbstractInputController p2InputController = UFE.GetPlayer2Controller(); float deltaTime = Time.fixedDeltaTime; // Animate the alert messages if they exist if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null) { this.player1GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp( this.player1GUI.alert.text.rectTransform.anchoredPosition, this.player1GUI.alert.finalPosition, this.player1GUI.alert.movementSpeed * deltaTime ); if (this.player1AlertTimer > 0f) { this.player1AlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.player1GUI.alert.text.text)) { this.player1GUI.alert.text.text = string.Empty; } } if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null) { this.player2GUI.alert.text.rectTransform.anchoredPosition = Vector3.Lerp( this.player2GUI.alert.text.rectTransform.anchoredPosition, this.player2GUI.alert.finalPosition, this.player2GUI.alert.movementSpeed * deltaTime ); if (this.player2AlertTimer > 0f) { this.player2AlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.player2GUI.alert.text.text)) { this.player2GUI.alert.text.text = string.Empty; } } if (this.mainAlert != null && this.mainAlert.text != null) { if (this.mainAlertTimer > 0f) { this.mainAlertTimer -= deltaTime; } else if (!string.IsNullOrEmpty(this.mainAlert.text.text)) { this.mainAlert.text.text = string.Empty; } } // Animate life points when it goes down (P1) if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints) { this.player1.targetLife -= this.lifeDownSpeed * deltaTime; if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints) { this.player1.targetLife = UFE.config.player1Character.currentLifePoints; } } if (this.player1.targetLife < UFE.config.player1Character.currentLifePoints) { this.player1.targetLife += this.lifeUpSpeed * deltaTime; if (this.player1.targetLife > UFE.config.player1Character.currentLifePoints) { this.player1.targetLife = UFE.config.player1Character.currentLifePoints; } } // Animate life points when it goes down (P2) if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints) { this.player2.targetLife -= this.lifeDownSpeed * deltaTime; if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints) { this.player2.targetLife = UFE.config.player2Character.currentLifePoints; } } if (this.player2.targetLife < UFE.config.player2Character.currentLifePoints) { this.player2.targetLife += this.lifeUpSpeed * deltaTime; if (this.player2.targetLife > UFE.config.player2Character.currentLifePoints) { this.player2.targetLife = UFE.config.player2Character.currentLifePoints; } } if ( // Check if both players have their life points above zero... UFE.config.player1Character.currentLifePoints > 0 && UFE.config.player2Character.currentLifePoints > 0 && UFE.gameMode != GameMode.NetworkGame && ( // and at least one of the players have pressed the Start button... p1InputController != null && p1InputController.GetButtonDown(ButtonPress.Start) || p2InputController != null && p2InputController.GetButtonDown(ButtonPress.Start) ) ) { // In that case, we can process pause menu events UFE.PauseGame(!UFE.isPaused()); } // Draw the Life Bars and Gauge Meters using the data stored in UFE.config.guiOptions if (this.player1GUI != null && this.player1GUI.lifeBar != null) { this.player1GUI.lifeBar.fillAmount = this.player1.targetLife / this.player1.totalLife; } if (this.player2GUI != null && this.player2GUI.lifeBar != null) { this.player2GUI.lifeBar.fillAmount = this.player2.targetLife / this.player2.totalLife; } if (UFE.config.gameGUI.hasGauge) { if (this.player1GUI != null && this.player1GUI.gaugeMeter != null) { this.player1GUI.gaugeMeter.fillAmount = UFE.config.player1Character.currentGaugePoints / UFE.config.player1Character.maxGaugePoints; } if (this.player2GUI != null && this.player2GUI.gaugeMeter != null) { this.player2GUI.gaugeMeter.fillAmount = UFE.config.player2Character.currentGaugePoints / UFE.config.player2Character.maxGaugePoints; } } if (this.pause != null) { this.pause.DoFixedUpdate(); } /* * if (Debug.isDebugBuild){ * player1NameGO.guiText.text = string.Format( * "{0}\t\t({1},\t{2},\t{3})", * this.player1.characterName, * UFE.GetPlayer1ControlsScript().transform.position.x, * UFE.GetPlayer1ControlsScript().transform.position.y, * UFE.GetPlayer1ControlsScript().transform.position.z * ); * * player2NameGO.guiText.text = string.Format( * "{0}\t\t({1},\t{2},\t{3})", * this.player2.characterName, * UFE.GetPlayer2ControlsScript().transform.position.x, * UFE.GetPlayer2ControlsScript().transform.position.y, * UFE.GetPlayer2ControlsScript().transform.position.z * ); * } */ } }
public virtual void ResumeGame() { UFE.PauseGame(false); }
void OnGUI() { GUI.skin = customSkin; if (showSpecials) { GUI.skin.label.fontSize = 14; } else { GUI.skin.label.fontSize = 20; } if (showControls && UFE.isPaused()) { GUI.BeginGroup(new Rect(Screen.width / 2 - 250, Screen.height / 2 - 200, 500, 400)); { GUI.Box(new Rect(0, 0, 500, 400), "Options"); GUI.BeginGroup(new Rect(15, 0, 480, 400)); { GUILayoutUtility.GetRect(1, 25, GUILayout.Width(470)); if (showSpecials) { GUILayout.Label("Fireball - Down, Forward, Punch (any)"); GUILayout.Label("Dragon Punch - Forward, Down, Forward, Punch (any)"); GUILayout.Label("Super Fireball - Down, Forward, Down, Forward, Light Punch"); GUILayout.Label("Super Dragon Punch - Down, Forward, Down, Forward, Medium Punch"); GUILayout.Label("Custom Combo 1:"); GUILayout.Label("Light Punch, Light Kick, Medium Kick, Heavy Kick"); GUILayout.Label("Custom Combo 2:"); GUILayout.Label("Light Punch, Heavy Dragon Punch"); GUILayout.Label("Custom Combo 3:"); GUILayout.Label("Crouching Light Punch, Crouching Light Kick, Crouching Medium Punch,"); GUILayout.Label("Crouching Medium Kick, Crouching Heavy Kick"); GUILayout.Label("Custom Combo 4:"); GUILayout.Label("Crouching Medium Kick, Crouching Heavy Punch, Jump, Medium Kick,"); GUILayout.Label("Medium Punch, (land) Crouching Heavy Punch, Super Fireball"); } else { GUILayout.BeginHorizontal(); { GUILayout.Label("Player 1"); GUILayout.FlexibleSpace(); GUILayout.Label("Player 2"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Controls - W A S D"); GUILayout.FlexibleSpace(); GUILayout.Label("Controls - Arrow Keys"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Light Punch - T"); GUILayout.FlexibleSpace(); GUILayout.Label("Light Punch - Insert"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Light Kick - G"); GUILayout.FlexibleSpace(); GUILayout.Label("Light Kick - Delete"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Medium Punch - Y"); GUILayout.FlexibleSpace(); GUILayout.Label("Medium Punch - Home"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Medium Kick - H"); GUILayout.FlexibleSpace(); GUILayout.Label("Medium Kick - End"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Heavy Punch - U"); GUILayout.FlexibleSpace(); GUILayout.Label("Heavy Punch - Page Up"); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.Label("Heavy Kick - J"); GUILayout.FlexibleSpace(); GUILayout.Label("Heavy Kick - Page Down"); } GUILayout.EndHorizontal(); } GUILayoutUtility.GetRect(1, 5); GUILayout.BeginHorizontal(); { if (showSpecials) { if (GUILayout.Button("Controls")) { showSpecials = false; } } else { if (GUILayout.Button("Specials")) { showSpecials = true; } } GUILayout.FlexibleSpace(); if (GUILayout.Button("Back")) { showControls = false; } } GUILayout.EndHorizontal(); } GUI.EndGroup(); } GUI.EndGroup(); } else if (!showEndMenu && UFE.isPaused()) { GUI.BeginGroup(new Rect(Screen.width / 2 - 200, Screen.height / 2 - 130, 400, 260)); { GUI.Box(new Rect(0, 0, 400, 260), "Options"); GUI.BeginGroup(new Rect(15, 0, 380, 260)); { GUILayoutUtility.GetRect(1, 45); GUILayout.BeginHorizontal(); { GUILayout.Label("Music", GUILayout.Width(240)); if (UFE.GetMusic()) { if (GUILayout.Button("On", GUILayout.Width(120))) { UFE.SetMusic(false); } } else { if (GUILayout.Button("Off", GUILayout.Width(120))) { UFE.SetMusic(true); } } } GUILayout.EndHorizontal(); if (UFE.GetMusic()) { GUILayout.BeginHorizontal(); { GUILayout.Label("Music Volume", GUILayout.Width(240)); UFE.SetVolume(GUILayout.HorizontalSlider(UFE.GetVolume(), 0, 1, GUILayout.Width(120))); } GUILayout.EndHorizontal(); } else { GUILayoutUtility.GetRect(1, 34); } GUILayout.BeginHorizontal(); { GUILayout.Label("Sound FX", GUILayout.Width(240)); if (UFE.GetSoundFX()) { if (GUILayout.Button("On", GUILayout.Width(120))) { UFE.SetSoundFX(false); } } else { if (GUILayout.Button("Off", GUILayout.Width(120))) { UFE.SetSoundFX(true); } } } GUILayout.EndHorizontal(); GUILayoutUtility.GetRect(1, 30); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Controls", GUILayout.Width(200))) { showControls = true; } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Special Moves", GUILayout.Width(200))) { showSpecials = true; showControls = true; } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Main Menu", GUILayout.Width(200))) { UFE.StartIntro(2); showEndMenu = false; Destroy(mainAlertGO); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Close")) { UFE.PauseGame(false); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } GUI.EndGroup(); } GUI.EndGroup(); } if (showEndMenu) { GUI.BeginGroup(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 20, 200, 130)); { GUI.Box(new Rect(0, 0, 200, 100), ""); { GUILayoutUtility.GetRect(1, 2); /*GUILayout.BeginHorizontal();{ // Not functional * GUILayout.FlexibleSpace(); * if (GUILayout.Button("Rematch", GUILayout.Width(200))) { * UFE.StartGame(2); * showMenu = false; * Destroy(mainAlertGO); * } * GUILayout.FlexibleSpace(); * }GUILayout.EndHorizontal();*/ GUILayoutUtility.GetRect(1, 20); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Character Select", GUILayout.Width(200))) { UFE.StartCharacterSelect(2); showEndMenu = false; Destroy(mainAlertGO); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayoutUtility.GetRect(1, 20); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (GUILayout.Button("Main Menu", GUILayout.Width(200))) { UFE.StartIntro(2); showEndMenu = false; Destroy(mainAlertGO); } GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); } } GUI.EndGroup(); } if (!isRunning) { return; } // Draw the lifebars and gauge bars using the data stored in UFE.config.guiOptions DrawBar(UFE.config.guiOptions.lifeBarOptions1, Side.Left, player1TargetLife, player1TotalLife, true); DrawBar(UFE.config.guiOptions.lifeBarOptions2, Side.Right, player2TargetLife, player2TotalLife, true); DrawBar(UFE.config.guiOptions.gaugeBarOptions1, Side.Left, UFE.config.player1Character.currentGaugePoints, UFE.config.player2Character.maxGaugePoints, false); DrawBar(UFE.config.guiOptions.gaugeBarOptions1, Side.Right, UFE.config.player2Character.currentGaugePoints, UFE.config.player2Character.maxGaugePoints, false); }
public virtual void GoToMainMenu() { UFE.PauseGame(false); UFE.StartMainMenuScreen(); }
void pauseFn() { pauseOnce = true; UFE.PauseGame(true); }