예제 #1
0
 private void OnAbilityActiveRPC(int abilityIndex, bool active)
 {
     if (active)
     {
         m_CharacterLocomotion.TryStartAbility(m_CharacterLocomotion.Abilities[abilityIndex]);
     }
     else
     {
         m_CharacterLocomotion.TryStopAbility(m_CharacterLocomotion.Abilities[abilityIndex], true);
     }
 }
예제 #2
0
        /// <summary>
        /// Tries to reload the current item.
        /// </summary>
        /// <returns>Success if the item was used.</returns>
        public override TaskStatus OnUpdate()
        {
            if (m_ReloadAbility == null)
            {
                return(TaskStatus.Failure);
            }

            // The Reload ability has been found - try to use the ability.
            return(m_CharacterLocomotion.TryStopAbility(m_ReloadAbility) ? TaskStatus.Success : TaskStatus.Failure);
        }
예제 #3
0
        /// <summary>
        /// Activates the specified demo zone.
        /// </summary>
        /// <param name="demoZone">The demo zone to active.</param>
        /// <param name="teleport">Should the character be teleported to the demo zone?</param>
        private void ActiveDemoZone(DemoZone demoZone, bool teleport)
        {
            // The ride ability should be force stopped.
            var ride = m_CharacterLocomotion.GetAbility <UltimateCharacterController.Character.Abilities.Ride>();

            if (ride != null && ride.IsActive)
            {
                m_CharacterLocomotion.TryStopAbility(ride, true);
            }
            if (m_ActiveZoneIndices.Count == 0 || m_ActiveZoneIndices[m_ActiveZoneIndices.Count - 1] != demoZone.Index)
            {
                m_ActiveZoneIndices.Add(demoZone.Index);
            }
            m_LastZoneIndex = demoZone.Index;
            ShowText(demoZone.Header, demoZone.Description, demoZone.Action);
            if (m_PreviousZoneArrow != null)
            {
                m_PreviousZoneArrow.SetActive(demoZone.Index != 0);
            }
            if (m_NextZoneArrow != null)
            {
                m_NextZoneArrow.SetActive(demoZone.Index != m_DemoZones.Length - 1);
            }
            m_EnterFrame = Time.frameCount;
            for (int i = 0; i < demoZone.EnableObjects.Length; ++i)
            {
                demoZone.EnableObjects[i].enabled = true;
            }
            for (int i = 0; i < demoZone.ToggleObjects.Length; ++i)
            {
                demoZone.ToggleObjects[i].SetActive(true);
            }

            // When the character reaches the outside section all doors should be unlocked.
            if (!m_AddOnDemoManager && !m_FullAccess && demoZone.Index >= m_DemoZones.Length - 6)
            {
                for (int i = 0; i < m_Doors.Count; ++i)
                {
                    m_Doors[i].CloseOnTriggerExit = false;
                    m_Doors[i].OpenClose(true, true, false);
                }
                m_FullAccess = true;
            }

            if (teleport)
            {
                var position = Vector3.zero;
                var rotation = Quaternion.identity;
                SpawnPointManager.GetPlacement(m_Character, demoZone.Index, ref position, ref rotation);
                m_CharacterLocomotion.SetPositionAndRotation(position, rotation, true);
            }

            // Set the group after the state so the default state doesn't override the grouping value.
            m_CharacterRespawner.Grouping = demoZone.Index;
        }
예제 #4
0
        /// <summary>
        /// Tries to start or stop the specified ability.
        /// </summary>
        /// <returns>Success if the ability was started or stopped.</returns>
        public override TaskStatus OnUpdate()
        {
            if (m_Ability == null)
            {
                return(TaskStatus.Failure);
            }

            // The ability is not null - try to start or stop the ability.
            if (m_Start.Value)
            {
                var abilityStarted = m_CharacterLocomotion.TryStartAbility(m_Ability);
                return((abilityStarted || m_AlwaysReturnSuccess.Value) ? TaskStatus.Success : TaskStatus.Failure);
            }
            else
            {
                var abilityStopped = m_CharacterLocomotion.TryStopAbility(m_Ability);
                return((abilityStopped || m_AlwaysReturnSuccess.Value) ? TaskStatus.Success : TaskStatus.Failure);
            }
        }
예제 #5
0
 /// <summary>
 /// Tries to stop the specified ability.
 /// </summary>
 /// <param name="ability">The ability to try to stop.</param>
 /// <returns>True if the ability was stopped.</returns>
 protected virtual bool TryStopAbility(Ability ability)
 {
     return(m_CharacterLocomotion.TryStopAbility(ability));
 }
예제 #6
0
        /// <summary>
        /// Tries to start or stop the use of the current item.
        /// </summary>
        /// <returns>Success if the item was used.</returns>
        public override TaskStatus OnUpdate()
        {
            if (m_UseAbility == null)
            {
                return(TaskStatus.Failure);
            }

            // Return a status of running for as long as the character is using the item.
            if (m_WaitForUse)
            {
                for (int i = 0; i < m_UseAbility.UsableItems.Length; ++i)
                {
                    if (m_UseAbility.UsableItems[i] != null)
                    {
                        return(TaskStatus.Running);
                    }
                }
                m_WaitForUse     = false;
                m_WaitForStopUse = true;
            }

            // The item has been used. Return success as soon as the ability is stopped.
            if (m_WaitForStopUse)
            {
                m_CharacterLocomotion.TryStopAbility(m_UseAbility);
                if (!m_UseAbility.IsActive)
                {
                    return(TaskStatus.Success);
                }
                return(TaskStatus.Running);
            }

            // The item should be used in the direction of the target.
            if (m_LocalLookSource != null)
            {
                if (m_AimTarget.Value != null)
                {
                    m_LocalLookSource.Target = m_AimTarget.Value.transform;
                }
                else
                {
                    m_LocalLookSource.Target = null;
                }
            }

            // The Use ability has been found - try to start or stop the ability.
            if (m_Start.Value)
            {
                var abilityStarted = m_CharacterLocomotion.TryStartAbility(m_UseAbility);
                // The ability should wait to end until the Use ability is complete.
                if (m_WaitForUseComplete.Value)
                {
                    m_WaitForUse = true;
                    return(TaskStatus.Running);
                }
                return((abilityStarted || m_AlwaysReturnSuccess.Value) ? TaskStatus.Success : TaskStatus.Failure);
            }
            else
            {
                var abilityStopped = m_CharacterLocomotion.TryStopAbility(m_UseAbility, true);
                return((abilityStopped || m_AlwaysReturnSuccess.Value) ? TaskStatus.Success : TaskStatus.Failure);
            }
        }