fix:调整音效,武器添加武器UI,添加武器装弹功能

This commit is contained in:
bzx
2025-11-08 18:32:31 +08:00
parent 5bba6beffc
commit fdeaac6867
117 changed files with 162430 additions and 4242 deletions

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class GunUI : MonoBehaviour
{
public Launcher launcher;
public TMP_Text gunAmount;
private void Update()
{
if(launcher==null)
return;
if (launcher.bullet_amount <= 0)
{
gunAmount.text = "充能中...";
}
if (launcher.userTime > 0)
{
gunAmount.text = launcher.userTime.ToString();
}
if (launcher.bullet_amount > 0)
{
gunAmount.text= launcher.bullet_amount.ToString();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b6e58d2ef9ad2404c97d858acafa8f04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,102 @@
using System.Collections;
using System.Collections.Generic;
using Common;
using DG.Tweening;
using DragonLi.Core;
using Mirror;
using UnityEngine;
public class PlayerUI : NetworkBehaviour
{
public SpriteRenderer[] bg;
public SpriteRenderer[] blood1;
public SpriteRenderer[] blood2;
public Sprite[] bgs;
public Sprite[] blood1s;
public State UIState;
private Enemy _enemy;
private float _lastHp = 0.0f;
private Tweener _lastTween = null;
[Server]
public void Init(Enemy enemy)
{
_enemy = enemy;
HPstyleChange((int)enemy.type);
// 0.2秒后展示ui防止在原点出现
CoroutineTaskManager.Instance.WaitSecondTodo(() =>
{
if (_enemy.type == EnemyType.DragonBoss)
{
UIStateChange(2);
}
else
{
UIStateChange(1);
}
}, 0.2f);
}
public void Update()
{
if (isClient)
{
Vector3 directionToCamera = GameLocal.Ins.MRCamera.transform.position - transform.position;
directionToCamera.y = 0;
// 计算新的旋转方向固定Y轴方向
Quaternion targetRotation = Quaternion.LookRotation(directionToCamera, Vector3.up);
// 应用新的旋转方向
transform.rotation = targetRotation;
}
if (isServer && _enemy != null)
{
transform.position = new Vector3(_enemy.transform.position.x, _enemy.height, _enemy.transform.position.z);
if (UIState.nowState == 1 || UIState.nowState == 2)
{
if (_enemy.health != _lastHp)
{
HpChange(_enemy.type, _enemy.health, _enemy.originHealth);
}
}
}
}
[ClientRpc]
public void HPstyleChange(int type)
{
bg[0].sprite = bgs[type];
blood1[0].sprite = blood1s[type];
blood2[0].sprite = blood1s[type];
UIState.StateChange(0);
}
[ClientRpc]
public void UIStateChange(int state)
{
UIState.StateChange(state);
}
[ClientRpc]
public void HpChange(EnemyType type, float currentBlood, float totalBlood)
{
float allLength = type == EnemyType.DragonBoss ? 3f : 1.58f;
float lastValue = _lastHp / totalBlood;
float value = currentBlood / totalBlood;
blood2[0].size = new Vector2(value * allLength, 0.14f);
blood2[1].size = new Vector2(value * allLength, 0.14f);
_lastHp = currentBlood;
if (_lastTween != null)
{
_lastTween.Kill();
}
_lastTween = DOVirtual.Float(lastValue, value, 0.5f, res =>
{
blood1[0].size = new Vector2(res * allLength, 0.14f);
blood1[1].size = new Vector2(res * allLength, 0.14f);
});
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 77c2ad26b5db5df47a16be7c70733fa4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: