Exemplo n.º 1
0
 public virtual void UpdateCameraAimSide()
 {
     if (CameraSide)
     {
         if (!(!ActiveAbility.ChangeAimCameraSide() && Weapon_is_RightHand))   //Prevent the Camera Swap if is Using A Bow
         {
             OnAimSide.Invoke(1);
         }
         else
         {
             OnAimSide.Invoke(-1);
         }
     }
     else
     {
         if (!(!ActiveAbility.ChangeAimCameraSide() && Weapon_is_LeftHand))  //Prevent the Camera Swap if is Using A Bow
         {
             OnAimSide.Invoke(-1);
         }
         else
         {
             OnAimSide.Invoke(1);
         }
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Resets the Aim if is Aiming
 /// </summary>
 public virtual void ResetAiming()
 {
     if (IsAiming)
     {
         isAiming = false;                                                                           //Reset the aiming state
         OnAimSide.Invoke(0);                                                                        //Send that is not aiming anymore
         SetAction(IsInCombatMode ? WeaponActions.Idle : WeaponActions.None);
     }
 }
Exemplo n.º 3
0
        /// <summary>Initialize all variables for the Rider</summary>
        protected virtual void InitRiderCombat()
        {
            _t    = transform;                                             //Get this Transform
            Anim  = GetComponent <Animator>();                             //Get the Animator
            Rider = GetComponent <MRider>();


            DefaultAnimUpdateMode = Anim.updateMode;
            GetHashIDs();

            Head  = Anim.GetBoneTransform(HumanBodyBones.Head);                    //Get the Rider Head transform
            Chest = Anim.GetBoneTransform(HumanBodyBones.Chest);                   //Get the Rider Head transform

            RightHand = Anim.GetBoneTransform(HumanBodyBones.RightHand);           //Get the Rider Right Hand transform
            LeftHand  = Anim.GetBoneTransform(HumanBodyBones.LeftHand);            //Get the Rider Left  Hand transform

            RightShoulder = Anim.GetBoneTransform(HumanBodyBones.RightUpperArm);   //Get the Rider Right Shoulder transform
            LeftShoulder  = Anim.GetBoneTransform(HumanBodyBones.LeftUpperArm);    //Get the Rider Left  Shoulder transform

            SetActiveHolder(ActiveHolderSide);                                     //Set one Holder to Draw Weapons
            CombatMode    = false;
            ActiveAbility = null;

            Layer_RiderArmLeft  = Anim.GetLayerIndex("Rider Arm Left");             //Gets the Left Arm Layer Index
            Layer_RiderArmRight = Anim.GetLayerIndex("Rider Arm Right");            //Gets the Right Arm Layer Index
            Layer_RiderCombat   = Anim.GetLayerIndex(CombatLayerName);              //Gets the Combat Later Index


            Aimer        = GetComponent <IAim>();
            Aimer.Active = true;

            if (CloneAbilities)
            {
                for (int i = 0; i < CombatAbilities.Count; i++)
                {
                    RiderCombatAbility instance = (RiderCombatAbility)ScriptableObject.CreateInstance(CombatAbilities[i].GetType());
                    instance           = ScriptableObject.Instantiate(CombatAbilities[i]);                       //Create a clone from the Original Scriptable Objects! IMPORTANT
                    instance.name      = instance.name.Replace("(Clone)", "(C)");
                    CombatAbilities[i] = instance;
                }
            }

            foreach (var ability in CombatAbilities)
            {
                ability.StartAbility(this); //Initialize the Abilities
            }


            //Event Listeners
            Rider.OnStartMounting.AddListener(OnStartMounting);
            Rider.OnStartDismounting.AddListener(OnStartDismounting);
            //rider.OnEndMounting.AddListener(OnEndMounting);
            //rider.OnEndDismounting.AddListener(OnEndDismounting);

            OnAimSide.AddListener(InAimMode);
        }
Exemplo n.º 4
0
        ///──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
        /// <summary>
        /// Change the Camera Sides for better Aiming
        /// </summary>
        void SetAim(bool Side)
        {
            aimSent           = true;
            CurrentCameraSide = CameraSide;                                 //Set the current camera = to the actual camera side

            if (_weaponAction != WeaponActions.Hold &&
                _weaponAction != WeaponActions.ReloadLeft &&
                _weaponAction != WeaponActions.ReloadRight)
            {
                SetAction(Active_IMWeapon.RightHand ? WeaponActions.AimRight : WeaponActions.AimLeft);   //If the weapon is Right Handed set the action to AimRight else AimLeft
            }
            OnAimSide.Invoke(Side ? 1 : -1);
        }
Exemplo n.º 5
0
        ///──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
        /// <summary>
        /// This method is used to activate the AIM mode when the right click is pressed
        /// </summary>
        public virtual void AimMode()
        {
            LookDirection();

            if (InputAim.GetPressed != InputButton.Press)               //If the Aim is set to One Click
            {
                if (InputAim.GetInput)                                  //Get the AIM input
                {
                    isAiming          = !isAiming;                      //Toogle the Aim Mode
                    aimSent           = false;
                    CurrentCameraSide = !CameraSide;                    //Camera Currentside = the opposite of the real CamSide to be able to enter in a state while Aiming
                }
            }
            else                                                         //If the Aim is set to Pressed
            {
                if (isAiming != InputAim.GetInput)
                {
                    isAiming = InputAim.GetInput;                       //is Aiming will be equal to the Input Entry
                    aimSent  = false;
                }
            }

            if (isAiming)
            {
                Transform origin = ActiveAbility.AimRayOrigin();       //Gets the Origing from where is going to Start the Ray Aim;

                if (AimDot)
                {
                    AimDot.gameObject.SetActive(true);
                }

                if (Target)
                {
                    aimDirection = Utilities.MalbersTools.DirectionTarget(origin, Target);
                }
                else
                {
                    Vector3 screenTarget = AimDot != null ? AimDot.position : new Vector3(Screen.width * 0.5f, Screen.height * 0.5f); //Gets the Center of the Aim Dot Transform
                    aimDirection = Utilities.MalbersTools.DirectionFromCamera(origin, screenTarget, out aimRayHit, HitMask);
                }

                if (debug)
                {
                    Debug.DrawLine(origin.position, AimRayCastHit.point, Color.red);        // Debug.DrawRay(origin.position, aimDirection * 50, Color.red);
                }
                if (CurrentCameraSide != CameraSide)                                        //Reset AimSent Values
                {
                    aimSent = false;
                }

                if (CameraSide && !aimSent)                                                     //Change the camera to the Right Side
                {
                    if (!(!ActiveAbility.ChangeAimCameraSide() && Active_IMWeapon.RightHand))   //Prevent the Camera Swap if is Using A Bow
                    {
                        SetAim(true);
                    }
                    else
                    {
                        SetAim(false);
                    }
                }
                else if (!CameraSide && !aimSent)                                               //Change the camera to the Left Side
                {
                    if (!(!ActiveAbility.ChangeAimCameraSide() && !Active_IMWeapon.RightHand))  //Prevent the Camera Swap if is Using A Bow
                    {
                        SetAim(false);
                    }
                    else
                    {
                        SetAim(true);
                    }
                }

                if (rider.Montura != null)
                {
                    rider.Montura.StraightAim(true);

                    //MountPoint.rotation =
                    //    Quaternion.FromToRotation(rider.Montura.transform.up, Vector3.up) * rider.Montura.MountPoint.rotation; //Keep a Straight Spine while Aiming
                }
            }
            else                                                            //If is not Aiming go to IsMounted Camera State
            {
                if (!aimSent)
                {
                    aimSent           = true;
                    CurrentCameraSide = !CameraSide;                        // Camera Currentside = the opposite of the real CamSide to be able to enter in a state while Aiming

                    SetAction(WeaponActions.Idle);                          //Sent Action to Idle again
                    OnAimSide.Invoke(0);                                    //Send that is not aiming anymore

                    if (AimDot)
                    {
                        AimDot.gameObject.SetActive(false);                 //Hide the AimDot;
                    }
                    rider.Montura.StraightAim(false);

                    //MountPoint.localRotation = MountStartRotation;

                    if ((_weaponAction == WeaponActions.AimLeft || _weaponAction == WeaponActions.AimRight ||
                         WeaponAction == WeaponActions.Hold || WeaponAction == WeaponActions.Fire_Proyectile))   //Fix theACtion if is not Aiming
                    {
                        SetAction(IsInCombatMode ? WeaponActions.Idle : WeaponActions.None);
                    }
                }
            }
        }