Example #1
0
        private bool IsCollidedWithAttackPoint(Grappler info)
        {
            /*
             * TriggerDetector trigger = control.GetTriggerDetector ();
             * foreach (Collider c in trigger.CollidingParts) {
             *  if (info.Attacker.GetAttackPoint () == c)
             *      return true;
             * }
             * return false;
             */

            /*
             * int layerMask = 1 << 9;
             * RaycastHit hit;
             * //if (Physics.Raycast (info.Attacker.gameObject.transform.position, info.Attacker.gameObject.transform.forward, out hit, Mathf.Infinity, layerMask)) {
             * if (Physics.BoxCast(info.Attacker.GetAttackPoint ().gameObject.transform.position,
             * info.Range * new Vector3(1.0f,1.0f,0.2f), info.Attacker.gameObject.transform.forward,
             * out hit, info.Attacker.gameObject.transform.rotation, info.Range, layerMask)) {
             *  //Debug.DrawRay (info.Attacker.transform.position, info.Attacker.transform.forward * hit.distance, Color.yellow, info.Range);
             *  //if (hit.distance <= info.Range) {
             *  Debug.Log("Did Hit");
             *  return true;
             *  //}
             * }
             * else
             * {
             *  Debug.DrawRay(info.Attacker.transform.position, info.Attacker.transform.forward * 100, Color.white);
             *  Debug.Log("Did not Hit");
             *  return false;
             * }
             */

            if (info.Mode == GrapplerTargetChosingMode.LockedTargetOnly)
            {
                if (control != info.Attacker.CharacterData.FormerAttackTarget)
                {
                    return(false);
                }
            }
            if (info.Mode == GrapplerTargetChosingMode.LockedStunnedTargetOnly)
            {
                if (control != info.Attacker.CharacterData.FormerAttackTarget && !control.CharacterData.IsStunned)
                {
                    return(false);
                }
            }
            //Debug.Log("Check Grappling in range!");
            Vector3 dist = control.gameObject.transform.position - info.Attacker.GetProjectileSpawnPoint().gameObject.transform.position;

            dist.y = 0f;
            if (dist.magnitude <= info.Range)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private void ProcessGrappling(Grappler info)
        {
            //if (info.Target == null) {
            info.Target = control;
            //Debug.Log ("Grappler HIT !!!");
            control.CharacterData.IsGrappled = true;
            control.TurnOffArmourRegen(3f);

            if (info.Type == GrapplerType.FrontStab)
            {
                control.HitReactionAndFreeze(info.FreezeStartTiming, GrapplerType.FrontStab);

                info.Attacker.CharacterController.Move(info.Attacker.gameObject.transform.forward * 0.6f);
                Vector3 AttackerFront = info.Attacker.gameObject.transform.forward * 1.2f;
                AttackerFront.y = 0f;
                Vector3 diff = control.gameObject.transform.position - info.Attacker.gameObject.transform.position;
                diff.y = 0f;
                Vector3 dir = AttackerFront - diff;
                control.CharacterController.Move(dir);

                Vector3 dirVector = control.gameObject.transform.position - info.Attacker.gameObject.transform.position;
                Vector3 hitVector = (new Vector3(dirVector.x, 0, dirVector.z)).normalized;
                control.FaceTarget = -hitVector;
                control.TurnToTarget(0f, 0f);
                info.Attacker.FaceTarget = hitVector;
                info.Attacker.TurnToTarget(0f, 0f);

                control.gameObject.transform.parent = info.Attacker.Animator.gameObject.transform;
            }
            else if (info.Type == GrapplerType.DownStab)
            {
                control.HitReactionAndFreeze(info.FreezeStartTiming, GrapplerType.DownStab);

                //info.Attacker.CharacterController.Move (info.Attacker.gameObject.transform.forward * 0.6f);
                Vector3 AttackerPos = control.gameObject.transform.position + control.gameObject.transform.forward * 0.9f;
                AttackerPos.y = 0f;
                Vector3 diff = AttackerPos - info.Attacker.gameObject.transform.position;
                diff.y = 0f;
                info.Attacker.CharacterController.Move(diff);

                Vector3 dirVector = control.gameObject.transform.position - info.Attacker.gameObject.transform.position;
                Vector3 hitVector = (new Vector3(dirVector.x, 0, dirVector.z)).normalized;
                control.FaceTarget = -hitVector;
                control.TurnToTarget(0f, 0f);
                info.Attacker.FaceTarget = hitVector;
                info.Attacker.TurnToTarget(0f, 0f);
            }

            //control.Animator.SetFloat (TransitionParameter.SpeedMultiplier.ToString (), 0f);
            info.GrapplingHit();

            //}
            //control.Dead ();
        }
        public override void OnEnter(StatewithEffect stateEffect, Animator animator, AnimatorStateInfo stateInfo)
        {
            animator.SetBool(TransitionParameter.AttackExecute.ToString(), false);
            stateEffect.CharacterControl.CommandExecute = false;
            GameObject obj = PoolManager.Instance.GetObject(PoolObjectType.Grappler);
            //PoolObject poolObj = obj.GetComponent<PoolObject>();
            //poolObj.WaitAndDestroy(2f);
            Grappler grappler = obj.GetComponent <Grappler> ();

            grappler.Init(this, stateEffect.CharacterControl);
            obj.SetActive(true);
            AttackManager.Instance.CurrentGrappler.Add(grappler);
            if (stateEffect.CharacterControl.isPlayerControl)
            {
                VirtualInputManager.Instance.ClearAllInputsInBuffer();
            }
            //stateEffect.CharacterControl.ExecuteTrigger = true;
            //animator.SetBool (TransitionParameter.ForcedTransition.ToString (), false);
            //Debug.Log ("Enter " + stateInfo.normalizedTime.ToString());
        }