Added crazy Dish ui screen
This commit is contained in:
@@ -8,7 +8,6 @@ public class CookButton : MonoBehaviour
|
||||
public GameObject Button;
|
||||
|
||||
void OnMouseUp() {
|
||||
Debug.Log("L");
|
||||
Button.GetComponentInParent<Cooking>().CreateDish();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Unity.VisualStudio.Editor;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cooking : MonoBehaviour
|
||||
@@ -14,6 +15,7 @@ public class Cooking : MonoBehaviour
|
||||
|
||||
// }
|
||||
|
||||
|
||||
public Vector3 FinishedDishPosition;
|
||||
public GameObject AllIngredients;
|
||||
|
||||
@@ -96,18 +98,17 @@ public class Cooking : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
// old code
|
||||
//--------------------------------------
|
||||
// // Remove ingredients and add the dish
|
||||
// foreach (GameObject Ingredient in UsedIngredients) {
|
||||
// Transform transform = Ingredient.GetComponent<Ingredient>().transform;
|
||||
// transform.position = Vector3.up * 50;
|
||||
// }
|
||||
//
|
||||
|
||||
BestDish.transform.position = FinishedDishPosition;
|
||||
|
||||
foreach (GameObject Ingredient in UsedIngredients) {
|
||||
Transform transform = Ingredient.GetComponent<Ingredient>().transform;
|
||||
transform.position = Vector3.up * 50;
|
||||
}
|
||||
//BestDish.transform.position = FinishedDishPosition;
|
||||
//--------------------------------------
|
||||
|
||||
// Return ingredients to table
|
||||
|
||||
@@ -118,6 +119,13 @@ public class Cooking : MonoBehaviour
|
||||
ingredient.GetComponent<Ingredient>().ResetPosition();
|
||||
}
|
||||
|
||||
// Show dish ui screen
|
||||
Sprite DishImage = BestDish.GetComponent<SpriteRenderer>().sprite;
|
||||
int Stars = 3;
|
||||
string DishName = BestDish.name;
|
||||
|
||||
gameObject.GetComponent<DishUI>().ShowUI(DishName, DishImage, Stars);
|
||||
|
||||
}
|
||||
|
||||
// Keep track of ingredients going on and off the cooker.
|
||||
|
||||
64
Assets/Scripts/DishUI.cs
Normal file
64
Assets/Scripts/DishUI.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DishUI : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI DishNameField;
|
||||
public Image DishImage;
|
||||
public GameObject UIScreen;
|
||||
public GameObject _1Star;
|
||||
public GameObject _2Stars;
|
||||
public GameObject _3Stars;
|
||||
public GameObject _4Stars;
|
||||
public GameObject _5Stars;
|
||||
float Timer = 0;
|
||||
bool IsVisible = false;
|
||||
|
||||
private void Start() {
|
||||
HideUI();
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
Timer -= Time.deltaTime;
|
||||
|
||||
if (Timer < 0 && IsVisible) {
|
||||
HideUI();
|
||||
IsVisible = false;
|
||||
}
|
||||
}
|
||||
public void ShowUI(string DishName, Sprite sprite, int Stars)
|
||||
{
|
||||
UIScreen.SetActive(true);
|
||||
DishNameField.text = DishName;
|
||||
DishImage.sprite = sprite;
|
||||
|
||||
if (Stars == 1)
|
||||
_1Star.SetActive(true);
|
||||
if (Stars == 2)
|
||||
_2Stars.SetActive(true);
|
||||
if (Stars == 3)
|
||||
_3Stars.SetActive(true);
|
||||
if (Stars == 4)
|
||||
_4Stars.SetActive(true);
|
||||
if (Stars == 5)
|
||||
_5Stars.SetActive(true);
|
||||
|
||||
IsVisible = true;
|
||||
Timer = 3;
|
||||
}
|
||||
|
||||
void HideUI()
|
||||
{
|
||||
UIScreen.SetActive(false);
|
||||
_1Star.SetActive(false);
|
||||
_2Stars.SetActive(false);
|
||||
_3Stars.SetActive(false);
|
||||
_4Stars.SetActive(false);
|
||||
_5Stars.SetActive(false);
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/DishUI.cs.meta
Normal file
11
Assets/Scripts/DishUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d759011136bcb314c8f8c7bcc3f3568e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user