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

            if (player == null)
            {
                return;
            }

            JCS_ClimbableManager cm = JCS_ClimbableManager.instance;

            AddSafe(player);

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

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

            player.CanRope         = true;
            player.CanLadder       = false;
            player.ClimbableObject = this;
        }
Esempio n. 2
0
        protected virtual void Start()
        {
            if (ClimbableManager == null)
            {
                /**
                 *  if climbable object found in the scene, we must have
                 *  the manager to manage.
                 */
                if (JCS_ClimbableManager.instance == null)
                {
                    JCS_ClimbableManager.instance = JCS_IndieManager.instance.gameObject.AddComponent <JCS_ClimbableManager>();
                }

                this.mClimbableManager = JCS_ClimbableManager.instance;
            }
        }
Esempio 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);
                    }
                }
            }
        }
Esempio n. 4
0
        /*******************************************/
        /*           Protected Variables           */
        /*******************************************/

        /*******************************************/
        /*             setter / getter             */
        /*******************************************/

        /*******************************************/
        /*            Unity's function             */
        /*******************************************/
        private void Awake()
        {
            instance = this;
        }