示例#1
0
    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);
    }
示例#2
0
    protected virtual void OnGameBegin(UFE3D.CharacterInfo player1, UFE3D.CharacterInfo player2, StageOptions stage)
    {
        this.player1.character  = player1;
        this.player1.targetLife = player1.lifePoints;
        this.player1.totalLife  = player1.lifePoints;
        this.player1.wonRounds  = 0;

        this.player2.character  = player2;
        this.player2.targetLife = player2.lifePoints;
        this.player2.totalLife  = player2.lifePoints;
        this.player2.wonRounds  = 0;

        UFE.PlayMusic(stage.music);
        this.isRunning = true;
    }
示例#3
0
    protected virtual string SetStringValues(string msg, ControlsScript controlsScript)
    {
        UFE3D.CharacterInfo character = controlsScript != null ? controlsScript.myInfo : null;
        if (controlsScript != null)
        {
            msg = msg.Replace("%combo%", controlsScript.opControlsScript.comboHits.ToString());
        }
        if (character != null)
        {
            msg = msg.Replace("%character%", character.characterName);
        }
        msg = msg.Replace("%round%", UFE.config.currentRound.ToString());

        return(msg);
    }
示例#4
0
 protected virtual void OnButtonPress(ButtonPress buttonPress, UFE3D.CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
     if (player.playerNum == 1 &&
         !complete &&
         !UFE.config.lockInputs &&
         UFE.gameMode == GameMode.ChallengeMode &&
         challengeActions[currentAction].actionType == ActionType.ButtonPress &&
         challengeActions[currentAction].button == buttonPress)
     {
         currentAction++;
         testChallenge();
     }
     else
     {
         currentAction = 0;
     }
 }
示例#5
0
 protected virtual void OnMove(MoveInfo move, UFE3D.CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
     if (player.playerNum == 1 &&
         !complete &&
         !UFE.config.lockInputs &&
         UFE.gameMode == GameMode.ChallengeMode &&
         challengeActions[currentAction].actionType == ActionType.SpecialMove &&
         challengeActions[currentAction].specialMove == move)
     {
         currentAction++;
         testChallenge();
     }
     else
     {
         currentAction = 0;
     }
 }
示例#6
0
    protected virtual void OnSideSwitch(int side, UFE3D.CharacterInfo player)
    {
        // Fires when a character switches orientation
        // player.playerNum = 1 or 2

        /*if (player.playerNum == 1) {
         *  leftZoneRegular.SetActive(false);
         *  rightZoneRegular.SetActive(false);
         *  leftZoneMirror.SetActive(false);
         *  rightZoneMirror.SetActive(false);
         *
         *  if (side == -1) {
         *      leftZoneMirror.SetActive(true);
         *      rightZoneMirror.SetActive(true);
         *  } else {
         *      leftZoneRegular.SetActive(true);
         *      rightZoneRegular.SetActive(true);
         *  }
         * }*/
    }
示例#7
0
    private static bool RetrieveSelection()
    {
        globalInfo    = null;
        characterInfo = null;
        moveInfo      = null;
        UnityEngine.Object[] selection = Selection.GetFiltered(typeof(GlobalInfo), SelectionMode.Assets);
        if (selection.Length > 0)
        {
            if (selection[0] == null)
            {
                return(false);
            }
            globalInfo = (GlobalInfo)selection[0];
        }
        selection = Selection.GetFiltered(typeof(UFE3D.CharacterInfo), SelectionMode.Assets);
        if (selection.Length > 0)
        {
            if (selection[0] == null)
            {
                return(false);
            }
            characterInfo = (UFE3D.CharacterInfo)selection[0];
        }
        selection = Selection.GetFiltered(typeof(MoveInfo), SelectionMode.Assets);
        if (selection.Length > 0)
        {
            if (selection[0] == null)
            {
                return(false);
            }
            moveInfo = (MoveInfo)selection[0];
        }

        if (globalInfo == null && characterInfo == null && moveInfo == null)
        {
            EditorUtility.DisplayDialog("UFE Upgrade", "Must be a valid UFE file", "Ok");
            return(false);
        }

        return(true);
    }
示例#8
0
    protected override void OnGameEnd(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser)
    {
        base.OnGameEnd(winner, loser);

        if (this.player1GUI.name != null)
        {
            this.player1GUI.name.text = string.Empty;
        }
        if (this.player2GUI.name != null)
        {
            this.player2GUI.name.text = string.Empty;
        }
        if (this.info != null)
        {
            this.info.text = string.Empty;
        }
        if (this.timer != null)
        {
            this.timer.text = string.Empty;
        }
    }
示例#9
0
 protected virtual void OnBasicMove(BasicMoveReference basicMove, UFE3D.CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
 }
示例#10
0
 protected virtual void OnRoundEnd(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser)
 {
     //++this.player1WonRounds;
     //++this.playe21WonRounds;
 }
示例#11
0
    private static void CharacterUpdate(UFE3D.CharacterInfo character)
    {
        character.version          = 2f;
        character._executionTiming = character.executionTiming;
        character._blendingTime    = character.blendingTime;

        // Character Physics
        character.physics._moveForwardSpeed    = character.physics.moveForwardSpeed;
        character.physics._moveBackSpeed       = character.physics.moveBackSpeed;
        character.physics._friction            = character.physics.friction;
        character.physics._minJumpForce        = character.physics.minJumpForce;
        character.physics._jumpDistance        = character.physics.jumpDistance;
        character.physics._weight              = character.physics.weight;
        character.physics._groundCollisionMass = character.physics.groundCollisionMass;

        // Move Set
        if (character.moves != null && character.moves.Length > 0)
        {
            foreach (MoveSetData moveSetData in character.moves)
            {
                // Basic Moves
                BasicMoveUpdate(moveSetData.basicMoves.idle);
                BasicMoveUpdate(moveSetData.basicMoves.moveForward);
                BasicMoveUpdate(moveSetData.basicMoves.moveBack);
                BasicMoveUpdate(moveSetData.basicMoves.crouching);

                BasicMoveUpdate(moveSetData.basicMoves.takeOff);
                BasicMoveUpdate(moveSetData.basicMoves.jumpStraight);
                BasicMoveUpdate(moveSetData.basicMoves.jumpBack);
                BasicMoveUpdate(moveSetData.basicMoves.jumpForward);
                BasicMoveUpdate(moveSetData.basicMoves.fallStraight);
                BasicMoveUpdate(moveSetData.basicMoves.fallBack);
                BasicMoveUpdate(moveSetData.basicMoves.fallForward);
                BasicMoveUpdate(moveSetData.basicMoves.landing);

                BasicMoveUpdate(moveSetData.basicMoves.blockingHighPose);
                BasicMoveUpdate(moveSetData.basicMoves.blockingHighHit);
                BasicMoveUpdate(moveSetData.basicMoves.blockingLowHit);
                BasicMoveUpdate(moveSetData.basicMoves.blockingCrouchingPose);
                BasicMoveUpdate(moveSetData.basicMoves.blockingCrouchingHit);
                BasicMoveUpdate(moveSetData.basicMoves.blockingAirPose);
                BasicMoveUpdate(moveSetData.basicMoves.blockingAirHit);

                BasicMoveUpdate(moveSetData.basicMoves.parryHigh);
                BasicMoveUpdate(moveSetData.basicMoves.parryLow);
                BasicMoveUpdate(moveSetData.basicMoves.parryCrouching);
                BasicMoveUpdate(moveSetData.basicMoves.parryAir);

                BasicMoveUpdate(moveSetData.basicMoves.getHitHigh);
                BasicMoveUpdate(moveSetData.basicMoves.getHitLow);
                BasicMoveUpdate(moveSetData.basicMoves.getHitCrouching);
                BasicMoveUpdate(moveSetData.basicMoves.getHitAir);
                BasicMoveUpdate(moveSetData.basicMoves.getHitKnockBack);
                BasicMoveUpdate(moveSetData.basicMoves.getHitHighKnockdown);
                BasicMoveUpdate(moveSetData.basicMoves.getHitMidKnockdown);
                BasicMoveUpdate(moveSetData.basicMoves.getHitSweep);
                BasicMoveUpdate(moveSetData.basicMoves.getHitCrumple);

                BasicMoveUpdate(moveSetData.basicMoves.fallDown);
                BasicMoveUpdate(moveSetData.basicMoves.groundBounce);
                BasicMoveUpdate(moveSetData.basicMoves.airWallBounce);
                BasicMoveUpdate(moveSetData.basicMoves.fallingFromGroundBounce);
                BasicMoveUpdate(moveSetData.basicMoves.standUp);

                // Special Moves
                foreach (MoveInfo moveInfo in moveSetData.attackMoves)
                {
                    SpecialMoveUpdate(moveInfo);
                }
                SpecialMoveUpdate(moveSetData.cinematicIntro);
                SpecialMoveUpdate(moveSetData.cinematicOutro);
            }
        }

        EditorUtility.SetDirty(character);
        Debug.Log("Character " + character.characterName + " updated.");
    }
示例#12
0
    // ---------------
    private void OnGameEnds(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser)
    {
//Debug.Log(ControlFreak2.CFUtils.LogPrefix() + "OnGameEnds");
        this.ShowBattleControls(false, false);
    }
示例#13
0
    // -------------
    private void OnRoundEnds(UFE3D.CharacterInfo winner, UFE3D.CharacterInfo loser)
    {
//Debug.Log(ControlFreak2.CFUtils.LogPrefix() + "Round Ends");
        //	this.ShowBattleControls(false, true);
    }
    public override void SetHoverIndex(int player, int characterIndex)
    {
        if (!this.closing)
        {
            int maxCharacterIndex = this.GetMaxCharacterIndex();
            this.p1HoverIndex = Mathf.Clamp(this.p1HoverIndex, 0, maxCharacterIndex);
            this.p2HoverIndex = Mathf.Clamp(this.p2HoverIndex, 0, maxCharacterIndex);
            base.SetHoverIndex(player, characterIndex);

            if (characterIndex >= 0 && characterIndex <= maxCharacterIndex)
            {
                UFE3D.CharacterInfo character = this.selectableCharacters[characterIndex];

                // First, update the big portrait or the character 3D model (depending on the Display Mode)
                if (player == 1)
                {
                    if (this.namePlayer1 != null)
                    {
                        this.namePlayer1.text = character.characterName;
                    }

                    if (this.displayMode == DisplayMode.CharacterPortrait)
                    {
                        if (this.portraitPlayer1 != null)
                        {
                            this.portraitPlayer1.sprite = Sprite.Create(
                                character.profilePictureBig,
                                new Rect(0f, 0f, character.profilePictureBig.width, character.profilePictureBig.height),
                                new Vector2(0.5f * character.profilePictureBig.width, 0.5f * character.profilePictureBig.height)
                                );
                        }
                    }
                    else
                    {
                        UFE3D.CharacterInfo characterInfo = UFE.config.characters[characterIndex];
                        if (this.gameObjectPlayer1 != null)
                        {
                            GameObject.Destroy(this.gameObjectPlayer1);
                        }


                        AnimationClip clip =
                            characterInfo.selectionAnimation != null ?
                            characterInfo.selectionAnimation :
                            characterInfo.moves[0].basicMoves.idle.animMap[0].clip;


                        if (characterInfo.characterPrefabStorage == StorageMode.Prefab)
                        {
                            this.gameObjectPlayer1 = GameObject.Instantiate(characterInfo.characterPrefab);
                        }
                        else
                        {
                            this.gameObjectPlayer1 = GameObject.Instantiate(Resources.Load <GameObject>(characterInfo.prefabResourcePath));
                        }
                        //this.gameObjectPlayer1 = GameObject.Instantiate(characterInfo.characterPrefab);
                        this.gameObjectPlayer1.transform.position = this.positionPlayer1;
                        this.gameObjectPlayer1.transform.SetParent(this.transform, true);

                        HitBoxesScript hitBoxes = this.gameObjectPlayer1.GetComponent <HitBoxesScript>();
                        if (hitBoxes != null)
                        {
                            foreach (HitBox hitBox in hitBoxes.hitBoxes)
                            {
                                if (hitBox != null && hitBox.bodyPart != BodyPart.none && hitBox.position != null)
                                {
                                    hitBox.position.gameObject.SetActive(hitBox.defaultVisibility);
                                }
                            }
                        }

                        if (characterInfo.animationType == AnimationType.Legacy)
                        {
                            Animation animation = this.gameObjectPlayer1.GetComponent <Animation>();
                            if (animation == null)
                            {
                                animation = this.gameObjectPlayer1.AddComponent <Animation>();
                            }

                            animation.AddClip(clip, "Idle");
                            animation.wrapMode = WrapMode.Loop;
                            animation.Play("Idle");
                        }
                        else
                        {
                            Animator animator = this.gameObjectPlayer1.GetComponent <Animator>();
                            if (animator == null)
                            {
                                animator = this.gameObjectPlayer1.AddComponent <Animator>();
                            }

                            AnimatorOverrideController overrideController = new AnimatorOverrideController();
                            overrideController.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("MC_Controller");
                            overrideController["State2"] = clip;

                            animator.avatar                    = characterInfo.avatar;
                            animator.applyRootMotion           = characterInfo.applyRootMotion;
                            animator.runtimeAnimatorController = overrideController;
                            animator.Play("State2");
                        }
                    }
                }
                else if (player == 2)
                {
                    if (this.namePlayer2 != null)
                    {
                        this.namePlayer2.text = character.characterName;
                    }

                    if (this.displayMode == DisplayMode.CharacterPortrait)
                    {
                        if (this.portraitPlayer2 != null)
                        {
                            this.portraitPlayer2.sprite = Sprite.Create(
                                character.profilePictureBig,
                                new Rect(0f, 0f, character.profilePictureBig.width, character.profilePictureBig.height),
                                new Vector2(0.5f * character.profilePictureBig.width, 0.5f * character.profilePictureBig.height)
                                );
                        }
                    }
                    else
                    {
                        UFE3D.CharacterInfo characterInfo = UFE.config.characters[characterIndex];
                        if (this.gameObjectPlayer2 != null)
                        {
                            GameObject.Destroy(this.gameObjectPlayer2);
                        }

                        if (UFE.gameMode != GameMode.StoryMode)
                        {
                            AnimationClip clip =
                                characterInfo.selectionAnimation != null ?
                                characterInfo.selectionAnimation :
                                characterInfo.moves[0].basicMoves.idle.animMap[0].clip;

                            if (characterInfo.characterPrefabStorage == StorageMode.Prefab)
                            {
                                this.gameObjectPlayer2 = GameObject.Instantiate(characterInfo.characterPrefab);
                            }
                            else
                            {
                                this.gameObjectPlayer2 = GameObject.Instantiate(Resources.Load <GameObject>(characterInfo.prefabResourcePath));
                            }
                            //this.gameObjectPlayer2 = GameObject.Instantiate(characterInfo.characterPrefab);
                            this.gameObjectPlayer2.transform.position      = this.positionPlayer2;
                            this.gameObjectPlayer2.transform.localRotation = Quaternion.Euler(0f, -90f, 0f);
                            this.gameObjectPlayer2.transform.SetParent(this.transform, true);

                            HitBoxesScript hitBoxes = this.gameObjectPlayer2.GetComponent <HitBoxesScript>();
                            if (hitBoxes != null)
                            {
                                foreach (HitBox hitBox in hitBoxes.hitBoxes)
                                {
                                    if (hitBox != null && hitBox.bodyPart != BodyPart.none && hitBox.position != null)
                                    {
                                        hitBox.position.gameObject.SetActive(hitBox.defaultVisibility);
                                    }
                                }
                            }

                            if (characterInfo.animationType == AnimationType.Legacy)
                            {
                                Animation animation = this.gameObjectPlayer2.GetComponent <Animation>();
                                if (animation == null)
                                {
                                    animation = this.gameObjectPlayer2.AddComponent <Animation>();
                                }

                                this.gameObjectPlayer2.transform.localScale = new Vector3(
                                    -this.gameObjectPlayer2.transform.localScale.x,
                                    this.gameObjectPlayer2.transform.localScale.y,
                                    this.gameObjectPlayer2.transform.localScale.z
                                    );

                                animation.AddClip(clip, "Idle");
                                animation.wrapMode = WrapMode.Loop;
                                animation.Play("Idle");
                            }
                            else
                            {
                                Animator animator = this.gameObjectPlayer2.GetComponent <Animator>();
                                if (animator == null)
                                {
                                    animator = this.gameObjectPlayer2.AddComponent <Animator>();
                                }

                                // Mecanim, mirror via Animator...
                                AnimatorOverrideController overrideController = new AnimatorOverrideController();
                                overrideController.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("MC_Controller");
                                overrideController["State3"] = clip;

                                animator.avatar                    = characterInfo.avatar;
                                animator.applyRootMotion           = characterInfo.applyRootMotion;
                                animator.runtimeAnimatorController = overrideController;
                                animator.Play("State3");
                            }
                        }
                    }
                }

                // Deal with alternative colors if both players have selected the same character

                /*if (this.gameObjectPlayer2 != null && this.displayMode == DisplayMode.CharacterGameObject){
                 *      UFE3D.CharacterInfo p2CharacterInfo = UFE.config.characters[this.p2HoverIndex];
                 *      if (p2CharacterInfo.enableAlternativeColor && this.p1HoverIndex == this.p2HoverIndex){
                 *              foreach(Renderer renderer in this.gameObjectPlayer2.GetComponentsInChildren<Renderer>()){
                 *                      renderer.material.color = p2CharacterInfo.alternativeColor;
                 *              }
                 *      }else{
                 *              Renderer[] originalRenderers = p2CharacterInfo.characterPrefab.GetComponentsInChildren<Renderer>(true);
                 *              Renderer[] instanceRenderers = this.gameObjectPlayer2.GetComponentsInChildren<Renderer>(true);
                 *
                 *              for (int i = 0; i < originalRenderers.Length && i < instanceRenderers.Length; ++i){
                 *                      instanceRenderers[i].material.color = originalRenderers[i].sharedMaterial.color;
                 *              }
                 *      }
                 * }*/

                // Then, update the cursor position
                if (this.hudPlayer1 != null)
                {
                    RectTransform rt = this.hudPlayer1.transform as RectTransform;
                    if (rt != null)
                    {
                        rt.anchoredPosition = this.characters[this.p1HoverIndex].rectTransform.anchoredPosition;
                    }
                    else
                    {
                        this.hudPlayer1.transform.position = this.characters[this.p1HoverIndex].transform.position;
                    }
                }

                if (this.hudPlayer2 != null)
                {
                    RectTransform rt = this.hudPlayer2.transform as RectTransform;
                    if (rt != null)
                    {
                        rt.anchoredPosition = this.characters[this.p2HoverIndex].rectTransform.anchoredPosition;
                    }
                    else
                    {
                        this.hudPlayer2.transform.position = this.characters[this.p2HoverIndex].transform.position;
                    }
                }

                if (this.hudBothPlayers != null)
                {
                    RectTransform rt = this.hudBothPlayers.transform as RectTransform;
                    if (rt != null)
                    {
                        rt.anchoredPosition = this.characters[this.p2HoverIndex].rectTransform.anchoredPosition;
                    }
                    else
                    {
                        this.hudBothPlayers.transform.position = this.characters[this.p2HoverIndex].transform.position;
                    }
                }
            }

            this.UpdateHud();
        }
    }
    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];
                UFE3D.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);
            }
        }
    }
示例#16
0
 protected virtual void OnParticleEffects(MoveInfo move, UFE3D.CharacterInfo player, MoveParticleEffect particleEffects)
 {
     // Fires when a move casts a particle effect
     // player.playerNum = 1 or 2
 }
示例#17
0
 protected virtual void OnLifePointsChange(float newFloat, UFE3D.CharacterInfo player)
 {
     // You can use this to have your own custom events when a player's life points changes
     // player.playerNum = 1 or 2
 }
示例#18
0
    protected override void OnNewAlert(string msg, UFE3D.CharacterInfo player)
    {
        base.OnNewAlert(msg, player);


        // You can use this to have your own custom events when a new text alert is fired from the engine
        if (player != null)
        {
            if (player.playerNum == 1)
            {
                ControlsScript controlsScript   = UFE.GetControlsScript(1);
                string         processedMessage = this.ProcessMessage(msg, controlsScript);

                if (this.player1GUI != null && this.player1GUI.alert != null && this.player1GUI.alert.text != null)
                {
                    this.player1GUI.alert.text.text = processedMessage;

                    if (
                        msg != UFE.config.selectedLanguage.combo ||
                        controlsScript.opControlsScript.comboHits == 2 ||
                        UFE.config.comboOptions.comboDisplayMode == ComboDisplayMode.ShowAfterComboExecution
                        )
                    {
                        this.player1GUI.alert.text.rectTransform.anchoredPosition = this.player1GUI.alert.initialPosition;
                    }
                    this.player1AlertTimer = 2f;
                }
            }
            else
            {
                ControlsScript controlsScript   = UFE.GetPlayer2ControlsScript();
                string         processedMessage = this.ProcessMessage(msg, controlsScript);

                if (this.player2GUI != null && this.player2GUI.alert != null && this.player2GUI.alert.text != null)
                {
                    this.player2GUI.alert.text.text = processedMessage;

                    if (
                        msg != UFE.config.selectedLanguage.combo ||
                        controlsScript.opControlsScript.comboHits == 2 ||
                        UFE.config.comboOptions.comboDisplayMode == ComboDisplayMode.ShowAfterComboExecution
                        )
                    {
                        this.player2GUI.alert.text.rectTransform.anchoredPosition = this.player2GUI.alert.initialPosition;
                    }
                    this.player2AlertTimer = 2f;
                }
            }
        }
        else
        {
            string processedMessage = this.ProcessMessage(msg, null);

            if (this.mainAlert != null && this.mainAlert.text != null)
            {
                this.mainAlert.text.text = processedMessage;

                if (msg == UFE.config.selectedLanguage.round || msg == UFE.config.selectedLanguage.finalRound)
                {
                    this.mainAlertTimer = 2f;
                }
                else if (msg == UFE.config.selectedLanguage.challengeBegins)
                {
                    this.mainAlertTimer = 2f;
                }
                else if (msg == UFE.config.selectedLanguage.fight)
                {
                    this.mainAlertTimer = 1f;
                }
                else if (msg == UFE.config.selectedLanguage.ko)
                {
                    this.mainAlertTimer = 2f;
                }
                else
                {
                    this.mainAlertTimer = 60f;
                }
            }
        }
    }
