/// <summary>
        /// Moves the item in each slot.
        /// </summary>
        private void FixedUpdate()
        {
            var lookVector = m_PlayerInput.GetLookVector(false);

            for (int i = 0; i < m_Inventory.SlotCount; ++i)
            {
                var item = m_Inventory.GetActiveItem(i);
                if (item != null && item.IsActive() && item.DominantItem)
                {
                    item.Move(lookVector.x, lookVector.y);
                }
            }

            // Each object should only be updated once. Clear the frame after execution to allow the objects to be updated again.
            UnityEngineUtility.ClearUpdatedObjects();
        }
Esempio n. 2
0
        /// <summary>
        /// Tries to start or stop the camera zoom. The camera may not be able to start if an ability doesn't allow it.
        /// </summary>
        /// <param name="zoom">Should the camera zoom?</param>
        public void TryZoom(bool zoom)
        {
            if (m_Character == null || !m_Character.activeInHierarchy)
            {
                return;
            }

            // The zoom state may not be able to start. Remember the input so when the game state changes (different ability, item, etc) zoom can try to activate again.
            m_ZoomInput = zoom;

            if (m_ZoomInput)
            {
                // The camera may not allow zooming.
                if (!m_CanZoom)
                {
                    SetZoom(false);
                    return;
                }

                // The ViewType may not allow zoomig.
                if (!m_ViewType.CanZoom())
                {
                    SetZoom(false);
                    return;
                }

                // The item may not allow zooming.
                if (m_CharacterInventory != null)
                {
                    for (int i = 0; i < m_CharacterInventory.SlotCount; ++i)
                    {
                        var item = m_CharacterInventory.GetActiveItem(i);
                        if (item != null && !item.CanCameraZoom())
                        {
                            SetZoom(false);
                            return;
                        }
                    }
                }

                // The character abilities disallow zoom.
                if (m_CharacterLocomotion.ActiveAbilityCount > 0)
                {
                    for (int i = 0; i < m_CharacterLocomotion.ActiveAbilityCount; ++i)
                    {
                        if (!m_CharacterLocomotion.ActiveAbilities[i].CanCameraZoom())
                        {
                            SetZoom(false);
                            return;
                        }
                    }
                }
                if (m_CharacterLocomotion.ActiveItemAbilityCount > 0)
                {
                    for (int i = 0; i < m_CharacterLocomotion.ActiveItemAbilityCount; ++i)
                    {
                        if (!m_CharacterLocomotion.ActiveItemAbilities[i].CanCameraZoom())
                        {
                            SetZoom(false);
                            return;
                        }
                    }
                }
            }

            // The camera can zoom or unzoom.
            SetZoom(zoom);
        }