Ejemplo n.º 1
0
        /// <summary>
        /// Jumps the player character onto the segment's checkpoint
        /// </summary>
        /// <param name="segment"></param>
        /// <param name="checkpointIndex"></param>
        public void Jump(StratusSegment segment, int checkpointIndex = 0)
        {
            Vector3 position = segment.checkpoints[checkpointIndex].transform.position;

            switch (mechanism)
            {
            case JumpMechanism.Translate:
                var navigation = targetTransform.GetComponent <NavMeshAgent>();
                if (navigation != null)
                {
                    navigation.Warp(position);
                }
                else
                {
                    targetTransform.position = position;
                }
                break;

            case JumpMechanism.Callback:
                onJump?.Invoke(segment, checkpointIndex);
                break;

            case JumpMechanism.Event:
                Scene.Dispatch <JumpToSegmentEvent>(new JumpToSegmentEvent(segment, checkpointIndex, position)
                {
                    episode = this
                });
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Jumps to the specified segment within this episode
        /// </summary>
        /// <param name="segment"></param>
        /// <param name="jump">Whether to teleport the player to the checkpoint</param>
        /// <param name="checkpointIndex">The checkpoint to jump to</param>
        public void Enter(StratusSegment segment, bool jump, int checkpointIndex = 0)
        {
            if (!Application.isPlaying)
            {
                return;
            }

            if (debugDisplay)
            {
                StratusDebug.Log($"Entering the segment {segment}, checkpoint {checkpointIndex}", this);
            }

            // Toggle the current segment on
            ToggleCurrentSegment();

            // Enter the segment
            currentSegmentIndex = GetSegmentIndex(segment);
            segment.Enter(mode == Mode.Suspended);

            // Now warp the player to it
            if (jump)
            {
                Jump(segment, checkpointIndex);
            }
        }
 protected override void OnReset()
 {
     segment = GetComponent <StratusSegment>();
     if (segment)
     {
         episode = segment.episode;
     }
 }
 bool ValidateSegment(StratusSegment segment)
 {
     return(this.segment == segment);
     //if (referenceType == ReferenceType.Label)
     //  return this.segmentLabel == segment.label;
     //else if (referenceType == ReferenceType.Reference)
     //  return this.segment = segment;
     //return false;
 }
Ejemplo n.º 5
0
 private void OnValidate()
 {
     debugTextColorHex = debugTextColor.ToHex();
     if (segments.Count == 1)
     {
         initialSegment = segments[0];
     }
     if (initialSegment)
     {
         SetInitialSegment(initialSegment);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Enters the specified (by label) segment within this episode if its present
        /// </summary>
        /// <param name="label">The label for the segment</param>
        /// <param name="jump">Whether to teleport the player to the checkpoint</param>
        /// <param name="checkpointIndex"></param>
        public bool Enter(string label, bool jump, int checkpointIndex = 0)
        {
            if (!StratusSegment.available.ContainsKey(label))
            {
                StratusDebug.Error($"The segment labeled {label} is not present at this time!", this);
                return(false);
            }

            StratusSegment segment = StratusSegment.available[label];

            Enter(segment, jump, checkpointIndex);
            return(true);
        }
Ejemplo n.º 7
0
        private void ShowSegment(StratusEpisode episode, StratusSegment segment)
        {
            //expanded = GUILayout.(expanded, ); //, expanded ? minimizeButtonContent : expandButtonContent);
            //if (segment.checkpoints.NotEmpty() && GUILayout.Button(expanded ? minimizeButtonContent : expandButtonContent, EditorStyles.toggle))
            //  segmentExpanded[segment] = !expanded;
            //GUILayout.EndHorizontal();


            // Show the checkpoints
            if (!segment.checkpoints.Empty() && segmentExpanded[segment])
            {
                GUILayout.BeginVertical();
                for (int i = 0; i < segment.checkpoints.Count; ++i)
                {
                    if (GUILayout.Button($"{segment.checkpoints[i].name}", EditorStyles.miniButton))
                    {
                        episode.Enter(segment, true, i);
                    }
                }
                GUILayout.EndVertical();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Sets the initial segment for this episode
        /// </summary>
        /// <param name="segment"></param>
        public void SetInitialSegment(StratusSegment initialSegment)
        {
            // Toggle the selected segment
            this.initialSegment = initialSegment;

            foreach (var segment in segments)
            {
                segment.episode = this;
                //if (segment != null && currentSegment)
                //  segment.Toggle(false);
            }

            //ToggleCurrentSegment();

            //initialSegment.Toggle(true);
            //// Toggle off all other ones
            //foreach (var segment in segments)
            //{
            //  segment.episode = this;
            //  if (segment != null && initialSegment)
            //    segment.Toggle(false);
            //}
        }
Ejemplo n.º 9
0
 public ExitedEvent(StratusSegment segment)
 {
     this.segment = segment;
 }
Ejemplo n.º 10
0
 public EnteredEvent(StratusSegment segment)
 {
     this.segment = segment;
 }
Ejemplo n.º 11
0
 public JumpToSegmentEvent(StratusSegment segment, int checkpointIndex, Vector3 position)
 {
     this.segment         = segment;
     this.checkpointIndex = checkpointIndex;
     this.position        = position;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Gets the index of a given segment, provided its part of this episode
 /// </summary>
 /// <param name="segment"></param>
 /// <returns></returns>
 public int GetSegmentIndex(StratusSegment segment)
 {
     return(segments.FindIndex(x => x == segment));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Exits this segment
 /// </summary>
 /// <param name="segment"></param>
 public void Exit(StratusSegment segment)
 {
     segment.Exit();
 }