PlayerController.cs select Item
This commit is contained in:
parent
d84a815d74
commit
3466d25dbb
1 changed files with 9 additions and 5 deletions
|
|
@ -1,9 +1,10 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class PlayerController : MonoBehaviour {
|
public class PlayerController : MonoBehaviour {
|
||||||
private List<Item> inventory;
|
private Dictionary<Item, int> inventory;
|
||||||
private int money;
|
private int money;
|
||||||
private UsableItem selectedItem;
|
private UsableItem selectedItem;
|
||||||
|
|
||||||
|
|
@ -19,7 +20,7 @@ public class PlayerController : MonoBehaviour {
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
inventory ??= new List<Item>();
|
inventory ??= new Dictionary<Item, int>();
|
||||||
money = startMoney;
|
money = startMoney;
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
@ -31,8 +32,11 @@ public class PlayerController : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSelectedItem(UsableItem item) {
|
public void setSelectedItem(UsableItem item) {
|
||||||
|
if (inventory.ContainsKey(item)) {
|
||||||
selectedItem = item;
|
selectedItem = item;
|
||||||
|
Cursor.SetCursor(item.defaultSprite.texture, Vector2.zero, CursorMode.Auto);
|
||||||
|
} else {
|
||||||
|
Debug.Log("An item requested to select isn't in the inventory" + item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue