Improved inputs (A SHIT MORE DYNAMIC BETWEEN GAMES) and a whole lot cleaner code in general

This commit is contained in:
Braedon 2022-01-17 00:00:26 -05:00
parent d99d420f59
commit ce193bf572
16 changed files with 405 additions and 774 deletions

View file

@ -187,7 +187,7 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 1, g: 1, b: 1, a: 1}
m_ColorMultiplier: 1
m_FadeDuration: 0
m_SpriteState:
@ -274,7 +274,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1906769993}
m_RootOrder: 2
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@ -3526,127 +3526,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 704039019}
m_CullTransparentMesh: 1
--- !u!1 &705284321
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 705284322}
- component: {fileID: 705284325}
- component: {fileID: 705284324}
- component: {fileID: 705284323}
m_Layer: 5
m_Name: Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &705284322
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705284321}
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:
- {fileID: 1863720033}
m_Father: {fileID: 1906769993}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 68.148, y: 0}
m_SizeDelta: {x: -146.3, y: -10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &705284323
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705284321}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 705284324}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &705284324
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705284321}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0, g: 0, b: 0, a: 0.34117648}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &705284325
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705284321}
m_CullTransparentMesh: 1
--- !u!1 &708484803
GameObject:
m_ObjectHideFlags: 0
@ -4612,7 +4491,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1906769993}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 0}
@ -6656,7 +6535,7 @@ MonoBehaviour:
m_HighlightedColor: {r: 1, g: 1, b: 1, a: 1}
m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 1, g: 1, b: 1, a: 1}
m_ColorMultiplier: 1
m_FadeDuration: 0
m_SpriteState:
@ -6858,8 +6737,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f86858990a87c764892672104bdaef1f, type: 3}
m_Name:
m_EditorClassIdentifier:
level: {fileID: 4900000, guid: 244c565c8088cfa4597e0ebda9c7de98, type: 3}
music: {fileID: 8300000, guid: e5cf71158cc9bff4a8fbfbca1e73e500, type: 3}
level: {fileID: 4900000, guid: 4b7512c586e16a847a5b8490bf35e852, type: 3}
music: {fileID: 8300000, guid: 92cf585c80f8fb843964e525aef1406c, type: 3}
debugUI: 0
playOnStart: 0
editor: 1
@ -8211,7 +8090,7 @@ MonoBehaviour:
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.7490196, g: 1, b: 1, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_DisabledColor: {r: 1, g: 1, b: 1, a: 1}
m_ColorMultiplier: 1
m_FadeDuration: 0
m_SpriteState:
@ -8597,140 +8476,6 @@ MonoBehaviour:
PauseBTN: {fileID: 9435782}
StopBTN: {fileID: 1783491359}
MetronomeBTN: {fileID: 129013734}
--- !u!1 &1863720032
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1863720033}
- component: {fileID: 1863720035}
- component: {fileID: 1863720034}
m_Layer: 5
m_Name: Text (TMP)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1863720033
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1863720032}
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: 705284322}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1863720034
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1863720032}
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: Active
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: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, 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: 14.89
m_fontSizeBase: 14.89
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
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 &1863720035
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1863720032}
m_CullTransparentMesh: 1
--- !u!1 &1906769992
GameObject:
m_ObjectHideFlags: 0
@ -8761,7 +8506,6 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1274849046}
- {fileID: 705284322}
- {fileID: 93132553}
- {fileID: 947065510}
m_Father: {fileID: 1671351975}

View file

@ -14,8 +14,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
[Header("References")]
public ForkLifterHand ForkLifterHand;
private GameManager GameManager;
[Header("Objects")]
public Animator handAnim;
@ -25,9 +23,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
public Sprite[] peaSprites;
public Sprite[] peaHitSprites;
private List<Beatmap.Entity> allPlayerActions = new List<Beatmap.Entity>();
private void Awake()
{
instance = this;
@ -38,33 +33,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
ForkLifterHand.CheckNextFlick();
}
private void Start()
{
GameManager = GameManager.instance;
// allPlayerActions = GameManager.Events.FindAll(c => c.eventName != "gulp" && c.eventName != "sigh" && c.eventName != "prepare" && c.eventName != "end");
/*List<Event> temp = new List<Event>();
for (int i = 0; i < allPlayerActions.Count; i++)
{
if (i - 1 > 0)
{
if (Mathp.IsWithin(allPlayerActions[i - 1].spawnTime, allPlayerActions[i].spawnTime - 1f, allPlayerActions[i].spawnTime))
{
// do nothing lul
continue;
}
}
Event e = (Event)allPlayerActions[i].Clone();
e.spawnTime = allPlayerActions[i].spawnTime - 1;
e.eventName = "prepare";
temp.Add(e);
}
string s = JsonConvert.SerializeObject(temp);
print(s);*/
}
public void Flick(float beat, int type)
{
Jukebox.PlayOneShotGame("forkLifter/flick");

View file

@ -26,12 +26,8 @@ namespace RhythmHeavenMania.Games.ForkLifter
private Animator anim;
public List<Eligible> EligibleHits = new List<Eligible>();
private int currentHitInList = 0;
public float timescale = 1;
private int currentEarlyPeasOnFork;
private int currentPerfectPeasOnFork;
private int currentLatePeasOnFork;
@ -44,15 +40,6 @@ namespace RhythmHeavenMania.Games.ForkLifter
// -----------
[System.Serializable]
public class Eligible
{
public Pea pea;
public bool early;
public bool perfect;
public bool late;
}
private void Awake()
{
instance = this;
@ -65,14 +52,12 @@ namespace RhythmHeavenMania.Games.ForkLifter
private void Update()
{
Time.timeScale = timescale;
if (PlayerInput.Pressed())
{
Stab();
}
if (EligibleHits.Count == 0)
if (ForkLifter.instance.EligibleHits.Count == 0)
{
currentHitInList = 0;
}
@ -134,8 +119,13 @@ namespace RhythmHeavenMania.Games.ForkLifter
public void Stab()
{
if (isEating) return;
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
var EligibleHits = ForkLifter.instance.EligibleHits;
bool canHit = (ForkLifter.instance.EligibleHits.Count > 0) && (currentHitInList < ForkLifter.instance.EligibleHits.Count);
int events = ForkLifter.instance.MultipleEventsAtOnce();
for (int pt = 0; pt < events; pt++)
{
if (canHit)
{
GameObject pea = new GameObject();
@ -153,9 +143,9 @@ namespace RhythmHeavenMania.Games.ForkLifter
}
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type];
psprite.sortingOrder = 20;
switch (EligibleHits[currentHitInList].pea.type)
switch (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type)
{
case 0:
psprite.sortingOrder = 101;
@ -179,21 +169,21 @@ namespace RhythmHeavenMania.Games.ForkLifter
hfxs.sortingOrder = 100;
hfxs.DOColor(new Color(1, 1, 1, 0), 0.05f).OnComplete(delegate { Destroy(hitFXo); });
FastEffectHit(EligibleHits[currentHitInList].pea.type);
FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
Jukebox.PlayOneShotGame("forkLifter/stab");
currentPerfectPeasOnFork++;
if (EligibleHits[currentHitInList].pea.type == 1)
if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 1)
{
topbun = true;
}
else if (EligibleHits[currentHitInList].pea.type == 2)
else if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 2)
{
middleburger = true;
}
else if (EligibleHits[currentHitInList].pea.type == 3)
else if (EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type == 3)
{
bottombun = true;
}
@ -216,14 +206,14 @@ namespace RhythmHeavenMania.Games.ForkLifter
}
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type];
psprite.sortingOrder = 20;
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
FastEffectHit(EligibleHits[currentHitInList].pea.type);
FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
Jukebox.PlayOneShot("miss");
@ -245,14 +235,14 @@ namespace RhythmHeavenMania.Games.ForkLifter
}
SpriteRenderer psprite = pea.AddComponent<SpriteRenderer>();
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].pea.type];
psprite.sprite = ForkLifter.instance.peaHitSprites[EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type];
psprite.sortingOrder = 20;
HitFXMiss(new Vector2(1.0424f, -4.032f), new Vector2(1.129612f, 1.129612f));
HitFXMiss(new Vector2(0.771f, -3.016f), new Vector2(1.71701f, 1.71701f));
HitFXMiss(new Vector2(2.598f, -2.956f), new Vector2(1.576043f, 1.576043f));
HitFXMiss(new Vector2(2.551f, -3.609f), new Vector2(1.200788f, 1.200788f));
FastEffectHit(EligibleHits[currentHitInList].pea.type);
FastEffectHit(ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().type);
Jukebox.PlayOneShot("miss");
@ -265,6 +255,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
{
Jukebox.PlayOneShotGame("forkLifter/stabnohit");
}
}
anim.Play("Player_Stab", 0, 0);
}
@ -297,12 +288,7 @@ namespace RhythmHeavenMania.Games.ForkLifter
private void RemovePea()
{
if (currentHitInList < EligibleHits.Count)
{
Destroy(EligibleHits[currentHitInList].pea.gameObject);
EligibleHits.Remove(EligibleHits[currentHitInList]);
currentHitInList++;
}
ForkLifter.instance.EligibleHits[currentHitInList].gameObject.GetComponent<Pea>().RemoveObject(currentHitInList, true);
}
}
}

View file

@ -6,34 +6,28 @@ using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.ForkLifter
{
public class Pea : MonoBehaviour
public class Pea : PlayerActionObject
{
private Animator anim;
public float startBeat;
private bool inList = false;
public int type;
private ForkLifterPlayer.Eligible e = new ForkLifterPlayer.Eligible();
public int estate, pstate, lstate, endstate;
private void Start()
{
anim = GetComponent<Animator>();
Jukebox.PlayOneShotGame("forkLifter/zoom");
GetComponentInChildren<SpriteRenderer>().sprite = ForkLifter.instance.peaSprites[type];
e = new ForkLifterPlayer.Eligible();
e.pea = this;
for (int i = 0; i < transform.GetChild(0).childCount; i++)
{
transform.GetChild(0).GetChild(i).GetComponent<SpriteRenderer>().sprite = transform.GetChild(0).GetComponent<SpriteRenderer>().sprite;
}
PlayerActionInit(this.gameObject, startBeat, ForkLifter.instance.EligibleHits);
isEligible = true;
}
private void Update()
@ -44,70 +38,13 @@ namespace RhythmHeavenMania.Games.ForkLifter
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 2f);
// Early State
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && estate <= 1)
{
MakeEligible(true, false, false);
estate++;
}
// Perfect State
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && pstate <= 1)
{
MakeEligible(false, true, false);
pstate++;
}
// Late State
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lstate <= 1)
{
MakeEligible(false, false, true);
lstate++;
}
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
{
MakeInEligible();
}
if (normalizedBeat > Minigame.EndTime() && endstate <= 1)
{
endstate++;
Jukebox.PlayOneShot("audience/disappointed");
}
StateCheck(normalizedBeat);
if (normalizedBeat > 1.35f)
{
MakeInEligible();
Jukebox.PlayOneShot("audience/disappointed");
Destroy(this.gameObject);
}
}
public void MakeEligible(bool early, bool perfect, bool late)
{
// print($"{early}, {perfect}, {late}");
if (!inList)
{
e.early = early;
e.perfect = perfect;
e.late = late;
ForkLifterPlayer.instance.EligibleHits.Add(e);
inList = true;
}
else
{
ForkLifterPlayer.Eligible es = ForkLifterPlayer.instance.EligibleHits[ForkLifterPlayer.instance.EligibleHits.IndexOf(e)];
es.early = early;
es.perfect = perfect;
es.late = late;
}
}
public void MakeInEligible()
{
if (!inList) return;
ForkLifterPlayer.instance.EligibleHits.Remove(e);
inList = false;
}
}
}

View file

@ -70,13 +70,15 @@ namespace RhythmHeavenMania.Games.KarateMan
private void Swing()
{
// you cant hit two pots at a time like this so i should fix this before a public build is eventually made.
var EligibleHits = KarateMan.instance.EligibleHits;
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
bool punchLeft = true;
int events = KarateMan.instance.MultipleEventsAtOnce();
for (int pt = 0; pt < events; pt++)
{
if (canHit)
{
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
@ -158,7 +160,7 @@ namespace RhythmHeavenMania.Games.KarateMan
p.Miss();
}
p.isEligible = false;
p.RemoveObject(currentHitInList, EligibleHits);
p.RemoveObject(currentHitInList);
}
else
{
@ -169,6 +171,7 @@ namespace RhythmHeavenMania.Games.KarateMan
else
anim.Play("PunchRight", 0, 0);
}
}
public void HitEffectF(Vector3 pos)
{

View file

@ -38,7 +38,6 @@ namespace RhythmHeavenMania.Games.KarateMan
private void Start()
{
PlayerActionInit(this.gameObject);
anim = GetComponent<Animator>();
Sprite.transform.eulerAngles = new Vector3(0, 0, Random.Range(0, 360));
@ -48,6 +47,8 @@ namespace RhythmHeavenMania.Games.KarateMan
hitLength = 23.45f;
else
hitLength = 16f;
PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleHits);
}
private void Update()
@ -65,7 +66,7 @@ namespace RhythmHeavenMania.Games.KarateMan
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, 1);
StateCheck(normalizedBeat, KarateMan.instance.EligibleHits);
StateCheck(normalizedBeat);
lastPos = Holder.transform.localPosition;
lastShadowX = Shadow.transform.localPosition.x;

View file

@ -16,6 +16,7 @@ namespace RhythmHeavenMania.Games
public bool early;
public bool perfect;
public bool late;
public float createBeat;
}
// hopefully these will fix the lowbpm problem
@ -50,5 +51,23 @@ namespace RhythmHeavenMania.Games
{
}
public int MultipleEventsAtOnce()
{
int sameTime = 0;
for (int i = 0; i < EligibleHits.Count; i++)
{
float createBeat = EligibleHits[i].createBeat;
if (EligibleHits.FindAll(c => c.createBeat == createBeat).Count > 0)
{
sameTime += 1;
}
}
if (sameTime == 0 && EligibleHits.Count > 0)
sameTime = 1;
return sameTime;
}
}
}

View file

@ -11,39 +11,43 @@ namespace RhythmHeavenMania.Games
public Minigame.Eligible state = new Minigame.Eligible();
public bool isEligible;
public void PlayerActionInit(GameObject g)
public List<Minigame.Eligible> eligibleHitsList = new List<Minigame.Eligible>();
public void PlayerActionInit(GameObject g, float createBeat, List<Minigame.Eligible> eligibleHitsList)
{
state.gameObject = g;
state.createBeat = createBeat;
this.eligibleHitsList = eligibleHitsList;
}
// could possibly add support for custom early, perfect, and end times if needed.
public void StateCheck(float normalizedBeat, List<Minigame.Eligible> eligibleHitsList)
public void StateCheck(float normalizedBeat)
{
if (!isEligible) return;
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
{
MakeEligible(true, false, false, eligibleHitsList);
MakeEligible(true, false, false);
lastState++;
}
// Perfect State
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
{
MakeEligible(false, true, false, eligibleHitsList);
MakeEligible(false, true, false);
lastState++;
}
// Late State
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
{
MakeEligible(false, false, true, eligibleHitsList);
MakeEligible(false, false, true);
lastState++;
}
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
{
MakeInEligible(eligibleHitsList);
MakeInEligible();
}
}
public void MakeEligible(bool early, bool perfect, bool late, List<Minigame.Eligible> eligibleHitsList)
public void MakeEligible(bool early, bool perfect, bool late)
{
if (!inList)
{
@ -63,7 +67,7 @@ namespace RhythmHeavenMania.Games
}
}
public void MakeInEligible(List<Minigame.Eligible> eligibleHitsList)
public void MakeInEligible()
{
if (!inList) return;
@ -71,12 +75,13 @@ namespace RhythmHeavenMania.Games
inList = false;
}
public void RemoveObject(int currentHitInList, List<Minigame.Eligible> EligibleHits)
public void RemoveObject(int currentHitInList, bool destroyObject = false)
{
if (currentHitInList < EligibleHits.Count)
if (currentHitInList < eligibleHitsList.Count)
{
EligibleHits.Remove(EligibleHits[currentHitInList]);
eligibleHitsList.Remove(eligibleHitsList[currentHitInList]);
currentHitInList++;
if (destroyObject) Destroy(this.gameObject);
}
}
@ -112,5 +117,10 @@ namespace RhythmHeavenMania.Games
state.perfect = perfect;
state.late = late;
}
private void OnDestroy()
{
MakeInEligible();
}
}
}

View file

@ -34,9 +34,9 @@ namespace RhythmHeavenMania.Games.Spaceball
for (int i = 1; i < BallsHolder.transform.childCount; i++)
Destroy(BallsHolder.transform.GetChild(i).gameObject);
GameManager.instance.GameCamera.orthographic = false;
if (SpaceballPlayer.instance != null)
if (SpaceballPlayer.instance.EligibleHits.Count > 0)
SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count);
if (EligibleHits.Count > 0)
EligibleHits.RemoveRange(0, EligibleHits.Count);
}
public override void OnTimeChange()

View file

@ -8,12 +8,10 @@ using DG.Tweening;
namespace RhythmHeavenMania.Games.Spaceball
{
public class SpaceballBall : MonoBehaviour
public class SpaceballBall : PlayerActionObject
{
public float startBeat;
private Animator anim;
private int lastState;
private bool inList = false;
public Animator anim;
public bool high;
@ -22,6 +20,12 @@ namespace RhythmHeavenMania.Games.Spaceball
public GameObject Holder;
public SpriteRenderer Sprite;
public bool hit;
public float hitBeat;
public Vector3 hitPos;
public float hitRot;
public float randomEndPosX;
private void Start()
{
anim = GetComponent<Animator>();
@ -30,9 +34,22 @@ namespace RhythmHeavenMania.Games.Spaceball
float rot = Random.Range(0, 360);
Sprite.gameObject.transform.eulerAngles = new Vector3(0, 0, rot);
PlayerActionInit(this.gameObject, startBeat, Spaceball.instance.EligibleHits);
isEligible = true;
}
private void Update()
{
if (hit)
{
float nba = Conductor.instance.GetLoopPositionFromBeat(hitBeat, 14);
Holder.transform.localPosition = Vector3.Lerp(hitPos, new Vector3(randomEndPosX, 0f, -600f), nba);
Holder.transform.eulerAngles = Vector3.Lerp(new Vector3(0, 0, hitRot), new Vector3(0, 0, -2260), nba);
}
else
{
float beatLength = 1f;
if (high) beatLength = 2f;
@ -53,27 +70,7 @@ namespace RhythmHeavenMania.Games.Spaceball
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(startBeat, beatLength);
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
{
MakeEligible(true, false, false);
lastState++;
}
// Perfect State
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
{
MakeEligible(false, true, false);
lastState++;
}
// Late State
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
{
MakeEligible(false, false, true);
lastState++;
}
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
{
MakeInEligible();
}
StateCheck(normalizedBeat);
// too lazy to make a proper fix for this
float endTime = 1.2f;
@ -85,65 +82,8 @@ namespace RhythmHeavenMania.Games.Spaceball
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
Destroy(this.gameObject);
}
if (PlayerInput.Pressed())
{
if (e.perfect)
{
Jukebox.PlayOneShotGame("spaceball/hit");
Holder.transform.DOLocalMove(new Vector3(Random.Range(5, 18), 0, -600), 4f).SetEase(Ease.Linear);
Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -245;
this.enabled = false;
gameObject.GetComponent<Animator>().enabled = false;
}
else if (e.late || e.early)
{
Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -55;
this.enabled = false;
gameObject.GetComponent<Animator>().enabled = false;
Rigidbody2D rb = gameObject.AddComponent<Rigidbody2D>();
rb.bodyType = RigidbodyType2D.Dynamic;
rb.AddForce(transform.up * 1100);
rb.AddForce(transform.right * 400);
rb.gravityScale = 9;
Jukebox.PlayOneShot("miss");
}
}
}
public void MakeEligible(bool early, bool perfect, bool late)
{
// print($"{early}, {perfect}, {late}");
if (!inList)
{
e.early = early;
e.perfect = perfect;
e.late = late;
SpaceballPlayer.instance.EligibleHits.Add(e);
inList = true;
}
else
{
Minigame.Eligible es = SpaceballPlayer.instance.EligibleHits[SpaceballPlayer.instance.EligibleHits.IndexOf(e)];
es.early = early;
es.perfect = perfect;
es.late = late;
}
}
public void MakeInEligible()
{
if (!inList) return;
SpaceballPlayer.instance.EligibleHits.Remove(e);
inList = false;
}
}
}