示例#19
0
 protected virtual void OnNewAlert(string msg, UFE3D.CharacterInfo player)
 {
     // You can use this to have your own custom events when a new text alert is fired from the engine
     // player.playerNum = 1 or 2
 }
示例#20
0
    protected override void OnGameBegin(UFE3D.CharacterInfo player1, UFE3D.CharacterInfo player2, StageOptions stage)
    {
        base.OnGameBegin(player1, player2, stage);

        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.player1GUI != null &&
                this.player1GUI.wonRoundsImages != null &&
                this.player1GUI.wonRoundsImages.Length >= targetNumberOfImages
                )
            {
                for (int i = 0; i < targetNumberOfImages; ++i)
                {
                    this.player1GUI.wonRoundsImages[i].enabled = true;
                    this.player1GUI.wonRoundsImages[i].sprite  = this.wonRounds.NotFinishedRounds;
                }

                for (int i = targetNumberOfImages; i < this.player1GUI.wonRoundsImages.Length; ++i)
                {
                    this.player1GUI.wonRoundsImages[i].enabled = false;
                }
            }
            else
            {
                Debug.LogError(
                    "Player 1: not enough \"Won Rounds\" Images not found! " +
                    "Expected:" + targetNumberOfImages + " / Found: " + this.player1GUI.wonRoundsImages.Length +
                    "\nMake sure you have set the images correctly in the Editor"
                    );
            }

            if (
                this.player2GUI != null &&
                this.player2GUI.wonRoundsImages != null &&
                this.player2GUI.wonRoundsImages.Length >= targetNumberOfImages
                )
            {
                for (int i = 0; i < targetNumberOfImages; ++i)
                {
                    this.player2GUI.wonRoundsImages[i].enabled = true;
                    this.player2GUI.wonRoundsImages[i].sprite  = this.wonRounds.NotFinishedRounds;
                }

                for (int i = targetNumberOfImages; i < this.player2GUI.wonRoundsImages.Length; ++i)
                {
                    this.player2GUI.wonRoundsImages[i].enabled = false;
                }
            }
            else
            {
                Debug.LogError(
                    "Player 2: not enough \"Won Rounds\" Images not found! " +
                    "Expected:" + targetNumberOfImages + " / Found: " + this.player2GUI.wonRoundsImages.Length +
                    "\nMake sure you have set the images correctly in the Editor"
                    );
            }
        }

        // Set the character names
        if (this.player1GUI != null && this.player1GUI.name != null)
        {
            this.player1GUI.name.text = player1.characterName;
        }

        if (this.player2GUI != null && this.player2GUI.name != null)
        {
            this.player2GUI.name.text = player2.characterName;
        }

        // Set the character portraits
        if (this.player1GUI != null && this.player1GUI.portrait != null)
        {
            if (player1.profilePictureSmall != null)
            {
                this.player1GUI.portrait.gameObject.SetActive(true);
                this.player1GUI.portrait.sprite = Sprite.Create(
                    player1.profilePictureSmall,
                    new Rect(0f, 0f, player1.profilePictureSmall.width, player1.profilePictureSmall.height),
                    new Vector2(0.5f * player1.profilePictureSmall.width, 0.5f * player1.profilePictureSmall.height)
                    );
            }
            else
            {
                this.player1GUI.portrait.gameObject.SetActive(false);
            }
        }

        if (this.player2GUI != null && this.player2GUI.portrait != null)
        {
            if (player2.profilePictureSmall != null)
            {
                this.player2GUI.portrait.gameObject.SetActive(true);
                this.player2GUI.portrait.sprite = Sprite.Create(
                    player2.profilePictureSmall,
                    new Rect(0f, 0f, player2.profilePictureSmall.width, player2.profilePictureSmall.height),
                    new Vector2(0.5f * player2.profilePictureSmall.width, 0.5f * player2.profilePictureSmall.height)
                    );
            }
            else
            {
                this.player2GUI.portrait.gameObject.SetActive(false);
            }
        }

        // If we want to use a Timer, set the default value for the timer
        if (this.timer != null)
        {
            if (UFE.config.roundOptions.hasTimer)
            {
                this.timer.gameObject.SetActive(true);
                this.timer.text = UFE.config.roundOptions._timer.ToString().Replace("Infinity", "∞");
            }
            else
            {
                this.timer.gameObject.SetActive(false);
            }
        }

        // Set the max and min values for the Life Bars and the Gauge Meters
        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.gameObject.SetActive(true);
                this.player1GUI.gaugeMeter.fillAmount = (float)UFE.config.player1Character.currentGaugePoints / UFE.config.player1Character.maxGaugePoints;
            }

            if (this.player2 != null && this.player2GUI.gaugeMeter != null)
            {
                this.player2GUI.gaugeMeter.gameObject.SetActive(true);
                this.player2GUI.gaugeMeter.fillAmount = (float)UFE.config.player2Character.currentGaugePoints / UFE.config.player2Character.maxGaugePoints;
            }
        }
        else
        {
            if (this.player1GUI != null && this.player1GUI.gaugeMeter != null)
            {
                this.player1GUI.gaugeMeter.gameObject.SetActive(false);
            }

            if (this.player2GUI != null && this.player2GUI.gaugeMeter != null)
            {
                this.player2GUI.gaugeMeter.gameObject.SetActive(false);
            }
        }
    }
