コード例 #1
0
        // TODO: Migrate this into seperate class accessible to climbingMotor and HangingMotor
        /// <summary>
        /// See if the player can pass a climbing skill check
        /// </summary>
        /// <returns>true if player passed climbing skill check</returns>
        public bool ClimbingSkillCheck(int basePercentSuccess)
        {
            player.TallySkill(DFCareer.Skills.Climbing, 1);

            if (overrideSkillCheck)
            {
                return(true);
            }

            int percentSuccess = FormulaHelper.CalculateClimbingChance(player, basePercentSuccess);

            if (Dice100.FailedRoll(percentSuccess))
            {
                // Don't allow skill check to break climbing while swimming
                // Water makes it easier to climb
                var playerPos     = controller.transform.position.y + (76 * MeshReader.GlobalScale) - 0.95f;
                var playerFootPos = playerPos - (controller.height / 2) - 1.20f; // to prevent player from failing to climb out of water
                var waterPos      = playerEnterExit.blockWaterLevel * -1 * MeshReader.GlobalScale;
                if (playerFootPos >= waterPos)                                   // prevent fail underwater
                {
                    return(false);
                }
            }
            return(true);
        }