Пример #1
0
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (control.MoveLeft || control.MoveRight)
            {
                animator.SetBool(TransitionParameter.Move.ToString(), true);
            }
            else
            {
                animator.SetBool(TransitionParameter.Move.ToString(), false);
            }
        }
Пример #2
0
        private void CheckTurn(CharacterControl control)
        {
            if (!LockDirection)
            {
                if (control.MoveRight)
                {
                    control.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                }

                if (control.MoveLeft)
                {
                    control.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
                }
            }
        }
Пример #3
0
        public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (control.aiProgress.findingAgent == null)
            {
                GameObject pathfindingAgent_Prefab = Instantiate(Resources.Load("PathFindingAgent", typeof(GameObject)) as GameObject);

                control.aiProgress.findingAgent = pathfindingAgent_Prefab.GetComponent <PathFindingAgent>();
            }

            control.aiProgress.findingAgent.GetComponent <NavMeshAgent>().enabled = false;
            control.aiProgress.findingAgent.transform.position = control.transform.position;
            control.aiProgress.findingAgent.GoToTarget();
        }
Пример #4
0
 public void CheckCombo(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
 {
     if (stateInfo.normalizedTime >= StartAttackTime + ((EndAttackTime - StartAttackTime) / 3f))
     {
         if (stateInfo.normalizedTime < EndAttackTime + ((EndAttackTime - StartAttackTime) / 2f))
         {
             CharacterControl control = characterState.GetCharacterControl(animator);
             if (control.Attack)
             {
                 Debug.Log("upper cut is done");
                 animator.SetBool(TransitionParameter.Attack.ToString(), true);
             }
         }
     }
 }
Пример #5
0
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (stateInfo.normalizedTime >= CheckTime)
            {
                if (isGrounded(control))
                {
                    animator.SetBool(TransitionParameter.Grounded.ToString(), true);
                }
                else
                {
                    animator.SetBool(TransitionParameter.Grounded.ToString(), false);
                }
            }
        }
Пример #6
0
        public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            control.Jump   = true;
            control.MoveUp = true;

            if (control.aiProgress.findingAgent.startSphere.transform.position.z
                < control.aiProgress.findingAgent.endSphere.transform.position.z)
            {
                control.FaceForward(true);
            }
            else
            {
                control.FaceForward(false);
            }
        }
Пример #7
0
        public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (AllowEarlyTurn && !control.animationProgress.thisAllowEarlyTurn)
            {
                if (control.MoveLeft)
                {
                    control.FaceForward(false);
                }
                if (control.MoveRight)
                {
                    control.FaceForward(true);
                }
            }

            control.animationProgress.thisAllowEarlyTurn = false;
            control.animationProgress.AirMomentum        = 0f;
        }
Пример #8
0
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (control.isFacingForward())
            {
                if (control.MoveLeft)
                {
                    animator.SetBool(TransitionParameter.RunningTurn180.ToString(), true);
                }
            }

            if (!control.isFacingForward())
            {
                if (control.MoveRight)
                {
                    animator.SetBool(TransitionParameter.RunningTurn180.ToString(), true);
                }
            }
        }
Пример #9
0
        public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            Vector3 dir = control.aiProgress.findingAgent.startSphere.transform.position - control.transform.position;

            if (dir.z > 0f)
            {
                control.MoveRight = true;
                control.MoveLeft  = false;
            }
            else
            {
                control.MoveLeft  = true;
                control.MoveRight = false;
            }


            // Debug.Log(dir);
        }
Пример #10
0
        bool isBodyPart(Collider col)
        {
            CharacterControl control = col.transform.root.GetComponent <CharacterControl>();

            if (control == null)
            {
                return(false);
            }

            if (control.gameObject == col.gameObject)
            {
                return(false);
            }

            if (control.RagdollParts.Contains(col))
            {
                return(true);
            }
            return(false);
        }
Пример #11
0
        private void UpdateMomentum(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (control.MoveRight)
            {
                control.animationProgress.AirMomentum += speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime;
            }

            if (control.MoveLeft)
            {
                control.animationProgress.AirMomentum -= speedGraph.Evaluate(stateInfo.normalizedTime) * Time.deltaTime;
            }

            if (Mathf.Abs(control.animationProgress.AirMomentum) >= maxMomentum)
            {
                if (control.animationProgress.AirMomentum > 0f)
                {
                    control.animationProgress.AirMomentum = maxMomentum;
                }
                else if (control.animationProgress.AirMomentum < 0f)
                {
                    control.animationProgress.AirMomentum = -maxMomentum;
                }
            }

            if (control.animationProgress.AirMomentum > 0f)
            {
                control.FaceForward(true);
            }
            else if (control.animationProgress.AirMomentum < 0f)
            {
                control.FaceForward(false);
            }
            if (!CheckFront(control))
            {
                control.MoveForward(speed, Mathf.Abs(control.animationProgress.AirMomentum));
            }
        }
Пример #12
0
        bool CheckFront(CharacterControl control)
        {
            foreach (GameObject o in control.FrontSpheres)
            {
                Debug.DrawRay(o.transform.position, control.transform.forward * 0.3f, Color.red);
                RaycastHit hit;

                if (Physics.Raycast(o.transform.position, control.transform.forward, out hit, BlockDistance))
                {
                    if (!control.RagdollParts.Contains(hit.collider))
                    {
                        if (!isBodyPart(hit.collider) &&
                            !Ledge.isLedge(hit.collider.gameObject) &&
                            !Ledge.isLedgeChecker(hit.collider.gameObject))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Пример #13
0
        bool TransitionTONextAI(CharacterControl characterControl)
        {
            if (aITransition == AI_TransitionType.RUN_TO_WALK)
            {
                Vector3 dist = characterControl.aiProgress.findingAgent.startSphere.transform.position - characterControl.transform.position;

                if (Vector3.SqrMagnitude(dist) < 2f)
                {
                    return(true);
                }
            }
            else if (aITransition == AI_TransitionType.WALK_TO_RUN)
            {
                Vector3 dist = characterControl.aiProgress.findingAgent.startSphere.transform.position - characterControl.transform.position;

                if (Vector3.SqrMagnitude(dist) > 2f)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #14
0
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            if (control.isFacingForward())
            {
                if (control.transform.position.z < control.aiProgress.findingAgent.endSphere.transform.position.z)
                {
                    control.MoveRight = true;
                    control.MoveLeft  = false;
                }
                else
                {
                    control.MoveRight = false;
                    control.MoveLeft  = false;

                    animator.gameObject.SetActive(false);
                    animator.gameObject.SetActive(true);
                }
            }
            else
            {
                if (control.transform.position.z > control.aiProgress.findingAgent.endSphere.transform.position.z)
                {
                    control.MoveRight = false;
                    control.MoveLeft  = true;
                }
                else
                {
                    control.MoveRight = false;
                    control.MoveLeft  = false;

                    animator.gameObject.SetActive(false);
                    animator.gameObject.SetActive(true);
                }
            }
        }
Пример #15
0
        private void OnTriggerEnter(Collider col)
        {
            if (owner.RagdollParts.Contains(col))
            {
                return;
            }

            CharacterControl attacker = col.transform.root.GetComponent <CharacterControl>();

            if (attacker == null)
            {
                return;
            }

            if (col.gameObject == attacker.gameObject)
            {
                return;
            }

            if (!CollidingParts.Contains(col))
            {
                CollidingParts.Add(col);
            }
        }
Пример #16
0
 private void Awake()
 {
     characterControl = this.gameObject.GetComponent <CharacterControl>();
 }
Пример #17
0
 private void Awake()
 {
     DamageTaken = 0;
     control     = GetComponent <CharacterControl>();
 }
Пример #18
0
        public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            control.animationProgress.thisAllowEarlyTurn = true;
        }
Пример #19
0
 private void ToggleBoxCol(CharacterControl control)
 {
     control.RIGIBODY.velocity = Vector3.zero;
     control.GetComponent <BoxCollider>().enabled = on;
 }
Пример #20
0
        public override void OnExit(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);

            control.animationProgress.AirMomentum = 0f;
        }
Пример #21
0
        private bool MakeTransition(CharacterControl control)
        {
            foreach (TransitionConditionType c in transitionConditions)
            {
                switch (c)
                {
                case TransitionConditionType.UP:
                {
                    if (!control.MoveUp)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.DOWN:
                {
                    if (!control.MoveDown)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.LEFT:
                {
                    if (!control.MoveLeft)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.RIGHT:
                {
                    if (!control.MoveRight)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.ATTACK:
                {
                    if (!control.Attack)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.JUMP:
                {
                    if (!control.Jump)
                    {
                        return(false);
                    }
                }
                break;

                case TransitionConditionType.GRABBING_LEDGE:
                {
                    if (!control.ledgeChecker.isGrabbingLedge)
                    {
                        return(false);
                    }
                }
                break;
                }
            }
            return(true);
        }
Пример #22
0
 private void Awake()
 {
     owner = this.GetComponentInParent <CharacterControl>();
 }
Пример #23
0
 public override void OnEnter(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
 {
     CharacterControl control = characterState.GetCharacterControl(animator);
 }
Пример #24
0
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            CharacterControl control = characterState.GetCharacterControl(animator);
            Vector3          dist    = control.aiProgress.findingAgent.startSphere.transform.position - control.transform.position;

            //Jumping, if startsphere is on lower platform than endphere

            if (control.aiProgress.findingAgent.startSphere.transform.position.y
                < control.aiProgress.findingAgent.endSphere.transform.position.y)
            {
                if (Vector3.SqrMagnitude(dist) < 0.01f)
                {
                    control.MoveLeft  = false;
                    control.MoveRight = false;

                    animator.SetBool(EnemyTransitions.JumpPlatform.ToString(), true);
                }
            }

            //Fall, if endsphere is on lower platform than startsphere

            if (control.aiProgress.findingAgent.startSphere.transform.position.y
                > control.aiProgress.findingAgent.endSphere.transform.position.y)
            {
                animator.SetBool(EnemyTransitions.FallPlatform.ToString(), true);
            }

            //Go straignt if Endsphere and startphare are on same platform

            if (control.aiProgress.findingAgent.startSphere.transform.position.y
                == control.aiProgress.findingAgent.endSphere.transform.position.y)
            {
                if (Vector3.SqrMagnitude(dist) < 0.7f)
                {
                    control.MoveLeft  = false;
                    control.MoveRight = false;

                    Vector3 playerDist = control.transform.position - CharacterManager.Instance.GetPlayableCharacter().transform.position;
                    if (playerDist.sqrMagnitude > 1f)
                    {
                        animator.gameObject.SetActive(false);
                        animator.gameObject.SetActive(true);
                    }
                    //temp attack

                    /*  else
                     * {
                     *    if(CharacterManager.Instance.GetPlayableCharacter().damageDetector.DamageTaken == 0)
                     *    {
                     *        if(control.isFacingForward())
                     *        {
                     *            control.MoveRight = false;
                     *            control.MoveLeft = false;
                     *            control.Attack = true;
                     *        }
                     *        else
                     *        {
                     *            control.MoveRight = false;
                     *            control.MoveLeft = false;
                     *            control.Attack = true;
                     *        }
                     *    }
                     *    else
                     *    {
                     *        control.Attack = false;
                     *        control.MoveLeft = false;
                     *        control.MoveRight = false;
                     *    }
                     *
                     * }*/
                }
            }
        }
Пример #25
0
 private void ToggleGrav(CharacterControl control)
 {
     // control.SkinnedMeshedAnimator
     control.RIGIBODY.velocity   = Vector3.zero;
     control.RIGIBODY.useGravity = on;
 }
Пример #26
0
 public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
 {
     CharacterControl control = characterState.GetCharacterControl(animator);
 }