示例#21
0
 protected virtual void OnMove(MoveInfo move, UFE3D.CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
 }
示例#22
0
 protected virtual void OnParry(HitBox strokeHitBox, MoveInfo move, UFE3D.CharacterInfo player)
 {
     // You can use this to have your own custom events when a character parries an attack
     // player.playerNum = 1 or 2
     // player = character parrying
 }
示例#23
0
 protected virtual void OnBlock(HitBox strokeHitBox, MoveInfo move, UFE3D.CharacterInfo player)
 {
     // You can use this to have your own custom events when a player blocks.
     // player.playerNum = 1 or 2
     // player = character blocking
 }
示例#24
0
 protected virtual void OnHit(HitBox strokeHitBox, MoveInfo move, UFE3D.CharacterInfo player)
 {
     // player.playerNum = 1 or 2
     // You can use this to have your own custom events when a character gets hit
 }
示例#25
0
 protected virtual void OnButtonPress(ButtonPress buttonPress, UFE3D.CharacterInfo player)
 {
     // Fires when a player successfully executes a move
     // player.playerNum = 1 or 2
 }
示例#26
0
 protected virtual void OnBodyVisibilityChange(MoveInfo move, UFE3D.CharacterInfo player, BodyPartVisibilityChange bodyPartVisibilityChange, HitBox hitBox)
 {
     // Fires when a move casts a body part visibility change
     // player.playerNum = 1 or 2
 }
示例#27
0
    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);
        }
    }
示例#28
0
    public virtual void OnCharacterSelectionAllowed(int characterIndex, int player)
    {
        // If we haven't started loading a different screen....
        if (!this.closing)
        {
            // Check if we are trying to select or deselect a character...
            if (characterIndex >= 0 && characterIndex <= this.GetMaxCharacterIndex())
            {
                // If we are selecting a character, check if the player has already selected a character...
                if (
                    player == 1 && UFE.config.player1Character == null ||
                    player == 2 && UFE.config.player2Character == null
                    )
                {
                    // If the player hasn't selected any character yet, process the request...
                    this.SetHoverIndex(player, characterIndex);
                    UFE3D.CharacterInfo character = this.selectableCharacters[characterIndex];
                    if (this.selectSound != null)
                    {
                        UFE.PlaySound(this.selectSound);
                    }
                    if (character != null && character.selectionSound != null)
                    {
                        UFE.PlaySound(character.selectionSound);
                    }
                    UFE.SetPlayer(player, character);


                    // And check if we should start loading the next screen...
                    if (
                        UFE.config.player1Character != null &&
                        (UFE.config.player2Character != null || UFE.gameMode == GameMode.StoryMode)
                        )
                    {
                        this.GoToNextScreen();
                    }
                }
            }
            else if (characterIndex < 0)
            {
                if (
                    // If we are trying to deselect a character, check if at least one player has selected a character
                    UFE.config.player1Character != null || UFE.config.player2Character != null
                    ||
                    // In network games, we also allow to return to the previous screen if the one of the player
                    // doesn't have a character selected and he presses the back button. We want to return to the
                    // previous screen even if the other player has a character selected.
                    UFE.gameMode == GameMode.NetworkGame
                    &&
                    (
                        player == 1 && UFE.config.player1Character != null ||
                        player == 2 && UFE.config.player2Character != null
                    )
                    )
                {
                    // In that case, check if the player that wants to deselect his current character has already
                    // selected a character and try to deselect that character.
                    if (
                        player == 1 && UFE.config.player1Character != null ||
                        player == 2 && UFE.config.player2Character != null
                        )
                    {
                        if (this.cancelSound != null)
                        {
                            UFE.PlaySound(this.cancelSound);
                        }
                        UFE.SetPlayer(player, null);
                    }
                }
                else
                {
                    // If none of the players has selected a character and one of the player wanted to deselect
                    // his current character, that means that the player wants to return to the previous menu instead.
                    this.GoToPreviousScreen();
                }
            }
        }
    }