mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 00:57:14 +08:00
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
|
|
using System.Linq;
|
||
|
|
using Data;
|
||
|
|
using Entity;
|
||
|
|
using Managers;
|
||
|
|
using UnityEngine;
|
||
|
|
using Random = UnityEngine.Random;
|
||
|
|
|
||
|
|
namespace UI
|
||
|
|
{
|
||
|
|
public class ShopCardUIBuff : ShopCardUI
|
||
|
|
{
|
||
|
|
private HediffDef hediffDef;
|
||
|
|
|
||
|
|
public override void Init()
|
||
|
|
{
|
||
|
|
var hediffList = DefineManager.Instance.QueryDefinesByType<HediffDef>();
|
||
|
|
if (!hediffList.Any())
|
||
|
|
return;
|
||
|
|
var index = Random.Range(0, hediffList.Length);
|
||
|
|
Init(hediffList[index]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public void Init(HediffDef def)
|
||
|
|
{
|
||
|
|
if (def.textures is { Length: > 0 })
|
||
|
|
icon.sprite = PackagesImageManager.Instance.GetSprite(def.textures[0]);
|
||
|
|
SetLabel(def.label);
|
||
|
|
description.text = def.description;
|
||
|
|
hediffDef = def;
|
||
|
|
}
|
||
|
|
|
||
|
|
public override void OnEnter()
|
||
|
|
{
|
||
|
|
base.OnEnter();
|
||
|
|
if (Program.Instance.FocusedEntity is LivingEntity livingEntity)
|
||
|
|
{
|
||
|
|
livingEntity.AddHediff(new Hediff(hediffDef));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|