Esempio n. 1
0
            private static bool Prefix(BagItem __instance)
            {
                try
                {
                    var isMouseInButton = (bool)BagItem_isMouseInButton.GetValue(__instance);
                    var rmbClicked      = isMouseInButton && UnityEngine.Input.GetMouseButtonDown(1);
                    if (!rmbClicked)
                    {
                        return(true);
                    }

                    var item         = __instance.GetItem();
                    var moneyHovered = (item != null) && (item.id == 9027);
                    if (moneyHovered)
                    {
                        return(true);
                    }

                    if (BaseBag.PickItem != null)
                    {
                        var count = KeyBindings.GetKey(KeyBindingType.Unpack) ? 10 : 1;
                        BagItemUtil.FillWithPickedItem(__instance, count);
                        return(false);
                    }
                }
                catch (Exception e) { Log.ExceptionOnce(e); }

                return(true);
            }
Esempio n. 2
0
        private bool TryInteract()
        {
            if (KeyBindings.GetKey(Controls.Action))
            {
                RaycastHit2D hit = CheckInteractableInFront(GetDirectionFacing());
                if (hit)
                {
                    Interaction.Point  = hit.collider;
                    Interaction.Object = hit.collider.transform.parent;

                    var stilt = Interaction.Object.GetComponentInParent <Stilt>();
                    if (stilt != null)
                    {
                        return(InteractWithStilt(stilt));
                    }
                    var chimney = Interaction.Object.GetComponentInChildren <ChimneyLid>();
                    if (chimney != null)
                    {
                        InteractWithChimney(chimney);
                        return(true);
                    }
                    var stove = Interaction.Object.GetComponentInChildren <Stove>();
                    if (stove != null)
                    {
                        InteractWithStove(stove);
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        private DirectionFacing AddNextClimbs(bool ignoreUp = false)
        {
            var direction = DirectionFacing.None;

            if (KeyBindings.GetKey(Controls.Left))
            {
                _climbHandler.NextClimbs.Add(Climb.AcrossLeft);
                direction = DirectionFacing.Left;
            }
            else if (KeyBindings.GetKey(Controls.Right))
            {
                _climbHandler.NextClimbs.Add(Climb.AcrossRight);
                direction = DirectionFacing.Right;
            }
            if (ignoreUp == false && KeyBindings.GetKey(Controls.Up))
            {
                _climbHandler.NextClimbs.Add(Climb.Up);
            }
            if (KeyBindings.GetKey(Controls.Down))
            {
                _climbHandler.NextClimbs.Add(Climb.Down);
            }

            return(direction);
        }
Esempio n. 4
0
        private void SetSliding()
        {
            Anim.SetBool(PlayerAnimBool.Sliding, true);
            if (_wasSliding == false)
            {
                bool slidingRight = MovementState.NormalDirection == DirectionFacing.Right;
                bool facingRight  = GetDirectionFacing() == DirectionFacing.Right;
                Anim.SetBool(PlayerAnimBool.Forward, slidingRight == facingRight);
                _normalizedHorizontalSpeed = slidingRight ? 1 : -1;
                if (slidingRight == facingRight)
                {
                    Anim.PlayAnimation(Animations.SlideForward);
                }
                else
                {
                    Anim.PlayAnimation(Animations.SlideBackward);
                }

                _wasSliding = true;
            }
            else
            {
                bool slidingRight = MovementState.NormalDirection == DirectionFacing.Right;
                if (KeyBindings.GetKey(Controls.Left))
                {
                    Anim.FlipSpriteLeft();
                    Anim.SetBool(PlayerAnimBool.Forward, !slidingRight);
                }
                else if (KeyBindings.GetKey(Controls.Right))
                {
                    Anim.FlipSpriteRight();
                    Anim.SetBool(PlayerAnimBool.Forward, slidingRight);
                }
            }
        }
Esempio n. 5
0
    void Update()
    {
        if (Menus.GetMenus.IsOpen)
        {
            return;
        }

        if (keyBindings.GetKey(BindingsNames.moveLeft).AnyInput)
        {
            MoveCamera(new Vector3(-speed, 0, 0));
        }
        if (keyBindings.GetKey(BindingsNames.moveRight).AnyInput)
        {
            MoveCamera(new Vector3(speed, 0, 0));
        }
        if (keyBindings.GetKey(BindingsNames.moveUp).AnyInput)
        {
            MoveCamera(new Vector3(0, speed, 0));
        }
        if (keyBindings.GetKey(BindingsNames.moveDown).AnyInput)
        {
            MoveCamera(new Vector3(0, -speed, 0));
        }
        if (Input.GetAxis("Mouse ScrollWheel") != 0f)
        {
            if (Input.GetAxis("Mouse ScrollWheel") > 0)
            {
                cam.assetsPPU += 1;
            }
            else
            {
                cam.assetsPPU -= 1;
            }

            if (cam.assetsPPU > camMaxZoom)
            {
                cam.assetsPPU = camMaxZoom;
            }
            if (cam.assetsPPU < camMinZoom)
            {
                cam.assetsPPU = camMinZoom;
            }
            speed = 5f / cam.assetsPPU;

            ResetCamSize();
        }
    }
Esempio n. 6
0
        void Update()
        {
            if (_elapsed > 0 && _elapsed < _delay)
            {
                _elapsed += Time.deltaTime;
                return;
            }
            else if (_elapsed > _delay)
            {
                _elapsed = 0;
            }
            if (KeyBindings.GetKey(Controls.Light) == false)
            {
                _setting = false;
            }

            if (_setting)
            {
                var direction = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

                foreach (int connection in _abilityPoints[_currentPoint].Connections)
                {
                    if (Vector2.Angle(direction, _abilityPoints[connection].Point - _abilityPoints[_currentPoint].Point) < 30f)
                    {
                        _elapsed += Time.deltaTime;

                        if ((_currentPoint == 4 && connection == 3 && _abilityPoints[3].IsActivated == false) ||
                            (_currentPoint == 4 && connection == 18 && _abilityPoints[18].IsActivated == false) ||
                            (_currentPoint == 7 && connection == 6 && _abilityPoints[6].IsActivated == false) ||
                            (_currentPoint == 7 && connection == 25 && _abilityPoints[25].IsActivated == false) ||
                            (_currentPoint == 10 && connection == 9 && _abilityPoints[9].IsActivated == false) ||
                            (_currentPoint == 10 && connection == 32 && _abilityPoints[32].IsActivated == false))
                        {
                            return;
                        }

                        AbilityPoint abilityPoint = _abilityPoints[connection];
                        if (abilityPoint.IsActivated)
                        {
                            PlayerPrefs.SetFloat(Meter, (abilityPoint.Point.y * 10) + 1);
                            DeactivateCurrentPoint();
                            _currentPoint = connection;
                        }
                        else if (PlayerPrefs.GetInt(IntVariable.AvailablePoints.ToString()) - PlayerPrefs.GetInt(IntVariable.SpentPoints.ToString()) > 0)
                        {
                            SetNewCurrentPoint(connection, abilityPoint);
                        }
                        return;
                    }
                }
            }
        }
Esempio n. 7
0
    private void Update()
    {
        if (!KeyBindings.GetKeyBindings.IsChanging)
        {
            if (Menus.GetMenus.IsOverUI())
            {
                return;
            }

            if (builder.building || builder.destroy)
            {
                return;
            }

            if (keyBindings.GetKey(BindingsNames.interact).AnyInput)
            {
                Interact();
            }
            if (keyBindings.GetKey(BindingsNames.select).AnyInput)
            {
                Select();
            }
        }
    }
Esempio n. 8
0
        private void HandleActions()
        {
            if (KeyBindings.GetKeyDown(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
            {
                float timeClicked = Time.realtimeSinceStartup;
                if (Mathf.Abs(timeClicked - _timeClicked) < 0.4f)
                {
                    Destroy(gameObject);
                }
                else
                {
                    _timeClicked = timeClicked;
                }
            }

            if (((AbilityState.IsActive(Ability.Flash) && _fireplace == null) ||
                 (AbilityState.IsActive(Ability.Ignite) && _fireplace != null)) &&
                IsScouting == false)
            {
                if (KeyBindings.GetKeyDown(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
                {
                    _burstTime += Time.deltaTime;
                }

                if (KeyBindings.GetKey(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
                {
                    if (_burstTime > 0)
                    {
                        float maxTime = 2f;
                        _burstTime += Time.deltaTime;
                        _burstTime  = _burstTime > maxTime ? maxTime : _burstTime;
                        DecreaseVariables();
                    }
                }

                if (KeyBindings.GetKeyUp(Controls.Light))
                {
                    _burstTime = 0;
                    _controller.ResetVariables();
                    Burst();
                }
            }
            else
            {
                _burstTime = 0;
            }
        }
Esempio n. 9
0
        private void TryGrab()
        {
            bool            grabbing        = false;
            DirectionFacing directionFacing = GetDirectionFacing();

            if (KeyBindings.GetKey(Controls.Left))
            {
                Anim.SetBool(PlayerAnimBool.IsGrabbing, true);
                Anim.SetBool(PlayerAnimBool.Inverted, directionFacing != DirectionFacing.Left);
                if (_climbHandler.CheckGrab(DirectionFacing.Left))
                {
                    MovementState.IsGrounded = true;
                    MovementAllowed          = true;
                    grabbing = true;
                }
            }
            else if (KeyBindings.GetKey(Controls.Right))
            {
                Anim.SetBool(PlayerAnimBool.IsGrabbing, true);
                Anim.SetBool(PlayerAnimBool.Inverted, directionFacing != DirectionFacing.Right);
                if (_climbHandler.CheckGrab(DirectionFacing.Right))
                {
                    MovementState.IsGrounded = true;
                    MovementAllowed          = true;
                    grabbing = true;
                }
            }
            else
            {
                if (_climbHandler.CheckGrab(holdingUp: KeyBindings.GetKey(Controls.Up)))
                {
                    MovementState.IsGrounded = true;
                    MovementAllowed          = true;
                    Anim.SetBool(PlayerAnimBool.IsGrabbing, true);
                    Anim.SetBool(PlayerAnimBool.Inverted, (_climbHandler.CurrentClimbingState.PivotCollider.gameObject.layer == LayerMask.NameToLayer(Layers.RightClimbSpot)) == (directionFacing == DirectionFacing.Right));
                    grabbing = true;
                }
            }
            Anim.SetBool(PlayerAnimBool.IsGrabbing, grabbing);
            _wasGrounded = grabbing;
            if (grabbing)
            {
                SetMotorToClimbState();
            }
        }
Esempio n. 10
0
 private void MovementInput()
 {
     if (KeyBindings.GetKey(Controls.Anchor))
     {
         _normalizedHorizontalSpeed = 0;
     }
     else if (KeyBindings.GetKey(Controls.Right))
     {
         if (MovementState.RightCollision == false && MovementState.RightEdge == false)
         {
             _normalizedHorizontalSpeed = 1;
         }
         else
         {
             _normalizedHorizontalSpeed = 0;
         }
         if (GetDirectionFacing() == DirectionFacing.Left)
         {
             FlipSprite();
         }
     }
     else if (KeyBindings.GetKey(Controls.Left))
     {
         if (MovementState.LeftCollision == false && MovementState.LeftEdge == false)
         {
             _normalizedHorizontalSpeed = -1;
         }
         else
         {
             _normalizedHorizontalSpeed = 0;
         }
         if (GetDirectionFacing() == DirectionFacing.Right)
         {
             FlipSprite();
         }
     }
     else
     {
         _normalizedHorizontalSpeed = 0;
     }
     if (MovementState.RightCollision || MovementState.LeftCollision)
     {
         //AtWallAnimation
     }
 }
Esempio n. 11
0
        private bool TryClimb()
        {
            bool topOfSlope = MovementState.IsOnSlope
                                ? topOfSlope = MovementState.NormalDirection != GetDirectionFacing()
                                : false;

            Climb  climb;
            string animation = "";

            if (_isCrouched == false && KeyBindings.GetKey(Controls.Up) && _climbHandler.CheckLedgeAbove(GetDirectionFacing(), out climb, true))
            {
                switch (climb)
                {
                case Climb.Up:
                    Anim.PlayAnimation(Animations.ToEdge);
                    break;

                case Climb.Flip:
                    Anim.PlayAnimation(Animations.InverseToEdge);
                    break;

                case Climb.Mantle:
                    Anim.PlayAnimation(Animations.Mantle);
                    break;
                }
            }
            else if (MovementState.IsOnSlope == false && KeyBindings.GetKey(Controls.Down) && _climbHandler.CheckLedgeBelow(Climb.Down, GetDirectionFacing(), out animation))
            {
                Anim.PlayAnimation(animation);
                SetCrouched(false);
            }
            else if (_isCrouched == false && topOfSlope == false && KeyBindings.GetKey(Controls.Jump) && _climbHandler.CheckLedgeBelow(Climb.Jump, GetDirectionFacing(), out animation))
            {
                Anim.PlayAnimation(animation);
            }
            else
            {
                return(false);
            }

            Transform.GetComponent <AudioSource>().Play();
            return(true);
        }
Esempio n. 12
0
        private PlayerState HandleMovementInputs()
        {
            if (MovementState.IsOnSlope)
            {
                if (TryClimb())
                {
                    MovementState.WasOnSlope = true;
                    MovementState.IsGrounded = true;
                    _wasGrounded             = true;
                    MovementState.IsOnSlope  = false;
                    _wasSliding = false;
                    Anim.SetBool(PlayerAnimBool.Sliding, false);
                    return(SetMotorToClimbState());
                }
                else
                {
                    return(PlayerState.Sliding);
                }
            }
            else
            {
                if (_wasSliding)
                {
                    _normalizedHorizontalSpeed = 0;
                }
                _wasSliding = false;
                Anim.SetBool(PlayerAnimBool.Sliding, false);
            }

            if (_isJumping)
            {
                return(PlayerState.Jumping);
            }
            else if (MovementState.IsGrounded)
            {
                if (_wasGrounded == false)
                {
                    _wasGrounded = true;
                    return(PlayerState.WaitingForInput);
                }
                else if (Interaction.IsInteracting)
                {
                    return(PlayerState.Interacting);
                }
                else if (ChannelingHandler.IsChanneling && ChannelingHandler.ChannelingSet == false)
                {
                    if (KeyBindings.GetKey(Controls.Light))
                    {
                        ChannelingHandler.Channel();
                    }
                    return(PlayerState.Static);
                }
                else if (IsClimbing())
                {
                    return(PlayerState.Climbing);
                }
                else if (TryClimb())
                {
                    return(SetMotorToClimbState());
                }
                else if (TryInteract())
                {
                    Interaction.IsInteracting = true;
                    return(PlayerState.Interacting);
                }
                else if (TryChannel())
                {
                    return(PlayerState.Static);
                }
                else
                {
                    return(PlayerState.WaitingForInput);
                }
            }
            else
            {
                _wasGrounded = false;

                if (Anim.GetBool(PlayerAnimBool.Falling) == false)
                {
                    Anim.PlayAnimation(Animations.Falling);
                }
                Anim.SetBool(PlayerAnimBool.Falling, true);
                Anim.SetBool(PlayerAnimBool.Moving, false);
                Anim.SetBool(PlayerAnimBool.Upright, false);
                _normalizedHorizontalSpeed = 0;
                return(PlayerState.Falling);
            }
        }