Example #1
0
        public static string GetDescription(this LedgeClimbAnimationTargetting me)
        {
            switch (me)
            {
            case LedgeClimbAnimationTargetting.SPRITE_PIVOT: return("The characters pivot point will be moved towards the target position.");

            case LedgeClimbAnimationTargetting.BAKED: return("Move the select bone to the target position then play the baked animation.");
            }
            return("No information available.");
        }
        /// <summary>
        /// Initialise the movement with the given movement data.
        /// </summary>
        /// <param name="character">Character.</param>
        /// <param name="movementData">Movement data.</param>
        override public Movement Init(Character character, MovementVariable[] movementData)
        {
            this.character = character;

            if (movementData != null && movementData.Length >= MovementVariableCount)
            {
                RequiredColliders   = movementData[RequiredCollidersIndex].IntValue;
                ledgeDetectionType  = (LedgeDetectionType)movementData[LedgeDetectionTypeIndex].IntValue;
                gapDetectionType    = (GapDetectionType)movementData[GapDetectionTypeIndex].IntValue;
                animationTargetting = (LedgeClimbAnimationTargetting)movementData[AnimationTargettingIndex].IntValue;
                ledgeOffset         = movementData[LedgeOffsetIndex].Vector2Value;
                standOffset         = movementData[StandOffsetIndex].Vector2Value;
                dismountOffset      = movementData[DismountOffsetIndex].Vector2Value;
                graspingBone        = (HumanBodyBones)movementData[GraspingBoneIndex].IntValue;
                minGraspLeeway      = movementData[MinGraspLeewayIndex].FloatValue;
                maxGraspLeeway      = movementData[MaxGraspLeewayIndex].FloatValue;
                minReachTime        = movementData[MinReachTimeIndex].FloatValue;
            }
            else
            {
                Debug.LogError("Invalid movement data, not enough values.");
            }

            // TODO Only get this if required
            myAnimator = character.gameObject.GetComponentInChildren <Animator> ();
            if (animationTargetting == LedgeClimbAnimationTargetting.SPRITE_PIVOT)
            {
                myRenderer = character.gameObject.GetComponentInChildren <SpriteRenderer> ();
                if (myRenderer == null)
                {
                    // TODO Throw error?
                }
                else
                {
                    initialSpritePivot = myRenderer.sprite.bounds.center;
                }
            }
            return(this);
        }