View file

@ -11,8 +11,7 @@ namespace RhythmHeavenMania.Games.Spaceball
{
private Animator anim;
public List<Minigame.Eligible> EligibleHits = new List<Minigame.Eligible>();
[SerializeField] private int currentHitInList = 0;
private int currentHitInList = 0;
public int costume;
@ -39,7 +38,7 @@ namespace RhythmHeavenMania.Games.Spaceball
private void Update()
{
if (EligibleHits.Count == 0)
if (Spaceball.instance.EligibleHits.Count == 0)
currentHitInList = 0;
if (PlayerInput.Pressed())
@ -56,9 +55,52 @@ namespace RhythmHeavenMania.Games.Spaceball
public void Swing()
{
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
var EligibleHits = Spaceball.instance.EligibleHits;
bool canHit = (Spaceball.instance.EligibleHits.Count > 0) && (currentHitInList < Spaceball.instance.EligibleHits.Count);
Jukebox.PlayOneShotGame("spaceball/swing");
int events = Spaceball.instance.MultipleEventsAtOnce();
for (int eventI = 0; eventI < events; eventI++)
{
if (canHit)
{
SpaceballBall ball = EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>();
if (EligibleHits[currentHitInList].perfect)
{
ball.hit = true;
ball.hitBeat = Conductor.instance.songPositionInBeats;
ball.hitPos = ball.Holder.transform.localPosition;
ball.hitRot = ball.Holder.transform.eulerAngles.z;
Jukebox.PlayOneShotGame("spaceball/hit");
ball.randomEndPosX = Random.Range(40f, 55f);
ball.anim.enabled = false;
}
else if (EligibleHits[currentHitInList].late || EligibleHits[currentHitInList].early)
{
ball.Holder.transform.GetChild(0).gameObject.AddComponent<Rotate>().rotateSpeed = -55;
ball.enabled = false;
ball.anim.enabled = false;
Rigidbody2D rb = ball.gameObject.AddComponent<Rigidbody2D>();
rb.bodyType = RigidbodyType2D.Dynamic;
rb.AddForce(transform.up * 1100);
rb.AddForce(transform.right * 400);
rb.gravityScale = 9;
Jukebox.PlayOneShot("miss");
}
ball.RemoveObject(currentHitInList);
}
}
if (!canHit)
Jukebox.PlayOneShotGame("spaceball/swing", false);
anim.Play("Swing", 0, 0);
}

View file

@ -29,6 +29,9 @@ namespace RhythmHeavenMania.Editor
{
tempoLayer.GetComponent<Image>().color = theme.properties.TempoLayerCol.Hex2RGB();
musicLayer.GetComponent<Image>().color = theme.properties.MusicLayerCol.Hex2RGB();
Tooltip.instance.AddTooltip(tempoLayer.gameObject, $"Tempo Track");
Tooltip.instance.AddTooltip(musicLayer.gameObject, $"Music Volume Track");
layer.gameObject.SetActive(false);
@ -36,7 +39,7 @@ namespace RhythmHeavenMania.Editor
{
GameObject layer = Instantiate(this.layer.gameObject, this.layer.transform.parent);
layer.SetActive(true);
layer.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Layer {i + 1}";
layer.transform.GetChild(0).GetComponent<TMP_Text>().text = $"Track {i + 1}";
Color c = Color.white;
@ -57,6 +60,7 @@ namespace RhythmHeavenMania.Editor
}
layer.GetComponent<Image>().color = c;
Tooltip.instance.AddTooltip(layer, $"Track {i + 1}");
}
Destroy(layer);
}

View file

@ -130,7 +130,6 @@ namespace RhythmHeavenMania.Editor
}
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && CheckIfMouseInTimeline())
{
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
@ -244,27 +243,33 @@ namespace RhythmHeavenMania.Editor
if (playEnabled)
{
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.green;
PlayBTN.enabled = true;
}
else
{
PlayBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
PlayBTN.enabled = false;
}
if (pauseEnabled)
{
PauseBTN.enabled = true;
PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.blue;
}
else
{ PauseBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
PauseBTN.enabled = false;
}
if (stopEnabled)
{
StopBTN.enabled = true;
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.red;
}
else
{
StopBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
StopBTN.enabled = false;
}
}
#endregion

