新增game hud字体
移除旧版血量控制
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using GameFramework;
|
||||
namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
// Handles health, damage, and death for entities
|
||||
@@ -27,15 +27,13 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
health -= damageAmount;
|
||||
|
||||
// Update UI if player
|
||||
if (isPlayer)
|
||||
HealthUI.Instance.UpdateHealthBar(maxHealth, health);
|
||||
|
||||
// If dead, reload scene if player, then die
|
||||
// If dead, trigger game over if player, then die
|
||||
if (health <= 0)
|
||||
{
|
||||
if (isPlayer)
|
||||
HealthUI.Instance.ReloadScene();
|
||||
{
|
||||
GameManager.GameOver();
|
||||
}
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
namespace IndianOceanAssets.Engine2_5D
|
||||
{
|
||||
// Handles updating and displaying the health UI
|
||||
public class HealthUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image healthFill; // UI image for health bar
|
||||
public static HealthUI Instance; // Singleton instance
|
||||
|
||||
// Assigns singleton instance
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
// Updates the health bar fill based on health values
|
||||
public void UpdateHealthBar(float maxHealth, float currentHealth)
|
||||
{
|
||||
healthFill.fillAmount = currentHealth / maxHealth;
|
||||
}
|
||||
|
||||
// Starts coroutine to reload scene
|
||||
public void ReloadScene()
|
||||
{
|
||||
StartCoroutine(_ReloadScene());
|
||||
}
|
||||
|
||||
// Waits and reloads current scene
|
||||
IEnumerator _ReloadScene()
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c8e10d31f74f214b9b18e7e378bbb30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: CnxJ5iylV3zv99KBJEv550fI5Zzg96V7taHDgiWC6pYJpWCFNb0483k=
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,136 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:yousandi.cn,2023:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
|
||||
m_Name: No.392-ShangShouNiShangTi-2 SDF
|
||||
m_EditorClassIdentifier:
|
||||
hashCode: 0
|
||||
material: {fileID: 0}
|
||||
materialHashCode: -2006316128
|
||||
m_Version: 1.1.0
|
||||
m_SourceFontFileGUID: d6774adf53d683d4dbe300c7d646853f
|
||||
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: d6774adf53d683d4dbe300c7d646853f, type: 3}
|
||||
m_SourceFontFile: {fileID: 12800000, guid: d6774adf53d683d4dbe300c7d646853f, type: 3}
|
||||
m_AtlasPopulationMode: 1
|
||||
m_FaceInfo:
|
||||
m_FaceIndex: 0
|
||||
m_FamilyName: 392-SS Ni Chang Ti
|
||||
m_StyleName: Regular
|
||||
m_PointSize: 90
|
||||
m_Scale: 1
|
||||
m_UnitsPerEM: 2048
|
||||
m_LineHeight: 107.53418
|
||||
m_AscentLine: 80.771484
|
||||
m_CapLine: 57
|
||||
m_MeanLine: 38
|
||||
m_Baseline: 0
|
||||
m_DescentLine: -26.762695
|
||||
m_SuperscriptOffset: 80.771484
|
||||
m_SuperscriptSize: 0.5
|
||||
m_SubscriptOffset: -26.762695
|
||||
m_SubscriptSize: 0.5
|
||||
m_UnderlineOffset: -15.732422
|
||||
m_UnderlineThickness: 4.482422
|
||||
m_StrikethroughOffset: 15.2
|
||||
m_StrikethroughThickness: 4.482422
|
||||
m_TabWidth: 45
|
||||
m_GlyphTable: []
|
||||
m_CharacterTable: []
|
||||
m_AtlasTextures:
|
||||
- {fileID: 0}
|
||||
m_AtlasTextureIndex: 0
|
||||
m_IsMultiAtlasTexturesEnabled: 1
|
||||
m_ClearDynamicDataOnBuild: 0
|
||||
m_UsedGlyphRects: []
|
||||
m_FreeGlyphRects:
|
||||
- m_X: 0
|
||||
m_Y: 0
|
||||
m_Width: 1023
|
||||
m_Height: 1023
|
||||
m_fontInfo:
|
||||
Name:
|
||||
PointSize: 0
|
||||
Scale: 0
|
||||
CharacterCount: 0
|
||||
LineHeight: 0
|
||||
Baseline: 0
|
||||
Ascender: 0
|
||||
CapHeight: 0
|
||||
Descender: 0
|
||||
CenterLine: 0
|
||||
SuperscriptOffset: 0
|
||||
SubscriptOffset: 0
|
||||
SubSize: 0
|
||||
Underline: 0
|
||||
UnderlineThickness: 0
|
||||
strikethrough: 0
|
||||
strikethroughThickness: 0
|
||||
TabWidth: 0
|
||||
Padding: 0
|
||||
AtlasWidth: 0
|
||||
AtlasHeight: 0
|
||||
atlas: {fileID: 0}
|
||||
m_AtlasWidth: 1024
|
||||
m_AtlasHeight: 1024
|
||||
m_AtlasPadding: 9
|
||||
m_AtlasRenderMode: 4165
|
||||
m_glyphInfoList: []
|
||||
m_KerningTable:
|
||||
kerningPairs: []
|
||||
m_FontFeatureTable:
|
||||
m_GlyphPairAdjustmentRecords: []
|
||||
fallbackFontAssets: []
|
||||
m_FallbackFontAssetTable: []
|
||||
m_CreationSettings:
|
||||
sourceFontFileName:
|
||||
sourceFontFileGUID:
|
||||
pointSizeSamplingMode: 0
|
||||
pointSize: 0
|
||||
padding: 0
|
||||
packingMode: 0
|
||||
atlasWidth: 0
|
||||
atlasHeight: 0
|
||||
characterSetSelectionMode: 0
|
||||
characterSequence:
|
||||
referencedFontAssetGUID:
|
||||
referencedTextAssetGUID:
|
||||
fontStyle: 0
|
||||
fontStyleModifier: 0
|
||||
renderMode: 0
|
||||
includeFontFeatures: 0
|
||||
m_FontWeightTable:
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
- regularTypeface: {fileID: 0}
|
||||
italicTypeface: {fileID: 0}
|
||||
fontWeights: []
|
||||
normalStyle: 0
|
||||
normalSpacingOffset: 0
|
||||
boldStyle: 0.75
|
||||
boldSpacing: 7
|
||||
italicStyle: 35
|
||||
tabSize: 10
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: XngZvXj/AHrmJuU1ZWY1y7W24SVA6Sc/x5zaFZUfXGwOzMVUJqeCqDc=
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
fileFormatVersion: 2
|
||||
guid: W3wYsi78By11HsA4FghHGcCpc+TLM2TzvhG28FPH9xgzypLQUBJBiP0=
|
||||
TrueTypeFontImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 4
|
||||
fontSize: 16
|
||||
forceTextureCase: -2
|
||||
characterSpacing: 0
|
||||
characterPadding: 1
|
||||
includeFontData: 1
|
||||
fontNames:
|
||||
- 392-SS Ni Chang Ti
|
||||
fallbackFontReferences: []
|
||||
customCharacters:
|
||||
fontRenderingMode: 0
|
||||
ascentCalculationMode: 1
|
||||
useLegacyBoundsCalculation: 0
|
||||
shouldRoundAdvanceValue: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
@@ -1,18 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Billboard 脚本 —— 让 Sprite 始终面朝相机,消除透视相机角度导致的 Sprite 变形。
|
||||
/// 挂到怪物/角色根物体上即可。
|
||||
/// </summary>
|
||||
public class facingcamera : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
private Camera _cam;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_cam = Camera.main;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
private void LateUpdate()
|
||||
{
|
||||
|
||||
if (_cam == null) return;
|
||||
// 让物体的 forward (Z+) 指向相机,Sprite 平面自然朝向相机
|
||||
transform.LookAt(
|
||||
transform.position + (_cam.transform.position - transform.position),
|
||||
Vector3.up
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
private float _attackTimer; // 攻击冷却计时器
|
||||
private Animator _animator; // 敌人动画
|
||||
private HealthSystem _playerHealth; // 玩家血量引用
|
||||
private Camera _mainCam; // 主相机引用(用于Billboard)
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -118,6 +119,7 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
}
|
||||
|
||||
_animator = GetComponent<Animator>();
|
||||
_mainCam = Camera.main;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -130,6 +132,18 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
EchoSystem.OnEchoReleased -= OnBell;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
// Billboard:让 Sprite 始终面朝相机,消除透视畸变
|
||||
if (_mainCam != null)
|
||||
{
|
||||
transform.LookAt(
|
||||
transform.position + (_mainCam.transform.position - transform.position),
|
||||
Vector3.up
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
switch (_state)
|
||||
@@ -225,13 +239,27 @@ namespace IndianOceanAssets.Engine2_5D
|
||||
// ===== ChasingBell:追击铃铛 =====
|
||||
private void UpdateChasingBell()
|
||||
{
|
||||
// 更新攻击冷却
|
||||
_attackTimer -= Time.deltaTime;
|
||||
|
||||
// 追击过程中检测是否看到玩家
|
||||
if (CanSeePlayer())
|
||||
if (playerTarget != null && CanSeePlayer())
|
||||
{
|
||||
float distToPlayer = XZDistance(transform.position, playerTarget.position);
|
||||
|
||||
// 进入攻击范围 → 近战攻击
|
||||
if (distToPlayer <= attackRange)
|
||||
{
|
||||
TryAttack();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 看到玩家但不在攻击范围,切换到追击玩家
|
||||
_state = State.ChasingPlayer;
|
||||
_loseSightTimer = 0f;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 追击计时
|
||||
_bellChaseTimer += Time.deltaTime;
|
||||
|
||||
Reference in New Issue
Block a user