Exemplo n.º 1
0
    void Start()
    {
        if (ChangeableVariables.levelWeAreIn == "3x3_1" || ChangeableVariables.levelWeAreIn == "3x3_2")
        {
            tL = GameObject.Find("Tutorial").GetComponent <TutorialLevel> ();
        }

        //  fire an event to change shapes directions (how we control the shape) - "switch feature"
        //  because we can rotate the camera before we decide to switch shapes
        //  and because the new shape each time takes the directions that used to be
        //  we need to change them
        SpawnCubes.switchMovements += ChangeDirections;

        scCtrl = GameObject.Find("Platform").GetComponent <ScoreController> ();

        dS = transform.GetComponent <DisablingScripts> ();

        zOc = transform.GetComponentInChildren <ZeroOverlappingCases> ();

        currentState = PossibleStates.TurnOff;
        cC           = GetComponentsInChildren <CubeController> ();

        spawner = GameObject.FindGameObjectWithTag("Spawner");
        sC      = (SpawnCubes)spawner.GetComponent(typeof(SpawnCubes));
        mC      = GetComponent <MovingController> ();

        directions = GameObject.FindGameObjectWithTag("Directions");
        dfc        = (DirectionsFollowingCamera)directions.GetComponent(typeof(DirectionsFollowingCamera));
    }
Exemplo n.º 2
0
        private void SetPossibleStates(int maxState)
        {
            var possibleStates = new List <string>();

            possibleStates.Add("-");
            for (var i = 1; i <= maxState; i++)
            {
                possibleStates.Add('a' + i.ToString());
            }

            PossibleStates.Clear();
            PossibleStates.AddRange(possibleStates);
        }
        /// <summary>
        /// Changes the status of the object
        /// </summary>
        /// <param name="state"></param>
        protected virtual void SetStatus(PossibleStates state)
        {
            switch (state)
            {
            case PossibleStates.Active:
                TargetGameObject.SetActive(true);
                break;

            case PossibleStates.Inactive:
                TargetGameObject.SetActive(false);
                break;

            case PossibleStates.Toggle:
                TargetGameObject.SetActive(!TargetGameObject.activeInHierarchy);
                break;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Changes the status of the Behaviour
        /// </summary>
        /// <param name="state"></param>
        protected virtual void SetStatus(PossibleStates state)
        {
            switch (state)
            {
            case PossibleStates.Enabled:
                TargetBehaviour.enabled = true;
                break;

            case PossibleStates.Disabled:
                TargetBehaviour.enabled = false;
                break;

            case PossibleStates.Toggle:
                TargetBehaviour.enabled = !TargetBehaviour.enabled;
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Changes the status of the Behaviour
        /// </summary>
        /// <param name="state"></param>
        protected virtual void SetStatus(PossibleStates state)
        {
            switch (state)
            {
            case PossibleStates.Enabled:
                TargetBehaviour.enabled = NormalPlayDirection ? true : false;
                break;

            case PossibleStates.Disabled:
                TargetBehaviour.enabled = NormalPlayDirection ? false : true;
                break;

            case PossibleStates.Toggle:
                TargetBehaviour.enabled = !TargetBehaviour.enabled;
                break;
            }
        }
        /// <summary>
        /// Changes the status of the object
        /// </summary>
        /// <param name="state"></param>
        protected virtual void SetStatus(PossibleStates state)
        {
            bool newState = false;

            switch (state)
            {
            case PossibleStates.Active:
                newState = NormalPlayDirection ? true : false;
                break;

            case PossibleStates.Inactive:
                newState = NormalPlayDirection ? false : true;
                break;

            case PossibleStates.Toggle:
                newState = !TargetGameObject.activeInHierarchy;
                break;
            }
            TargetGameObject.SetActive(newState);
        }
Exemplo n.º 7
0
    //---------------------------------------------------
    // Sets State and Animator Controller bool true and the rest of the bools to false

    public void SetStateTo(PossibleStates stateToSet)
    {
        for (int i = 0; i < animator.parameterCount; i++)
        {
            if (animator.GetParameter(i).name == stateToSet.ToString())
            {
                animator.SetBool(stateToSet.ToString(), true);
                currentState = stateToSet;
            }

            else
            {
                // If it is a Bool then sets it to false. So it doesn't try to set the Speed Variable
                if (animator.GetParameter(i).type == AnimatorControllerParameterType.Bool)
                {
                    animator.SetBool(animator.GetParameter(i).name, false);
                }
            }
        }
    }
Exemplo n.º 8
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            _finiteStateMachine.SetEvent((int)PossibleEvents.ToggleStartWait);
        }
        _actualState = (PossibleStates)_finiteStateMachine.GetState();

        switch (_actualState)
        {
        case PossibleStates.Wait:
            break;

        case PossibleStates.Come:
            transform.position = Vector3.MoveTowards(transform.position, DestinationGo.transform.position, Time.deltaTime * MoveVelocity);
            break;

        case PossibleStates.Go:
            transform.position = Vector3.MoveTowards(transform.position, DestinationCome.transform.position, Time.deltaTime * MoveVelocity);
            break;
        }
    }
Exemplo n.º 9
0
        public UptimeReport CalculateUptimePerIntervals()
        {
            UptimePerIntervals = RelevantTimespans.Select(relevantTimespan =>
            {
                var since       = CalculatedOn - relevantTimespan;
                var events      = StateChanges.Where(s => s.NobreakState.Timestamp >= since).ToList();
                var rightBefore = StateChanges.SkipWhile(s => s.NobreakState.Timestamp >= (events.LastOrDefault()?.NobreakState.Timestamp ?? DateTime.Now)).FirstOrDefault();
                if (rightBefore != null)
                {
                    events.Add(rightBefore);
                }
                var sumPerState = PossibleStates.Select(s => new KeyValuePair <PowerStates, TimeSpan>(s, TimeSpan.Zero)).ToDictionary();
                for (int i = 0; i < events.Count; i++)
                {
                    sumPerState[events[i].PowerState] += events[i].NobreakState.Timestamp < since
                        ? events[i].Duration - (CalculatedOn - relevantTimespan - events[i].NobreakState.Timestamp)
                        : events[i].Duration;
                }
                var sum = TimeSpan.Zero;
                foreach (var state in sumPerState)
                {
                    sum += state.Value;
                }

                return(new UptimeInInterval
                {
                    UptimeStates = sumPerState.Select(stateSum => new UptimeState
                    {
                        ShareTimespan = stateSum.Value,
                        SharePercentage = stateSum.Value / sum * 100,
                        PowerState = stateSum.Key
                    }).ToList(),
                    Since = since,
                    TimeSpan = relevantTimespan
                });
            }).ToList();
            return(this);
        }
Exemplo n.º 10
0
    private void translateInputs(AbstractInputController inputController)
    {
        if (!introPlayed || !opControlsScript.introPlayed) return;
        if (UFE.config.lockInputs && !UFE.config.roundOptions.allowMovement) return;
        if (UFE.config.lockMovements) return;

        foreach (InputReferences inputRef in inputController.inputReferences) {
            if (((inputRef.engineRelatedButton == ButtonPress.Down && inputController.GetAxisRaw(inputRef) >= 0)
                 || (inputRef.engineRelatedButton == ButtonPress.Up && inputController.GetAxisRaw(inputRef) <= 0))
                && myPhysicsScript.IsGrounded()
                && !myHitBoxesScript.isHit
                && currentSubState != SubStates.Stunned){
                currentState = PossibleStates.Stand;
            }

            if (inputRef.inputType != InputType.Button && inputRef.heldDown > 0 && inputController.GetAxisRaw(inputRef) == 0) {
                if ((inputRef.engineRelatedButton == ButtonPress.Back && UFE.config.blockOptions.blockType == BlockType.HoldBack)){
                    potentialBlock = false;
                }

                storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                inputRef.heldDown = 0;
                if (storedMove != null){
                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                    return;
                }
            }

            if (inputRef.heldDown == 0 && inputRef.inputType != InputType.Button) {
                inputRef.activeIcon = inputController.GetAxisRaw(inputRef) > 0? inputRef.inputViewerIcon1 : inputRef.inputViewerIcon2;
            }

            /*if (inputController.GetButtonUp(inputRef)) {
                storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                inputRef.heldDown = 0;
                if (storedMove != null){
                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                    return;
                }
            }*/

            // Axis Press
            if (inputRef.inputType != InputType.Button && inputController.GetAxisRaw(inputRef) != 0) {
                if (inputRef.inputType == InputType.HorizontalAxis) {
                    // Horizontal Movements
                    if (inputController.GetAxisRaw(inputRef) > 0) {
                        inputRef.engineRelatedButton = mirror == 1? ButtonPress.Back : ButtonPress.Foward;
                        inputRef.heldDown += Time.fixedDeltaTime;
                        if (inputRef.heldDown == Time.fixedDeltaTime && testMoveExecution(inputRef.engineRelatedButton, false)) return;

                        if (currentState == PossibleStates.Stand
                            && !isBlocking
                            && !myPhysicsScript.isTakingOff
                            && !myPhysicsScript.isLanding
                            && currentSubState != SubStates.Stunned
                            && !blockStunned
                            && currentMove == null
                            && myMoveSetScript.basicMoves.moveEnabled) {
                            myPhysicsScript.Move(-mirror, inputController.GetAxisRaw(inputRef));
                        }
                    }

                    if (inputController.GetAxisRaw(inputRef) < 0) {
                        inputRef.engineRelatedButton = mirror == 1? ButtonPress.Foward : ButtonPress.Back;
                        inputRef.heldDown += Time.fixedDeltaTime;
                        if (inputRef.heldDown == Time.fixedDeltaTime && testMoveExecution(inputRef.engineRelatedButton, false)) return;

                        if (currentState == PossibleStates.Stand
                            && !isBlocking
                            && !myPhysicsScript.isTakingOff
                            && !myPhysicsScript.isLanding
                            && currentSubState != SubStates.Stunned
                            && !blockStunned
                            && currentMove == null
                            && myMoveSetScript.basicMoves.moveEnabled) {
                            myPhysicsScript.Move(mirror, inputController.GetAxisRaw(inputRef));
                        }
                    }

                    // Check for potential blocking
                    if (inputRef.engineRelatedButton == ButtonPress.Back
                        && UFE.config.blockOptions.blockType == BlockType.HoldBack
                        && !myPhysicsScript.isTakingOff
                        && myMoveSetScript.basicMoves.blockEnabled) {
                        potentialBlock = true;
                    }

                    // Check for potential parry
                    if (((inputRef.engineRelatedButton == ButtonPress.Back && UFE.config.blockOptions.parryType == ParryType.TapBack) ||
                         (inputRef.engineRelatedButton == ButtonPress.Foward && UFE.config.blockOptions.parryType == ParryType.TapForward))
                        && potentialParry == 0
                        && inputRef.heldDown == Time.fixedDeltaTime
                        && currentMove == null
                        && !isBlocking
                        && !myPhysicsScript.isTakingOff
                        && currentSubState != SubStates.Stunned
                        && !blockStunned
                        && myMoveSetScript.basicMoves.parryEnabled) {
                        potentialParry = UFE.config.blockOptions.parryTiming;
                    }

                }else{
                    // Vertical Movements
                    if (inputController.GetAxisRaw(inputRef) > 0) {
                        inputRef.engineRelatedButton = ButtonPress.Up;
                        if (!myPhysicsScript.isTakingOff && !myPhysicsScript.isLanding){
                            if (inputRef.heldDown == 0) {
                                if (!myPhysicsScript.IsGrounded() && myInfo.physics.canJump && myInfo.physics.multiJumps > 1){
                                    myPhysicsScript.Jump();
                                }
                                if (testMoveExecution(inputRef.engineRelatedButton, false)) return;
                            }
                            if (!myPhysicsScript.freeze
                                && !myPhysicsScript.IsJumping()
                                && storedMove == null
                                && currentMove == null
                                && currentState == PossibleStates.Stand
                                && currentSubState != SubStates.Stunned
                                && !isBlocking
                                && myInfo.physics.canJump
                                && !blockStunned
                                && myMoveSetScript.basicMoves.jumpEnabled) {

                                float delayTime = (float)myInfo.physics.jumpDelay/UFE.config.fps;
                                myPhysicsScript.isTakingOff = true;
                                potentialBlock = false;
                                potentialParry = 0;

                                UFE.DelaySynchronizedAction(myPhysicsScript.Jump, delayTime);

                                if (myMoveSetScript.AnimationExists(myMoveSetScript.basicMoves.takeOff.name)){
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.takeOff);

                                    if (myMoveSetScript.basicMoves.takeOff.autoSpeed) {
                                        myMoveSetScript.SetAnimationSpeed(
                                            myMoveSetScript.basicMoves.takeOff.name,
                                            myMoveSetScript.GetAnimationLengh(myMoveSetScript.basicMoves.takeOff.name) / delayTime);
                                    }

                                }
                            }
                        }
                        inputRef.heldDown += Time.fixedDeltaTime;

                    }else if (inputController.GetAxisRaw(inputRef) < 0) {
                        inputRef.engineRelatedButton = ButtonPress.Down;
                        if (inputRef.heldDown == 0 && testMoveExecution(inputRef.engineRelatedButton, false)) return;
                        inputRef.heldDown += Time.fixedDeltaTime;

                        if (!myPhysicsScript.freeze
                            && myPhysicsScript.IsGrounded()
                            && currentMove == null
                            && currentSubState != SubStates.Stunned
                            && !myPhysicsScript.isTakingOff
                            && !blockStunned
                            && myMoveSetScript.basicMoves.crouchEnabled) {
                            currentState = PossibleStates.Crouch;
                            if (!myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name)) {
                                if (!isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.crouching.name))
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.crouching);

                                if (isBlocking && !myMoveSetScript.IsAnimationPlaying(myMoveSetScript.basicMoves.blockingCrouchingPose.name))
                                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.blockingCrouchingPose);
                            }
                        }
                    }
                }

                foreach (InputReferences inputRef2 in inputController.inputReferences) {
                    if (inputRef2.inputType == InputType.Button && inputController.GetButtonDown(inputRef2)) {
                        storedMove = myMoveSetScript.GetMove(
                            new ButtonPress[]{inputRef.engineRelatedButton, inputRef2.engineRelatedButton}, 0, currentMove, false, true);

                        if (storedMove != null){
                            storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                            return;
                        }
                    }
                }
            }

            // Button Press
            if (inputRef.inputType == InputType.Button && !UFE.config.lockInputs){
                if (inputController.GetButton(inputRef)) {
                    if (myMoveSetScript.CompareBlockButtons(inputRef.engineRelatedButton)
                        && currentSubState != SubStates.Stunned
                        && !myPhysicsScript.isTakingOff
                        && !blockStunned
                        && myMoveSetScript.basicMoves.blockEnabled) {
                        potentialBlock = true;
                        CheckBlocking(true);
                    }

                    if (myMoveSetScript.CompareParryButtons(inputRef.engineRelatedButton)
                        && inputRef.heldDown == 0
                        && potentialParry == 0
                        && currentMove == null
                        && !isBlocking
                        && currentSubState != SubStates.Stunned
                        && !myPhysicsScript.isTakingOff
                        && !blockStunned
                        && myMoveSetScript.basicMoves.parryEnabled) {
                        potentialParry = UFE.config.blockOptions.parryTiming;
                    }

                    inputRef.heldDown += Time.fixedDeltaTime;
                    if (inputRef.heldDown <= ((float)UFE.config.plinkingDelay/(float)UFE.config.fps)) {
                        foreach (InputReferences inputRef2 in inputController.inputReferences) {
                            if (inputRef2 != inputRef
                                && inputRef2.inputType == InputType.Button
                                && inputController.GetButtonDown(inputRef2)) {
                                inputRef2.heldDown += Time.fixedDeltaTime;
                                storedMove = myMoveSetScript.GetMove(
                                    new ButtonPress[]{inputRef.engineRelatedButton, inputRef2.engineRelatedButton}, 0, currentMove, false, true);

                                if (storedMove != null && (currentMove == null || currentMove.currentFrame <= UFE.config.plinkingDelay)){
                                    KillCurrentMove();
                                    storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                                    return;
                                }
                            }
                        }
                    }
                }

                if (inputController.GetButtonDown(inputRef)) {
                    storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, 0, currentMove, false);
                    if (storedMove != null){
                        storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                        return;
                    }
                }

                if (inputController.GetButtonUp(inputRef)) {
                    storedMove = myMoveSetScript.GetMove(new ButtonPress[]{inputRef.engineRelatedButton}, inputRef.heldDown, currentMove, true);
                    inputRef.heldDown = 0;
                    if (storedMove != null) {
                        storedMoveTime = ((float)UFE.config.executionBufferTime / UFE.config.fps);
                        return;
                    }
                    if (myMoveSetScript.CompareBlockButtons(inputRef.engineRelatedButton)
                        && !myPhysicsScript.isTakingOff) {
                        potentialBlock = false;
                        CheckBlocking(false);
                    }
                }
            }
        }
    }
