40 lines
822 B
C#
40 lines
822 B
C#
|
|
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();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|