/// <summary>
 /// When the player respawns, we reset the position and behaviour of this moving platform
 /// </summary>
 /// <param name="checkpoint">Checkpoint.</param>
 /// <param name="player">Player.</param>
 public virtual void OnPlayerRespawn(CheckPoint checkpoint, Character player)
 {
     if (ResetPositionWhenPlayerRespawns)
     {
         Initialization();
     }
 }
예제 #2
0
        /// <summary>
        /// When the player respawns, we reinstate this agent.
        /// </summary>
        /// <param name="checkpoint">Checkpoint.</param>
        /// <param name="player">Player.</param>
        public virtual void OnPlayerRespawn(CheckPoint checkpoint, Character player)
        {
            if (RepositionToInitOnPlayerRespawn)
            {
                this.transform.position = _initialPosition;
            }

            if (RespawnOnPlayerRespawn)
            {
                if (GetComponent <Health>() != null)
                {
                    GetComponent <Health>().Revive();
                }
                Revive();
            }
        }
        /// <summary>
        /// Gets current camera, points number, start time, etc.
        /// </summary>
        protected virtual void Initialization()
        {
            // storage
            LevelCameraController = FindObjectOfType <CameraController>();
            _savedPoints          = GameManager.Instance.Points;
            _started = DateTime.UtcNow;

            // if we don't find a bounds collider we generate one
            BoundsCollider = this.gameObject.GetComponent <Collider>();
            if (BoundsCollider == null)
            {
                GenerateColliderBounds();
                BoundsCollider = this.gameObject.GetComponent <Collider>();
            }

            // we store all the checkpoints present in the level, ordered by their x value
            if ((CheckpointAttributionAxis == CheckpointsAxis.x) && (CheckpointAttributionDirection == CheckpointDirections.Ascending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderBy(o => o.transform.position.x).ToList();
            }
            if ((CheckpointAttributionAxis == CheckpointsAxis.x) && (CheckpointAttributionDirection == CheckpointDirections.Descending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderByDescending(o => o.transform.position.x).ToList();
            }
            if ((CheckpointAttributionAxis == CheckpointsAxis.y) && (CheckpointAttributionDirection == CheckpointDirections.Ascending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderBy(o => o.transform.position.y).ToList();
            }
            if ((CheckpointAttributionAxis == CheckpointsAxis.y) && (CheckpointAttributionDirection == CheckpointDirections.Descending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderByDescending(o => o.transform.position.y).ToList();
            }
            if ((CheckpointAttributionAxis == CheckpointsAxis.z) && (CheckpointAttributionDirection == CheckpointDirections.Ascending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderBy(o => o.transform.position.z).ToList();
            }
            if ((CheckpointAttributionAxis == CheckpointsAxis.z) && (CheckpointAttributionDirection == CheckpointDirections.Descending))
            {
                Checkpoints = FindObjectsOfType <CheckPoint> ().OrderByDescending(o => o.transform.position.z).ToList();
            }

            // we assign the first checkpoint
            CurrentCheckPoint = Checkpoints.Count > 0 ? Checkpoints[0] : null;
        }
예제 #4
0
 /// <summary>
 /// Sets the current checkpoint.
 /// </summary>
 /// <param name="newCheckPoint">New check point.</param>
 public virtual void SetCurrentCheckpoint(CheckPoint newCheckPoint)
 {
     CurrentCheckPoint = newCheckPoint;
 }