Exemplo n.º 11
0
    //---------------------------------------------------
    // Returns if it is certain state

    public bool IsState(PossibleStates stateToCheck)
    {
        return(animator.GetBool(stateToCheck.ToString()));
    }
Exemplo n.º 12
0
        // Update is called once per frame
        void Update()
        {
            // 存放动作时间减少
            if (!myPhysicsScript.freeze && storedMoveTime > 0)
            {
                storedMoveTime -= Time.deltaTime;
            }
            if (storedMoveTime < 0)
            {
                storedMoveTime = 0;
                storedMove     = null;
            }
            // 执行存放动作
            if ((currentMove == null || currentMove.cancelable) && storedMove != null && !myPhysicsScript.freeze)
            {
                if (currentMove != null)
                {
                    KillCurrentMove();
                }
                //if (System.Array.IndexOf(storedMove.possibleStates, currentState) != -1) currentMove = storedMove;
                storedMove = null;
                return;
            }

            foreach (AnimationState animState in character.GetComponent <Animation>())
            {
                if (character.GetComponent <Animation>().IsPlaying(animState.name))
                {
                    Debug.Log("IsPlaying: " + animState.name);
                }
            }

            // 执行存放动作
            if ((currentMove == null || currentMove.cancelable) && storedMove != null && !myPhysicsScript.freeze)
            {
                if (currentMove != null)
                {
                    KillCurrentMove();
                }
                if (System.Array.IndexOf(storedMove.possibleStates, currentState) != -1)
                {
                    currentMove = storedMove;
                }
                storedMove = null;
                return;
            }
            // 执行默认idle动作
            if (!myPhysicsScript.freeze && myPhysicsScript.isGrounded() && isAxisRested() && !character.GetComponent <Animation>().IsPlaying("idle"))
            {
                Debug.Log(character.GetComponent <Animation>().GetClipCount());

                bool playIdle = true;
                foreach (AnimationState animState in character.GetComponent <Animation>())
                {
                    if (animState.name != "idle" &&
                        animState.name != "moveForward" &&
                        animState.name != "moveBack" &&
                        animState.name != "run" &&
                        animState.name != "crouching" &&
                        animState.name != "blockingLowPose" &&
                        character.GetComponent <Animation>().IsPlaying(animState.name))
                    {
                        playIdle = false;
                    }
                }
                if (playIdle)
                {
                    myMoveSetScript.playBasicMove(myMoveSetScript.basicMoves.idle);
                    currentState = PossibleStates.Stand;
                    //if (GlobalScript.prefs.blockOptions.blockType == BlockType.AutoBlock) potentialBlock = true;
                }
            }

            bool hasAxisKeyDown = false;

            foreach (InputReferences inputRef in inputReferences)
            {
                // 清空方向键 按下时间heldDown
                if (inputRef.inputType != InputType.Button && inputRef.heldDown > 0 && Input.GetAxisRaw(inputRef.inputButtonName) == 0)
                {
                    if (inputRef.heldDown >= myInfo.chargeTiming)
                    {
                        storedMove = myMoveSetScript.getMove(new ButtonPress[] { inputRef.engineRelatedButton }, inputRef.heldDown, currentMove, true);
                    }
                    inputRef.heldDown = 0;
                    if (inputRef.inputType == InputType.Left)
                    {
                        leftHeldTime = 0;
                    }
                    else if (inputRef.inputType == InputType.Right)
                    {
                        rightHeldTime = 0;
                    }
                    else if (inputRef.inputType == InputType.Up)
                    {
                        upHeldTime = 0;
                    }
                    else if (inputRef.inputType == InputType.Down)
                    {
                        downHeldTime = 0;
                    }

                    if ((currentMove == null || currentMove.cancelable) && storedMove != null)
                    {
                        currentMove = storedMove;
                        storedMove  = null;
                        return;
                    }
                    else if (storedMove != null)
                    {
                        storedMoveTime = UFE.config.storedExecutionDelay;
                        return;
                    }
                }

                if (Input.GetButtonUp(inputRef.inputButtonName))
                {
                    if (inputRef.heldDown >= myInfo.chargeTiming)
                    {
                        storedMove = myMoveSetScript.getMove(new ButtonPress[] { inputRef.engineRelatedButton }, inputRef.heldDown, currentMove, true);
                    }
                    inputRef.heldDown = 0;
                    if ((currentMove == null || currentMove.cancelable) && storedMove != null)
                    {
                        currentMove = storedMove;
                        storedMove  = null;
                        return;
                    }
                    else if (storedMove != null)
                    {
                        storedMoveTime = UFE.config.storedExecutionDelay;
                        return;
                    }
                }

                // 方向键按下
                if (inputRef.inputType != InputType.Button && Input.GetAxisRaw(inputRef.inputButtonName) != 0)
                {
                    hasAxisKeyDown = true;
                    bool axisPressed = false;
                    moveDirection = Vector2.zero;


                    if (inputRef.inputType == InputType.Left)
                    {
                        inputRef.engineRelatedButton = ButtonPress.Left;
                        moveDirection.x = -1;
                        leftHeldTime    = inputRef.heldDown;
                    }
                    else if (inputRef.inputType == InputType.Right)
                    {
                        inputRef.engineRelatedButton = ButtonPress.Right;
                        moveDirection.x = 1;
                        rightHeldTime   = inputRef.heldDown;
                    }
                    else if (inputRef.inputType == InputType.Up)
                    {
                        inputRef.engineRelatedButton = ButtonPress.Up;
                        moveDirection.y = 1;
                        upHeldTime      = inputRef.heldDown;
                    }
                    else if (inputRef.inputType == InputType.Down)
                    {
                        inputRef.engineRelatedButton = ButtonPress.Down;
                        moveDirection.y = -1;
                        downHeldTime    = inputRef.heldDown;
                    }

                    if (inputRef.heldDown == 0)
                    {
                        axisPressed = true;
                    }
                    inputRef.heldDown += Time.deltaTime;

                    // 第一次(或执行动作之后)按下方向键
                    if (axisPressed)
                    {
                        storedMove = myMoveSetScript.getMove(new ButtonPress[] { inputRef.engineRelatedButton }, 0, currentMove, false);
                        if ((currentMove == null || currentMove.cancelable) && storedMove != null)
                        {
                            currentMove = storedMove;
                            storedMove  = null;
                            return;
                        }
                        else if (storedMove != null)
                        {
                            storedMoveTime = UFE.config.storedExecutionDelay;
                            return;
                        }
                    }
                }// END 方向键

                // 按钮判断
                if (inputRef.inputType == InputType.Button && !UFE.config.lockInputs)
                {
                    if (Input.GetButton(inputRef.inputButtonName))
                    {
                        // 多个按钮同时按下
                    }

                    // 单个按钮按下时可能执行的动作
                    if (Input.GetButtonDown(inputRef.inputButtonName))
                    {
                        storedMove = myMoveSetScript.getMove(new ButtonPress[] { inputRef.engineRelatedButton }, 0, currentMove, false);
                        if ((currentMove == null || currentMove.cancelable) && storedMove != null)
                        {
                            currentMove = storedMove;
                            storedMove  = null;
                            return;
                        }
                        else if (storedMove != null)
                        {
                            storedMoveTime = UFE.config.storedExecutionDelay;
                            return;
                        }
                        // 跳跃键按下
                        if (inputRef.engineRelatedButton == ButtonPress.Jump)
                        {
                            if (currentMove == null)
                            {
                                if (myPhysicsScript.isGrounded())
                                {
                                    myPhysicsScript.jump();
                                }
                                if (inputRef.heldDown == 0)
                                {
                                    if (!myPhysicsScript.isGrounded() && myInfo.physics.multiJumps > 1)
                                    {
                                        myPhysicsScript.jump();
                                    }
                                }
                            }
                        }
                    }
                    // 执行只有当按钮弹起才执行的动作
                    if (Input.GetButtonUp(inputRef.inputButtonName))
                    {
                        storedMove = myMoveSetScript.getMove(new ButtonPress[] { inputRef.engineRelatedButton }, 0, currentMove, true);
                        if ((currentMove == null || currentMove.cancelable) && storedMove != null)
                        {
                            currentMove = storedMove;
                            storedMove  = null;
                        }
                        else if (storedMove != null)
                        {
                            storedMoveTime = UFE.config.storedExecutionDelay;
                            return;
                        }
                    }
                }
            }// END 按键列表循环


            SetMovementForce();

            if (!hasAxisKeyDown)
            {
                //readyToRun = PreRunDirection.None;
                isRun = false;
            }
        }
