Added project
This commit is contained in:
39
Platformer/Assets/Scripts/Cell.cs
Normal file
39
Platformer/Assets/Scripts/Cell.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
public class Cell : MonoBehaviour {
|
||||
|
||||
public Action OnUpdateCell;
|
||||
|
||||
[SerializeField] private Image icon;
|
||||
private Item item;
|
||||
|
||||
private void Awake() {
|
||||
icon.sprite = null;
|
||||
}
|
||||
|
||||
public void Init(Item item) {
|
||||
this.item = item;
|
||||
if (item == null) {
|
||||
icon.sprite = null;
|
||||
}
|
||||
else {
|
||||
icon.sprite = item.Icon;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickCell() {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
GameManager.Instance.inventory.Items.Remove(item);
|
||||
var buff = new Buff {
|
||||
type = item.Type,
|
||||
additiveBonus = item.Value
|
||||
};
|
||||
GameManager.Instance.inventory.BuffReceiver.AddBuff(buff);
|
||||
OnUpdateCell?.Invoke();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user