Esempio n. 1
0
        /// <summary>
        /// Equip all items in the weapon set
        /// </summary>
        /// <param name="rIndex">Index of the weapon set whose items will be stored</param>
        protected virtual IEnumerator Internal_EquipWeaponsSet(int rIndex)
        {
            // First, find all the entries with no equip motions and spawn them first
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventoryItem lItem = GetInventoryItem(WeaponSets[rIndex].Items[i].ItemID);
                if (lItem != null && lItem.EquipMotion.Length == 0)
                {
                    BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                    if (lSlot != null)
                    {
                        if (WeaponSets[rIndex].Items[i].Instantiate)
                        {
                            GameObject lInstance = EquipItem(lItem.ID, lSlot.ID);
                            if (lInstance != null)
                            {
                                lSlot.ItemID = lItem.ID;
                            }
                        }
                        else
                        {
                            lSlot.ItemID = lItem.ID;
                        }
                    }
                }
            }

            // Now, find all the entries that do have an equip motion
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventoryItem lItem = GetInventoryItem(WeaponSets[rIndex].Items[i].ItemID);
                if (lItem != null && lItem.EquipMotion.Length > 0)
                {
                    BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                    if (lSlot != null && lSlot.ItemID.Length == 0)
                    {
                        // If we have a motion to equip, activate it
                        MotionControllerMotion lMotion = mMotionController.GetMotion(lItem.EquipMotion);
                        if (lMotion != null)
                        {
                            IEquipStoreMotion lEquipStoreMotion = lMotion as IEquipStoreMotion;
                            if (lEquipStoreMotion != null)
                            {
                                lEquipStoreMotion.OverrideItemID = lItem.ID;
                                lEquipStoreMotion.OverrideSlotID = lSlot.ID;
                            }

                            mMotionController.ActivateMotion(lMotion);
                            while (lMotion.IsActive || lMotion.QueueActivation)
                            {
                                yield return(null);
                            }

                            // Set the item
                            lSlot.ItemID = lItem.ID;
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Store all items in the weapon set
        /// </summary>
        /// <param name="rIndex">Index of the weapon set whose items will be stored</param>
        protected virtual IEnumerator Internal_StoreWeaponsSet(int rIndex)
        {
            mIsEquippingItem = true;

            // First, find all the entries that do have a store motion
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                if (lSlot != null && lSlot.ItemID.Length > 0)
                {
                    BasicInventoryItem lItem = GetInventoryItem(lSlot.ItemID);
                    if (lItem != null && lItem.StoreMotion.Length > 0)
                    {
                        // If we have a motion to unequip, activate it
                        MotionControllerMotion lMotion = mMotionController.GetMotion(lItem.StoreMotion);
                        if (lMotion != null)
                        {
                            // This is an extra test so we don't try to sheathe a weapons we just
                            // unsheathed... until we're totally done with the transitions
                            while (lMotion.MotionLayer._AnimatorTransitionID != 0)
                            {
                                yield return(null);
                            }

                            // Ensure we override the item and slot
                            IEquipStoreMotion lEquipStoreMotion = lMotion as IEquipStoreMotion;
                            if (lEquipStoreMotion != null)
                            {
                                lEquipStoreMotion.OverrideItemID = lItem.ID;
                                lEquipStoreMotion.OverrideSlotID = lSlot.ID;
                            }

                            // Now sheathe
                            mMotionController.ActivateMotion(lMotion);
                            while (lMotion.IsActive || lMotion.QueueActivation)
                            {
                                yield return(null);
                            }

                            // Clear the item
                            lSlot.ItemID = "";
                        }
                    }
                }
            }

            // Second, find all the entries with no store motions destroy them
            for (int i = 0; i < WeaponSets[rIndex].Items.Count; i++)
            {
                BasicInventorySlot lSlot = GetInventorySlot(WeaponSets[rIndex].Items[i].SlotID);
                if (lSlot != null && lSlot.ItemID.Length > 0)
                {
                    StoreItem(lSlot.ID);
                }
            }

            mIsEquippingItem = false;
        }
Esempio n. 3
0
        /// <summary>
        /// Clears a slot by the storing the current item. We'll use the
        /// store motion if it exists
        /// </summary>
        /// <param name="rSlotID">Slot that is being cleared</param>
        /// <returns></returns>
        protected virtual IEnumerator Internal_StoreItem(string rSlotID)
        {
            BasicInventorySlot lSlot = GetInventorySlot(rSlotID);

            if (lSlot != null)
            {
                BasicInventoryItem lItem = GetInventoryItem(lSlot.ItemID);
                if (lItem != null)
                {
                    // Run the unequip motion
                    if (lItem.StoreMotion.Length > 0)
                    {
                        // If we have a motion to unequip, activate it
                        MotionControllerMotion lMotion = mMotionController.GetMotion(lItem.StoreMotion);
                        if (lMotion != null)
                        {
                            // This is an extra test so we don't try to sheathe a weapons we just
                            // unsheathed... until we're totally done with the transitions
                            while (lMotion.MotionLayer._AnimatorTransitionID != 0)
                            {
                                yield return(null);
                            }

                            IEquipStoreMotion lEquipStoreMotion = lMotion as IEquipStoreMotion;
                            if (lEquipStoreMotion != null)
                            {
                                lEquipStoreMotion.OverrideItemID = lItem.ID;
                                lEquipStoreMotion.OverrideSlotID = lSlot.ID;
                            }

                            // Now sheathe
                            mMotionController.ActivateMotion(lMotion);
                            while (lMotion.IsActive || lMotion.QueueActivation)
                            {
                                yield return(null);
                            }
                        }
                    }
                    // Otherwise, simply unequip
                    else
                    {
                        StoreItem(lSlot.ID);
                    }
                }

                // Clear the slot
                lSlot.ItemID = "";
            }
        }