Пример #1
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;
        }
Пример #2
0
        /// <summary>
        /// Does the respawn by setting the position and rotation to the specified values.
        /// Enable the GameObject and let all of the listening objects know that the object has been respawned.
        /// </summary>
        /// <param name="position">The respawn position.</param>
        /// <param name="rotation">The respawn rotation.</param>
        /// <param name="transformChange">Was the position or rotation changed?</param>
        public virtual void Respawn(Vector3 position, Quaternion rotation, bool transformChange)
        {
            // Send a pre-respawn event so abilities can stop if they should no longer be active.
            EventHandler.ExecuteEvent(m_GameObject, "OnWillRespawn");

            if (transformChange)
            {
                // Characters require a specific setter for the position and rotation.
                if (m_CharacterLocomotion != null)
                {
                    m_CharacterLocomotion.SetPositionAndRotation(position, rotation);
                }
                else
                {
                    m_Transform.position = position;
                    m_Transform.rotation = rotation;
                }
            }

            m_GameObject.SetActive(true);

            // Play any respawn audio.
            m_RespawnAudioClipSet.PlayAudioClip(m_GameObject);

            EventHandler.ExecuteEvent(m_GameObject, "OnRespawn");
            if (m_OnRespawnEvent != null)
            {
                m_OnRespawnEvent.Invoke();
            }

#if ULTIMATE_CHARACTER_CONTROLLER_MULTIPLAYER
            if (m_NetworkInfo != null && m_NetworkInfo.IsLocalPlayer())
            {
                m_NetworkRespawnerMonitor.Respawn(position, rotation, transformChange);
            }
#endif
        }
Пример #3
0
 /// <summary>
 /// Performs the cast.
 /// </summary>
 /// <param name="castID">The ID of the cast.</param>
 /// <param name="origin">The location that the cast should spawn from.</param>
 /// <param name="direction">The direction of the cast.</param>
 /// <param name="targetPosition">The target position of the cast.</param>
 public override void Cast(Transform origin, Vector3 direction, Vector3 targetPosition)
 {
     direction = Vector3.ProjectOnPlane(targetPosition - m_GameObject.transform.position, m_CharacterLocomotion.Up);
     m_CharacterLocomotion.SetPositionAndRotation(targetPosition, Quaternion.LookRotation(direction), m_SnapAnimator, false);
 }
Пример #4
0
 public void SetPositionAndRotationRPC(Vector3 position, Quaternion rotation, bool snapAnimator)
 {
     m_CharacterLocomotion.SetPositionAndRotation(position, rotation, snapAnimator);
 }