Multiple events can now be called onto same frame + more Spaceball camera fixes

This commit is contained in:
Starpelly 2021-12-26 00:11:54 -05:00
parent 417986c08c
commit 95ac1306d4
11 changed files with 128 additions and 48 deletions

View file

@ -7476,7 +7476,7 @@ Camera:
y: 0
width: 1
height: 1
near clip plane: 0.3
near clip plane: 0.01
far clip plane: 1000
field of view: 53.15
orthographic: 0
@ -14209,7 +14209,7 @@ MonoBehaviour:
currentEvent: 0
currentPlayerEvent: 0
txt: {fileID: 4900000, guid: 50b54b23c06076c4598134813da27f18, type: 3}
startOffset: 0
startOffset: 0.5
GameCamera: {fileID: 519420031}
CursorCam: {fileID: 79134728}
CircleCursor: {fileID: 1855769658}

View file

@ -90,7 +90,7 @@ namespace RhythmHeavenMania
{
new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, true ),
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(currentBeat, true, currentType); }, true ),
new GameAction("cameraZoom", delegate { Spaceball.instance.CameraZoom(currentBeat, currentLength, currentValA); } ),
// new GameAction("cameraZoom", delegate { Spaceball.instance.CameraZoom(currentBeat, currentLength, currentValA); } ),
})
};
@ -148,7 +148,21 @@ namespace RhythmHeavenMania
}
}
public static List<Beatmap.Entity> GetAllInGameManagerList(string gameName, string[] exclude)
public static List<Beatmap.Entity> GetAllInGameManagerList(string gameName, string[] include)
{
List<Beatmap.Entity> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
List<Beatmap.Entity> temp2 = new List<Beatmap.Entity>();
for (int i = 0; i < temp1.Count; i++)
{
if (include.Any(temp1[i].datamodel.Split('/')[1].Contains))
{
temp2.Add(temp1[i]);
}
}
return temp2;
}
public static List<Beatmap.Entity> GetAllInGameManagerListExclude(string gameName, string[] exclude)
{
List<Beatmap.Entity> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
List<Beatmap.Entity> temp2 = new List<Beatmap.Entity>();

View file

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 150
icon: {instanceID: 0}
userData:
assetBundleName:

View file

@ -37,7 +37,8 @@ namespace RhythmHeavenMania
instance = this;
}
private void Start()
// before Start() since this is very important
private void OnEnable()
{
SortEventsList();
@ -71,11 +72,14 @@ namespace RhythmHeavenMania
if (Input.GetKeyDown(KeyCode.A))
{
Conductor.instance.musicSource.time += 3;
SetCurrentEventToClosest();
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
}
else if (Input.GetKeyDown(KeyCode.S))
{
Conductor.instance.musicSource.time -= 3;
GameManager.instance.SetCurrentEventToClosest();
SetCurrentEventToClosest();
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
}
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
@ -84,10 +88,19 @@ namespace RhythmHeavenMania
{
if (Conductor.instance.songPositionInBeats >= entities[currentEvent])
{
eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel);
// allows for multiple events on the same beat to be executed on the same frame, so no more 1-frame delay
List<Beatmap.Entity> entitesAtSameBeat = Beatmap.entities.FindAll(c => c.beat == Beatmap.entities[currentEvent].beat);
for (int i = 0; i < entitesAtSameBeat.Count; i++)
{
eventCaller.CallEvent(entitesAtSameBeat[i].datamodel);
currentEvent++;
}
// eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel);
// currentEvent++;
}
}
}

View file

@ -60,18 +60,17 @@ namespace RhythmHeavenMania.Games.ClappyTrio
lastClapLength = 0;
lastClapBeat = 0;
hit = false;
ClearLog();
}
}
}
public void ClearLog()
/*public void ClearLog()
{
var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor));
var type = assembly.GetType("UnityEditor.LogEntries");
var method = type.GetMethod("Clear");
method.Invoke(new object(), null);
}
}*/
public void SetClapAvailability(float startBeat, float length)
{

View file

@ -44,5 +44,10 @@ namespace RhythmHeavenMania.Games
{
}
public virtual void OnTimeChange()
{
}
}
}

View file