Exemplo n.º 13
0
    // Imediately cancels any move being executed
    public void KillCurrentMove()
    {
        if (currentMove == null) return;
        currentMove.currentFrame = 0;
        currentMove.currentTick = 0;
        //myMoveSetScript.SetAnimationSpeed(currentMove.name, currentMove.animationSpeed);

        myHitBoxesScript.activeHurtBoxes = null;
        myHitBoxesScript.blockableArea = null;
        myHitBoxesScript.HideHitBoxes(false);
        ignoreCollisionMass = false;
        if (UFE.config.blockOptions.blockType == BlockType.HoldBack ||
            UFE.config.blockOptions.blockType == BlockType.AutoBlock) opControlsScript.CheckBlocking(false);

        if (currentMove.applyRootMotion) {
            character.transform.localPosition = new Vector3(0, 0, 0);

            Vector3 newPosition = character.transform.position;

            if (currentMove.rootMotionNode != BodyPart.none){
                newPosition = myHitBoxesScript.GetPosition(currentMove.rootMotionNode);
            }
            newPosition.z = 0;

            transform.position = newPosition;

            if (currentMove.forceGrounded) myPhysicsScript.ForceGrounded();
        }

        if (currentMove.disableHeadLook) ToggleHeadLook(true);

        if (currentMove.invertRotationLeft && mirror == -1) InvertRotation();
        if (currentMove.forceMirrorLeft && mirror == -1) ForceMirror(false);

        if (currentMove.invertRotationRight && mirror == 1) InvertRotation();
        if (currentMove.forceMirrorRight && mirror == 1) ForceMirror(UFE.config.characterRotationOptions.autoMirror);

        testCharacterRotation(100);

        if (stunTime > 0){
            standUpOverride = currentMove.standUpOptions;
            if (standUpOverride != StandUpOptions.None) currentState = PossibleStates.Down;
        }

        currentMove = null;
        ReleaseCam();
    }
Exemplo n.º 14
0
        void FixedUpdate()
        {
            if (opHitBoxesScript == null)
            {
                if (opControlsScript == null)
                {
                    opControlsScript = opponent.GetComponent <ControlsScript>();
                }
                opPhysicsScript  = opponent.GetComponent <PhysicsScript>();
                opHitBoxesScript = opponent.GetComponentInChildren <HitBoxesScript>();
                opInfo           = opControlsScript.myInfo;
                if (gameObject.name == "Player2" && character.name == opControlsScript.character.name)
                {
                    // Alternative Costume
                    //Renderer charRender = character.GetComponentInChildren<Renderer>();
                    //charRender.material.color = myInfo.alternativeColor;

                    Renderer[] charRenders = character.GetComponentsInChildren <Renderer>();
                    foreach (Renderer charRender in charRenders)
                    {
                        //charRender.material.shader = Shader.Find("VertexLit");
                        charRender.material.color = myInfo.alternativeColor;
                        //charRender.material.SetColor("_Emission", myInfo.alternativeColor);
                    }
                }

                Renderer[]    charRenderers = character.GetComponentsInChildren <Renderer>();
                List <Shader> shaderList    = new List <Shader>();
                List <Color>  colorList     = new List <Color>();
                foreach (Renderer char_rend in charRenderers)
                {
                    shaderList.Add(char_rend.material.shader);
                    colorList.Add(char_rend.material.color);
                }
                normalShaders = shaderList.ToArray();
                normalColors  = colorList.ToArray();
            }

            // 两个hitbox碰撞的越多,退的越远(攻击碰撞?)身体碰撞体
            if (Vector3.Distance(transform.position, opponent.transform.position) < 10)
            {
                float totalHits = myHitBoxesScript.testCollision(opHitBoxesScript.hitBoxes);
                if (totalHits > 0)
                {
                    if (transform.position.x < opponent.transform.position.x)
                    {
                        transform.Translate(new Vector3(-.05f * totalHits, 0, 0));
                    }
                    else
                    {
                        transform.Translate(new Vector3(.05f * totalHits, 0, 0));
                    }
                }
            }

            if (currentMove != null)
            {
                /*debugger.text = "";
                 * if (storedMove != null) debugger.text += storedMove.name + "\n";
                 * debugger.text += currentMove.name +": "+ character.animation.IsPlaying(currentMove.name) + "\n";
                 * debugger.text += "frames:"+ currentMove.currentFrame + "/" + currentMove.totalFrames + "\n";
                 * debugger.text += "animationPaused:"+ animationPaused + "\n";
                 * if (character.animation.IsPlaying(currentMove.name)){
                 *  debugger.text += "normalizedTime: "+ character.animation[currentMove.name].normalizedTime + "\n";
                 *  debugger.text += "time: "+ character.animation[currentMove.name].time + "\n";
                 * }*/

                // 动作还没开始执行时,赋值动画参数
                if (currentMove.currentFrame == 0)
                {
                    if (character.GetComponent <Animation>()[currentMove.name] == null)
                    {
                        Debug.LogError("Animation for move '" + currentMove.moveName + "' not found!");
                    }
                    character.GetComponent <Animation>()[currentMove.name].time = 0;
                    character.GetComponent <Animation>().CrossFade(currentMove.name, currentMove.interpolationSpeed);
                    character.GetComponent <Animation>()[currentMove.name].speed = currentMove.animationSpeed;
                }

                // ANIMATION FRAME DATA
                if (!animationPaused)
                {
                    currentMove.currentFrame++;
                }
                //if (currentMove.currentFrame == 1) AddGauge(currentMove.gaugeGainOnMiss);
                // 根据配置的动画类型 设置当前动画的时间点
                //if (UFE.config.animationFlow == AnimationFlow.MorePrecision)
                //{
                //    character.GetComponent<Animation>()[currentMove.name].speed = 0;
                //    AnimationState animState = character.GetComponent<Animation>()[currentMove.name];
                //    animState.time = GetAnimationTime(currentMove.currentFrame);
                //    //animState.time = ((float)currentMove.currentFrame / (float)GlobalScript.prefs.framesPerSeconds) / (1/currentMove.animationSpeed);
                //}

                // 生成该动作的发射物
                foreach (Projectile projectile in currentMove.projectiles)
                {
                    if (!projectile.casted && currentMove.currentFrame >= projectile.castingFrame)
                    {
                        if (projectile.projectilePrefab == null)
                        {
                            continue;
                        }
                        projectile.casted = true;

                        if (projectile.projectilePrefab == null)
                        {
                            Debug.LogError("Projectile prefab for move " + currentMove.moveName + " not found. Make sure you have set the prefab correctly in the Move Editor");
                        }
                        GameObject pTemp = (GameObject)Instantiate(projectile.projectilePrefab,
                                                                   projectile.position.position,
                                                                   Quaternion.Euler(0, 0, projectile.directionAngle));
                        pTemp.AddComponent <ProjectileMoveScript>();
                        ProjectileMoveScript pTempScript = pTemp.GetComponent <ProjectileMoveScript>();
                        pTempScript.data             = projectile;
                        pTempScript.opHitBoxesScript = opHitBoxesScript;
                        pTempScript.opControlsScript = opControlsScript;
                        //pTempScript.mirror = mirror;
                    }
                }
                // 播放动作的特效
                //foreach (MoveParticleEffect particleEffect in currentMove.particleEffects)
                //{
                //    if (!particleEffect.casted && currentMove.currentFrame >= particleEffect.castingFrame)
                //    {
                //        if (particleEffect.particleEffect.prefab == null)
                //            Debug.LogError("Particle effect for move " + currentMove.moveName + " not found. Make sure you have set the prefab for this particle correctly in the Move Editor");
                //        particleEffect.casted = true;
                //        GameObject pTemp = (GameObject)Instantiate(particleEffect.particleEffect.prefab);
                //        pTemp.transform.parent = transform;
                //        pTemp.transform.localPosition = particleEffect.particleEffect.position;
                //        Destroy(pTemp, particleEffect.particleEffect.duration);
                //    }
                //}

                // 应用动作施加的力
                foreach (AppliedForce addedForce in currentMove.appliedForces)
                {
                    if (!addedForce.casted && currentMove.currentFrame >= addedForce.castingFrame)
                    {
                        myPhysicsScript.resetForces(addedForce.resetPreviousHorizontal, addedForce.resetPreviousVertical, true);
                        myPhysicsScript.addForce(addedForce.force, 1);
                        addedForce.casted = true;
                    }
                }

                // 播放动作的音效
                //foreach (SoundEffect soundEffect in currentMove.soundEffects)
                //{
                //    if (!soundEffect.casted && currentMove.currentFrame >= soundEffect.castingFrame)
                //    {
                //        if (UFE.config.soundfx) Camera.main.GetComponent<AudioSource>().PlayOneShot(soundEffect.sound);
                //        soundEffect.casted = true;
                //    }
                //}

                // 播放摄像机的移动
                //foreach (CameraMovement cameraMovement in currentMove.cameraMovements)
                //{
                //    if (currentMove.currentFrame >= cameraMovement.castingFrame)
                //    {
                //        cameraMovement.time += Time.deltaTime;
                //        if (!cameraMovement.casted)
                //        {
                //            myPhysicsScript.freeze = cameraMovement.freezeGame;
                //            opPhysicsScript.freeze = cameraMovement.freezeGame;
                //            LockCam(cameraMovement.freezeAnimation);
                //            cameraMovement.casted = true;
                //            Vector3 targetPosition = character.transform.TransformPoint(cameraMovement.position);
                //            Vector3 targetRotation = cameraMovement.rotation;
                //            targetRotation.y *= mirror;
                //            targetRotation.z *= mirror;
                //            cameraScript.moveCameraToLocation(targetPosition,
                //                                              targetRotation,
                //                                              cameraMovement.fieldOfView,
                //                                              cameraMovement.camSpeed);
                //        }
                //    }
                //    if (cameraMovement.casted && UFE.freeCamera && cameraMovement.time >= cameraMovement.duration)
                //    {
                //        ReleaseCam();
                //    }
                //}

                // 隐藏动作无敌部分的hitbox
                if (currentMove.invincibleBodyParts.Length > 0)
                {
                    foreach (InvincibleBodyParts invBodyPart in currentMove.invincibleBodyParts)
                    {
                        if (currentMove.currentFrame >= invBodyPart.activeFramesBegin &&
                            currentMove.currentFrame < invBodyPart.activeFramesEnds)
                        {
                            if (invBodyPart.completelyInvincible)
                            {
                                myHitBoxesScript.hideHitBoxes();
                            }
                            else
                            {
                                myHitBoxesScript.hideHitBoxes(invBodyPart.hitBoxes);
                            }
                        }
                        if (currentMove.currentFrame >= invBodyPart.activeFramesEnds)
                        {
                            if (invBodyPart.completelyInvincible)
                            {
                                myHitBoxesScript.showHitBoxes();
                            }
                            else
                            {
                                myHitBoxesScript.showHitBoxes(invBodyPart.hitBoxes);
                            }
                        }
                    }
                }
                // 防御区域判断
                //if (currentMove.blockableArea.bodyPart != BodyPart.none)
                //{
                //    if (currentMove.currentFrame >= currentMove.blockableArea.activeFramesBegin &&
                //        currentMove.currentFrame < currentMove.blockableArea.activeFramesEnds)
                //    {
                //        myHitBoxesScript.blockableArea = currentMove.blockableArea;
                //        Vector3 collisionVector_block = opHitBoxesScript.testCollision(myHitBoxesScript.blockableArea);
                //        if (collisionVector_block != Vector3.zero) opControlsScript.CheckBlocking(true);
                //    }
                //    else if (currentMove.currentFrame >= currentMove.blockableArea.activeFramesEnds)
                //    {
                //        opControlsScript.CheckBlocking(false);
                //    }
                //}

                // 动作的多段攻击?在动作文件中activeframe 中可以设置 hit数组
                foreach (Hit hit in currentMove.hits)
                {
                    //if (comboHits >= UFE.config.comboOptions.maxCombo) continue;
                    // 取消技,当播放到可以取消的帧的时候执行下个动作
                    if ((hit.hasHit && currentMove.frameLink.onlyOnHit) || !currentMove.frameLink.onlyOnHit)
                    {
                        if (currentMove.currentFrame >= currentMove.frameLink.activeFramesBegins)
                        {
                            currentMove.cancelable = true;
                        }
                        if (currentMove.currentFrame >= currentMove.frameLink.activeFramesEnds)
                        {
                            currentMove.cancelable = false;
                        }
                    }
                    if (hit.hasHit)
                    {
                        continue;
                    }

                    if (currentMove.currentFrame >= hit.activeFramesBegin &&
                        currentMove.currentFrame < hit.activeFramesEnds)
                    {
                        if (hit.hurtBoxes.Length > 0)
                        {
                            myHitBoxesScript.activeHurtBoxes = hit.hurtBoxes;
                            // hurtbox判断,攻击中敌方
                            Vector3 collisionVector_hit = opHitBoxesScript.testCollision(myHitBoxesScript.activeHurtBoxes);
                            if (collisionVector_hit != Vector3.zero)
                            { // HURTBOX TEST
                              // 对手成功防御
                              //if (!opControlsScript.stunned && opControlsScript.currentMove == null && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType))
                              //{
                              //    opControlsScript.GetHitBlocking(hit, currentMove.totalFrames - currentMove.currentFrame, collisionVector_hit);
                              //    AddGauge(currentMove.gaugeGainOnBlock);
                              //    opControlsScript.AddGauge(currentMove.opGaugeGainOnBlock);
                              //    // 对手成功避开
                              //}
                              //else if (opControlsScript.potentialParry > 0 && opControlsScript.currentMove == null && opControlsScript.TestParryStances(hit.hitType))
                              //{
                              //    opControlsScript.GetHitParry(hit, collisionVector_hit);
                              //    opControlsScript.AddGauge(currentMove.opGaugeGainOnParry);
                              //}
                              //else
                              //{
                                // 成功攻击到对手
                                opControlsScript.GetHit(hit, currentMove.totalFrames - currentMove.currentFrame, collisionVector_hit);
                                //AddGauge(currentMove.gaugeGainOnHit);
                                // 攻击拉近?
                                //if (hit.pullSelfIn.enemyBodyPart != BodyPart.none && hit.pullSelfIn.characterBodyPart != BodyPart.none)
                                //{
                                //    Vector3 newPos = opHitBoxesScript.getPosition(hit.pullSelfIn.enemyBodyPart);
                                //    if (newPos != Vector3.zero)
                                //    {
                                //        pullInLocation = transform.position + (newPos - hit.pullSelfIn.position.position);
                                //        pullInSpeed = hit.pullSelfIn.speed;
                                //    }
                                //}
                                //}

                                // 施加力
                                myPhysicsScript.resetForces(hit.resetPreviousHorizontal, hit.resetPreviousVertical, true);
                                myPhysicsScript.addForce(hit.appliedForce, 1);

                                // 碰到屏幕两边施加力
                                //if ((opponent.transform.position.x >= UFE.config.selectedStage.rightBoundary - 2 ||
                                //    opponent.transform.position.x <= UFE.config.selectedStage.leftBoundary + 2) &&
                                //    myPhysicsScript.isGrounded())
                                //{

                                //    myPhysicsScript.addForce(
                                //        new Vector2(hit.pushForce.x + (opPhysicsScript.airTime * opInfo.physics.friction), 0),
                                //        mirror * -1);
                                //}
                                // 场景抖动效果
                                //HitPause();
                                //Invoke("HitUnpause", GetFreezingTime(hit.hitStrengh));
                                if (!hit.continuousHit)
                                {
                                    hit.hasHit = true;
                                }
                            }
                            ;
                        }
                    }
                }
                // 当前动作的帧播完
                if (currentMove.currentFrame >= currentMove.totalFrames)
                {
                    //if (currentMove == myMoveSetScript.getIntro()) introPlayed = true;
                    KillCurrentMove();
                }
            }
            // 击晕判断
            if ((stunned || blockStunned) && stunTime > 0 && !myPhysicsScript.freeze)
            {
                // 动画减速
                character.GetComponent <Animation>()[currentHitAnimation].speed -= hitStunDeceleration * Time.deltaTime;
                // 空中覆盖时空中连击不减少眩晕时间
                if (UFE.config.comboOptions.neverAirRecover && !myPhysicsScript.isGrounded())
                {
                    stunTime = 1;
                }
                else
                {
                    stunTime -= Time.deltaTime;
                }

                /*if (myPhysicsScript.debugger != null){
                 *  myPhysicsScript.debugger.text = "";
                 *  myPhysicsScript.debugger.text += "<color=#003300>animation speed: "+ character.animation[currentHitAnimation].speed +"</color>\n";
                 *  myPhysicsScript.debugger.text += "<color=#003300>stunTime: "+ stunTime +"</color>\n";
                 * }*/
                // 倒地爬起判断
                if (!isDead && stunTime <= UFE.config.knockDownOptions.getUpTime)
                {
                    if (currentState == PossibleStates.FallDown && myPhysicsScript.isGrounded())
                    {
                        currentState = PossibleStates.Stand;
                        character.GetComponent <Animation>().Play("getUp");
                    }
                }
                // 眩晕时间结束
                if (stunTime <= 0)
                {
                    ReleaseStun();
                }
            }

            myPhysicsScript.applyForces(currentMove);

            myPhysicsScript.resetForces(true, false, true);
        }
