new ui done
This commit is contained in:
@@ -20,11 +20,17 @@ public class GameManager : MonoBehaviour
|
||||
public float game_end_timer = 15;
|
||||
public GameObject gameOverPanel;
|
||||
public GameObject gameWonPanel;
|
||||
public Image[] stars;
|
||||
// public GameObject[] stars;
|
||||
public GameObject[] bees;
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
|
||||
gameWonPanel.transform.Find("btn_next").GetComponent<Button>().onClick.AddListener(NextLevel);
|
||||
gameWonPanel.transform.Find("btn_leave").GetComponent<Button>().onClick.AddListener(BackToMenu);
|
||||
gameOverPanel.transform.Find("btn_leave").GetComponent<Button>().onClick.AddListener(BackToMenu);
|
||||
gameWonPanel.transform.Find("btn_restart").GetComponent<Button>().onClick.AddListener(Restart);
|
||||
gameOverPanel.transform.Find("btn_restart").GetComponent<Button>().onClick.AddListener(Restart);
|
||||
}
|
||||
|
||||
float t;
|
||||
@@ -116,13 +122,15 @@ public class GameManager : MonoBehaviour
|
||||
void gameWon(){
|
||||
float fuelLeft = Drawer.instance.drawingFuel.value / Drawer.instance.drawingFuel.maxValue;
|
||||
int level = 1;
|
||||
if(fuelLeft > 0.5f){
|
||||
level=2;
|
||||
}else if(fuelLeft> 0.8f){
|
||||
level =3;
|
||||
if(fuelLeft > 0.65f){
|
||||
level=3;
|
||||
}else if(fuelLeft> 0.25f){
|
||||
level =2;
|
||||
}
|
||||
Debug.Log("Fuel left : " + fuelLeft);
|
||||
for(int i =0;i < 3; i++){
|
||||
stars[i].color = level-1 >= i ? Color.yellow : Color.gray;
|
||||
// stars[i].color = level-1 >= i ? Color.yellow : Color.gray;
|
||||
gameWonPanel.transform.Find("Star").GetChild(i+4).gameObject.SetActive(level-1 >= i);
|
||||
}
|
||||
|
||||
int levelNumber = int.Parse(SceneManager.GetActiveScene().name.Replace("Level",""));
|
||||
|
||||
@@ -58,9 +58,8 @@ public class LevelSelect : MonoBehaviour
|
||||
}
|
||||
|
||||
public Sprite locked,unlocked;
|
||||
void Start()
|
||||
{
|
||||
// levelProgress.Add(0,2);
|
||||
|
||||
public static void Init(){
|
||||
if(PlayerPrefs.HasKey("progress")){
|
||||
string savedata = PlayerPrefs.GetString("progress");
|
||||
levelProgress = JsonConvert.DeserializeObject<Dictionary<int,int>>(savedata);
|
||||
@@ -69,6 +68,11 @@ public class LevelSelect : MonoBehaviour
|
||||
}else{
|
||||
levelProgress = new Dictionary<int, int>();
|
||||
}
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
// levelProgress.Add(0,2);
|
||||
Init();
|
||||
|
||||
//Populate level selection
|
||||
for(int i=0; i < LevelCount;i++){
|
||||
@@ -124,4 +128,9 @@ public class LevelSelect : MonoBehaviour
|
||||
|
||||
Debug.Log("saving: " +val);
|
||||
}
|
||||
|
||||
|
||||
public void BackToMainMenu(){
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
|
||||
33
Assets/Scripts/MainMenu.cs
Normal file
33
Assets/Scripts/MainMenu.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MainMenu : MonoBehaviour
|
||||
{
|
||||
public void Play(){
|
||||
int lastLevel = -1;
|
||||
foreach(KeyValuePair<int,int> level in LevelSelect.levelProgress){
|
||||
if(level.Key > lastLevel){
|
||||
lastLevel=level.Key;
|
||||
}
|
||||
}
|
||||
|
||||
SceneManager.LoadScene($"Level{lastLevel+1}");
|
||||
}
|
||||
|
||||
public void Levels(){
|
||||
SceneManager.LoadScene("LevelSelect");
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
LevelSelect.Init();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/MainMenu.cs.meta
Normal file
11
Assets/Scripts/MainMenu.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 45d62b70b9b3aff4693ffa781a834000
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user