Esempio n. 1
0
        private static bool IsEdgeLip(Collider2D col)
        {
            bool         isLeft = col.transform.gameObject.layer == _leftClimbLayer;
            RaycastHit2D hit    = Physics2D.Raycast((isLeft ? col.GetTopLeft() : col.GetTopRight()) + new Vector3(isLeft ? -0.3f : 0.3f, 0),
                                                    OrientationHelper.GetDownwardVector(col.transform), ConstantVariables.MaxLipHeight, Layers.Platforms);

            return(hit);
        }
Esempio n. 2
0
        public void MovePivotDown()
        {
            Vector3 v = OrientationHelper.GetDownwardVector(Pivot.transform);

            Vector3 movement = v.normalized * 0.5f;

            UpdatePivot = false;
            Pivot.transform.Translate(movement, Space.World);
        }
Esempio n. 3
0
        private static bool IsUprightAccessible(Collider2D col, Vector3 playerCentre, BoxCollider2D playerCol)
        {
            if (col.IsUpright() == false)
            {
                return(true);
            }

            Vector2 playerPosition = col.bounds.center - playerCentre;

            float angleDirection = AngleDir(OrientationHelper.GetDownwardVector(col.transform), playerPosition);

            bool onRight = angleDirection > 0;

            return((col.transform.gameObject.layer == LayerMask.NameToLayer(Layers.RightClimbSpot) && onRight) ||
                   (col.transform.gameObject.layer == LayerMask.NameToLayer(Layers.LeftClimbSpot)) && !onRight);
        }
Esempio n. 4
0
        private static bool IsSpaceBelowEdge(Collider2D col, BoxCollider2D playerCol)
        {
            bool isLeft = col.transform.gameObject.layer == _leftClimbLayer;

            RaycastHit2D[] hits = Physics2D.BoxCastAll((isLeft ? col.GetTopLeft() : col.GetTopRight()) + new Vector3(isLeft ? -playerCol.size.x / 2 : playerCol.size.x / 2, 0),
                                                       new Vector2(playerCol.size.x - 0.2f, 0.1f), 0, col.IsCorner() ? OrientationHelper.GetDownwardVector(col.transform) : Vector3.down, playerCol.size.y, Layers.Platforms);

            return(hits.Any(hit => hit.collider.transform != col.transform.parent) == false);
        }