mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 05:37:11 +08:00
(client) feat:健康给予,路径优化,结算界面,商店界面 (#60)
Co-authored-by: m0_75251201 <m0_75251201@noreply.gitcode.com> Reviewed-on: http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite/pulls/60
This commit is contained in:
41
Client/Assets/Scripts/UI/ShopCardUIBuff.cs
Normal file
41
Client/Assets/Scripts/UI/ShopCardUIBuff.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user