Can pick places on timeline and gamemanager bugs fixed

This commit is contained in:
Starpelly 2022-01-07 18:51:08 -05:00
parent afa2d6d482
commit 0208e6c490
8 changed files with 1706 additions and 1413 deletions

File diff suppressed because one or more lines are too long

View file

@ -123,6 +123,140 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &117889362
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 117889363}
- component: {fileID: 117889365}
- component: {fileID: 117889364}
m_Layer: 5
m_Name: PlaybackTime
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &117889363
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 117889362}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 770589360}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 89.61, y: 120.28999}
m_SizeDelta: {x: 160.43, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &117889364
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 117889362}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Beat 0.000
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: c2df694f599b22b42817910ff570a9df, type: 2}
m_sharedMaterial: {fileID: -5829441969153149921, guid: c2df694f599b22b42817910ff570a9df, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281532210
m_fontColor: {r: 0.19607845, g: 1, b: 0.19607845, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 15.5
m_fontSizeBase: 15.5
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &117889365
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 117889362}
m_CullTransparentMesh: 1
--- !u!1 &156962253
GameObject:
m_ObjectHideFlags: 0
@ -472,6 +606,140 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 355353077}
m_CullTransparentMesh: 1
--- !u!1 &424396916
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 424396917}
- component: {fileID: 424396919}
- component: {fileID: 424396918}
m_Layer: 5
m_Name: PlaybackLabel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &424396917
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 424396916}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 770589360}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -48.28, y: 120.28999}
m_SizeDelta: {x: 77.76, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &424396918
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 424396916}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: Playback
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: c2df694f599b22b42817910ff570a9df, type: 2}
m_sharedMaterial: {fileID: -5829441969153149921, guid: c2df694f599b22b42817910ff570a9df, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4281532210
m_fontColor: {r: 0.19607845, g: 1, b: 0.19607845, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 15.5
m_fontSizeBase: 15.5
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 4
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &424396919
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 424396916}
m_CullTransparentMesh: 1
--- !u!1 &441876680
GameObject:
m_ObjectHideFlags: 0
@ -1524,6 +1792,8 @@ RectTransform:
m_Children:
- {fileID: 1928361019}
- {fileID: 529053006}
- {fileID: 424396917}
- {fileID: 117889363}
m_Father: {fileID: 1852819573}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -2236,6 +2506,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
MainCanvas: {fileID: 1791483802}
EditorCamera: {fileID: 2047408675}
ScreenRenderTexture: {fileID: 8400000, guid: d3f3d6ca32122da4d9e3a8e7aa2ede16, type: 2}
Screen: {fileID: 558010761}
Timeline: {fileID: 1861169747}
@ -2251,8 +2522,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f86858990a87c764892672104bdaef1f, type: 3}
m_Name:
m_EditorClassIdentifier:
level: {fileID: 4900000, guid: 4b7512c586e16a847a5b8490bf35e852, type: 3}
music: {fileID: 0}
level: {fileID: 4900000, guid: 244c565c8088cfa4597e0ebda9c7de98, type: 3}
music: {fileID: 8300000, guid: e5cf71158cc9bff4a8fbfbca1e73e500, type: 3}
debugUI: 0
playOnStart: 0
editor: 1
@ -3046,6 +3317,7 @@ MonoBehaviour:
SongBeat: {fileID: 932211468}
SongPos: {fileID: 1567318397}
TimelineSlider: {fileID: 770589360}
TimelinePlaybackBeat: {fileID: 117889364}
TimelineContent: {fileID: 1852819573}
TimelineSongPosLineRef: {fileID: 580861938}
--- !u!1 &1928361018

View file

