I was programing to create a game same like the tutorial here
this is my entire code do you see something weird or wrong?
please help me
(154,1): error CS1022: Type or namespace definition, or end-of-file expected
(153,5): error CS1022: Type or namespace definition, or end-of-file expected
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CraftingSystem : MonoBehaviour
{
public GameObject craftingScreenUI;
public GameObject toolsScreenUI;
public List<string> inventoryItemList = new List<string>();
//Category buttons
Button toolsBTN;
//Craft buttons
Button craftAxeBTN;
//Requairement Text
Text AxeReq1, AxeReq2;
public bool isOpen;
//All Blueprints
public Blueprint AxeBLP = new Blueprint("Axe", 2, "Stone", 3, "Stick", 3);
public static CraftingSystem Instance { get; set; }
private void Awake()
{
if(Instance != null && Instance != this)
{
Destroy(gameObject);
}
else
{
Instance = this;
}
}
// Start is called before the first frame update
void Start()
{
isOpen = false;
toolsBTN = craftingScreenUI.transform.Find("ToolsButton").GetComponent<Button>();
toolsBTN.onClick.AddListener(delegate { OpenToolsCategory(); });
//Axe
AxeReq1 = toolsScreenUI.transform.Find("Axe").transform.Find("Req1").GetComponent<Text>();
AxeReq2 = toolsScreenUI.transform.Find("Axe").transform.Find("Req2").GetComponent<Text>();
craftAxeBTN = toolsScreenUI.transform.Find("Axe").transform.Find("Button").GetComponent<Button>();
craftAxeBTN.onClick.AddListener(delegate { CraftAnyItem(AxeBLP); });
}
void OpenToolsCategory()
{
craftingScreenUI.SetActive(false);
toolsScreenUI.SetActive(true);
}
void CraftAnyItem(Blueprint blueprintToCraft)
{
//Add item into inventory
InventorySystem.Instance.AddToInventory(blueprintToCraft.itemName);
//Remove resources from inventory
if(blueprintToCraft.numOfReqirements >= 1)
{
InventorySystem.Instance.RemoveItem(blueprintToCraft.Req1, blueprintToCraft.Req1Amount);
}
if(blueprintToCraft.numOfReqirements >= 2)
{
InventorySystem.Instance.RemoveItem(blueprintToCraft.Req2, blueprintToCraft.Req2Amount);
}
//Refresh List
InventorySystem.Instance.ReCalculateList();
RefreshNeededItems();
}
// Update is called once per frame
void Update()
{
RefreshNeededItems();
if (Input.GetKeyDown(KeyCode.C) && !isOpen)
{
Debug.Log("C is pressed");
craftingScreenUI.SetActive(true);
isOpen = true;
Cursor.lockState = CursorLockMode.None;
}
else if (Input.GetKeyDown(KeyCode.C) && isOpen)
{
craftingScreenUI.SetActive(false);
toolsScreenUI.SetActive(false);
isOpen = false;
if(!InventorySystem.Instance.isOpen)
{
Cursor.lockState = CursorLockMode.Locked;
}
//Cursor.lockState = CursorLockMode.Locked;
}
}
private void RefreshNeededItems();
{
int stone_count = 0;
int stick_count = 0;
inventoryItemList = InventorySystem.Instance.itemList;
foreach(string itemName in inventoryItemList)
{
switch(itemName)
{
case "Stone":
stone_count += 1;
break;
case "Stick":
stick_count += 1;
break;
}
}
//---- AXE ----//
AxeReq1.text = "3 Stones [" + stone_count + "]";
AxeReq2.text = "3 Sticks [" + stick_count + "]";
if(stone_count >= 3 && stick_count >= 3)
{
craftAxeBTN.gameObject.SetActive(true);
}
else
{
craftAxeBTN.gameObject.SetActive(false);
}
}
}
thank you