public override void UpdateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     if (stateInfo.normalizedTime >= TransitionTiming)
     {
         animator.SetBool("ForceTransitions", true);
     }
 }
 // To update all cards
 public void UpdateAll(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     foreach (StateData d in ListAbilityData)
     {
         d.UpdateAbility(characterStateBase, animator, stateInfo);
     }
 }
Ejemplo n.º 3
0
        private void Update()
        {
            if (parent.isSuspended)
            {
                return;
            }

            CharacterStateBase.SetActive(states.graphic, allowGraphic);
            CharacterStateBase.SetActive(states.gravity, allowGravity);
            CharacterStateBase.SetActive(states.input, allowInput);
            CharacterStateBase.SetActive(states.motor, allowMotor);
            CharacterStateBase.SetActive(states.movement, allowMovement);
            CharacterStateBase.SetActive(states.wallSlide, allowWallSlide);

            CharacterStateBase.UpdateState(states.gravity);
            CharacterStateBase.UpdateState(states.input);
            CharacterStateBase.UpdateState(states.wallSlide);

            CharacterStateBase.UpdateState(states.jump);
            CharacterStateBase.UpdateState(states.knockback);
            CharacterStateBase.UpdateState(states.slide);
            CharacterStateBase.UpdateState(states.wallDash);
            CharacterStateBase.UpdateState(states.wallJump);

            CharacterStateBase.UpdateState(states.motor);

            CharacterStateBase.UpdateState(states.movement);
            CharacterStateBase.UpdateState(states.graphic);
        }
Ejemplo n.º 4
0
    public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // move left
        if (control.moveLeft || control.moveRight)
        {
            animator.SetBool(AnimationTags.WALK, true);
        }
        else
        {
            animator.SetBool(AnimationTags.WALK, false);
        }

        // switch to attack
        if (control.attack)
        {
            animator.SetBool(AnimationTags.LEFT_SWING, true);
        }

        // switch to recall
        if (control.recall)
        {
            animator.SetBool(AnimationTags.RECALL, true);
        }


        // Hammer throw
        if (control.throwHammer && control.hammerEquipped)
        {
            animator.SetBool(AnimationTags.THROW, true);
        }
    }
    public override void OnEnter(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // get Control script component attached to our gameObject
        control = characterStateBase.getController(animator);


        // attack kicked off, now disable
        animator.SetBool(AnimationTags.LEFT_SWING, false);
        animator.SetBool(AnimationTags.RIGHT_SWING, false);
        animator.SetBool(AnimationTags.END, false);


        // Load prefab empty object that contains the attack info script
        // We can use this object as a way to broadcast information on attacks
        GameObject obj        = Instantiate(Resources.Load("AttackInfo", typeof(GameObject))) as GameObject;
        AttackInfo attackInfo = obj.GetComponent <AttackInfo>();

        attackInfo.resetAttackInfo(this);

        // Add object containing attack info into the attack manager
        if (!AttackManager.Instance.currentAttacks.Contains(attackInfo))
        {
            AttackManager.Instance.currentAttacks.Add(attackInfo);
        }
    }
    public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // BEGIN RECALL
        if (canRecall)
        {
            Hammer.recall = true;
        }

        // control recalling timer
        if (control.recall)
        {
            TimerRecalling += Time.deltaTime;
        }


        // enable recall
        if (control.recall && TimerRecalling > TimeEnableRecall)
        {
            canRecall = true;

            // not recalling. go Idle
        }
        else if (!control.recall && !Hammer.isEquipped && TimerRecalling < TimeEnableRecall)
        {
            animator.SetBool(AnimationTags.RECALL, false);
        }

        // hammer equipped. disable recall
        if (Hammer.isEquipped)
        {
            Hammer.recall = false;
        }
    }