View file

@ -40,21 +40,22 @@ namespace RhythmHeavenMania.Util
FindJukebox().GetComponent<AudioSource>().volume = volume;
}
public static void PlayOneShot(string name)
public static void PlayOneShot(string name, bool relyOnBeat = true)
{
GameObject oneShot = new GameObject("oneShot");
AudioSource aus = oneShot.AddComponent<AudioSource>();
aus.playOnAwake = false;
Sound snd = oneShot.AddComponent<Sound>();
snd.relyOnBeat = relyOnBeat;
AudioClip clip = Resources.Load<AudioClip>($"Sfx/{name}");
snd.clip = clip;
// snd.pitch = (clip.length / Conductor.instance.secPerBeat);
}
public static void PlayOneShotGame(string name)
public static void PlayOneShotGame(string name, bool relyOnBeat = true)
{
if (GameManager.instance.currentGame == name.Split('/')[0])
PlayOneShot($"games/{name}");
PlayOneShot($"games/{name}", relyOnBeat);
}
}

View file

@ -15,6 +15,8 @@ namespace RhythmHeavenMania.Util
private float startTime;
public bool relyOnBeat = true;
private void Start()
{
audioSource = GetComponent<AudioSource>();
@ -23,9 +25,16 @@ namespace RhythmHeavenMania.Util
audioSource.PlayScheduled(Time.time);
startTime = Conductor.instance.songPosition;
if (!relyOnBeat)
{
StartCoroutine(NotRelyOnBeatSound());
}
}
private void Update()
{
if (relyOnBeat)
{
if (Conductor.instance.isPaused && !Conductor.instance.isPlaying && pauseTimes == 0)
{
@ -44,11 +53,17 @@ namespace RhythmHeavenMania.Util
{
Destroy(this.gameObject);
}
if (Conductor.instance.songPosition > startTime + clip.length)
{
Destroy(this.gameObject);
}
}
}
IEnumerator NotRelyOnBeatSound()
{
yield return new WaitForSeconds(clip.length);
Destroy(this.gameObject);
}
}
}

View file

@ -1,45 +1 @@
{
"bpm": 119,
"entities": [
{
"beat": 0,
"datamodel": "karateman/bgfxon"
},
{
"beat": 1,
"datamodel": "karateman/bop"
},
{
"beat": 2,
"datamodel": "karateman/kick"
},
{
"beat": 14,
"datamodel": "karateman/rock"
},
{
"beat": 20,
"datamodel": "karateman/pot"
},
{
"beat": 22,
"datamodel": "karateman/pot"
},
{
"beat": 24,
"datamodel": "karateman/pot"
},
{
"beat": 26,
"datamodel": "karateman/pot"
},
{
"beat": 28,
"datamodel": "karateman/pot"
},
{
"beat": 30,
"datamodel": "karateman/bulb"
},
]
}
{"bpm":119.0,"entities":[{"beat":14.0,"track":0,"datamodel":"karateman/pot"},{"beat":22.0,"track":2,"datamodel":"karateman/pot"},{"beat":30.0,"track":3,"datamodel":"karateman/pot"},{"beat":50.0,"track":0,"datamodel":"karateman/rock"},{"beat":56.0,"track":3,"datamodel":"karateman/bgfxon"},{"beat":58.0,"track":2,"datamodel":"karateman/pot"},{"beat":62.0,"track":2,"datamodel":"karateman/pot"},{"beat":66.0,"track":2,"datamodel":"karateman/pot"}]}