mirror of
http://47.107.252.169:3000/Roguelite-Game-Developing-Team/Gen_Hack-and-Slash-Roguelite.git
synced 2025-11-20 04:47:13 +08:00
(client) feat:支持定义实体的碰撞体大小和偏移;建筑支持定义实体建筑和瓦片建筑,建筑支持指定按钮回调;添加存档管理器;Dev支持设置是否暂停;实体允许定义事件组;添加基地界面 (#57)
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/57
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
using System;
|
||||
using Base;
|
||||
using Data;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Entity
|
||||
@@ -5,16 +9,55 @@ namespace Entity
|
||||
public class BuildingOutline : Outline
|
||||
{
|
||||
public BoxCollider2D boxCollider;
|
||||
public CircleCollider2D trigger;
|
||||
|
||||
public TMP_Text tip;
|
||||
public bool PlayerOnGround { get; private set; }
|
||||
|
||||
override public void Init()
|
||||
{
|
||||
var size = GetSize();
|
||||
outlineRenderer.size = size;
|
||||
boxCollider.size = size;
|
||||
var textureSize = GetBodyTextureSize();
|
||||
outlineRenderer.size = textureSize;
|
||||
var colliderSize = GetColliderSize();
|
||||
boxCollider.size = colliderSize;
|
||||
boxCollider.offset = GetOffset();
|
||||
if (progressBarPrefab)
|
||||
{
|
||||
progressBarPrefab.transform.localPosition += new Vector3(0f, size.y * 2 / 3, 0f);
|
||||
progressBarPrefab.transform.localScale = new Vector3(size.x, 1f / 10f, 1);
|
||||
progressBarPrefab.transform.localPosition += new Vector3(0f, textureSize.y * 2 / 3, 0f);
|
||||
progressBarPrefab.transform.localScale = new Vector3(textureSize.x, 1f / 10f, 1);
|
||||
}
|
||||
|
||||
if (entity.entityDef is not BuildingDef buildingDef || buildingDef.triggerEvents == null)
|
||||
{
|
||||
trigger.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
trigger.radius = buildingDef.detectionRadius;
|
||||
if (!string.IsNullOrEmpty(buildingDef.triggerPosition))
|
||||
{
|
||||
var position = Utils.StringUtils.StringToVector2(buildingDef.triggerPosition);
|
||||
trigger.offset = position;
|
||||
}
|
||||
|
||||
tip.transform.localPosition += new Vector3(0f, textureSize.y * 2 / 3, 0f);
|
||||
tip.text = $"按{buildingDef.activateKey}打开{buildingDef.label}\n{buildingDef.description}";
|
||||
tip.gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.gameObject.CompareTag("Player"))
|
||||
{
|
||||
tip.gameObject.SetActive(true);
|
||||
PlayerOnGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
tip.gameObject.SetActive(false);
|
||||
PlayerOnGround = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user