Ejemplo n.º 7
0
    public override void UpdateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        AliController control = characterStateBase.GetBotController(animator);

        if (control.MoveRight && control.MoveLeft)
        {
            control.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
            animator.SetBool("IsRunning", false);
            return;
        }

        if (!control.MoveRight && !control.MoveLeft)
        {
            control.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
            animator.SetBool("IsRunning", false);
            return;
        }

        if (control.MoveRight)
        {
            /* DONT NEED TO SWITCH TO RUN (THIS IS RUN SCRIPT), JUST MOVE */
            control.transform.Translate(Vector3.forward * Speed * Time.deltaTime);
            control.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
            //animator.SetBool("IsRunning", true);
        }

        if (control.MoveLeft)
        {
            /* DONT NEED TO SWITCH TO RUN (THIS IS RUN SCRIPT), JUST MOVE */
            control.transform.Translate(Vector3.forward * Speed * Time.deltaTime);
            control.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
            //animator.SetBool("IsRunning", true);
        }
    }
Ejemplo n.º 8
0
 public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     if (canMakeTransition())
     {
         // Index is publicly set. It's the value our condition will respond to
         animator.SetInteger(AnimationTags.TRANSITION_INDEX, Index);
     }
 }
Ejemplo n.º 9
0
 public override void OnEnter(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     animator.SetBool(AnimationTags.RECALL, false);
     animator.SetBool(AnimationTags.THROW, false);
     animator.SetBool(AnimationTags.LEFT_SWING, false);
     animator.SetBool(AnimationTags.RIGHT_SWING, false);
     animator.SetBool(AnimationTags.DEAD, false);
 }
 public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     // after elapsed time, switch animator held in Control
     if (stateInfo.normalizedTime >= switchTiming)
     {
         characterStateBase.getController(animator).GetComponent <Animator>().runtimeAnimatorController = targetAnimator;
     }
 }
Ejemplo n.º 11
0
    protected override void setNewState(CharacterStateBase newState)
    {
        if (groundedInternalState != null)
        {
            groundedInternalState.Exit();
        }

        base.setNewState(newState);
    }
Ejemplo n.º 12
0
 // CharacterStateBase, which is attached to the object, will call updateAbility from all StateData
 public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     // The normalized time of the animation. A value of 1 is the end of the animation. A value of 0.5 is the middle of the animation.
     if (stateInfo.normalizedTime >= transitionTiming)
     {
         // change "ForceTransition" to an enum value
         animator.SetBool("forceTransition", true);
     }
 }
Ejemplo n.º 13
0
    private void Awake()
    {
        Physics.gravity = new Vector3(0, GRAVITY_FALLING, 0);

        Grounded = new GroundedCharacterState();
        Jumping  = new JumpingCharacterState();
        Falling  = new FallingCharacterState();
        Moving   = new MovingCharacterState();
        Damage   = new DamageCharacterState();

        icounter = 0;
    }
    protected override void enterState(CharacterStateBase state)
    {
        if (state is PlayerState)
        {
            PlayerState playerCharacterControllerStateBase = (PlayerState)state;
            playerCharacterControllerStateBase.Enter(inputManager, this, components);

            if (state is PlayerGroundState)
            {
                blinkingController.ResetCounter();
            }
        }
    }
Ejemplo n.º 15
0
    public override void UpdateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        AliController ali = characterStateBase.GetBotController(animator);

        if (IsGrounded(ali))
        {
            animator.SetBool("IsGrounded", true);
        }
        else
        {
            animator.SetBool("IsGrounded", false);
        }
    }
Ejemplo n.º 16
0
    public void SetNewState(CharacterStateBase newState)
    {
        if (mainMovementState == null || newState.GetType() != mainMovementState.GetType())
        {
            if (mainMovementState != null)
            {
                exitState(mainMovementState);
            }

            enterState(newState);
            mainMovementState = newState;
        }
    }
Ejemplo n.º 17
0
    public override void OnEnter(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        TimerRecalling = 0f;
        canRecall      = false;

        control = characterStateBase.getController(animator);
        Hammer  = control.Hammer.GetComponent <Hammer>();

        // reset previous animation values
        animator.SetBool(AnimationTags.FORCE_TRANSITION, false);
        animator.SetInteger(AnimationTags.TRANSITION_INDEX, 0);
        animator.SetBool(AnimationTags.END, false);
    }