@ -15,13 +15,16 @@ namespace RhythmHeavenMania.Games.Spaceball
public GameObject Dust;
private float lastCamDistance;
private bool zoomingCamera = false;
private float lastZoomCamBeat;
private float lastZoomCamLength;
private float lastZoomCamDistance;
private float currentZoomCamBeat;
private float currentZoomCamLength;
private float currentZoomCamDistance;
private int currentZoomIndex;
public Sprite[] Balls;
private List<Beatmap.Entity> allCameraEvents = new List<Beatmap.Entity>();
public static Spaceball instance { get; set; }
public override void OnGameSwitch()
@ -32,11 +35,21 @@ namespace RhythmHeavenMania.Games.Spaceball
SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count);
}
public override void OnTimeChange()
{
UpdateCameraZoom();
}
private void Awake()
{
instance = this;
}
private void Start()
{
UpdateCameraZoom();
}
private void Update()
{
var allPlayerActions = EventCaller.GetAllPlayerEntities("spaceball");
@ -50,30 +63,56 @@ namespace RhythmHeavenMania.Games.Spaceball
}
}
if (zoomingCamera)
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
{
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(lastZoomCamBeat, lastZoomCamLength);
float newPosZ = Mathf.Lerp(lastCamDistance, lastZoomCamDistance, normalizedBeat);
if (Conductor.instance.songPositionInBeats >= allCameraEvents[currentZoomIndex].beat)
{
UpdateCameraZoom();
currentZoomIndex++;
}
}
float normalizedBeat = Conductor.instance.GetLoopPositionFromBeat(currentZoomCamBeat, currentZoomCamLength);
if (normalizedBeat > Minigame.EndTime())
{
lastCamDistance = GameManager.instance.GameCamera.transform.localPosition.z;
}
else
{
if (currentZoomCamLength <= 0)
GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, currentZoomCamDistance);
else
{
float newPosZ = Mathf.Lerp(lastCamDistance, currentZoomCamDistance, normalizedBeat);
GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, newPosZ);
}
}
}
public void CameraZoom(float beat, float length, float distance)
private void UpdateCameraZoom()
{
lastZoomCamBeat = beat;
lastZoomCamLength = length;
allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "cameraZoom" });
float dist = distance;
dist = dist * -1;
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
{
if (currentZoomIndex - 1 >= 0)
lastCamDistance = allCameraEvents[currentZoomIndex - 1].valA * -1;
else
lastCamDistance = allCameraEvents[0].valA * -1;
currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat;
currentZoomCamLength = allCameraEvents[currentZoomIndex].length;
float dist = allCameraEvents[currentZoomIndex].valA * -1;
print(dist);
if (dist > 0)
lastZoomCamDistance = 0;
currentZoomCamDistance = 0;
else
lastZoomCamDistance = dist;
zoomingCamera = true;
lastCamDistance = GameManager.instance.GameCamera.transform.localPosition.z;
currentZoomCamDistance = dist;
}
}
public void Shoot(float beat, bool high, string type)

View file

@ -73,6 +73,10 @@ namespace RhythmHeavenMania.Games.Spaceball
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
Destroy(this.gameObject);
}
else if (Conductor.instance.songPositionInBeats < startBeat)
{
Destroy(this.gameObject);
}
}
public void MakeEligible(bool early, bool perfect, bool late)

View file

@ -45,7 +45,7 @@ namespace RhythmHeavenMania.Games.Spaceball
if (EligibleHits[currentHitInList].perfect)
{
Jukebox.PlayOneShotGame("spaceball/hit");
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().Holder.transform.DOMove(new Vector3(Random.Range(5, 25), 0, -600), 5f);
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().Holder.transform.DOLocalMove(new Vector3(Random.Range(0, 8), 0, -600), 5f);
EligibleHits[currentHitInList].gameObject.GetComponent<SpaceballBall>().enabled = false;
EligibleHits[currentHitInList].gameObject.GetComponent<Animator>().enabled = false;

View file

@ -1,23 +1,29 @@
{
"bpm": 105,
"entities": [
{
"beat": 0,
"length": 0,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 0,
"length": 4,
"valA": 10,
"datamodel":"spaceball/cameraZoom"
},
{
"beat": 4,
"type": "riceball",
"datamodel": "spaceball/shoot"
},
{
"beat": 4,
"beat": 8,
"length": 42,
"valA": 30,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 44,
"length": 2,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
},
{
"beat": 6,
"datamodel": "spaceball/shoot"
@ -43,12 +49,12 @@
"datamodel": "gameManager/switchGame/clappyTrio"
},
{
"beat": 16,
"beat": 17,
"length": 2,
"datamodel": "clappyTrio/clap"
},
{
"beat": 21,
"beat": 22,
"datamodel": "gameManager/switchGame/spaceball"
},
{
@ -104,6 +110,12 @@
{
"beat": 44,
"datamodel": "spaceball/shootHigh"
},
{
"beat": 44,
"length": 2,
"valA": 170,
"datamodel": "spaceball/cameraZoom"
}
]
}

View file

@ -5,13 +5,7 @@ EditorBuildSettings:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/Menu.unity
guid: 1acb71090c3028849a57a2c234e53a6d
- enabled: 1
path: Assets/Scenes/Game.unity
guid: 2cda990e2423bbf4892e6590ba056729
- enabled: 1
path: Assets/Scenes/Rating.unity
guid: 536b14300e086f04785985e8e915ca09
m_configObjects: {}