Ejemplo n.º 1
0
        protected virtual void OnTriggerEnter(Collider other)
        {
            JCS_2DSideScrollerPlayer player = other.GetComponent <JCS_2DSideScrollerPlayer>();

            if (player == null)
            {
                return;
            }

            AddSafe(player);

            bool isTopOfBox = JCS_Physics.TopOfBox(
                player.GetCharacterController(),
                mPositionPlatform.GetPlatformCollider());

            if (isTopOfBox)
            {
                // show character behind the ladder
                int backOrderLayer = OrderLayerObject.sortingOrder - ClimbableManager.SORTING_ORDER_BEHIND_OFFSET;
                SetPlayerSortingOrder(player, backOrderLayer);
            }
            else
            {
                // show character infront
                int frontOrderLayer = OrderLayerObject.sortingOrder + ClimbableManager.SORTING_ORDER_INFRONT_OFFSET;
                SetPlayerSortingOrder(player, frontOrderLayer);
            }

            player.CanLadder       = true;
            player.CanRope         = false;
            player.ClimbableObject = this;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Check if is on top of the lean platform.
        /// </summary>
        /// <param name="player"></param>
        /// <returns>
        /// true: is on top of the box.
        /// false: vice versa.
        /// </returns>
        public virtual bool IsOpTopOfLeanPlatform(JCS_Player player)
        {
            if (mPositionPlatform == null || player == null)
            {
                return(false);
            }

            bool isTopOfBox = JCS_Physics.TopOfBox(
                player.GetCharacterController(),
                mPositionPlatform.GetPlatformCollider());

            return(isTopOfBox);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Something that needed to check in update can be design here.
        /// This function should get call by when the player is done climbing.
        /// </summary>
        public override void ClimbableUpdate()
        {
            JCS_ClimbableManager cm = JCS_ClimbableManager.instance;

            foreach (JCS_2DSideScrollerPlayer player in mSSPlayers)
            {
                if (player.isGrounded())
                {
                    player.CanRope         = true;
                    player.CanLadder       = false;
                    player.ClimbableObject = this;

                    continue;
                }

                if (player.CharacterState == JCS_2DCharacterState.CLIMBING &&
                    player.ClimbMoveType == JCS_ClimbMoveType.MOVE_UP)
                {
                    // show character infront
                    int frontOrderLayer = OrderLayerObject.sortingOrder + cm.SORTING_ORDER_INFRONT_OFFSET;
                    SetPlayerSortingOrder(player, frontOrderLayer);


                    bool isTopOfBox = JCS_Physics.TopOfBox(
                        player.GetCharacterController(),
                        mPositionPlatform.GetPlatformCollider());

                    /* Check top of the platform */
                    if (isTopOfBox)
                    {
                        player.ClimbableObject = null;
                        player.GetCharacterAnimator().PlayAnimationInFrame();
                        player.CanRope             = false;
                        player.VelY                = 0;
                        player.JustClimbOnTopOfBox = true;

                        // show character behind the ladder
                        int backOrderLayer = OrderLayerObject.sortingOrder - cm.SORTING_ORDER_BEHIND_OFFSET;
                        SetPlayerSortingOrder(player, backOrderLayer);
                    }
                }
            }
        }