Ejemplo n.º 18
0
    // Idle is a StateData; which is an item from a list of abilities.
    // CharacterStateBase, which is attached to the object, will call updateAbility from all StateData
    public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // get control component
        control = characterStateBase.getController(animator);


        // move left
        if (control.moveLeft || control.moveRight)
        {
            animator.SetBool(AnimationTags.WALK, true);
        }
        else
        {
            animator.SetBool(AnimationTags.WALK, false);
        }


        // attack
        if (control.attack)
        {
            // different arm jab triggered depending on forward position
            if (control.transform.forward.x > 1)
            {
                animator.SetBool(AnimationTags.RIGHT_SWING, true);
            }
            else
            {
                animator.SetBool(AnimationTags.LEFT_SWING, true);
            }
        }


        // Hammer recall
        if (control.recall && !control.hammerEquipped)
        {
            animator.SetBool(AnimationTags.RECALL, true);
        }

        // Hammer throw
        if (control.throwHammer && control.hammerEquipped)
        {
            animator.SetBool(AnimationTags.THROW, true);
        }


        // Death
        if (control.dead)
        {
            animator.SetBool(AnimationTags.DEAD, true);
        }
    }
Ejemplo n.º 19
0
    protected void setNewState <T> () where T : CharacterStateBase
    {
        if (mainMovementState == null || typeof(T) != mainMovementState.GetType())
        {
            CharacterStateBase newState = (T)Activator.CreateInstance(typeof(T));

            if (mainMovementState != null)
            {
                exitState(mainMovementState);
            }

            enterState(newState);
            mainMovementState = newState;
        }
    }
Ejemplo n.º 20
0
    // MoveForward is a StateData; which is an item from a list of abilities.
    // CharacterStateBase, which is attached to the object, will call updateAbility from all StateData
    public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // get control script component
        control = characterStateBase.getController(animator);


        // if moving left
        if (control.moveLeft)
        {
            // animate walk
            animator.SetBool(AnimationTags.WALK, true);

            // move left
            control.transform.Translate(Vector3.forward * speed * speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime);

            // rotate left
            control.transform.rotation = Quaternion.Euler(0f, -90f, 0f);
        }



        // if moving right
        if (control.moveRight)
        {
            animator.SetBool(AnimationTags.WALK, true);

            control.transform.Translate(Vector3.forward * speed * speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime);

            control.transform.rotation = Quaternion.Euler(0f, 90f, 0f);
        }



        // not moving
        if (!control.moving)
        {
            animator.SetBool(AnimationTags.WALK, false);
        }



        // move forward regarless of input. Uses include moving forward with a punch
        if (constant)
        {
            control.transform.Translate(Vector3.forward * speed * speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime);
        }
    }
        void onStateChanged(CharacterStateBase newState, CharacterStateBase prevState)
        {
            if (typeof(InAirState).IsAssignableFrom(prevState.GetType()) && typeof(GroundState).IsAssignableFrom(newState.GetType()))
            {
                InAirState inAirState = (InAirState)prevState;

                if (Mathf.Abs(inAirState.LastInAirVelocity.y) > minYVelocityToAnimateLanding)
                {
                    headAnimationController.AnimateLand();
                }
            }

            if (typeof(WallRunState).IsAssignableFrom(newState.GetType()))
            {
                WallRunState wallRunState = (WallRunState)newState;

                switch (wallRunState.WallRunSide)
                {
                case WallRunState.WallRunType.LEFT:

                    spineAnimationController.AnimateWallRunLeft();

                    break;

                case WallRunState.WallRunType.RIGH:

                    spineAnimationController.AnimateWallRunRight();

                    break;
                }
            }

            if (typeof(WallRunState).IsAssignableFrom(prevState.GetType()))
            {
                spineAnimationController.AnimateToDefaultPosition();
            }
            else if (typeof(GroundState).IsAssignableFrom(newState.GetType()))
            {
                GroundState groundState = (GroundState)newState;
                onGroundStateInternalStateChaged(groundState.InternalState);
            }
            else if (typeof(SlideState).IsAssignableFrom(newState.GetType()))
            {
                headAnimationController.SetCrouch(true);
            }
        }
Ejemplo n.º 22
0
    public override void OnExit(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        // if inside the 'throw hammer begin' state. throw hammer
        if (control.hammerEquipped)
        {
            HammerScript.throwHammer();

            // camera shake
            //CameraManager.Instance.CameraShake(0.03f);

            // if inside the 'throw hammer end' state. throw hammer
        }
        else
        {
            control.hammerEquipped = false;

            animator.SetBool(AnimationTags.THROW, false);
        }
    }
Ejemplo n.º 23
0
    public override void UpdateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        AliController control = characterStateBase.GetBotController(animator);

        if (control.Jump)
        {
            animator.SetBool("IsJumping", true); //This is where you left off
        }

        if (control.MoveRight)
        {
            animator.SetBool("IsRunning", true);
        }

        if (control.MoveLeft)
        {
            animator.SetBool("IsRunning", true);
        }
    }
Ejemplo n.º 24
0
    public void deRegisterAttack(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        if (stateInfo.normalizedTime >= endAttackTime)
        {
            foreach (AttackInfo attackInfo in AttackManager.Instance.currentAttacks)
            {
                if (attackInfo == null)
                {
                    continue;
                }

                if (attackInfo.attackAbility == this && !attackInfo.isFinished)
                {
                    attackInfo.isFinished = true;

                    Destroy(attackInfo.gameObject);
                }
            }
        }
    }
Ejemplo n.º 25
0
        private void LateUpdate()
        {
            if (parent.isSuspended)
            {
                return;
            }

            CharacterStateBase.SetActive(states.bounds, allowBounds);
            CharacterStateBase.SetActive(states.follow, allowFollow);
            CharacterStateBase.SetActive(states.movement, allowMovement);
            CharacterStateBase.SetActive(states.viewport, allowViewport);
            CharacterStateBase.SetActive(states.zoom, allowZoom);

            CharacterStateBase.UpdateState(states.bounds);

            CharacterStateBase.UpdateState(states.follow);
            CharacterStateBase.UpdateState(states.viewport);
            CharacterStateBase.UpdateState(states.zoom);

            CharacterStateBase.UpdateState(states.movement);
        }
Ejemplo n.º 26
0
    public void registerAttack(CharacterStateBase characterState, Animator animator, AnimatorStateInfo stateInfo)
    {
        // register attack if our start attack time is less than the end of the animation and our end time is bigger than the animation length
        if (startAttackTime <= stateInfo.normalizedTime && endAttackTime > stateInfo.normalizedTime)
        {
            // cycle through all attack info objects
            foreach (AttackInfo attackInfo in AttackManager.Instance.currentAttacks)
            {
                // fail safe
                if (attackInfo == null)
                {
                    continue;
                }

                // register only the attack associated with this attack object
                if (!attackInfo.isRegistered && attackInfo.attackAbility == this)
                {
                    attackInfo.register(this, control);
                }
            }
        }
    }
Ejemplo n.º 27
0
    // CharacterStateBase, which is attached to the object, will call updateAbility from all StateData. This will run while the animation lasts.
    public override void updateAbility(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
    {
        registerAttack(characterStateBase, animator, stateInfo);
        deRegisterAttack(characterStateBase, animator, stateInfo);

        // if player presses attack again he might be able to trigger a combo
        if (control.attack)
        {
            if (
                stateInfo.normalizedTime > startAttackTime &&
                stateInfo.normalizedTime < endAttackTime)
            {
                animator.SetBool(AnimationTags.RIGHT_SWING, true);
            }

            // time window on which combo can be triggered
            if (
                stateInfo.normalizedTime > startAttackTime &&
                stateInfo.normalizedTime < endAttackTime &&
                stateInfo.normalizedTime > (startAttackTime + endAttackTime / 2)
                )
            {
                combo = true;
            }
        }

        // Transition to Right Swing Combo
        if (combo)
        {
            animator.SetBool(AnimationTags.RIGHT_SWING, true);
        }


        // if moving switch to Walk
        if (stateInfo.normalizedTime > 0.7f && control.moving)
        {
            animator.SetBool(AnimationTags.END, true);
        }
    }
Ejemplo n.º 28
0
 // will be called when the parameter for this animation is off
 public override void OnExit(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     //
 }
Ejemplo n.º 29
0
 public override void OnExit(CharacterStateBase characterStateBase, Animator animator, AnimatorStateInfo stateInfo)
 {
     animator.SetBool("forceTransition", false);
 }
 protected virtual void setNewState(CharacterStateBase newState)
 {
     characterController.SetNewState(newState);
 }