Commit 0633109d authored by Michael But's avatar Michael But

SaveListe für die Auswahlliste, die die verschiedene SavePoints anzeigt.

parent ab70a329
fileFormatVersion: 2
guid: bc43ac6a6d9af5e44b800027e40c1e84
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -105,6 +105,7 @@ GameObject:
- component: {fileID: 395035932932740995}
- component: {fileID: 395035932932740993}
- component: {fileID: 26295510}
- component: {fileID: 4164987020508732221}
m_Layer: 0
m_Name: SavePoint
m_TagString: Untagged
......@@ -203,3 +204,18 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!111 &4164987020508732221
Animation:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 395035932932740994}
m_Enabled: 1
serializedVersion: 3
m_Animation: {fileID: 0}
m_Animations: []
m_WrapMode: 0
m_PlayAutomatically: 1
m_AnimatePhysics: 0
m_CullingType: 0
This diff is collapsed.
......@@ -18,20 +18,6 @@ namespace PlayerSpawnPointScript
SetPlayerPosition();
}
// Update is called once per frame
//void Update()
//{
// if (Input.GetKeyDown(KeyCode.N))
// {
// SaveSystem.NewGame();
// }
// if (Input.GetKeyDown(KeyCode.O))
// {
// SetPlayerPosition();
// }
//}
private void SetPlayerPosition()
{
SavePointData savePosition = SaveSystem.LoadSavePoint();
......
......@@ -28,8 +28,8 @@ public class SavePoint : MonoBehaviour
{
if (Input.GetButtonDown("Interact"))
{
SaveSystem.SavePointUpdate(this);
isUsed = true;
isUsed = true;
SaveSystem.SavePointUpdate(this);
} else if (Input.GetButtonDown("Teleport") && Levelauswahl.la.auswahlIsActive() == false)
{
Levelauswahl.la.GetLevelauswahl();
......
......@@ -2,20 +2,29 @@ using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using SavePointListScript;
using System;
[System.Serializable]
public class SavePointData
{
public float[] position;
public bool[] savePointIsActiv;
public bool[] savePointIsActiv = null;
public SavePointData(SavePoint save)
{
position = new float[2];
position[0] = save.transform.position.x;
position[1] = save.transform.position.y;
savePointIsActiv = SavePointList.spl.GetIsActivList();
try
{
savePointIsActiv = SavePointList.spl.GetIsActivList();
}
catch (Exception e)
{
Debug.Log(e);
savePointIsActiv = null;
}
}
public SavePointData(Vector2 save)
......
......@@ -9,20 +9,27 @@ namespace SavePointListScript
public static SavePointList spl;
public GameObject[] savePointList;
public void Start()
{
spl = this;
}
public bool[] GetIsActivList()
{
bool[] savePointIsActiv = new bool[savePointList.Length];
int i = 0;
foreach(GameObject var in savePointList)
if (savePointList.Length > 1)
{
SavePoint temp = savePointList[i].GetComponent<SavePoint>();
savePointIsActiv[i] = temp.GetIsUsed();
i++;
bool[] savePointIsActiv = new bool[savePointList.Length -1];
int i = 0;
foreach (GameObject var in savePointList)
{
SavePoint temp = savePointList[i].GetComponent<SavePoint>();
savePointIsActiv[i] = temp.GetIsUsed();
i++;
}
return savePointIsActiv;
}
return savePointIsActiv;
return null;
}
public void setIsActivList(bool[] savePointIsActiv)
public void SetIsActivList(bool[] savePointIsActiv)
{
int i = 0;
foreach (GameObject var in savePointList)
......
......@@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine;
using SavePointListScript;
using UnityEngine.SceneManagement;
using PlayerSpawnPointScript;
......@@ -29,6 +30,10 @@ public class SaveSystem
FileStream stream = new FileStream(path, FileMode.Open);
SavePointData data = formatter.Deserialize(stream) as SavePointData;
if (data.savePointIsActiv != null)
{
SavePointList.spl.SetIsActivList(data.savePointIsActiv);
}
stream.Close();
......@@ -50,8 +55,6 @@ public class SaveSystem
try
{
data = new SavePointData(new Vector2(vec.x, vec.y));
//data = new SavePointData(new Vector2(PlayerSpawnPointScript.PlayerSpawnPoint.startPoint.transform.position.x, PlayerSpawnPointScript.PlayerSpawnPoint.startPoint.transform.position.y));
//SavePointData data = new SavePointData(new Vector2(GameObject.Find("StartPoint").transform.position.x, GameObject.Find("StartPoint").transform.position.y));
}
catch (Exception e)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment