You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.5 KiB

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using TMPro;
  6. using System;
  7. public class Recipe : MonoBehaviour {
  8. public Player localPlayer;
  9. int PlayerCount;
  10. public Vegetable[] Veggies;
  11. public Frame[] Frames;
  12. public int[] Qtys;
  13. public GameObject RecipeCanvas;
  14. public Image Inventory;
  15. // Use this for initialization
  16. void Start () {
  17. for (int i = 0; i < PlayerCount; i++)
  18. {
  19. int rand = UnityEngine.Random.Range(0, Qtys.Length - 1);
  20. Qtys[rand] += 1;
  21. }
  22. for (int i = 0; i < 4; i++) //Set the recipe UI
  23. {
  24. Frames[i].VegetableSpot.sprite = Veggies[i].Image;
  25. Frames[i].Qty.text = Qtys[i] + "";
  26. }
  27. }
  28. //Button calls
  29. public void OpenRecipe()
  30. {
  31. RecipeCanvas.SetActive(true);
  32. }
  33. public void CloseRecipe()
  34. {
  35. RecipeCanvas.SetActive(false);
  36. }
  37. //Veggie interactions
  38. public void pickupItem(Vegetable newVeggie)
  39. {
  40. localPlayer.heldVeggie = newVeggie;
  41. Inventory.gameObject.SetActive(true);
  42. Inventory.sprite = newVeggie.Image;
  43. }
  44. public void dropItem()
  45. {
  46. localPlayer.heldVeggie = null;
  47. Inventory.gameObject.SetActive(false);
  48. }
  49. }
  50. [Serializable]
  51. public class Vegetable
  52. {
  53. public string Name;
  54. public Sprite Image;
  55. }
  56. [Serializable]
  57. public class Frame
  58. {
  59. public Image VegetableSpot;
  60. public TextMeshProUGUI Qty;
  61. }