Exemplo n.º 15
0
 public List <S> GetPossibleHiddenStates(T observation)
 {
     return(PossibleStates.Where(s => EmissionMatrix[s][observation] > 0).ToList());
 }
Exemplo n.º 16
0
    public void ResetData(bool resetLife)
    {
        if (UFE.config.roundOptions.resetPositions){
            if (gameObject.name == "Player1"){
                transform.position = new Vector2(UFE.config.roundOptions.p1XPosition, .009f);
            }else{
                transform.position = new Vector2(UFE.config.roundOptions.p2XPosition, .009f);
            }
            myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle, myMoveSetScript.basicMoves.idle.name, 0);
            myPhysicsScript.ForceGrounded();

        }else if (currentState == PossibleStates.Down && myPhysicsScript.IsGrounded()){
            myMoveSetScript.PlayAnimation("standUp", 0);
        }

        if (resetLife || UFE.config.roundOptions.resetLifePoints){
            myInfo.currentLifePoints = (float)myInfo.lifePoints;
        }
        blockStunned = false;
        stunTime = 0;
        comboHits = 0;
        comboDamage = 0;
        comboHitDamage = 0;
        airJuggleHits = 0;
        CheckBlocking(false);
        isDead = false;
        myPhysicsScript.isTakingOff = false;
        myPhysicsScript.isLanding = false;

        myHitBoxesScript.HideHitBoxes(false);
        myPhysicsScript.ResetWeight();
        ToggleHeadLook(true);

        currentState = PossibleStates.Stand;
        currentSubState = SubStates.Resting;
    }
