Autoplay began

This commit is contained in:
Braedon
2022-01-22 22:40:53 -05:00
parent 1ed2291844
commit 2b88703e3f
39 changed files with 1579 additions and 306 deletions

View File

@ -37,12 +37,14 @@ namespace RhythmHeavenMania
public bool playOnStart;
public float startBeat;
private GameObject currentGameO;
public bool autoplay;
public static GameManager instance { get; private set; }
private EventCaller eventCaller;
private void Awake()
{
autoplay = true;
instance = this;
}

View File

@ -37,9 +37,14 @@ namespace RhythmHeavenMania.Games.KarateMan
eligible = true;
}
public override void OnAce()
{
Hit();
}
private void Update()
{
shadow.transform.localPosition = new Vector3(Holder.transform.localPosition.x, shadow.transform.localPosition.y);
shadow.transform.localPosition = new Vector3(Holder.transform.localPosition.x, shadow.transform.localPosition.y);
if (!kicked)
{
if (!missed)
@ -67,9 +72,8 @@ namespace RhythmHeavenMania.Games.KarateMan
}
if (PlayerInput.PressedUp() && eligible)
if (PlayerInput.PressedUp())
{
eligible = false;
if (state.perfect)
{
Hit();
@ -119,6 +123,9 @@ namespace RhythmHeavenMania.Games.KarateMan
hitBeat = Conductor.instance.songPositionInBeats;
kicked = true;
RotHolder.transform.eulerAngles = lastRot;
KarateJoe.instance.ResetKick();
KarateJoe.instance.AnimPlay("Kick");
}
public void Miss()
@ -126,6 +133,9 @@ namespace RhythmHeavenMania.Games.KarateMan
missBeat = Conductor.instance.songPositionInBeats;
missed = true;
Jukebox.PlayOneShot("miss");
KarateJoe.instance.ResetKick();
KarateJoe.instance.AnimPlay("Kick");
}
}
}

View File

