From 76b293398e05b95a48598d77c0d687aa2b86d393 Mon Sep 17 00:00:00 2001 From: fu-majime Date: Sun, 24 Mar 2024 14:41:56 +0900 Subject: [PATCH] Change Block --- Assets/Resources/Games/builtToScaleRvl.prefab | 68 ++++++++++++- .../Games/BuiltToScaleRvl/whiteblock.prefab | 16 +++ Assets/Scripts/Games/BuiltToScaleRvl/Block.cs | 99 +++++++++++++++++++ .../Games/BuiltToScaleRvl/Block.cs.meta | 11 +++ .../Games/BuiltToScaleRvl/BuiltToScaleRvl.cs | 60 +++-------- Assets/Scripts/Games/BuiltToScaleRvl/Rod.cs | 17 ++-- 6 files changed, 212 insertions(+), 59 deletions(-) create mode 100644 Assets/Scripts/Games/BuiltToScaleRvl/Block.cs create mode 100644 Assets/Scripts/Games/BuiltToScaleRvl/Block.cs.meta diff --git a/Assets/Resources/Games/builtToScaleRvl.prefab b/Assets/Resources/Games/builtToScaleRvl.prefab index b68254874..4f086ffcb 100644 --- a/Assets/Resources/Games/builtToScaleRvl.prefab +++ b/Assets/Resources/Games/builtToScaleRvl.prefab @@ -171,6 +171,11 @@ MonoBehaviour: m_EditorClassIdentifier: SoundSequences: [] scheduledInputs: [] + blocks: + - {fileID: 5696860149884327676} + - {fileID: 224928381323362584} + - {fileID: 6254207078265654522} + - {fileID: 5821551822996478014} blockAnims: - {fileID: 1844026232355082904} - {fileID: 6162902461251519868} @@ -181,7 +186,6 @@ MonoBehaviour: baseRightSquare: {fileID: 6631181169301220531} baseAssembled: {fileID: 3641708035931060140} widgetHolder: {fileID: 4637116116151750227} - spawnedRods: [] curve: - {fileID: 5374345566761818774} - {fileID: 1936227407808079596} @@ -210,8 +214,6 @@ MonoBehaviour: - {fileID: 663361784237137429} - {fileID: 2107336164975858084} - {fileID: 5864016952948325823} - isPlayerOpen: 0 - isPlayerPrepare: 0 --- !u!1 &2979763165916823418 GameObject: m_ObjectHideFlags: 0 @@ -1227,7 +1229,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &6137499710566233010 Transform: m_ObjectHideFlags: 0 @@ -1689,7 +1691,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!4 &7566142852410955114 Transform: m_ObjectHideFlags: 0 @@ -2532,6 +2534,10 @@ PrefabInstance: propertyPath: m_Name value: whiteblock (2) objectReference: {fileID: 0} + - target: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + propertyPath: position + value: 1 + objectReference: {fileID: 0} - target: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} propertyPath: m_RootOrder value: 1 @@ -2578,6 +2584,17 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} +--- !u!114 &224928381323362584 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + m_PrefabInstance: {fileID: 1160394556917220591} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af1ad68da0d45f4459bc6f243a8749c0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &2477724359068826475 stripped Transform: m_CorrespondingSourceObject: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} @@ -2984,6 +3001,10 @@ PrefabInstance: propertyPath: m_Name value: whiteblock (4) objectReference: {fileID: 0} + - target: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + propertyPath: position + value: 3 + objectReference: {fileID: 0} - target: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} propertyPath: m_RootOrder value: 2 @@ -3035,6 +3056,17 @@ Animator: m_CorrespondingSourceObject: {fileID: 5016319015922827667, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} m_PrefabInstance: {fileID: 4886362793593036233} m_PrefabAsset: {fileID: 0} +--- !u!114 &5821551822996478014 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + m_PrefabInstance: {fileID: 4886362793593036233} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af1ad68da0d45f4459bc6f243a8749c0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &8194282533764227661 stripped Transform: m_CorrespondingSourceObject: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} @@ -3059,6 +3091,10 @@ PrefabInstance: propertyPath: m_Sprite value: objectReference: {fileID: 1261120505, guid: 8c8670c5276d2c746be1ae29cba493ef, type: 3} + - target: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + propertyPath: position + value: 2 + objectReference: {fileID: 0} - target: {fileID: 2393234158427641566, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} propertyPath: m_Sprite value: @@ -3154,6 +3190,17 @@ Animator: m_CorrespondingSourceObject: {fileID: 5016319015922827667, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} m_PrefabInstance: {fileID: 5030238947133212941} m_PrefabAsset: {fileID: 0} +--- !u!114 &6254207078265654522 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + m_PrefabInstance: {fileID: 5030238947133212941} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af1ad68da0d45f4459bc6f243a8749c0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &8626317659644753545 stripped Transform: m_CorrespondingSourceObject: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} @@ -3590,6 +3637,17 @@ Animator: m_CorrespondingSourceObject: {fileID: 5016319015922827667, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} m_PrefabInstance: {fileID: 6632332787516494603} m_PrefabAsset: {fileID: 0} +--- !u!114 &5696860149884327676 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1370668342187640311, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} + m_PrefabInstance: {fileID: 6632332787516494603} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af1ad68da0d45f4459bc6f243a8749c0, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!4 &7958685283159960719 stripped Transform: m_CorrespondingSourceObject: {fileID: 3636702461004627844, guid: 7f6c0a32ae05cc9499e4e8fe2c729bbb, type: 3} diff --git a/Assets/Resources/Prefabs/Games/BuiltToScaleRvl/whiteblock.prefab b/Assets/Resources/Prefabs/Games/BuiltToScaleRvl/whiteblock.prefab index 55a2ee354..2831be4a5 100644 --- a/Assets/Resources/Prefabs/Games/BuiltToScaleRvl/whiteblock.prefab +++ b/Assets/Resources/Prefabs/Games/BuiltToScaleRvl/whiteblock.prefab @@ -262,6 +262,7 @@ GameObject: m_Component: - component: {fileID: 3636702461004627844} - component: {fileID: 5016319015922827667} + - component: {fileID: 1370668342187640311} m_Layer: 0 m_Name: whiteblock m_TagString: Untagged @@ -308,6 +309,21 @@ Animator: m_AllowConstantClipSamplingOptimization: 1 m_KeepAnimatorStateOnDisable: 0 m_WriteDefaultValuesOnDisable: 0 +--- !u!114 &1370668342187640311 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 876647762485842733} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: af1ad68da0d45f4459bc6f243a8749c0, type: 3} + m_Name: + m_EditorClassIdentifier: + position: 0 + isOpen: 0 + isPrepare: 0 --- !u!1 &1305944185207812440 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs b/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs new file mode 100644 index 000000000..48e9e7397 --- /dev/null +++ b/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs @@ -0,0 +1,99 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering; +using NaughtyBezierCurves; + +namespace HeavenStudio.Games.Scripts_BuiltToScaleRvl +{ + using HeavenStudio.Util; + public class Block : MonoBehaviour + { + public int position; + private Animator blockAnim; + + public bool isOpen = false; + public bool isPrepare = false; + private double closeBeat; + + private BuiltToScaleRvl game; + + private void Awake() + { + game = BuiltToScaleRvl.instance; + blockAnim = GetComponent(); + if (!BuiltToScaleRvl.IsPositionInRange(position)) position = 0; + } + + public void Bounce(double beat) + { + SoundByte.PlayOneShotGame(position switch { + 0 => "builtToScaleRvl/left", + 1 => "builtToScaleRvl/middleLeft", + 2 => "builtToScaleRvl/middleRight", + 3 => "builtToScaleRvl/right", + _ => throw new System.NotImplementedException() + }); + blockAnim.Play("bounce", 0, 0); + if (closeBeat < beat) closeBeat = beat; + } + public void BounceNearlyMiss() + { + blockAnim.Play("open", 0, 0); + } + public void BounceMiss() + { + blockAnim.Play("miss", 0, 0); + } + + public void Prepare() + { + SoundByte.PlayOneShotGame("builtToScaleRvl/playerRetract"); + if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { + blockAnim.Play("prepare B", 0, 0); + } else { + blockAnim.Play("prepare AB", 0, 0); + } + isOpen = false; + isPrepare = true; + } + public void Shoot() + { + SoundByte.PlayOneShotGame("builtToScaleRvl/shoot"); + blockAnim.Play("shoot", 0, 0); + isPrepare = false; + } + public void ShootNearlyMiss() + { + if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { + blockAnim.Play("shoot miss B", 0, 0); + } else { + blockAnim.Play("shoot miss AB", 0, 0); + } + isPrepare = false; + } + public void ShootMiss() + { + if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { + blockAnim.Play("shoot miss B", 0, 0); + } else { + blockAnim.Play("shoot miss AB", 0, 0); + } + isPrepare = false; + } + + public void Open() + { + blockAnim.Play("open", 0, 0); + isOpen = true; + } + public void Idle(double beat = double.MinValue) + { + Debug.Log($"Idle:{closeBeat}, {beat}"); + if (closeBeat > beat) return; + blockAnim.Play("idle", 0, 0); + isOpen = false; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs.meta b/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs.meta new file mode 100644 index 000000000..37e29e8a8 --- /dev/null +++ b/Assets/Scripts/Games/BuiltToScaleRvl/Block.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: af1ad68da0d45f4459bc6f243a8749c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Games/BuiltToScaleRvl/BuiltToScaleRvl.cs b/Assets/Scripts/Games/BuiltToScaleRvl/BuiltToScaleRvl.cs index 8ea7ae9e6..13a7e9f9b 100644 --- a/Assets/Scripts/Games/BuiltToScaleRvl/BuiltToScaleRvl.cs +++ b/Assets/Scripts/Games/BuiltToScaleRvl/BuiltToScaleRvl.cs @@ -75,7 +75,7 @@ namespace HeavenStudio.Games using Scripts_BuiltToScaleRvl; public class BuiltToScaleRvl : Minigame { - [SerializeField] Animator[] blockAnims; + [SerializeField] Block[] blocks; [SerializeField] GameObject baseRod; [SerializeField] GameObject baseLeftSquare; [SerializeField] GameObject baseRightSquare; @@ -126,7 +126,6 @@ namespace HeavenStudio.Games private double gameStartBeat = double.MinValue, gameEndBeat = double.MaxValue; List scheduledWidgets = new List(); int widgetIndex; - public List spawnedRods = new List(); public BezierCurve3D[] curve; public static readonly Dictionary<(int, int), int> curveMap = new Dictionary<(int, int), int> { @@ -243,8 +242,8 @@ namespace HeavenStudio.Games OnGameSwitch(beat); } - public bool isPlayerOpen = false; - public bool isPlayerPrepare = false; + public bool isPlayerOpen { get { return blocks[2].isOpen; } } + public bool isPlayerPrepare { get { return blocks[2].isPrepare; } } void Update() { @@ -287,10 +286,8 @@ namespace HeavenStudio.Games } public void SpawnRod(double beat, double length, int currentPos, int nextPos, int id, CustomBounceItem[] bounceItems, int endTime, bool isShoot) - { - // if (spawnedRods.Any(x => x.ID == id)) return; + { var newRod = Instantiate(baseRod, widgetHolder).GetComponent(); - spawnedRods.Add(newRod); newRod.startBeat = beat; newRod.lengthBeat = length; @@ -427,79 +424,52 @@ namespace HeavenStudio.Games return shootTime; } - public void PlayBlockBounce(int position) + public void PlayBlockBounce(int position, double beat) { if (!IsPositionInRange(position)) return; - SoundByte.PlayOneShotGame(position switch { - 0 => "builtToScaleRvl/left", - 1 => "builtToScaleRvl/middleLeft", - 2 => "builtToScaleRvl/middleRight", - 3 => "builtToScaleRvl/right", - _ => throw new System.NotImplementedException() - }); - blockAnims[position].Play("bounce", 0, 0); + blocks[position].Bounce(beat); } public void PlayBlockBounceNearlyMiss(int position) { if (!IsPositionInRange(position)) return; - blockAnims[position].Play("open", 0, 0); + blocks[position].BounceNearlyMiss(); } public void PlayBlockBounceMiss(int position) { if (!IsPositionInRange(position)) return; - blockAnims[position].Play("miss", 0, 0); + blocks[position].BounceMiss(); } public void PlayBlockPrepare(int position) { if (!IsPositionInRange(position)) return; - SoundByte.PlayOneShotGame("builtToScaleRvl/playerRetract"); - if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { - blockAnims[position].Play("prepare B", 0, 0); - } else { - blockAnims[position].Play("prepare AB", 0, 0); - } - isPlayerOpen = false; - isPlayerPrepare = true; + blocks[position].Prepare(); } public void PlayBlockShoot(int position) { if (!IsPositionInRange(position)) return; - SoundByte.PlayOneShotGame("builtToScaleRvl/shoot"); - blockAnims[position].Play("shoot", 0, 0); - isPlayerPrepare = false; + blocks[position].Shoot(); } public void PlayBlockShootNearlyMiss(int position) { if (!IsPositionInRange(position)) return; - if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { - blockAnims[position].Play("shoot miss B", 0, 0); - } else { - blockAnims[position].Play("shoot miss AB", 0, 0); - } - isPlayerPrepare = false; + blocks[position].ShootNearlyMiss(); } public void PlayBlockShootMiss(int position) { if (!IsPositionInRange(position)) return; - if (PlayerInput.CurrentControlStyle is InputSystem.InputController.ControlStyles.Pad) { - blockAnims[position].Play("shoot miss B", 0, 0); - } else { - blockAnims[position].Play("shoot miss AB", 0, 0); - } - isPlayerPrepare = false; + blocks[position].ShootMiss(); } public void PlayBlockOpen(int position) { if (!IsPositionInRange(position)) return; - blockAnims[position].Play("open", 0, 0); - isPlayerOpen = true; + blocks[position].Open(); } - public void PlayBlockIdle(int position) + public void PlayBlockIdle(int position, double beat = double.MinValue) { if (!IsPositionInRange(position)) return; - blockAnims[position].Play("idle", 0, 0); + blocks[position].Idle(beat); } public static int getFollowingPos(int currentPos, int nextPos, int nextTime, CustomBounceItem[] bounceItems) diff --git a/Assets/Scripts/Games/BuiltToScaleRvl/Rod.cs b/Assets/Scripts/Games/BuiltToScaleRvl/Rod.cs index 40be45d3e..bf4d580b7 100644 --- a/Assets/Scripts/Games/BuiltToScaleRvl/Rod.cs +++ b/Assets/Scripts/Games/BuiltToScaleRvl/Rod.cs @@ -62,7 +62,7 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleRvl if (BuiltToScaleRvl.IsPositionInRange(currentPos) && playBounce) { - actions.Add(new BeatAction.Action(beat, () => game.PlayBlockBounce(currentPos))); + actions.Add(new BeatAction.Action(beat, () => game.PlayBlockBounce(currentPos, beat + length))); } actions.Add(new BeatAction.Action(beat, delegate @@ -97,7 +97,7 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleRvl if (BuiltToScaleRvl.IsPositionInRange(currentPos)) { - actions.Add(new BeatAction.Action(beat + length, () => game.PlayBlockIdle(currentPos))); + actions.Add(new BeatAction.Action(beat + length, () => game.PlayBlockIdle(currentPos, beat + length))); } BeatAction.New(game, actions); @@ -132,20 +132,20 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleRvl return; } - game.PlayBlockBounce(this.nextPos); + game.PlayBlockBounce(this.nextPos, currentBeat + 2*lengthBeat); BounceRecursion(currentBeat + lengthBeat, lengthBeat, nextPos, followingPos, false); } private void BounceOnMiss(PlayerActionEvent caller) { + game.PlayBlockBounceMiss(this.nextPos); + BeatAction.New(this, new List() {new BeatAction.Action(currentBeat + 2*lengthBeat, delegate { + game.PlayBlockIdle(this.nextPos, currentBeat + 2*lengthBeat); + RemoveAndDestroy(); + })}); currentCurve = game.curve[^1]; // miss currentBeat = Conductor.instance.songPositionInBeats; rodAnim.SetFloat("speed", -1f); isMiss = true; - game.PlayBlockBounceMiss(this.nextPos); - BeatAction.New(this, new List() {new BeatAction.Action(currentBeat + lengthBeat, delegate { - game.PlayBlockIdle(this.nextPos); - RemoveAndDestroy(); - })}); } private bool CanBounceHit() { @@ -200,7 +200,6 @@ namespace HeavenStudio.Games.Scripts_BuiltToScaleRvl void RemoveAndDestroy() { - game.spawnedRods.Remove(this); Destroy(gameObject); } }