1 using System.Collections;
2 using System.Collections.Generic;
5 public class Checkpoint : MonoBehaviour
7 public GameObject[] CheckPoints;
9 public GameObject Mouse;
12 private Health health;
17 // Start is called before the first frame update
20 abyss = GetComponent<Abyss>();
21 health = GetComponent<Health>();
24 // Update is called once per frame
27 if (abyss.fallenDown == true || health.mouseHealth == 0)
34 for (int i = 0; i < CheckPoints.Length; i++)
36 if (CheckPoints[i].transform.position.x <= Mouse.transform.position.x && CheckPoints[i + 1].transform.position.x >= Mouse.transform.position.x && CheckPoints[CheckPoints.Length-1].transform.position.x > Mouse.transform.position.x)
38 Mouse.transform.position = CheckPoints[i].transform.position;
40 else if (CheckPoints[0].transform.position.x >= Mouse.transform.position.x)
42 Mouse.transform.position = CheckPoints[0].transform.position;
44 else if (CheckPoints[CheckPoints.Length - 1].transform.position.x <= Mouse.transform.position.x)
46 Mouse.transform.position = CheckPoints[CheckPoints.Length - 1].transform.position;
49 if (Mouse.transform.position == CheckPoints[i].transform.position || Mouse.transform.position == CheckPoints[CheckPoints.Length - 1].transform.position)
52 abyss.fallenDown = false;
53 if(health.mouseHealth == 0)
55 health.mouseHealth = 5;