@ -20,7 +20,7 @@ namespace RhythmHeavenMania.Games.KarateMan
public GameObject BulbHit;
public bool hitBarrel = false;
private Coroutine kickC;
public Coroutine kickC;
private float barrelBeat;
@ -33,6 +33,8 @@ namespace RhythmHeavenMania.Games.KarateMan
private int currentComboHitInList;
private int comboIndex;
public float comboNormalizedBeat = 0;
public static KarateJoe instance { get; set; }
private void Start()
@ -45,7 +47,7 @@ namespace RhythmHeavenMania.Games.KarateMan
{
if (inCombo)
{
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(comboBeat, 1);
comboNormalizedBeat = Conductor.instance.GetLoopPositionFromBeat(comboBeat, 1);
if (hitCombo)
{
@ -53,10 +55,10 @@ namespace RhythmHeavenMania.Games.KarateMan
}
else
{
normalizedBeat += 1;
comboNormalizedBeat += 1;
}
if (normalizedBeat >= 1 && comboIndex < 1)
if (comboNormalizedBeat >= 1 && comboIndex < 1)
{
if (hitCombo)
{
@ -72,7 +74,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("PunchLeft");
}
else if (normalizedBeat >= 1.25f && comboIndex < 2)
else if (comboNormalizedBeat >= 1.25f && comboIndex < 2)
{
if (hitCombo)
{
@ -88,7 +90,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("PunchRight");
}
else if (normalizedBeat >= 1.5f && comboIndex < 3)
else if (comboNormalizedBeat >= 1.5f && comboIndex < 3)
{
if (hitCombo)
{
@ -100,7 +102,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboCrouch");
}
else if (normalizedBeat >= 1.75f && comboIndex < 4)
else if (comboNormalizedBeat >= 1.75f && comboIndex < 4)
{
if (hitCombo)
{
@ -116,7 +118,7 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboKick");
}
else if (normalizedBeat >= 2f && comboIndex < 5)
else if (comboNormalizedBeat >= 2f && comboIndex < 5)
{
if (hitCombo)
{
@ -128,13 +130,13 @@ namespace RhythmHeavenMania.Games.KarateMan
comboIndex++;
AnimPlay("ComboCrouchPunch");
}
else if (normalizedBeat >= 2.05f)
else if (comboNormalizedBeat >= 2.05f)
{
if (hitCombo)
{
if (PlayerInput.AltPressedUp())
{
ComboPow();
// ComboPow(null);
}
}
else
@ -147,75 +149,47 @@ namespace RhythmHeavenMania.Games.KarateMan
}
else
{
if (!inCombo)
if (PlayerInput.AltPressed())
{
Combo();
Combo(null);
}
}
if (hitBarrel)
{
if (PlayerInput.PressedUp())
{
if (kickC != null) StopCoroutine(kickC);
hitBarrel = false;
AnimPlay("Kick");
}
if (Conductor.instance.songPositionInBeats > barrelBeat + 3)
{
if (kickC != null) StopCoroutine(kickC);
hitBarrel = false;
// should be inebetween for this
AnimPlay("Idle");
}
}
else
if (!hitBarrel)
{
if (PlayerInput.Pressed() && !inCombo)
{
Swing();
Swing(null);
}
}
}
private void Combo()
public void Combo(Pot p)
{
var EligibleHits = KarateMan.instance.EligibleCombos;
bool canHit = (EligibleHits.Count > 0) && (currentComboHitInList < EligibleHits.Count);
if (canHit)
{
if (KarateMan.instance.EligibleCombos[currentComboHitInList].perfect)
{
comboBeat = EligibleHits[currentComboHitInList].createBeat;
hitCombo = true;
// Debug.Break();
}
else
{
comboBeat = Conductor.instance.songPositionInBeats;
hitCombo = false;
}
}
else
if (p == null)
{
comboBeat = Conductor.instance.songPositionInBeats;
hitCombo = false;
}
else
{
comboBeat = p.createBeat;
hitCombo = true;
}
inCombo = true;
}
private void ComboPow()
public void ComboPow(Pot p, bool overrideState = false)
{
if (!hitCombo || !inCombo || !hitCombo && !inCombo) return;
anim.Play("Pow", 0, 0);
if (currentComboPots[comboPotIndex].state.perfect)
/*if (currentComboPots[comboPotIndex].state.perfect)
{
BarrelDestroy(currentComboPots[comboPotIndex], true);
// BarrelDestroy(currentComboPots[comboPotIndex], true);
HitEffectF(currentComboPots[comboPotIndex].Holder.transform.localPosition);
Destroy(currentComboPots[comboPotIndex].gameObject);
Jukebox.PlayOneShotGame("karateman/comboHit4");
@ -224,6 +198,21 @@ namespace RhythmHeavenMania.Games.KarateMan
{
Jukebox.PlayOneShot("miss");
currentComboPots[comboPotIndex].Miss();
}*/
if (p != null)
{
if (p.state.perfect || overrideState)
{
p.BarrelDestroy(true);
HitEffectF(p.Holder.transform.localPosition);
Destroy(p.gameObject);
Jukebox.PlayOneShotGame("karateman/comboHit4");
}
else if (p.state.notPerfect())
{
p.Miss();
}
}
ResetCombo();
@ -239,7 +228,7 @@ namespace RhythmHeavenMania.Games.KarateMan
currentComboPots.Clear();
}
private IEnumerator PrepareKick()
public IEnumerator PrepareKick()
{
barrelBeat = Conductor.instance.songPositionInBeats;
hitBarrel = true;
@ -247,70 +236,43 @@ namespace RhythmHeavenMania.Games.KarateMan
AnimPlay("KickPrepare");
}
private void Swing()
public void ResetKick()
{
var EligibleHits = KarateMan.instance.EligibleHits;
bool canHit = (EligibleHits.Count > 0) && (currentHitInList < EligibleHits.Count);
if (kickC != null)
{
StopCoroutine(kickC);
}
hitBarrel = false;
}
public void Swing(Pot p)
{
bool punchLeft = true;
int events = KarateMan.instance.MultipleEventsAtOnce();
for (int pt = 0; pt < events; pt++)
if (p == null)
{
if (canHit)
{
Pot p = EligibleHits[currentHitInList].gameObject.GetComponent<Pot>();
if (p.type == 2 || p.type == 3 || p.type == 4)
{
punchLeft = false;
}
else
{
punchLeft = true;
}
if (KarateMan.instance.EligibleHits[currentHitInList].perfect)
{
Jukebox.PlayOneShotGame(p.hitSnd);
p.Hit();
HitEffectF(HitEffect.transform.localPosition);
switch (p.type)
{
case 0:
// HitParticle.Play();
break;
case 1:
GameObject bulbHit = Instantiate(BulbHit);
bulbHit.transform.parent = BulbHit.transform.parent;
bulbHit.SetActive(true);
Destroy(bulbHit, 0.7f);
break;
case 2:
// RockParticle.Play();
break;
case 4:
if (kickC != null) StopCoroutine(kickC);
kickC = StartCoroutine(PrepareKick());
BarrelDestroy(p, false);
break;
}
}
else
{
Jukebox.PlayOneShot("miss");
p.Miss();
}
p.isEligible = false;
p.RemoveObject(currentHitInList);
}
}
if (!canHit)
Jukebox.PlayOneShotGame("karateman/swingNoHit");
}
else
{
if (p.type == 2 || p.type == 3 || p.type == 4)
{
punchLeft = false;
}
else
{
punchLeft = true;
}
if (p.type == 4)
{
if (kickC != null) StopCoroutine(kickC);
kickC = StartCoroutine(PrepareKick());
}
if (!p.combo)
HitEffectF(HitEffect.transform.localPosition);
}
if (punchLeft)
AnimPlay("PunchLeft");
@ -332,71 +294,5 @@ namespace RhythmHeavenMania.Games.KarateMan
anim.Play(name, 0, 0);
anim.speed = 1;
}
private void BarrelDestroy(Pot p, bool combo)
{
for (int i = 0; i < 8; i++)
{
GameObject be = new GameObject();
be.transform.localPosition = p.Holder.transform.localPosition;
be.transform.parent = this.transform.parent;
be.transform.localScale = p.Holder.transform.localScale;
BarrelDestroyEffect bde = be.AddComponent<BarrelDestroyEffect>();
Vector3 pos = be.transform.localPosition;
SpriteRenderer sprite = be.AddComponent<SpriteRenderer>();
bde.shadow = Instantiate(p.Shadow, transform.parent);
bde.shadow.transform.position = p.Shadow.transform.position;
bde.shadow.transform.localScale = p.Shadow.transform.lossyScale;
bde.index = i;
bde.combo = combo;
switch (i)
{
case 0:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 35;
bde.spriteIndex = 3;
break;
case 1:
be.transform.localPosition = new Vector3(pos.x, pos.y + -0.55f);
sprite.sortingOrder = 31;
bde.spriteIndex = 3;
break;
case 2:
be.transform.localPosition = new Vector3(pos.x - 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
bde.spriteIndex = 0;
break;
case 3:
be.transform.localPosition = new Vector3(pos.x - 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
bde.spriteIndex = 1;
break;
case 4:
be.transform.localPosition = new Vector3(pos.x, pos.y + 0.45f);
sprite.sortingOrder = 34;
bde.spriteIndex = 2;
break;
case 5:
be.transform.localPosition = new Vector3(pos.x + 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
sprite.flipX = true;
bde.spriteIndex = 1;
break;
case 6:
be.transform.localPosition = new Vector3(pos.x + 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
sprite.flipX = true;
bde.spriteIndex = 0;
break;
case 7:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 39;
bde.spriteIndex = 4;
break;
}
}
}
}
}

View File

@ -2,6 +2,8 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RhythmHeavenMania.Util;
namespace RhythmHeavenMania.Games.KarateMan
{
public class Pot : PlayerActionObject
@ -58,12 +60,12 @@ namespace RhythmHeavenMania.Games.KarateMan
else
hitLength = 14f;
if (combo)
/*if (combo)
{
if (comboIndex == 0)
{
isEligible = true;
PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleCombos);
// PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleCombos);
}
else if (comboIndex == 5)
{
@ -73,12 +75,32 @@ namespace RhythmHeavenMania.Games.KarateMan
else
{
isEligible = true;
PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleHits);
}
// PlayerActionInit(this.gameObject, createBeat, KarateMan.instance.EligibleHits);
}*/
Sprite.GetComponent<SpriteRenderer>().enabled = false;
}
public override void OnAce()
{
if (combo)
{
if (comboIndex == 0)
{
KarateJoe.instance.Combo(this);
}
else if (comboIndex == 5)
{
KarateJoe.instance.ComboPow(this, true);
}
}
else
{
this.Hit();
}
// KarateJoe.instance.Swing(state);
}
private void Update()
{
if (Conductor.instance.songPositionInBeats >= createBeat)
@ -117,6 +139,42 @@ namespace RhythmHeavenMania.Games.KarateMan
StateCheck(normalizedBeat);
if (!combo)
{
if (PlayerInput.Pressed())
{
if (state.perfect)
{
Hit();
}
else if (state.notPerfect())
{
Miss();
}
}
}
else
{
if (comboIndex == 0)
{
if (PlayerInput.AltPressed())
{
if (state.perfect)
{
KarateJoe.instance.Combo(this);
}
}
}
else if (comboIndex == 5)
{
if (KarateJoe.instance.comboNormalizedBeat >= 2.05f)
if (PlayerInput.AltPressedUp())
{
KarateJoe.instance.ComboPow(this);
}
}
}
if (normalizedBeat > 1)
{
Sprite.GetComponent<SpriteRenderer>().sortingOrder = -20;
@ -163,9 +221,33 @@ namespace RhythmHeavenMania.Games.KarateMan
public void Hit()
{
Jukebox.PlayOneShotGame(hitSnd);
KarateJoe.instance.Swing(this);
NewHolder();
switch (type)
{
case 0:
// HitParticle.Play();
break;
case 1:
GameObject bulbHit = Instantiate(KarateJoe.instance.BulbHit);
bulbHit.transform.parent = KarateJoe.instance.BulbHit.transform.parent;
bulbHit.SetActive(true);
Destroy(bulbHit, 0.7f);
break;
case 2:
// RockParticle.Play();
break;
case 4:
BarrelDestroy(false);
break;
}
if (!kick)
{
NewHolder();
}
else if (kick)
{
@ -185,6 +267,8 @@ namespace RhythmHeavenMania.Games.KarateMan
public void Miss()
{
Jukebox.PlayOneShot("miss");
NewHolder();
Holder.transform.parent = newHolder.transform;
@ -201,5 +285,71 @@ namespace RhythmHeavenMania.Games.KarateMan
newHolder.transform.parent = this.gameObject.transform;
Holder.transform.parent = newHolder.transform;
}
public void BarrelDestroy(bool combo)
{
for (int i = 0; i < 8; i++)
{
GameObject be = new GameObject();
be.transform.localPosition = Holder.transform.localPosition;
be.transform.parent = this.transform.parent;
be.transform.localScale = Holder.transform.localScale;
BarrelDestroyEffect bde = be.AddComponent<BarrelDestroyEffect>();
Vector3 pos = be.transform.localPosition;
SpriteRenderer sprite = be.AddComponent<SpriteRenderer>();
bde.shadow = Instantiate(Shadow, transform.parent);
bde.shadow.transform.position = Shadow.transform.position;
bde.shadow.transform.localScale = Shadow.transform.lossyScale;
bde.index = i;
bde.combo = combo;
switch (i)
{
case 0:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 35;
bde.spriteIndex = 3;
break;
case 1:
be.transform.localPosition = new Vector3(pos.x, pos.y + -0.55f);
sprite.sortingOrder = 31;
bde.spriteIndex = 3;
break;
case 2:
be.transform.localPosition = new Vector3(pos.x - 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
bde.spriteIndex = 0;
break;
case 3:
be.transform.localPosition = new Vector3(pos.x - 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
bde.spriteIndex = 1;
break;
case 4:
be.transform.localPosition = new Vector3(pos.x, pos.y + 0.45f);
sprite.sortingOrder = 34;
bde.spriteIndex = 2;
break;
case 5:
be.transform.localPosition = new Vector3(pos.x + 0.5f, pos.y + 0.45f);
sprite.sortingOrder = 33;
sprite.flipX = true;
bde.spriteIndex = 1;
break;
case 6:
be.transform.localPosition = new Vector3(pos.x + 0.8f, pos.y + 0.45f);
sprite.sortingOrder = 32;
sprite.flipX = true;
bde.spriteIndex = 0;
break;
case 7:
be.transform.localPosition = new Vector3(pos.x, pos.y + 1.25f);
sprite.sortingOrder = 39;
bde.spriteIndex = 4;
break;
}
}
}
}
}

View File

@ -16,6 +16,8 @@ namespace RhythmHeavenMania.Games
public bool early;
public bool perfect;
public bool late;
public bool notPerfect() { return early || late; }
public bool eligible() { return early || perfect || late; }
public float createBeat;
}

View File

@ -13,6 +13,8 @@ namespace RhythmHeavenMania.Games
public List<Minigame.Eligible> eligibleHitsList = new List<Minigame.Eligible>();
private int aceTimes;
public void PlayerActionInit(GameObject g, float createBeat, List<Minigame.Eligible> eligibleHitsList)
{
state.gameObject = g;
@ -20,10 +22,23 @@ namespace RhythmHeavenMania.Games
this.eligibleHitsList = eligibleHitsList;
}
private void CheckForAce(float normalizedBeat)
{
if (aceTimes == 0)
{
if (GameManager.instance.autoplay && normalizedBeat > 0.99f)
{
OnAce();
AceVisuals();
aceTimes++;
}
}
}
// could possibly add support for custom early, perfect, and end times if needed.
public void StateCheck(float normalizedBeat)
{
if (!isEligible) return;
CheckForAce(normalizedBeat);
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
{
MakeEligible(true, false, false);
@ -69,6 +84,9 @@ namespace RhythmHeavenMania.Games
public void MakeInEligible()
{
state.early = false;
state.perfect = false;
state.late = false;
if (!inList) return;
eligibleHitsList.Remove(state);
@ -88,6 +106,7 @@ namespace RhythmHeavenMania.Games
// No list
public void StateCheckNoList(float normalizedBeat)
{
CheckForAce(normalizedBeat);
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
{
ModifyState(true, false, false);
@ -111,6 +130,18 @@ namespace RhythmHeavenMania.Games
}
}
public virtual void OnAce()
{
}
private void AceVisuals()
{
if (Editor.Timeline.instance != null)
{
Editor.Timeline.instance.AutoplayBTN.GetComponent<Animator>().Play("Ace", 0, 0);
}
}
private void ModifyState(bool early, bool perfect, bool late)
{
state.early = early;

View File

@ -7,19 +7,31 @@ namespace RhythmHeavenMania.Editor.Commands
{
public class Selection : IAction
{
List<TimelineEventObj> eventObjs;
public Selection(List<TimelineEventObj> eventObjs)
{
this.eventObjs = eventObjs;
}
public void Execute()
{
throw new System.NotImplementedException();
}
public void Redo()
{
throw new System.NotImplementedException();
for (int i = 0; i < eventObjs.Count; i++)
{
Selections.instance.ShiftClickSelect(eventObjs[i]);
}
}
public void Undo()
{
throw new System.NotImplementedException();
for (int i = 0; i < eventObjs.Count; i++)
{
Selections.instance.ShiftClickSelect(eventObjs[i]);
}
}
}
@ -69,7 +81,6 @@ namespace RhythmHeavenMania.Editor.Commands
public void Undo()
{
for (int i = 0; i < pos.Count; i++)
{
EnsureEventObj(i);
@ -86,10 +97,36 @@ namespace RhythmHeavenMania.Editor.Commands
}
}
public class Place : IAction
{
TimelineEventObj eventObj;
public Place(TimelineEventObj eventObj)
{
this.eventObj = eventObj;
}
public void Execute()
{
}
public void Redo()
{
throw new System.NotImplementedException();
}
public void Undo()
{
Selections.instance.Deselect(eventObj);
Timeline.instance.DestroyEventObject(eventObj.entity);
// Beatmap.Entity e = deletedObjs[i].entity;
// Timeline.instance.AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * Timeline.instance.LayerHeight()), e, true, e.eventObj.eventObjID);
}
}
public class Deletion : IAction
{
List<TimelineEventObj> eventObjs;
List<TimelineEventObj> deletedObjs;
public Deletion(List<TimelineEventObj> eventObjs)

View File

@ -60,11 +60,11 @@ namespace RhythmHeavenMania.Editor
GameIcon_.name = EventCaller.instance.minigames[i].displayName;
}
Tooltip.AddTooltip(NewBTN.gameObject, "New");
Tooltip.AddTooltip(OpenBTN.gameObject, "Open");
Tooltip.AddTooltip(SaveBTN.gameObject, "Save");
Tooltip.AddTooltip(UndoBTN.gameObject, "Undo");
Tooltip.AddTooltip(RedoBTN.gameObject, "Redo");
Tooltip.AddTooltip(NewBTN.gameObject, "New <color=#adadad>[Ctrl+N]</color>");
Tooltip.AddTooltip(OpenBTN.gameObject, "Open <color=#adadad>[Ctrl+O]</color>");
Tooltip.AddTooltip(SaveBTN.gameObject, "Save Project <color=#adadad>[Ctrl+S]</color>\nSave Project As <color=#adadad>[Ctrl+Alt+S]</color>");
Tooltip.AddTooltip(UndoBTN.gameObject, "Undo <color=#adadad>[Ctrl+Z]</color>");
Tooltip.AddTooltip(RedoBTN.gameObject, "Redo <color=#adadad>[Ctrl+Y or Ctrl+Shift+Z]</color>");
}
public void Update()
@ -100,6 +100,21 @@ namespace RhythmHeavenMania.Editor
else
RedoBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
if (Input.GetKey(KeyCode.LeftControl))
{
if (Input.GetKeyDown(KeyCode.Z))
{
if (Input.GetKey(KeyCode.LeftShift))
CommandManager.instance.Redo();
else
CommandManager.instance.Undo();
}
else if (Input.GetKeyDown(KeyCode.Y))
{
CommandManager.instance.Redo();
}
}
if (Input.GetMouseButtonUp(0) && Timeline.instance.CheckIfMouseInTimeline())
{
List<TimelineEventObj> selectedEvents = Timeline.instance.eventObjs.FindAll(c => c.selected == true && c.eligibleToMove == true);
@ -134,10 +149,12 @@ namespace RhythmHeavenMania.Editor
public void DebugSave()
{
// temp
#if UNITY_EDITOR
string path = UnityEditor.AssetDatabase.GetAssetPath(GameManager.instance.txt);
path = Application.dataPath.Remove(Application.dataPath.Length - 6, 6) + path;
System.IO.File.WriteAllText(path, JsonConvert.SerializeObject(GameManager.instance.Beatmap));
Debug.Log("Saved to " + path);
#endif
}
public void SetGameEventTitle(string txt)

View File

@ -159,14 +159,18 @@ namespace RhythmHeavenMania.Editor
if (Timeline.instance.CheckIfMouseInTimeline() && dragTimes < 1)
{
dragTimes++;
TimelineEventObj eventObj = new TimelineEventObj();
if (currentEventIndex == 0)
{
Timeline.instance.AddEventObject($"gameManager/switchGame/{mg.name}", true, new Vector3(0, 0), null, true);
eventObj = Timeline.instance.AddEventObject($"gameManager/switchGame/{mg.name}", true, new Vector3(0, 0), null, true, Timeline.RandomID());
}
else
{
Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0), null, true);
eventObj = Timeline.instance.AddEventObject(mg.name + "/" + mg.actions[currentEventIndex - 1].actionName, true, new Vector3(0, 0), null, true, Timeline.RandomID());
}
CommandManager.instance.Execute(new Commands.Place(eventObj));
}
}

View File

@ -30,6 +30,8 @@ namespace RhythmHeavenMania.Editor
{
DeselectAll();
eventsSelected.Add(eventToAdd);
// CommandManager.instance.Execute(new Commands.Selection(new List<TimelineEventObj>() { eventToAdd } ));
}
public void ShiftClickSelect(TimelineEventObj eventToAdd)

View File

@ -33,10 +33,11 @@ namespace RhythmHeavenMania.Editor
private RectTransform TimelineSongPosLine;
[Header("Timeline Playbar")]
[SerializeField] private Button PlayBTN;
[SerializeField] private Button PauseBTN;
[SerializeField] private Button StopBTN;
[SerializeField] private Button MetronomeBTN;
public Button PlayBTN;
public Button PauseBTN;
public Button StopBTN;
public Button MetronomeBTN;
public Button AutoplayBTN;
public static Timeline instance { get; private set; }
@ -51,7 +52,7 @@ namespace RhythmHeavenMania.Editor
var entity = GameManager.instance.Beatmap.entities[i];
var e = GameManager.instance.Beatmap.entities[i];
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, Starpelly.Random.Strings.RandomString(Starpelly.Enums.Strings.StringType.Alphanumeric, 128));
AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * LayerHeight()), e, false, RandomID());
}
TimelineSlider.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BeatMarkerCol.Hex2RGB();
@ -91,16 +92,36 @@ namespace RhythmHeavenMania.Editor
Conductor.instance.metronome = false;
}
});
AutoplayBTN.onClick.AddListener(delegate
{
if (!GameManager.instance.autoplay)
{
AutoplayBTN.GetComponent<Animator>().Play("Idle", 0, 0);
GameManager.instance.autoplay = true;
}
else
{
AutoplayBTN.GetComponent<Animator>().Play("Disabled", 0, 0);
GameManager.instance.autoplay = false;
}
});
Tooltip.AddTooltip(PlayBTN.gameObject, "Play <color=#adadad>[Space]</color>");
Tooltip.AddTooltip(PauseBTN.gameObject, "Pause <color=#adadad>[Shift + Space]</color>");
Tooltip.AddTooltip(StopBTN.gameObject, "Stop <color=#adadad>[Space]</color>");
Tooltip.AddTooltip(MetronomeBTN.gameObject, "Metronome");
Tooltip.AddTooltip(AutoplayBTN.gameObject, "Autoplay");
SetTimeButtonColors(true, false, false);
MetronomeBTN.transform.GetChild(0).GetComponent<Image>().color = Color.gray;
}
public static string RandomID()
{
return Starpelly.Random.Strings.RandomString(Starpelly.Enums.Strings.StringType.Alphanumeric, 128);
}
#endregion
private void Update()

View File

@ -96,7 +96,13 @@ namespace RhythmHeavenMania
new GameAction("prepare", delegate { KarateMan.instance.Prepare(eventCaller.currentBeat, eventCaller.currentLength); }, 1f, true),
new GameAction("bgfxon", delegate { KarateMan.instance.BGFXOn(); } ),
new GameAction("bgfxoff", delegate { KarateMan.instance.BGFXOff(); }),
})
}),
/*new Minigame("spaceSoccer", "Space Soccer", "70A8D8", new List<GameAction>()
{
new GameAction("ball dispense", delegate { }, 2f),
new GameAction("keep-up", delegate { }, 4f, true),
new GameAction("high kick-toe!", delegate { }, 3f),
})*/
};
}
}