@ -23,9 +23,7 @@ namespace RhythmHeavenMania
// Current song position, in beats
public float songPositionInBeats;
// How many seconds have passed since the song started
public float startTime;
// Time that the song paused
private float pauseTime;
// Current time of the song
@ -43,6 +41,8 @@ namespace RhythmHeavenMania
public bool isPlaying;
public bool isPaused;
public float currentTime;
// private AudioDspTimeKeeper timeKeeper;
void Awake()
@ -57,23 +57,33 @@ namespace RhythmHeavenMania
secPerBeat = 60f / songBpm;
}
public void SetBeat(float t)
{
float secFromBeat = secPerBeat * t;
currentTime = secFromBeat;
pauseTime = 0;
if (secFromBeat < musicSource.clip.length)
musicSource.time = secFromBeat;
GameManager.instance.SetCurrentEventToClosest(t);
}
public void Play()
{
float lastTime = pauseTime - startTime;
startTime = Time.time;
time = startTime + lastTime;
time = currentTime + pauseTime;
isPlaying = true;
isPaused = false;
musicSource.PlayScheduled(startTime);
musicSource.PlayScheduled(Time.time);
}
public void Pause()
{
pauseTime = time;
currentTime = 0;
isPlaying = false;
isPaused = true;
@ -87,15 +97,17 @@ namespace RhythmHeavenMania
isPlaying = false;
isPaused = false;
GameManager.instance.SetCurrentEventToClosest(songPositionInBeats);
musicSource.Stop();
}
public void SetTime(float startBeat)
/*public void SetTime(float startBeat)
{
musicSource.time = GetSongPosFromBeat(startBeat);
songPositionInBeats = musicSource.time / secPerBeat;
GameManager.instance.SetCurrentEventToClosest(songPositionInBeats);
}
}*/
public void Update()
{
@ -103,7 +115,7 @@ namespace RhythmHeavenMania
{
time += Time.deltaTime * musicSource.pitch;
songPosition = time - startTime - firstBeatOffset;
songPosition = time - firstBeatOffset;
songPositionInBeats = songPosition / secPerBeat;
}
@ -115,7 +127,7 @@ namespace RhythmHeavenMania
return a;
}
private float GetSongPosFromBeat(float beat)
public float GetSongPosFromBeat(float beat)
{
return secPerBeat * beat;
}

View file

@ -93,18 +93,18 @@ namespace RhythmHeavenMania
if (!Conductor.instance.isPlaying)
return;
if (Input.GetKeyDown(KeyCode.A))
/*if (Input.GetKeyDown(KeyCode.A))
{
Conductor.instance.SetTime(Conductor.instance.songPositionInBeats + 3);
Conductor.instance.SetBeat(Conductor.instance.songPositionInBeats + 3);
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
}
else if (Input.GetKeyDown(KeyCode.S))
{
Conductor.instance.SetTime(Conductor.instance.songPositionInBeats - 3);
Conductor.instance.SetBeat(Conductor.instance.songPositionInBeats - 3);
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
}
}*/
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
@ -152,14 +152,23 @@ namespace RhythmHeavenMania
List<float> entities_p = playerEntities.Select(c => c.beat).ToList();
currentPlayerEvent = entities_p.IndexOf(Mathp.GetClosestInList(entities_p, beat));
}
currentEvent = entities.IndexOf(Mathp.GetClosestInList(entities, beat));
print(currentEvent);
string newGame = Beatmap.entities[currentEvent].datamodel.Split('/')[0];
if (newGame != currentGame)
if (Beatmap.entities[currentEvent].datamodel.Split('/')[1] != "switchGame")
{
SwitchGame(newGame);
if (newGame == "gameManager")
{
// holy shit
newGame = Beatmap.entities[entities.IndexOf(Mathp.GetClosestInList(Beatmap.entities.FindAll(c => c.datamodel != "gameManager" && c.beat < Conductor.instance.songPositionInBeats).ToList().Select(c => c.beat).ToList(), beat))].datamodel.Split('/')[0];
}
if (newGame != currentGame)
{
SwitchGame(newGame);
}
}
}
}
@ -191,12 +200,15 @@ namespace RhythmHeavenMania
{
for (int i = 0; i < preloadedGames.Count; i++)
{
if (preloadedGames[i].gameObject.name == game)
if (preloadedGames[i].gameObject != null)
{
preloadedGames[i].SetActive(true);
currentGameO = preloadedGames[i];
preloadedGames.Remove(preloadedGames[i]);
instantiate = false;
if (preloadedGames[i].gameObject.name == game)
{
preloadedGames[i].SetActive(true);
currentGameO = preloadedGames[i];
preloadedGames.Remove(preloadedGames[i]);
instantiate = false;
}
}
}
}

View file

