Merge remote-tracking branch 'origin/main' into main

main
Ivy 4 years ago
commit 3b8ad70d7c

@ -1,119 +1,119 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Assertions.Must;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public GameObject canvas;
public GameObject spriteToFade;
public GameObject events;
public GameObject player;
public List<Powerup> obtainedPowerups = new List<Powerup>{ };
public List<bool> powerupStatus = new List<bool>{ };
public string sceneToLoad = "";
void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
DontDestroyOnLoad(canvas);
DontDestroyOnLoad(events);
DontDestroyOnLoad(player);
}
else
{
Destroy(gameObject);
Destroy(canvas);
Destroy(events);
DontDestroyOnLoad(player);
}
}
// Start is called before the first frame update
void Start()
{
if (sceneToLoad != "")
{
LoadLevel(sceneToLoad, new Vector3(0, 0, 0));
}
}
// Update is called once per frame
void Update()
{
doGliderButtonCheck();
}
public void LoadLevel(string levelName, Vector3 whereTo)
{
StartCoroutine(LerpFunction(Color.black, 0.25f));
StartCoroutine(LoadSceneAsync(levelName, whereTo));
}
IEnumerator LoadSceneAsync(string scene, Vector3 whereTo)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(scene);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
player.transform.position = whereTo;
}
IEnumerator LerpFunction(Color endValue, float duration)
{
Image sprite = spriteToFade.GetComponent<Image>();
spriteToFade.SetActive(true);
float time = 0;
Color startValue = sprite.color;
while (time < duration)
{
sprite.color = Color.Lerp(startValue, endValue, time / duration);
time += Time.deltaTime;
yield return null;
}
sprite.color = endValue;
spriteToFade.SetActive(false);
}
private void doGliderButtonCheck()
{
if (obtainedPowerups.Contains(Powerup.Glider))
{
if (Input.GetKeyDown("1"))
{
var index = Array.IndexOf(obtainedPowerups.ToArray(), Powerup.Glider);
var status = powerupStatus[index];
if (!status)
{
player.GetComponent<Glider>().IsGliding = true;
powerupStatus[index] = true;
}
else
{
player.GetComponent<Glider>().IsGliding = false;
powerupStatus[index] = false;
}
}
}
}
}
// }
//}
//}
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Assertions.Must;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
{
public static GameManager Instance { get; private set; }
public GameObject canvas;
public GameObject spriteToFade;
public GameObject events;
public GameObject player;
public List<Powerup> obtainedPowerups = new List<Powerup>{ };
public List<bool> powerupStatus = new List<bool>{ };
public string sceneToLoad = "";
void Awake()
{
if (Instance == null)
{
Instance = this;
DontDestroyOnLoad(gameObject);
DontDestroyOnLoad(canvas);
DontDestroyOnLoad(events);
DontDestroyOnLoad(player);
}
else
{
Destroy(gameObject);
Destroy(canvas);
Destroy(events);
Destroy(player);
}
}
// Start is called before the first frame update
void Start()
{
if (sceneToLoad != "")
{
LoadLevel(sceneToLoad, new Vector3(0, 0, 0));
}
}
// Update is called once per frame
void Update()
{
doGliderButtonCheck();
}
public void LoadLevel(string levelName, Vector3 whereTo)
{
StartCoroutine(LerpFunction(Color.black, 0.25f));
StartCoroutine(LoadSceneAsync(levelName, whereTo));
}
IEnumerator LoadSceneAsync(string scene, Vector3 whereTo)
{
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(scene);
// Wait until the asynchronous scene fully loads
while (!asyncLoad.isDone)
{
yield return null;
}
player.transform.position = whereTo;
}
IEnumerator LerpFunction(Color endValue, float duration)
{
Image sprite = spriteToFade.GetComponent<Image>();
spriteToFade.SetActive(true);
float time = 0;
Color startValue = sprite.color;
while (time < duration)
{
sprite.color = Color.Lerp(startValue, endValue, time / duration);
time += Time.deltaTime;
yield return null;
}
sprite.color = endValue;
spriteToFade.SetActive(false);
}
private void doGliderButtonCheck()
{
if (obtainedPowerups.Contains(Powerup.Glider))
{
if (Input.GetKeyDown("1"))
{
var index = Array.IndexOf(obtainedPowerups.ToArray(), Powerup.Glider);
var status = powerupStatus[index];
if (!status)
{
player.GetComponent<Glider>().IsGliding = true;
powerupStatus[index] = true;
}
else
{
player.GetComponent<Glider>().IsGliding = false;
powerupStatus[index] = false;
}
}
}
}
}
// }
//}
//}

@ -7,15 +7,18 @@ EditorUserSettings:
m_ConfigSettings:
RecentlyUsedScenePath-0:
value: 22424703114646680e0b0227036c6c111b07142f1f2b233e2867083debf42d
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620d183eedd43b2fe7f578fce9332b25
flags: 0
RecentlyUsedScenePath-1:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e52637edea78fce9332b25
flags: 0
RecentlyUsedScenePath-2:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1132eceb7414e7f133e5a92f31352d1b
flags: 0
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620c1336eff9002dece933e5a92f31352d1b
value: 22424703114646680e0b0227036c72110203102f3b1c2323391a1e36ece57a2decee22f0
flags: 0
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d3ae9e5740be1e238eca92f31352d1b
@ -31,6 +34,7 @@ EditorUserSettings:
flags: 0
RecentlyUsedScenePath-8:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23620b1220f1d23b37efa923e7ee2e26
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621d1224e7f27a2decee22f0
flags: 0
RecentlyUsedScenePath-9:
value: 22424703114646680e0b0227036c7b151b18342f3a2d2a23621a0d32f5ee7a2decee22f0

Loading…
Cancel
Save