示例#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);
         }
     }
 }
示例#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);
     }
 }
示例#3
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);
        }
示例#4
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);
                    }
                }
            }
        }