TheKingsRace/Assets/Scripts/PlayerScripts/ResetZones.cs
Julia Butenhoff 0c9a5f11ef Implemented Checkpoint for Both Vertical and Upper Mountain
- Now two seperate reset points in case players get stuck
2022-04-13 21:23:29 -05:00

67 lines
2.1 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using MLAPI;
using MLAPI.Messaging;
using MLAPI.Exceptions;
using System.Linq;
public class ResetZones : MonoBehaviour {
private Transform ValleyRespawnPoint;
private Transform PlainsRespawnPoint;
private Transform FoothillsRespawnPoint;
private Transform MountainVerticalRespawnPoint;
private Transform MountainUpperRespawnPoint;
public enum Zone {
VALLEY,
PLAINS,
FOOTHILLS,
MOUNTAIN_VERTICAL,
MOUNTAIN_UPPER
}
private Zone currentZone;
void Start() {
// Make sure we are in the game scene
if (SceneManager.GetActiveScene().buildIndex == 3) {
ValleyRespawnPoint = GameObject.FindGameObjectWithTag("ValleyRespawnPoint").transform;
PlainsRespawnPoint = GameObject.FindGameObjectWithTag("PlainsRespawnPoint").transform;
FoothillsRespawnPoint = GameObject.FindGameObjectWithTag("FoothillsRespawnPoint").transform;
MountainVerticalRespawnPoint = GameObject.FindGameObjectWithTag("MountainRespawnPoint").transform;
MountainUpperRespawnPoint = GameObject.FindGameObjectWithTag("MountainUpperRespawnPoint").transform;
}
// Starting zone is the valley
currentZone = Zone.VALLEY;
}
public void SetCurrentZone(int newZone) {
currentZone = (Zone)newZone;
}
public Zone GetCurrentZone() {
return currentZone;
}
public Vector3 GetRespawnPosition(Zone zone) {
switch(zone) {
case Zone.PLAINS:
return PlainsRespawnPoint.position;
case Zone.FOOTHILLS:
return FoothillsRespawnPoint.position;
case Zone.MOUNTAIN_VERTICAL:
return MountainVerticalRespawnPoint.position;
case Zone.MOUNTAIN_UPPER:
return MountainUpperRespawnPoint.position;
default:
case Zone.VALLEY:
return ValleyRespawnPoint.position;
}
}
}