Ejemplo n.º 1
0
 bool FlyingKick(CharacterControl control)
 {
     if (control.aiProgress.DoFlyingKick &&
         control.aiProgress.TargetIsOnSamePlatform())
     {
         control.Attack = true;
         return(true);
     }
     else
     {
         control.Attack = false;
         return(false);
     }
 }
Ejemplo n.º 2
0
        private void OnTriggerExit(Collider other)
        {
            CharacterControl control = other.gameObject.transform.root.gameObject.GetComponent <CharacterControl>();

            if (control != null)
            {
                if (control.gameObject != other.gameObject)
                {
                    if (ListCharacters.Contains(control))
                    {
                        ListCharacters.Remove(control);
                    }
                }
            }
        }
Ejemplo n.º 3
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);
                }
            }
        }
        private void CheckTurn(CharacterControl control)
        {
            if (!LockDirection)
            {
                if (control.MoveRight)
                {
                    control.ROTATION_DATA.FaceForward(true);
                }

                if (control.MoveLeft)
                {
                    control.ROTATION_DATA.FaceForward(false);
                }
            }
        }
Ejemplo n.º 5
0
        private void ConstantMove(CharacterControl control, Animator animator, AnimatorStateInfo stateInfo)
        {
            if (!IsBlocked(control, Speed, stateInfo))
            {
                control.MoveForward(Speed, SpeedGraph.Evaluate(stateInfo.normalizedTime));
            }

            if (!control.MoveRight && !control.MoveLeft)
            {
                animator.SetBool(HashManager.Instance.DicMainParams[TransitionParameter.Move], false);
            }
            else
            {
                animator.SetBool(HashManager.Instance.DicMainParams[TransitionParameter.Move], true);
            }
        }
Ejemplo n.º 6
0
        void ForwardGroundAttack(CharacterControl control)
        {
            if (control.aiProgress.TargetIsOnRightSide())
            {
                control.MoveRight = true;
                control.MoveLeft  = false;

                ProcForwardGroundAttack(control);
            }
            else
            {
                control.MoveRight = false;
                control.MoveLeft  = true;

                ProcForwardGroundAttack(control);
            }
        }
        void UpdateCharacterIgnoreTime(CharacterControl control, AnimatorStateInfo stateInfo)
        {
            if (!IgnoreCharacterBox)
            {
                control.animationProgress.IsIgnoreCharacterTime = false;
            }

            if (stateInfo.normalizedTime > IgnoreStartTime &&
                stateInfo.normalizedTime < IgnoreEndTime)
            {
                control.animationProgress.IsIgnoreCharacterTime = true;
            }
            else
            {
                control.animationProgress.IsIgnoreCharacterTime = false;
            }
        }
Ejemplo n.º 8
0
        void CheckLeftRightUpDown(CharacterControl control)
        {
            if (control.MoveLeft)
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Left], true);
            }
            else
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Left], false);
            }

            if (control.MoveRight)
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Right], true);
            }
            else
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Right], false);
            }

            if (control.MoveUp)
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Up], true);
            }
            else
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Up], false);
            }

            if (control.MoveDown)
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Down], true);
            }
            else
            {
                control.SkinnedMeshAnimator.
                SetBool(HashManager.Instance.ArrMainParams[(int)MainParameterType.Down], false);
            }
        }
Ejemplo n.º 9
0
        bool AIIsOnGround(CharacterControl control)
        {
            if (control.animationProgress.IsRunning(typeof(MoveUp)))
            {
                return(false);
            }

            if (control.RIGID_BODY.useGravity)
            {
                if (control.SkinnedMeshAnimator.GetBool(
                        HashManager.Instance.DicMainParams[TransitionParameter.Grounded]))
                {
                    return(true);
                }
            }

            return(false);
        }
        bool AIIsOnGround(CharacterControl control)
        {
            if (control.ANIMATION_DATA.IsRunning(typeof(MoveUp)))
            {
                return(false);
            }

            if (control.RIGID_BODY.useGravity)
            {
                if (control.SkinnedMeshAnimator.GetBool(
                        HashManager.Instance.ArrMainParams[(int)MainParameterType.Grounded]))
                {
                    return(true);
                }
            }

            return(false);
        }
        void ShowHitParticles(CharacterControl attacker, PoolObjectType EffectsType)
        {
            GameObject vfx = PoolManager.Instance.GetObject(EffectsType);

            vfx.transform.position =
                control.DAMAGE_DATA.damageTaken.DAMAGEE.triggerCollider.bounds.center;

            vfx.SetActive(true);

            if (attacker.ROTATION_DATA.IsFacingForward())
            {
                vfx.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
            else
            {
                vfx.transform.rotation = Quaternion.Euler(0f, 180f, 0f);
            }
        }
Ejemplo n.º 12
0
        public void NormalGroundAttack(CharacterControl control)
        {
            if (control.aiProgress.TargetIsOnSamePlatform())
            {
                control.MoveRight = false;
                control.MoveLeft  = false;

                if (control.aiProgress.IsFacingTarget() &&
                    !control.animationProgress.IsRunning(typeof(MoveForward)))
                {
                    control.Attack = true;
                }
            }
            else
            {
                control.Attack = false;
            }
        }
Ejemplo n.º 13
0
        bool IsGrounded(CharacterControl control)
        {
            if (control.contactPoints != null)
            {
                foreach (ContactPoint c in control.contactPoints)
                {
                    float colliderBottom = (control.transform.position.y + control.boxCollider.center.y)
                                           - (control.boxCollider.size.y / 2f);
                    float yDifference = Mathf.Abs(c.point.y - colliderBottom);

                    if (yDifference < 0.01f)
                    {
                        if (Mathf.Abs(control.RIGID_BODY.velocity.y) < 0.001f)
                        {
                            control.animationProgress.Ground = c.otherCollider.transform.root.gameObject;
                            return(true);
                        }
                    }
                }
            }

            if (control.RIGID_BODY.velocity.y < 0f)
            {
                foreach (GameObject o in control.collisionSpheres.BottomSpheres)
                {
                    Debug.DrawRay(o.transform.position, -Vector3.up * 0.7f, Color.yellow);
                    RaycastHit hit;
                    if (Physics.Raycast(o.transform.position, -Vector3.up, out hit, Distance))
                    {
                        if (!control.RagdollParts.Contains(hit.collider) &&
                            !Ledge.IsLedge(hit.collider.gameObject) &&
                            !Ledge.IsLedgeChecker(hit.collider.gameObject) &&
                            !Ledge.IsCharacter(hit.collider.gameObject))
                        {
                            control.animationProgress.Ground = hit.collider.transform.root.gameObject;
                            return(true);
                        }
                    }
                }
            }

            control.animationProgress.Ground = null;
            return(false);
        }
        List <GameObject> GetFrontBlockingCharacterList()
        {
            FrontBlockingCharacters.Clear();

            foreach (KeyValuePair <GameObject, GameObject> data in FrontBlockingObjs)
            {
                CharacterControl c = CharacterManager.Instance.GetCharacter(data.Value.transform.root.gameObject);

                if (c != null)
                {
                    if (!FrontBlockingCharacters.Contains(c.gameObject))
                    {
                        FrontBlockingCharacters.Add(c.gameObject);
                    }
                }
            }

            return(FrontBlockingCharacters);
        }
        bool UpIsBlocked(CharacterControl control)
        {
            foreach (GameObject o in control.collisionSpheres.UpSpheres)
            {
                Debug.DrawRay(o.transform.position, control.transform.up * 0.3f, Color.yellow);

                RaycastHit hit;
                if (Physics.Raycast(o.transform.position, control.transform.up, out hit, 0.125f))
                {
                    if (hit.collider.transform.root.gameObject != control.gameObject &&
                        !Ledge.IsLedge(hit.collider.gameObject))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        private void MoveOnMomentum(CharacterControl control, AnimatorStateInfo stateInfo)
        {
            float speed = SpeedGraph.Evaluate(stateInfo.normalizedTime) * Speed * Time.deltaTime;

            control.MOMENTUM_DATA.CalculateMomentum(speed, MaxMomentum);

            if (control.MOMENTUM_DATA.Momentum > 0f)
            {
                control.ROTATION_DATA.FaceForward(true);
            }
            else if (control.MOMENTUM_DATA.Momentum < 0f)
            {
                control.ROTATION_DATA.FaceForward(false);
            }

            if (!IsBlocked(control))
            {
                control.MoveForward(Speed, Mathf.Abs(control.MOMENTUM_DATA.Momentum));
            }
        }
        CharacterControl CheckCollidingBodyParts(Collider col)
        {
            if (control == null)
            {
                return(null);
            }

            for (int i = 0; i < control.RAGDOLL_DATA.ArrBodyParts.Length; i++)
            {
                if (control.RAGDOLL_DATA.ArrBodyParts[i].Equals(col))
                {
                    return(null);
                }
            }

            CharacterControl attacker = CharacterManager.Instance.GetCharacter(col.transform.root.gameObject);

            if (attacker == null)
            {
                return(null);
            }

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

            // add collider to dictionary

            if (!control.animationProgress.CollidingBodyParts.ContainsKey(this))
            {
                control.animationProgress.CollidingBodyParts.Add(this, new List <Collider>());
            }

            if (!control.animationProgress.CollidingBodyParts[this].Contains(col))
            {
                control.animationProgress.CollidingBodyParts[this].Add(col);
            }

            return(attacker);
        }
 private void ConstantMove(CharacterControl control, AnimatorStateInfo stateInfo)
 {
     if (!IsBlocked(control))
     {
         if (MoveOnHit)
         {
             if (!control.animationProgress.IsFacingAttacker())
             {
                 control.MoveForward(Speed, SpeedGraph.Evaluate(stateInfo.normalizedTime));
             }
             else
             {
                 control.MoveForward(-Speed, SpeedGraph.Evaluate(stateInfo.normalizedTime));
             }
         }
         else
         {
             control.MoveForward(Speed, SpeedGraph.Evaluate(stateInfo.normalizedTime));
         }
     }
 }
Ejemplo n.º 19
0
        IEnumerator Start()
        {
            switch (characterSelect.SelectedCharacterType)
            {
            case PlayableCharacterType.YELLOW:
            {
                objName = "yBot - Yellow";
            }
            break;

            case PlayableCharacterType.RED:
            {
                objName = "yBot - Red Variant";
            }
            break;

            case PlayableCharacterType.GREEN:
            {
                objName = "yBot - Green Variant";
            }
            break;
            }

            GameObject obj = Instantiate(Resources.Load(objName, typeof(GameObject))) as GameObject;

            obj.transform.position = this.transform.position;
            GetComponent <MeshRenderer>().enabled = false;

            yield return(new WaitForEndOfFrame());

            Cinemachine.CinemachineVirtualCamera[] arr = GameObject.FindObjectsOfType <Cinemachine.CinemachineVirtualCamera>();
            foreach (Cinemachine.CinemachineVirtualCamera v in arr)
            {
                CharacterControl control = CharacterManager.Instance.GetCharacter(characterSelect.SelectedCharacterType);
                Collider         target  = control.RAGDOLL_DATA.GetBody("Spine1");

                v.LookAt = target.transform;
                v.Follow = target.transform;
            }
        }
        bool IsBodyPart(Collider col)
        {
            if (col.transform.root.gameObject == control.gameObject)
            {
                return(true);
            }

            CharacterControl target = CharacterManager.Instance.GetCharacter(col.transform.root.gameObject);

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

            if (target.damageDetector.IsDead())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        void TakeCollateralDamage(CharacterControl attacker, Collider col)
        {
            if (attacker.RAGDOLL_DATA.flyingRagdollData.IsTriggered)
            {
                if (attacker.RAGDOLL_DATA.flyingRagdollData.Attacker != control)
                {
                    float mag = Vector3.SqrMagnitude(col.attachedRigidbody.velocity);
                    Debug.Log("incoming ragdoll: " + attacker.gameObject.name + "\n" + "Velocity: " + mag);

                    if (mag >= 10f)
                    {
                        control.DAMAGE_DATA.damageTaken = new DamageTaken(
                            null,
                            null,
                            this,
                            null,
                            col.attachedRigidbody.velocity);

                        control.DAMAGE_DATA.hp = 0;
                        control.RAGDOLL_DATA.RagdollTriggered = true;
                    }
                }
            }
        }
        public void RemoveWeaponFromDictionary(CharacterControl c)
        {
            for (int i = 0; i < c.RAGDOLL_DATA.ArrBodyParts.Length; i++)
            {
                TriggerDetector t = c.RAGDOLL_DATA.ArrBodyParts[i].GetComponent <TriggerDetector>();

                if (t != null)
                {
                    ProcRemove(c.animationProgress.CollidingWeapons, t);
                    ProcRemove(c.animationProgress.CollidingBodyParts, t);
                }
            }

            //foreach(Collider col in c.RAGDOLL_DATA.BodyParts)
            //{
            //    TriggerDetector t = col.GetComponent<TriggerDetector>();
            //
            //    if (t != null)
            //    {
            //        ProcRemove(c.animationProgress.CollidingWeapons, t);
            //        ProcRemove(c.animationProgress.CollidingBodyParts, t);
            //    }
            //}
        }
Ejemplo n.º 23
0
        public void DropWeapon()
        {
            MeleeWeapon w = control.animationProgress.HoldingWeapon;

            if (w != null)
            {
                w.transform.parent = null;

                if (control.IsFacingForward())
                {
                    w.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
                }
                else
                {
                    w.transform.rotation = Quaternion.Euler(-90f, 0f, 0f);
                }

                w.transform.position = control.transform.position + (Vector3.up * 0.0225f);

                control.animationProgress.HoldingWeapon = null;
                control = null;
                w.triggerDetector.control = null;
            }
        }
Ejemplo n.º 24
0
 private void Start()
 {
     control = this.gameObject.GetComponentInParent <CharacterControl>();
 }
Ejemplo n.º 25
0
        private void FixedUpdate()
        {
            if (control.SubComponentsDic.ContainsKey(SubComponents.MANUALINPUT))
            {
                return;
            }

            if (!control.SkinnedMeshAnimator.GetBool(HashManager.Instance.DicMainParams[TransitionParameter.Grounded]))
            {
                return;
            }

            foreach (KeyValuePair <TriggerDetector, List <Collider> > data in control.animationProgress.CollidingBodyParts)
            {
                foreach (Collider col in data.Value)
                {
                    CharacterControl c = CharacterManager.Instance.GetCharacter(col.transform.root.gameObject);

                    if (c == control)
                    {
                        continue;
                    }

                    if (!c.SubComponentsDic.ContainsKey(SubComponents.MANUALINPUT))
                    {
                        continue;
                    }

                    if (!c.SkinnedMeshAnimator.GetBool(HashManager.Instance.DicMainParams[TransitionParameter.Grounded]))
                    {
                        continue;
                    }

                    if (c.animationProgress.IsRunning(typeof(Attack)))
                    {
                        continue;
                    }

                    if (control.animationProgress.IsRunning(typeof(Attack)))
                    {
                        continue;
                    }

                    if (c.animationProgress.StateNameContains("RunningSlide"))
                    {
                        continue;
                    }

                    if (c.damageDetector.IsDead())
                    {
                        continue;
                    }

                    if (control.damageDetector.IsDead())
                    {
                        continue;
                    }

                    Debug.Log("instaKill");
                    c.damageDetector.DeathByInstaKill(control);

                    return;
                }
            }
        }
Ejemplo n.º 26
0
 private void Awake()
 {
     ArrSubComponents = new SubComponent[(int)SubComponentType.COUNT];
     control          = GetComponentInParent <CharacterControl>();
 }
Ejemplo n.º 27
0
 private void Start()
 {
     control = this.transform.root.gameObject.GetComponent <CharacterControl>();
 }
 private void ToggleGrav(CharacterControl control)
 {
     control.RIGID_BODY.velocity   = Vector3.zero;
     control.RIGID_BODY.useGravity = On;
 }
 private void Awake()
 {
     control = this.GetComponentInParent <CharacterControl>();
 }
        public override void UpdateAbility(CharacterState characterState, Animator animator, AnimatorStateInfo stateInfo)
        {
            // walking
            if (characterState.characterControl.aiProgress.AIDistanceToEndSphere() < 1f)
            {
                if (characterState.characterControl.aiProgress.TargetDistanceToEndSphere() > 0.5f)
                {
                    if (characterState.characterControl.aiProgress.TargetIsGrounded())
                    {
                        characterState.characterControl.aiController.InitializeAI();
                    }
                }
            }

            // landing
            if (characterState.characterControl.animationProgress.IsRunning(typeof(Landing)))
            {
                characterState.characterControl.Turbo  = false;
                characterState.characterControl.Jump   = false;
                characterState.characterControl.MoveUp = false;
                characterState.characterControl.aiController.InitializeAI();
            }

            // path is blocked
            if (characterState.characterControl.animationProgress.BlockingObjs.Count == 0)
            {
                characterState.characterControl.aiProgress.BlockingCharacter = null;
            }
            else
            {
                foreach (KeyValuePair <GameObject, GameObject> data in
                         characterState.characterControl.animationProgress.BlockingObjs)
                {
                    CharacterControl blockingChar = CharacterManager.Instance.GetCharacter(data.Value);

                    if (blockingChar != null)
                    {
                        characterState.characterControl.aiProgress.BlockingCharacter = blockingChar;
                        break;
                    }
                    else
                    {
                        characterState.characterControl.aiProgress.BlockingCharacter = null;
                    }
                }
            }

            if (characterState.characterControl.aiProgress.BlockingCharacter != null)
            {
                if (characterState.characterControl.animationProgress.Ground != null)
                {
                    if (!characterState.characterControl.animationProgress.IsRunning(typeof(Jump)) &&
                        !characterState.characterControl.animationProgress.IsRunning(typeof(JumpPrep)))
                    {
                        characterState.characterControl.Turbo     = false;
                        characterState.characterControl.Jump      = false;
                        characterState.characterControl.MoveUp    = false;
                        characterState.characterControl.MoveLeft  = false;
                        characterState.characterControl.MoveRight = false;
                        characterState.characterControl.MoveDown  = false;
                        characterState.characterControl.aiController.InitializeAI();
                    }
                }
            }

            //startsphere height
            if (characterState.characterControl.animationProgress.Ground != null &&
                !characterState.characterControl.animationProgress.IsRunning(typeof(Jump)) &&
                !characterState.characterControl.animationProgress.IsRunning(typeof(WallJumpPrep)))
            {
                if (characterState.characterControl.aiProgress.GetStartSphereHeight() > 0.1f)
                {
                    characterState.characterControl.Turbo     = false;
                    characterState.characterControl.Jump      = false;
                    characterState.characterControl.MoveUp    = false;
                    characterState.characterControl.MoveLeft  = false;
                    characterState.characterControl.MoveRight = false;
                    characterState.characterControl.MoveDown  = false;
                    characterState.characterControl.aiController.InitializeAI();
                }
            }
        }