SavePoint.cs 1.17 KB
Newer Older
1
2
3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Isa's avatar
Isa committed
4
using LevelauswahlScript;
Isa's avatar
Isa committed
5
using PlayerSpawnPointScript;
Michael But's avatar
Michael But committed
6
using UnityEngine.UI;
7
8
9

public class SavePoint : MonoBehaviour
{
10
	private bool isUsed;
Isa's avatar
Isa committed
11
	private Transform options;
Michael But's avatar
Michael But committed
12
	public Button button;
13
14
15

	private void Start()
	{
Michael But's avatar
Michael But committed
16
		button.interactable = false;
17
		isUsed = false;
Isa's avatar
Isa committed
18
19
20
21
22
		options = gameObject.transform.Find("Options");
	}

	public void OnTriggerEnter2D(Collider2D other)
	{
Michael But's avatar
Michael But committed
23
		//options.gameObject.SetActive(true);
Isa's avatar
Isa committed
24
25
26
27
	}

	public void OnTriggerExit2D(Collider2D other)
	{
Michael But's avatar
Michael But committed
28
		//options.gameObject.SetActive(false);
29
30
	}

31
32
	public void OnTriggerStay2D(Collider2D collision)
	{
33
		if (Input.GetButtonDown("Interact"))
34
		{
Michael But's avatar
Michael But committed
35
			button.interactable = true;
36
37
			isUsed = true;
			SaveSystem.SavePointUpdate(this);
Isa's avatar
Isa committed
38
39
40
		} else if (Input.GetButtonDown("Teleport") && Levelauswahl.la.auswahlIsActive() == false)
		{
			Levelauswahl.la.GetLevelauswahl();
41
42
		}
	}
43
44
45
46
47

	public bool GetIsUsed()
	{
		return isUsed;
	}
48
49
50

	public void SetIsUsed(bool var)
	{
Michael But's avatar
Michael But committed
51
		button.interactable = var;
52
53
		isUsed = var;
	}
Isa's avatar
Isa committed
54
55
56
57
58
59

	public void LoadSafePoint()
	{
		SaveSystem.SavePointUpdate(this);
		PlayerSpawnPoint.psp.SetPlayerToSafePoint(gameObject.transform.position);
	}
60
}