Added project
This commit is contained in:
28
Platformer/Assets/Scripts/PlayerInventory.cs
Normal file
28
Platformer/Assets/Scripts/PlayerInventory.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerInventory : MonoBehaviour {
|
||||
|
||||
public int CoinsCount { get; set; }
|
||||
public BuffReceiver BuffReceiver;
|
||||
|
||||
public List<Item> Items { get; private set; }
|
||||
|
||||
private void Start() {
|
||||
GameManager.Instance.inventory = this;
|
||||
Items = new List<Item>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other) {
|
||||
if (GameManager.Instance.coinContainer.ContainsKey(other.gameObject)) {
|
||||
var coin = GameManager.Instance.coinContainer[other.gameObject];
|
||||
coin.StartDestroy();
|
||||
}
|
||||
if (GameManager.Instance.itemsContainer.ContainsKey(other.gameObject)) {
|
||||
var itemComponent = GameManager.Instance.itemsContainer[other.gameObject];
|
||||
Items.Add(itemComponent.Item);
|
||||
itemComponent.Destroy(other.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user