예제 #1
0
        /// <summary>
        /// Change the magic item to the specified item.
        /// </summary>
        /// <param name="itemIndex">The item index to change the value to.</param>
        public void ChangeMagicItem(int itemIndex)
        {
            if (itemIndex < 0 || itemIndex >= m_ItemDefinitions.Length || itemIndex == m_Index)
            {
                return;
            }
            if (m_CharacterLocomotion.IsAbilityTypeActive <Use>())
            {
                return;
            }

            if (m_Index != -1)
            {
                m_Objects[m_Index].SetActive(false);
                m_ParticleStreamAttributeMonitor.SetActive(false);
                SetButtonColor(m_Index, m_NormalColor);
            }
            m_Index = itemIndex;
            m_Inventory.Pickup(m_ItemDefinitions[itemIndex].CreateItemIdentifier(), 1, 0, false, true);
            m_Objects[m_Index].SetActive(true);
            for (int i = 0; i < m_Objects[m_Index].transform.childCount; ++i)
            {
                m_Objects[m_Index].transform.GetChild(i).gameObject.SetActive(true);
            }
            if (m_ItemDefinitions[itemIndex] == m_ParticleStreamItemDefinition)
            {
                m_ParticleStreamAttributeMonitor.SetActive(true);
            }
            SetButtonColor(m_Index, m_PressedColor);
        }
예제 #2
0
        /// <summary>
        /// Switches the movement type when the specified keycode is pressed.
        /// </summary>
        private void Update()
        {
            if (UnityEngine.Input.GetKeyDown(m_SwitchKeycode))
            {
                // The character needs to be alive to switch movement types.
                if (!m_CharacterHealth.IsAlive())
                {
                    return;
                }

                // The movement type cannot be switched if ride or drive is active.
                if (m_CharacterLocomotion.IsAbilityTypeActive <UltimateCharacterController.Character.Abilities.Ride>() ||
                    m_CharacterLocomotion.IsAbilityTypeActive <UltimateCharacterController.Character.Abilities.Drive>())
                {
                    return;
                }

                if (m_CharacterLocomotion.FirstPersonPerspective)
                {
                    UpdateMovementType(true, (m_ActiveFirstPersonIndex + 1) % m_FirstPersonMovementStates.Length);
                }
                else
                {
#if THIRD_PERSON_CONTROLLER
                    if (!m_IncludeTopDownPseudo3D)
                    {
                        // The state cannot be switched if the top down or 2.5D movement type is active.
                        if (m_CharacterLocomotion.ActiveMovementType is ThirdPersonController.Character.MovementTypes.TopDown ||
                            m_CharacterLocomotion.ActiveMovementType is ThirdPersonController.Character.MovementTypes.Pseudo3D)
                        {
                            return;
                        }
                    }
#endif
                    UpdateMovementType(false, (m_ActiveThirdPersonIndex + 1) % (m_ThirdPersonMovementStates.Length - (m_IncludeTopDownPseudo3D ? 0 : 2)));
                }
            }
        }