Add menu scene, scene transition, simple position save and load

This commit is contained in:
2022-04-11 16:34:14 +03:00
parent 26e2d0d1db
commit 1ed57d5c31
25 changed files with 23436 additions and 130 deletions

View File

@@ -34,8 +34,8 @@ public class ArmSwingLocomotion : MonoBehaviour
float Yrot = CenterEyeCamera.transform.eulerAngles.y;
ForwardDirection.transform.eulerAngles = new Vector3(0, Yrot, 0);
/*float Yrot = CenterEyeCamera.transform.eulerAngles.y;
ForwardDirection.transform.eulerAngles = new Vector3(0, Yrot, 0);*/
PositionCurrentFrameLeftHand = LeftHand.transform.position;
PositionCurrentFrameRightHand = RightHand.transform.position;

View File

@@ -22,10 +22,10 @@ public class EnableArmSwing : MonoBehaviour
{
if (other.tag == "Hand")
{
if(_renderer.material.color == Color.white)
Player.GetComponent<ArmSwingLocomotion>().enabled = true;
else
if(Player.GetComponent<ArmSwingLocomotion>().enabled == true)
Player.GetComponent<ArmSwingLocomotion>().enabled = false;
else
Player.GetComponent<ArmSwingLocomotion>().enabled = true;
}
}

View File

@@ -22,10 +22,10 @@ public class EnableDash : MonoBehaviour
{
if (other.tag == "Hand")
{
if (_renderer.material.color == Color.white)
Player.GetComponent<Dash>().enabled = true;
else
if (Player.GetComponent<Dash>().enabled == true)
Player.GetComponent<Dash>().enabled = false;
else
Player.GetComponent<Dash>().enabled = true;
}
}

View File

@@ -6,12 +6,14 @@ public class EnableJoyStick : MonoBehaviour
{
private MeshCollider _collider;
private MeshRenderer _renderer;
public GameObject LocomotionSystem;
// Start is called before the first frame update
void Start()
{
_collider = GetComponent<MeshCollider>();
_renderer = GetComponent<MeshRenderer>();
LocomotionSystem.SetActive(false);
}
@@ -20,8 +22,7 @@ public class EnableJoyStick : MonoBehaviour
{
if (other.tag == "Hand")
{
LocomotionSystem.SetActive(true);
LocomotionSystem.SetActive(!LocomotionSystem.activeSelf);
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class EnterGameScene : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
SceneManager.LoadScene("GameScene");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1114a137d02f184db2b6291d9d31cb5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ForwardDirection : MonoBehaviour
{
public GameObject CenterEyeCamera;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
float Yrot = CenterEyeCamera.transform.eulerAngles.y;
transform.eulerAngles = new Vector3(0, Yrot, 0);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 01869e86b22555a449cd53043f5c4afa
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PauseMenu : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5a2662b3abecb914cad356619e832f13
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
/*public int level;
public int health;*/
public void SavePlayer()
{
SaveSystem.SavePlayer(this);
}
public void LoadPlayer()
{
PlayerData data = SaveSystem.LoadPlayer();
Vector3 position;
position.x = data.position[0];
position.y = data.position[1];
position.z = data.position[2];
transform.position = position;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ff82a98832d12249b30083bc9ae2dd3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,22 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class PlayerData
{
/*public int level;
public int health;*/
public float[] position;
public PlayerData(Player player)
{
/*level = player.level;
health = player.health;*/
position = new float[3];
position[0] = player.transform.position.x;
position[1] = player.transform.position.y;
position[2] = player.transform.position.z;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9cdb4de85d282744083c6d9cee4fef3c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,42 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
public static class SaveSystem
{
public static void SavePlayer(Player player)
{
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/player.data";
FileStream stream = new FileStream(path, FileMode.Create);
PlayerData data = new PlayerData(player);
formatter.Serialize(stream, data);
stream.Close();
}
public static PlayerData LoadPlayer ()
{
string path = Application.persistentDataPath + "/player.data";
if (File.Exists(path))
{
BinaryFormatter formatter = new BinaryFormatter();
FileStream stream = new FileStream(path, FileMode.Open);
PlayerData data = formatter.Deserialize(stream) as PlayerData;
stream.Close();
return data;
}
else
{
Debug.Log("Save File not found in " + path);
return null;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 49c2ebd233ef7a547b12ce163244e30a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class XRGUI : MonoBehaviour
{
[SerializeField]
private Button SettingsButton;
[SerializeField]
private Button LoadButton;
[SerializeField]
private Button ExitButton;
// Start is called before the first frame update
void Start()
{
SettingsButton.onClick.AddListener(() =>
{
});
LoadButton.onClick.AddListener(() =>
{
});
ExitButton.onClick.AddListener(() =>
{
Debug.Log("Clicked");
UnityEditor.EditorApplication.isPlaying = false;
});
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 37cfb6899ccd00b4280ac4eb92f84851
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: