mirror of
https://github.com/zoriya/Magical-Garden.git
synced 2025-12-05 23:06:17 +00:00
R button now revert to the initial item number and random trees.
This commit is contained in:
@@ -23,6 +23,9 @@ public class InventoryManager : MonoBehaviour
|
||||
private Vector3 defaultPos;
|
||||
private Vector2Int selectorPos;
|
||||
|
||||
private Dictionary<int, TreeType> preSpawnedTree = new Dictionary<int, TreeType>();
|
||||
private int[] savedItems = new int[15];
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -63,6 +66,8 @@ public class InventoryManager : MonoBehaviour
|
||||
if (Input.GetKeyDown(KeyCode.R))
|
||||
{
|
||||
ClearBoard();
|
||||
PlacePreSpawnedTrees();
|
||||
GiveItemsBack();
|
||||
GetComponent<Mission>().WinUI.SetActive(false);
|
||||
GetComponent<Pokedex>().UpdateMissionText();
|
||||
turnCount.text = "Turn: 01";
|
||||
@@ -131,7 +136,6 @@ public class InventoryManager : MonoBehaviour
|
||||
|
||||
private void PlaceTree(TreeItem item, int index)
|
||||
{
|
||||
print("Index: " + index);
|
||||
Vector2Int plotPos = GetPlotPositionByIndex(index);
|
||||
plots[index].treePlaced = item.type;
|
||||
|
||||
@@ -162,12 +166,23 @@ public class InventoryManager : MonoBehaviour
|
||||
}
|
||||
|
||||
if (index != plots.Length)
|
||||
{
|
||||
PlaceTree(tree, index);
|
||||
preSpawnedTree.Add(index, tree.type);
|
||||
}
|
||||
else
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
private void PlacePreSpawnedTrees()
|
||||
{
|
||||
foreach (KeyValuePair<int, TreeType> item in preSpawnedTree)
|
||||
{
|
||||
PlaceTree(items[(int)item.Value - 1], item.Key);
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteTreeAt(int index)
|
||||
{
|
||||
Vector2Int plotPos = GetPlotPositionByIndex(index);
|
||||
@@ -519,6 +534,23 @@ public class InventoryManager : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SaveUserItems()
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
savedItems[i] = items[i].count;
|
||||
}
|
||||
}
|
||||
|
||||
private void GiveItemsBack()
|
||||
{
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
items[i].count = savedItems[i];
|
||||
}
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
public void ClearBoard()
|
||||
{
|
||||
for (int i = 0; i < 25; i++)
|
||||
|
||||
@@ -88,6 +88,7 @@ public class Mission : MonoBehaviour {
|
||||
}
|
||||
}
|
||||
manager.UpdateUI();
|
||||
manager.SaveUserItems();
|
||||
}
|
||||
|
||||
public string GetMissionText()
|
||||
|
||||
Reference in New Issue
Block a user