@ -107,7 +107,6 @@ namespace RhythmHeavenMania.Games.ClappyTrio
}
else
{
print(early + " " + perfect + " " + late);
clapEffect.SetActive(false);
Jukebox.PlayOneShot("miss");
ClappyTrio.instance.playerHitLast = false;

View file

@ -11,6 +11,7 @@ namespace RhythmHeavenMania.Editor
private Initializer Initializer;
[SerializeField] private Canvas MainCanvas;
[SerializeField] public Camera EditorCamera;
[Header("Rect")]
[SerializeField] private RenderTexture ScreenRenderTexture;
@ -19,12 +20,14 @@ namespace RhythmHeavenMania.Editor
[Header("Components")]
[SerializeField] private Timeline Timeline;
public static Editor instance { get; private set; }
private void Start()
{
instance = this;
Initializer = GetComponent<Initializer>();
MainCanvas.gameObject.SetActive(false);
print("d");
}
public void Init()

View file

@ -14,11 +14,12 @@ namespace RhythmHeavenMania.Editor
[SerializeField] private TMP_Text SongPos;
[Header("Timeline Properties")]
private bool isPlaying = false;
private float lastBeatPos = 0;
private Vector2 lastMousePos;
[Header("Timeline Components")]
[SerializeField] private RectTransform TimelineSlider;
[SerializeField] private TMP_Text TimelinePlaybackBeat;
[SerializeField] private RectTransform TimelineContent;
[SerializeField] private RectTransform TimelineSongPosLineRef;
private RectTransform TimelineSongPosLine;
@ -33,10 +34,18 @@ namespace RhythmHeavenMania.Editor
private void Update()
{
SongBeat.text = $"Beat {string.Format("{0:0.000}", Conductor.instance.songPositionInBeats)}";
SongPos.text = FormatTime(Conductor.instance.songPosition);
if (!Conductor.instance.isPlaying && !Conductor.instance.isPaused)
{
SongBeat.text = $"Beat {string.Format("{0:0.000}", TimelineSlider.localPosition.x)}";
SongPos.text = FormatTime(Conductor.instance.GetSongPosFromBeat(TimelineSlider.localPosition.x));
}
else
{
SongBeat.text = $"Beat {string.Format("{0:0.000}", Conductor.instance.songPositionInBeats)}";
SongPos.text = FormatTime(Conductor.instance.songPosition);
}
isPlaying = Conductor.instance.isPlaying;
SliderControl();
if (Input.GetKeyDown(KeyCode.Space))
{
@ -50,13 +59,22 @@ namespace RhythmHeavenMania.Editor
}
}
SliderControl();
lastBeatPos = Conductor.instance.songPositionInBeats;
if (Input.GetMouseButtonDown(1) && !Conductor.instance.isPlaying)
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
TimelineSlider.localPosition = new Vector3(lastMousePos.x, TimelineSlider.transform.localPosition.y);
Conductor.instance.SetBeat(TimelineSlider.transform.localPosition.x);
}
}
private void SliderControl()
{
TimelinePlaybackBeat.text = $"Beat {string.Format("{0:0.000}", TimelineSlider.localPosition.x)}";
if (TimelineSongPosLine != null)
{
TimelineSongPosLine.transform.localPosition = new Vector3(Conductor.instance.songPositionInBeats, TimelineSlider.transform.localPosition.y);
@ -69,14 +87,14 @@ namespace RhythmHeavenMania.Editor
{
if (fromStart)
{
if (isPlaying)
if (Conductor.instance.isPlaying)
Play(true);
else
Stop();
}
else
{
if (!isPlaying)
if (!Conductor.instance.isPlaying)
{
Play(false);
}
@ -111,6 +129,7 @@ namespace RhythmHeavenMania.Editor
// isPaused = true;
// timelineSlider.value = 0;
if (TimelineSongPosLine != null)
Destroy(TimelineSongPosLine.gameObject);
Conductor.instance.Stop();

View file

@ -8,17 +8,17 @@ namespace RhythmHeavenMania
{
public static bool Pressed()
{
return (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0));
return Input.GetKeyDown(KeyCode.Z);
}
public static bool PressedUp()
{
return (Input.GetKeyUp(KeyCode.Z) || Input.GetKeyUp(KeyCode.Space) || Input.GetMouseButtonUp(0));
return Input.GetKeyUp(KeyCode.Z);
}
public static bool Pressing()
{
return (Input.GetKey(KeyCode.Z) || Input.GetKey(KeyCode.Space) || Input.GetMouseButton(0));
return Input.GetKey(KeyCode.Z);
}
}
}