Make DataSaver
This commit is contained in:
44
Assets/Scripts/DataManager.cs
Normal file
44
Assets/Scripts/DataManager.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DataManager : MonoBehaviour
|
||||
{
|
||||
public static float score = 0;
|
||||
public static int actualLevel = 0;
|
||||
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
if (PlayerPrefs.HasKey("level"))
|
||||
{
|
||||
actualLevel = PlayerPrefs.GetInt("level");
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static void Score(float value)
|
||||
{
|
||||
score = value;
|
||||
}
|
||||
|
||||
public static float Score()
|
||||
{
|
||||
return score;
|
||||
}
|
||||
|
||||
public static void Level(int value)
|
||||
{
|
||||
actualLevel = value;
|
||||
PlayerPrefs.SetInt("level", value);
|
||||
}
|
||||
|
||||
public static int Level()
|
||||
{
|
||||
return actualLevel;
|
||||
}
|
||||
}
|
11
Assets/Scripts/DataManager.cs.meta
Normal file
11
Assets/Scripts/DataManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a1bf5899e586bf44b99a8432ec6136cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -43,9 +43,10 @@ public class MainMenu : MonoBehaviour
|
||||
{
|
||||
WWWForm form = new WWWForm();
|
||||
form.AddField("name", name.text);
|
||||
form.AddField("score", 20);
|
||||
form.AddField("score", DataManager.Score().ToString());
|
||||
|
||||
StartCoroutine(PostText("dev.steelants.cz/vasek/GGJ2021/GeorgeJones/Server/api.php", form));
|
||||
DataManager.Level(0);
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
|
||||
|
@@ -35,6 +35,7 @@ public class ObjectManager : MonoBehaviour
|
||||
{
|
||||
meshRenderer = GetComponent<MeshRenderer>();
|
||||
}
|
||||
meshRenderer.materials[0].DisableKeyword("_EMISSION");
|
||||
meshRenderer.materials[1].SetFloat ("_Outline", 0.0f);
|
||||
meshRenderer.materials[1].SetColor("_OutlineColor", new Color(0.5276349f, 0.5566038f, 0.118147f));
|
||||
rigidBody = GetComponent<Rigidbody>();
|
||||
|
@@ -59,7 +59,7 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
if (actualHealth <= 0 || gameObject.transform.position.y < -400.0f)
|
||||
{
|
||||
@@ -194,6 +194,7 @@ public class PlayerManager : MonoBehaviour
|
||||
|
||||
public void Die()
|
||||
{
|
||||
DataManager.Level(SceneManager.GetActiveScene().buildIndex);
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||
}
|
||||
|
||||
@@ -272,6 +273,7 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
if ((powerType.GetHashCode() - 1) == 3)
|
||||
{
|
||||
DataManager.Level(SceneManager.GetSceneByName(nextSceneName).buildIndex);
|
||||
SceneManager.LoadScene(nextSceneName);
|
||||
}
|
||||
else if ((powerType.GetHashCode() - 1) == 4)
|
||||
|
@@ -14,22 +14,6 @@ public class PowerCubeManager : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (powerType == PowerType.DubleJump)
|
||||
{
|
||||
GetComponentInChildren<MeshRenderer>().material.color = Color.cyan;
|
||||
}
|
||||
if (powerType == PowerType.PushPull)
|
||||
{
|
||||
GetComponentInChildren<MeshRenderer>().material.color = Color.yellow;
|
||||
}
|
||||
if (powerType == PowerType.Dash)
|
||||
{
|
||||
GetComponentInChildren<MeshRenderer>().material.color = Color.white;
|
||||
}
|
||||
if (powerType == PowerType.Ladder)
|
||||
{
|
||||
GetComponentInChildren<MeshRenderer>().material.color = Color.black;
|
||||
}
|
||||
if (powerType == PowerType.Bigger) {
|
||||
GetComponentInChildren<MeshRenderer>().material.color = Color.blue;
|
||||
}
|
||||
@@ -44,6 +28,7 @@ public class PowerCubeManager : MonoBehaviour
|
||||
else if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
||||
{
|
||||
meshRenderer = GetComponentInChildren<MeshRenderer>();
|
||||
meshRenderer.materials[0].DisableKeyword("_EMISSION");
|
||||
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
|
||||
meshRenderer.materials[1].SetColor("_OutlineColor", new Color(0.5276349f, 0.5566038f, 0.118147f));
|
||||
}
|
||||
@@ -61,11 +46,15 @@ public class PowerCubeManager : MonoBehaviour
|
||||
{
|
||||
if (powerType == PowerType.Artefact)
|
||||
{
|
||||
meshRenderer.materials[0].EnableKeyword("_EMISSION");
|
||||
meshRenderer.materials[0].SetColor("_EmissionColor", new Color(0.2735849f, 0.2018939f, 0.09162514f) * 0.8f);
|
||||
meshRenderer.materials[1].SetFloat("_Outline", 0.4f);
|
||||
}
|
||||
else if (powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
||||
{
|
||||
meshRenderer.materials[1].SetFloat("_Outline", 0.01f);
|
||||
meshRenderer.materials[1].SetFloat("_Outline", 6f);
|
||||
meshRenderer.materials[0].EnableKeyword("_EMISSION");
|
||||
meshRenderer.materials[0].SetColor("_EmissionColor", new Color(0.2735849f, 0.2018939f, 0.09162514f) * 0.8f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +64,7 @@ public class PowerCubeManager : MonoBehaviour
|
||||
{
|
||||
if (powerType == PowerType.Artefact || powerType == PowerType.DubleJump || powerType == PowerType.PushPull || powerType == PowerType.Dash || powerType == PowerType.Ladder)
|
||||
{
|
||||
meshRenderer.materials[0].DisableKeyword("_EMISSION");
|
||||
meshRenderer.materials[1].SetFloat("_Outline", 0.0f);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user