View File

@ -8,33 +8,33 @@ namespace RhythmHeavenMania
{
public static bool Pressed()
{
return Input.GetKeyDown(KeyCode.Z);
return Input.GetKeyDown(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
public static bool PressedUp()
{
return Input.GetKeyUp(KeyCode.Z);
return Input.GetKeyUp(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
public static bool Pressing()
{
return Input.GetKey(KeyCode.Z);
return Input.GetKey(KeyCode.Z) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
public static bool AltPressed()
{
return Input.GetKeyDown(KeyCode.X);
return Input.GetKeyDown(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
public static bool AltPressedUp()
{
return Input.GetKeyUp(KeyCode.X);
return Input.GetKeyUp(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
public static bool AltPressing()
{
return Input.GetKey(KeyCode.X);
return Input.GetKey(KeyCode.X) && !GameManager.instance.autoplay && Conductor.instance.isPlaying;
}
}
}

View File

@ -0,0 +1,64 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.ShortcutManagement;
#endif
using System.Linq;
#if UNITY_EDITOR
[InitializeOnLoad]
public class SwitchShortcutsProfileOnPlay
{
private const string PlayingProfileId = "Playing";
private static string _activeProfileId;
private static bool _switched;
static SwitchShortcutsProfileOnPlay()
{
EditorApplication.playModeStateChanged += DetectPlayModeState;
}
private static void SetActiveProfile(string profileId)
{
Debug.Log($"Activating Shortcut profile \"{profileId}\"");
ShortcutManager.instance.activeProfileId = profileId;
}
private static void DetectPlayModeState(PlayModeStateChange state)
{
switch (state)
{
case PlayModeStateChange.EnteredPlayMode:
OnEnteredPlayMode();
break;
case PlayModeStateChange.ExitingPlayMode:
OnExitingPlayMode();
break;
}
}
private static void OnExitingPlayMode()
{
if (!_switched)
return;
_switched = false;
SetActiveProfile("Default");
}
private static void OnEnteredPlayMode()
{
_activeProfileId = ShortcutManager.instance.activeProfileId;
if (_activeProfileId.Equals(PlayingProfileId))
return; // Same as active
var allProfiles = ShortcutManager.instance.GetAvailableProfileIds().ToList();
if (!allProfiles.Contains(PlayingProfileId))
return; // Couldn't find PlayingProfileId
_switched = true;
SetActiveProfile("Playing");
}
}
#endif

View File

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