Beispiel #1
0
        /// <summary>
        /// Create the item to unsheathe
        /// </summary>
        /// <returns></returns>
        private GameObject CreateItem()
        {
            string lResourcePath = "";

            string lItemID = "";

            if (OverrideItemID.Length > 0)
            {
                lItemID = OverrideItemID;
            }
            else if (ResourcePath.Length > 0)
            {
                lResourcePath = ResourcePath;
            }
            else if (ItemID.Length > 0)
            {
                lItemID = ItemID;
            }

            string lSlotID = "";

            if (OverrideSlotID.Length > 0)
            {
                lSlotID = OverrideSlotID;
            }
            else
            {
                lSlotID = SlotID;
            }

            GameObject lItem = mInventorySource.EquipItem(lItemID, lSlotID, lResourcePath);

            // Set the weapon type for the combatant
            if (mCombatant != null)
            {
                mCombatant.PrimaryWeapon = lItem.GetComponent <IWeaponCore>();
                if (mCombatant.PrimaryWeapon != null)
                {
                    mCombatant.PrimaryWeapon.Owner = mMotionController.gameObject;
                }
            }

            // Add another body shape in order to compensate for the pose
            if (_AddCombatantBodyShape)
            {
                BodyCapsule lShape = new BodyCapsule();
                lShape.Name                 = "Combatant Shape";
                lShape.Radius               = _CombatantBodyShapeRadius;
                lShape.Offset               = new Vector3(0f, 1.0f, 0f);
                lShape.EndOffset            = new Vector3(0f, 1.2f, 0f);
                lShape.IsEnabledOnGround    = true;
                lShape.IsEnabledOnSlope     = true;
                lShape.IsEnabledAboveGround = true;
                mActorController.AddBodyShape(lShape);
            }

            return(lItem);
        }
Beispiel #2
0
        /// <summary>
        /// Recreate the default body shapes on the character's ActorController
        /// </summary>
        /// <param name="rMotionController"></param>
        public static void CreateDefaultBodyShapes(MotionController rMotionController)
        {
            ActorController lActorController = rMotionController.GetOrAddComponent <ActorController>();

            lActorController.BodyShapes.Clear();
            BodyCapsule lCapsule = new BodyCapsule
            {
                _Parent              = lActorController.transform,
                Name                 = "Body Capsule",
                Radius               = 0.3f,
                Offset               = new Vector3(0f, 0.6f, 0f),
                IsEnabledOnGround    = true,
                IsEnabledOnSlope     = true,
                IsEnabledAboveGround = true,
                EndTransform         = lActorController.transform.FindTransform(HumanBodyBones.Head)
            };

            if (lCapsule.EndTransform == null)
            {
                lCapsule.EndTransform = lActorController.transform.FindTransform("Head");
            }
            if (lCapsule.EndTransform == null)
            {
                lCapsule.EndOffset = new Vector3(0f, 1.6f, 0f);
            }

            lActorController.BodyShapes.Add(lCapsule);

            BodySphere lSphere = new BodySphere
            {
                _Parent              = lActorController.transform,
                Name                 = "Foot Sphere",
                Radius               = 0.25f,
                Offset               = new Vector3(0f, 0.25f, 0f),
                IsEnabledOnGround    = false,
                IsEnabledOnSlope     = false,
                IsEnabledAboveGround = true
            };

            lActorController.BodyShapes.Add(lSphere);

            // Save the new body shapes
            lActorController.SerializeBodyShapes();
        }
Beispiel #3
0
    /// <summary>
    /// Initializes the shapes
    /// </summary>
    private void CreateDefaultShapes()
    {
        mTarget.BodyShapes.Clear();

        BodyCapsule lCapsule = new BodyCapsule();

        lCapsule._Parent              = mTarget.transform;
        lCapsule.Name                 = "Body Capsule";
        lCapsule.Radius               = 0.25f;
        lCapsule.Offset               = new Vector3(0f, 0.6f, 0f);
        lCapsule.IsEnabledOnGround    = true;
        lCapsule.IsEnabledOnSlope     = true;
        lCapsule.IsEnabledAboveGround = true;

        lCapsule.EndTransform = mTarget.transform.FindTransform(HumanBodyBones.Head);
        if (lCapsule.EndTransform == null)
        {
            lCapsule.EndTransform = mTarget.transform.FindTransform("Head");
        }
        if (lCapsule.EndTransform == null)
        {
            lCapsule.EndOffset = new Vector3(0f, 1.6f, 0f);
        }

        mTarget.BodyShapes.Add(lCapsule);

        BodySphere lSphere = new BodySphere();

        lSphere._Parent              = mTarget.transform;
        lSphere.Name                 = "Foot Sphere";
        lSphere.Radius               = 0.25f;
        lSphere.Offset               = new Vector3(0f, 0.25f, 0f);
        lSphere.IsEnabledOnGround    = false;
        lSphere.IsEnabledOnSlope     = false;
        lSphere.IsEnabledAboveGround = true;

        mTarget.BodyShapes.Add(lSphere);

        // Store the current body shapes
        mTarget.SerializeBodyShapes();
    }
    /// <summary>
    /// Initializes the shapes
    /// </summary>
    private void CreateDefaultShapes()
    {
        mTarget.BodyShapes.Clear();

        BodyCapsule lCapsule = new BodyCapsule();
        lCapsule._Parent = mTarget.transform;
        lCapsule.Name = "Body Capsule";
        lCapsule.Radius = 0.25f;
        lCapsule.Offset = new Vector3(0f, 0.6f, 0f);
        lCapsule.IsEnabledOnGround = true;
        lCapsule.IsEnabledOnSlope = true;
        lCapsule.IsEnabledAboveGround = true;

        lCapsule.EndTransform = mTarget.transform.FindTransform(HumanBodyBones.Head);
        if (lCapsule.EndTransform == null) { lCapsule.EndTransform = mTarget.transform.FindTransform("Head"); }
        if (lCapsule.EndTransform == null) { lCapsule.EndOffset = new Vector3(0f, 1.6f, 0f); }

        mTarget.BodyShapes.Add(lCapsule);

        BodySphere lSphere = new BodySphere();
        lSphere._Parent = mTarget.transform;
        lSphere.Name = "Foot Sphere";
        lSphere.Radius = 0.25f;
        lSphere.Offset = new Vector3(0f, 0.25f, 0f);
        lSphere.IsEnabledOnGround = false;
        lSphere.IsEnabledOnSlope = false;
        lSphere.IsEnabledAboveGround = true;

        mTarget.BodyShapes.Add(lSphere);

        // Store the current body shapes
        mTarget.SerializeBodyShapes();
    }