UIBattleSuccess/UIBattleFailed: 弹幕支持

This commit is contained in:
fatiao 2025-10-18 12:01:01 +08:00
parent c1fc684fed
commit 7efb9905d8
3 changed files with 6 additions and 12 deletions

View File

@ -394,7 +394,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
_speed: 2
_danmuSpacing: 150
_danmuSpacing: 100
_trackSpacing: 30
_wordWidth: 40
--- !u!1 &7849903800921837072

View File

@ -35,6 +35,7 @@ function UIBattleFailedView:Init()
"AAAAAAAAAAA111", "VVVVVVVVVV222", "DDDDDDDDDDD333", "FFFFFFFFF444", "EEEEEEEEE555",
"AAAAAAAAAAA111", "VVVVVVVVVV222", "DDDDDDDDDDD333", "FFFFFFFFF444", "EEEEEEEEE555",
}
self.danmuPlayerComp:ResetPlayer()
self.danmuPlayerComp:Play(
danmuList, 10,
function()
@ -217,15 +218,7 @@ function UIBattleFailedView:OpenGoPage(parentPageId,pageID,params)
end
function UIBattleFailedView:GetTipsGo(idx)
if idx == 1 then
return self.tips1
elseif idx == 2 then
return self.tips2
elseif idx == 3 then
return self.tips3
end
return nil
return self["gotoIncreaseItem1"..idx]
end
return UIBattleFailedView

View File

@ -14,7 +14,7 @@ public class DanmuItemData
public class MyDanmuPlayer : MonoBehaviour
{
[SerializeField] private float _speed = 2.0f;
[SerializeField] private float _danmuSpacing = 150.0f;
[SerializeField] private float _danmuSpacing = 100.0f;
[SerializeField] private float _trackSpacing = 30.0f;
[SerializeField] private float _wordWidth = 40.0f;
@ -167,9 +167,10 @@ public class MyDanmuPlayer : MonoBehaviour
var screenHeight = _danmuScreen.GetComponent<RectTransform>().rect.height;
var screenRectTransform = _danmuScreen.GetComponent<RectTransform>();
int trackCount = (int)(screenHeight/(danmuHeight+_trackSpacing));
int offset = (int)screenHeight % (int)(danmuHeight+_trackSpacing);
for (int i = trackCount-1; i >= 0; i--)
{
var danmuPosY = danmuHeight/2 + i * (danmuHeight + _trackSpacing) - screenRectTransform.rect.height/2;
var danmuPosY = -offset/2 + (i+1) * (danmuHeight + _trackSpacing) - screenRectTransform.rect.height/2;
var startPos = new Vector2(screenRectTransform.rect.width, danmuPosY);
var endPos = new Vector2(0, danmuPosY);
Debug.Log("[MyDanmuPlayer] Start Track " + startPos.ToString());