Exemplo n.º 17
0
    public void DoFixedUpdate()
    {
        // If both controllers aren't ready, ignore the player input
        if (!UFE.GetPlayer1Controller().isReady || !UFE.GetPlayer2Controller().isReady) return;

        // Training Mode
        if ((playerNum == 1 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p1Life == LifeBarTrainingMode.Refill) ||
            (playerNum == 2 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p2Life == LifeBarTrainingMode.Refill)) {
            if (!UFE.FindDelaySynchronizedAction(this.RefillLife))
                UFE.DelaySynchronizedAction(this.RefillLife, UFE.config.trainingModeOptions.refillTime);
        }

        if ((playerNum == 1 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p1Gauge == LifeBarTrainingMode.Refill) ||
            (playerNum == 2 && UFE.gameMode == GameMode.TrainingRoom && UFE.config.trainingModeOptions.p2Gauge == LifeBarTrainingMode.Refill)) {
            if (!UFE.FindDelaySynchronizedAction(this.RefillGauge))
                UFE.DelaySynchronizedAction(this.RefillGauge, UFE.config.trainingModeOptions.refillTime);
        }

        if (UFE.gameMode == GameMode.TrainingRoom && myInfo.currentGaugePoints < myInfo.maxGaugePoints &&
            ((playerNum == 1 && UFE.config.trainingModeOptions.p1Gauge == LifeBarTrainingMode.Infinite) ||
            (playerNum == 2 && UFE.config.trainingModeOptions.p2Gauge == LifeBarTrainingMode.Infinite))) RefillGauge();

        if (UFE.gameMode == GameMode.TrainingRoom && myInfo.currentLifePoints < myInfo.lifePoints &&
            ((playerNum == 1 && UFE.config.trainingModeOptions.p1Life == LifeBarTrainingMode.Infinite) ||
            (playerNum == 2 && UFE.config.trainingModeOptions.p2Life == LifeBarTrainingMode.Infinite))) RefillLife();

        // Debugger
        if (debugger != null && UFE.config.debugOptions.debugMode){
            debugger.text = "";
            if (UFE.config.debugOptions.debugMode) {
                debugger.text += "-----Character Info-----\n";
                if (debugInfo.lifePoints) debugger.text += "Life Points: " + myInfo.currentLifePoints + "\n";
                if (debugInfo.position) debugger.text += "Position: " + transform.position + "\n";
                if (debugInfo.currentState) debugger.text += "State: " + currentState + "\n";
                if (debugInfo.currentSubState) debugger.text += "Sub State: " + currentSubState + "\n";
                if (debugInfo.stunTime && stunTime > 0) debugger.text += "Stun Time: " + stunTime + "\n";
                if (opControlsScript != null && opControlsScript.comboHits > 0) {
                    debugger.text += "Current Combo\n";
                    if (debugInfo.comboHits) debugger.text += "- Total Hits: "+ opControlsScript.comboHits + "\n";
                    if (debugInfo.comboDamage) {
                        debugger.text += "- Total Damage: " + opControlsScript.comboDamage + "\n";
                        debugger.text += "- Hit Damage: " + opControlsScript.comboHitDamage + "\n";
                    }
                }

                // Other uses
                //if (potentialParry > 0) debugger.text += "Parry Window: "+ potentialParry + "\n";
                //debugger.text += "Air Jumps: "+ myPhysicsScript.currentAirJumps + "\n";

                if (UFE.config.debugOptions.p1DebugInfo.currentMove && currentMove != null) {
                    debugger.text += "Move: "+ currentMove.name + " ("+ currentMove.currentFrame +"/"+ currentMove.totalFrames +") \n";
                    /*if (currentMove.chargeMove) {
                        debugger.text += "First Input Charge: "+ myMoveSetScript.chargeValues[currentMove.buttonSequence[0]] + "\n";
                    }*/
                    //debugger.text += "StartupFrames: "+ currentMove.moveClassification.startupSpeed +" \n";
                }
            }
            if (aiDebugger != null && debugInfo.aiWeightList) debugger.text += aiDebugger;
        }

        // Once per game
        if (opHitBoxesScript == null) {
            opControlsScript = opponent.GetComponent<ControlsScript>();
            opPhysicsScript = opponent.GetComponent<PhysicsScript>();
            opHitBoxesScript = opponent.GetComponentInChildren<HitBoxesScript>();
            opInfo = opControlsScript.myInfo;

            if (myInfo.enableAlternativeColor){
                if (gameObject.name == "Player2" && character.name == opControlsScript.character.name){  // Alternative Costume
                    Renderer[] charRenders = character.GetComponentsInChildren<Renderer>();
                    foreach(Renderer charRender in charRenders){
                        charRender.material.color = myInfo.alternativeColor;
                        //charRender.material.shader = Shader.Find("VertexLit");
                        //charRender.material.SetColor("_Emission", myInfo.alternativeColor);
                    }
                }
            }

            Renderer[] charRenderers = character.GetComponentsInChildren<Renderer>();
            List<Shader> shaderList = new List<Shader>();
            List<Color> colorList = new List<Color>();
            foreach(Renderer char_rend in charRenderers){
                //if (char_rend.material.HasProperty("color") && char_rend.material.HasProperty("shader")){
                    shaderList.Add(char_rend.material.shader);
                    colorList.Add(char_rend.material.color);
                //}
            }
            normalShaders = shaderList.ToArray();
            normalColors = colorList.ToArray();

            myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle);
        }

        // Once per round
        if ((gameObject.name == "Player1" && !introPlayed && currentMove == null) ||
            (gameObject.name == "Player2" && !introPlayed && opControlsScript.introPlayed && currentMove == null))
        {
            KillCurrentMove();
            CastMove(myMoveSetScript.intro, true, true, false);
            if (currentMove == null) {
                introPlayed = true;
                UFE.CastNewRound();
            }
        }

        // Resolve move
        resolveMove();

        // Check inputs
        translateInputs(inputController);

        // Validate rotation
        validateRotation();

        // Input Viewer
        List<InputReferences> inputList = new List<InputReferences>();
        foreach (InputReferences inputRef in inputController.inputReferences){
            if (debugger != null && UFE.config.debugOptions.debugMode && debugInfo.inputs){
                debugger.text += inputRef.inputButtonName + " - "+ inputRef.heldDown + "\n";
            }
            if (inputRef.heldDown > 0 && inputRef.heldDown <= (2f/(float)UFE.config.fps)){
                inputList.Add(inputRef);
            }
        }
        UFE.CastInput(inputList.ToArray(), playerNum);

        // Force character local position
        if (ignoreAnimationTransform && (currentMove == null || !currentMove.applyRootMotion))
            character.transform.localPosition = new Vector3(0, 0, 0);

        // Force stand state
        if (!myPhysicsScript.freeze
            && !isDead
            && currentSubState != SubStates.Stunned
            && introPlayed
            && myPhysicsScript.IsGrounded()
            && !myPhysicsScript.IsMoving()
            && currentMove == null
            && !myMoveSetScript.IsBasicMovePlaying(myMoveSetScript.basicMoves.idle)
            && !myMoveSetScript.IsAnimationPlaying("fallStraight")
            && isAxisRested(inputController)
            && !myPhysicsScript.isTakingOff
            && !myPhysicsScript.isLanding
            && !blockStunned
            && currentState != PossibleStates.Crouch
            && !isBlocking
            ){

                myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle);
                currentState = PossibleStates.Stand;
                currentSubState = SubStates.Resting;
                if (UFE.config.blockOptions.blockType == BlockType.AutoBlock
                    && myMoveSetScript.basicMoves.blockEnabled) potentialBlock = true;
        }

        if (myMoveSetScript.IsAnimationPlaying("idle")
            && !UFE.config.lockInputs
            && !UFE.config.lockMovements) {
            afkTimer += Time.fixedDeltaTime;
            if (afkTimer >= myMoveSetScript.basicMoves.idle.restingClipInterval) {
                afkTimer = 0;
                int clipNum = Mathf.RoundToInt(Random.Range(2, 6));
                if (myMoveSetScript.AnimationExists("idle_" + clipNum)) {
                    myMoveSetScript.PlayBasicMove(myMoveSetScript.basicMoves.idle, "idle_" + clipNum, false);
                }
            }
        } else {
            afkTimer = 0;
        }

        // Character colliders based on collision mass and body colliders
        normalizedDistance = Mathf.Clamp01(Vector3.Distance(opponent.transform.position, transform.position) / UFE.config.cameraOptions.maxDistance);
        if (!ignoreCollisionMass && !opControlsScript.ignoreCollisionMass) {
            float pushForce = myHitBoxesScript.TestCollision(opHitBoxesScript.hitBoxes);
            if (pushForce > 0) {
                if (transform.position.x < opponent.transform.position.x) {
                    transform.Translate(new Vector3(-.1f * pushForce, 0, 0));
                }else{
                    transform.Translate(new Vector3(.1f * pushForce, 0, 0));
                }
                if (opponent.transform.position.x == UFE.config.selectedStage.rightBoundary){
                    opponent.transform.Translate(new Vector3(-.2f * pushForce, 0, 0));
                }
            }

            pushForce = myInfo.physics.groundCollisionMass - Vector3.Distance(transform.position, opponent.transform.position);
            if (pushForce > 0) {
                if (transform.position.x < opponent.transform.position.x) {
                    transform.Translate(new Vector3(-.5f * pushForce, 0, 0));
                }else{
                    transform.Translate(new Vector3(.5f * pushForce, 0, 0));
                }
                if (opponent.transform.position.x == UFE.config.selectedStage.rightBoundary){
                    opponent.transform.Translate(new Vector3(-.2f * pushForce, 0, 0));
                }
            }
        }

        // Shake character
        if (shakeDensity > 0) {
            shakeDensity -= Time.fixedDeltaTime;
            if (myHitBoxesScript.isHit && myPhysicsScript.freeze){
                if (shakeCharacter) shake();
                if (shakeCamera) shakeCam();
            }else{
                if (UFE.config.bounceOptions.shakeCamOnBounce && myPhysicsScript.isBouncing) shakeCam();
            }
        }else if (shakeDensity < 0) {
            shakeDensity = 0;
            shakeCamera = false;
            shakeCharacter = false;
        }

        // Validate Parry
        if (potentialParry > 0){
            potentialParry -= Time.fixedDeltaTime;
            if (potentialParry <= 0) potentialParry = 0;
        }

        // Update head movement
        if (headLookScript != null && opHitBoxesScript != null)
            headLookScript.target = opHitBoxesScript.GetPosition(myInfo.headLook.target);

        // Execute Move
        if (currentMove != null) ReadMove(currentMove);

        // Apply Stun
        if ((currentSubState == SubStates.Stunned || blockStunned) && stunTime > 0 && !myPhysicsScript.freeze && !isDead)
            ApplyStun();

        // Apply Forces
        myPhysicsScript.ApplyForces(currentMove);
    }
Exemplo n.º 18
0
 private float AdjustKnockdownVariables(SubKnockdownOptions knockdownOptions)
 {
     myPhysicsScript.ResetForces(true, true);
     myPhysicsScript.AddForce(knockdownOptions.predefinedPushForce, -opControlsScript.mirror);
     currentState = PossibleStates.Down;
     return knockdownOptions.standUpTime + knockdownOptions.knockedOutTime;
 }
Exemplo n.º 19
0
    // Release character to be playable again
    private void ReleaseStun()
    {
        if (currentSubState != SubStates.Stunned && !blockStunned) return;
        if (!isBlocking && comboHits > 1) {
            UFE.FireAlert(UFE.config.selectedLanguage.combo, opInfo);
        }
        currentSubState = SubStates.Resting;
        blockStunned = false;
        stunTime = 0;
        comboHits = 0;
        comboDamage = 0;
        comboHitDamage = 0;
        airJuggleHits = 0;
        CheckBlocking(false);

        standUpOverride = StandUpOptions.None;

        myPhysicsScript.ResetWeight();
        if (!isDead) ToggleHeadLook(true);

        if (myPhysicsScript.IsGrounded()) currentState = PossibleStates.Stand;
        translateInputs(inputController);

        myHitBoxesScript.HideHitBoxes(false);
    }