Multiple events can now be called onto same frame + more Spaceball camera fixes
This commit is contained in:
parent
417986c08c
commit
95ac1306d4
|
@ -7476,7 +7476,7 @@ Camera:
|
||||||
y: 0
|
y: 0
|
||||||
width: 1
|
width: 1
|
||||||
height: 1
|
height: 1
|
||||||
near clip plane: 0.3
|
near clip plane: 0.01
|
||||||
far clip plane: 1000
|
far clip plane: 1000
|
||||||
field of view: 53.15
|
field of view: 53.15
|
||||||
orthographic: 0
|
orthographic: 0
|
||||||
|
@ -14209,7 +14209,7 @@ MonoBehaviour:
|
||||||
currentEvent: 0
|
currentEvent: 0
|
||||||
currentPlayerEvent: 0
|
currentPlayerEvent: 0
|
||||||
txt: {fileID: 4900000, guid: 50b54b23c06076c4598134813da27f18, type: 3}
|
txt: {fileID: 4900000, guid: 50b54b23c06076c4598134813da27f18, type: 3}
|
||||||
startOffset: 0
|
startOffset: 0.5
|
||||||
GameCamera: {fileID: 519420031}
|
GameCamera: {fileID: 519420031}
|
||||||
CursorCam: {fileID: 79134728}
|
CursorCam: {fileID: 79134728}
|
||||||
CircleCursor: {fileID: 1855769658}
|
CircleCursor: {fileID: 1855769658}
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace RhythmHeavenMania
|
||||||
{
|
{
|
||||||
new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, true ),
|
new GameAction("shoot", delegate { Spaceball.instance.Shoot(currentBeat, false, currentType); }, true ),
|
||||||
new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(currentBeat, true, 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> temp1 = GameManager.instance.Beatmap.entities.FindAll(c => c.datamodel.Split('/')[0] == gameName);
|
||||||
List<Beatmap.Entity> temp2 = new List<Beatmap.Entity>();
|
List<Beatmap.Entity> temp2 = new List<Beatmap.Entity>();
|
||||||
|
|
|
@ -4,7 +4,7 @@ MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences: []
|
defaultReferences: []
|
||||||
executionOrder: 0
|
executionOrder: 150
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
|
|
|
@ -37,7 +37,8 @@ namespace RhythmHeavenMania
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
// before Start() since this is very important
|
||||||
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
SortEventsList();
|
SortEventsList();
|
||||||
|
|
||||||
|
@ -71,11 +72,14 @@ namespace RhythmHeavenMania
|
||||||
if (Input.GetKeyDown(KeyCode.A))
|
if (Input.GetKeyDown(KeyCode.A))
|
||||||
{
|
{
|
||||||
Conductor.instance.musicSource.time += 3;
|
Conductor.instance.musicSource.time += 3;
|
||||||
|
SetCurrentEventToClosest();
|
||||||
|
GetGame(currentGame).holder.GetComponent<Minigame>().OnTimeChange();
|
||||||
}
|
}
|
||||||
else if (Input.GetKeyDown(KeyCode.S))
|
else if (Input.GetKeyDown(KeyCode.S))
|
||||||
{
|
{
|
||||||
Conductor.instance.musicSource.time -= 3;
|
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();
|
List<float> entities = Beatmap.entities.Select(c => c.beat).ToList();
|
||||||
|
@ -84,9 +88,18 @@ namespace RhythmHeavenMania
|
||||||
{
|
{
|
||||||
if (Conductor.instance.songPositionInBeats >= entities[currentEvent])
|
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);
|
||||||
|
|
||||||
currentEvent++;
|
for (int i = 0; i < entitesAtSameBeat.Count; i++)
|
||||||
|
{
|
||||||
|
eventCaller.CallEvent(entitesAtSameBeat[i].datamodel);
|
||||||
|
currentEvent++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// eventCaller.CallEvent(Beatmap.entities[currentEvent].datamodel);
|
||||||
|
|
||||||
|
// currentEvent++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,18 +60,17 @@ namespace RhythmHeavenMania.Games.ClappyTrio
|
||||||
lastClapLength = 0;
|
lastClapLength = 0;
|
||||||
lastClapBeat = 0;
|
lastClapBeat = 0;
|
||||||
hit = false;
|
hit = false;
|
||||||
ClearLog();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearLog()
|
/*public void ClearLog()
|
||||||
{
|
{
|
||||||
var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor));
|
var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor));
|
||||||
var type = assembly.GetType("UnityEditor.LogEntries");
|
var type = assembly.GetType("UnityEditor.LogEntries");
|
||||||
var method = type.GetMethod("Clear");
|
var method = type.GetMethod("Clear");
|
||||||
method.Invoke(new object(), null);
|
method.Invoke(new object(), null);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
public void SetClapAvailability(float startBeat, float length)
|
public void SetClapAvailability(float startBeat, float length)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,5 +44,10 @@ namespace RhythmHeavenMania.Games
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public virtual void OnTimeChange()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,13 +15,16 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||||
public GameObject Dust;
|
public GameObject Dust;
|
||||||
|
|
||||||
private float lastCamDistance;
|
private float lastCamDistance;
|
||||||
private bool zoomingCamera = false;
|
private float currentZoomCamBeat;
|
||||||
private float lastZoomCamBeat;
|
private float currentZoomCamLength;
|
||||||
private float lastZoomCamLength;
|
private float currentZoomCamDistance;
|
||||||
private float lastZoomCamDistance;
|
|
||||||
|
private int currentZoomIndex;
|
||||||
|
|
||||||
public Sprite[] Balls;
|
public Sprite[] Balls;
|
||||||
|
|
||||||
|
private List<Beatmap.Entity> allCameraEvents = new List<Beatmap.Entity>();
|
||||||
|
|
||||||
public static Spaceball instance { get; set; }
|
public static Spaceball instance { get; set; }
|
||||||
|
|
||||||
public override void OnGameSwitch()
|
public override void OnGameSwitch()
|
||||||
|
@ -32,11 +35,21 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||||
SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count);
|
SpaceballPlayer.instance.EligibleHits.RemoveRange(0, SpaceballPlayer.instance.EligibleHits.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnTimeChange()
|
||||||
|
{
|
||||||
|
UpdateCameraZoom();
|
||||||
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
UpdateCameraZoom();
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
var allPlayerActions = EventCaller.GetAllPlayerEntities("spaceball");
|
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);
|
if (Conductor.instance.songPositionInBeats >= allCameraEvents[currentZoomIndex].beat)
|
||||||
float newPosZ = Mathf.Lerp(lastCamDistance, lastZoomCamDistance, normalizedBeat);
|
{
|
||||||
GameManager.instance.GameCamera.transform.localPosition = new Vector3(0, 0, newPosZ);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateCameraZoom()
|
||||||
public void CameraZoom(float beat, float length, float distance)
|
|
||||||
{
|
{
|
||||||
lastZoomCamBeat = beat;
|
allCameraEvents = EventCaller.GetAllInGameManagerList("spaceball", new string[] { "cameraZoom" });
|
||||||
lastZoomCamLength = length;
|
|
||||||
|
|
||||||
float dist = distance;
|
if (currentZoomIndex < allCameraEvents.Count && currentZoomIndex >= 0)
|
||||||
dist = dist * -1;
|
{
|
||||||
|
if (currentZoomIndex - 1 >= 0)
|
||||||
|
lastCamDistance = allCameraEvents[currentZoomIndex - 1].valA * -1;
|
||||||
|
else
|
||||||
|
lastCamDistance = allCameraEvents[0].valA * -1;
|
||||||
|
|
||||||
if (dist > 0)
|
currentZoomCamBeat = allCameraEvents[currentZoomIndex].beat;
|
||||||
lastZoomCamDistance = 0;
|
currentZoomCamLength = allCameraEvents[currentZoomIndex].length;
|
||||||
else
|
|
||||||
lastZoomCamDistance = dist;
|
|
||||||
|
|
||||||
zoomingCamera = true;
|
float dist = allCameraEvents[currentZoomIndex].valA * -1;
|
||||||
lastCamDistance = GameManager.instance.GameCamera.transform.localPosition.z;
|
|
||||||
|
print(dist);
|
||||||
|
|
||||||
|
if (dist > 0)
|
||||||
|
currentZoomCamDistance = 0;
|
||||||
|
else
|
||||||
|
currentZoomCamDistance = dist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Shoot(float beat, bool high, string type)
|
public void Shoot(float beat, bool high, string type)
|
||||||
|
|
|
@ -73,6 +73,10 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||||
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
|
Instantiate(Spaceball.instance.Dust, Spaceball.instance.Dust.transform.parent).SetActive(true);
|
||||||
Destroy(this.gameObject);
|
Destroy(this.gameObject);
|
||||||
}
|
}
|
||||||
|
else if (Conductor.instance.songPositionInBeats < startBeat)
|
||||||
|
{
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MakeEligible(bool early, bool perfect, bool late)
|
public void MakeEligible(bool early, bool perfect, bool late)
|
||||||
|
|
|
@ -45,7 +45,7 @@ namespace RhythmHeavenMania.Games.Spaceball
|
||||||
if (EligibleHits[currentHitInList].perfect)
|
if (EligibleHits[currentHitInList].perfect)
|
||||||
{
|
{
|
||||||
Jukebox.PlayOneShotGame("spaceball/hit");
|
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<SpaceballBall>().enabled = false;
|
||||||
EligibleHits[currentHitInList].gameObject.GetComponent<Animator>().enabled = false;
|
EligibleHits[currentHitInList].gameObject.GetComponent<Animator>().enabled = false;
|
||||||
|
|
|
@ -1,23 +1,29 @@
|
||||||
{
|
{
|
||||||
"bpm": 105,
|
"bpm": 105,
|
||||||
"entities": [
|
"entities": [
|
||||||
|
{
|
||||||
|
"beat": 0,
|
||||||
|
"length": 0,
|
||||||
|
"valA": 170,
|
||||||
|
"datamodel": "spaceball/cameraZoom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"beat": 0,
|
||||||
|
"length": 4,
|
||||||
|
"valA": 10,
|
||||||
|
"datamodel":"spaceball/cameraZoom"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"beat": 4,
|
"beat": 4,
|
||||||
"type": "riceball",
|
"type": "riceball",
|
||||||
"datamodel": "spaceball/shoot"
|
"datamodel": "spaceball/shoot"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"beat": 4,
|
"beat": 8,
|
||||||
"length": 42,
|
"length": 42,
|
||||||
"valA": 30,
|
"valA": 30,
|
||||||
"datamodel": "spaceball/cameraZoom"
|
"datamodel": "spaceball/cameraZoom"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"beat": 44,
|
|
||||||
"length": 2,
|
|
||||||
"valA": 170,
|
|
||||||
"datamodel": "spaceball/cameraZoom"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"beat": 6,
|
"beat": 6,
|
||||||
"datamodel": "spaceball/shoot"
|
"datamodel": "spaceball/shoot"
|
||||||
|
@ -43,12 +49,12 @@
|
||||||
"datamodel": "gameManager/switchGame/clappyTrio"
|
"datamodel": "gameManager/switchGame/clappyTrio"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"beat": 16,
|
"beat": 17,
|
||||||
"length": 2,
|
"length": 2,
|
||||||
"datamodel": "clappyTrio/clap"
|
"datamodel": "clappyTrio/clap"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"beat": 21,
|
"beat": 22,
|
||||||
"datamodel": "gameManager/switchGame/spaceball"
|
"datamodel": "gameManager/switchGame/spaceball"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -104,6 +110,12 @@
|
||||||
{
|
{
|
||||||
"beat": 44,
|
"beat": 44,
|
||||||
"datamodel": "spaceball/shootHigh"
|
"datamodel": "spaceball/shootHigh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"beat": 44,
|
||||||
|
"length": 2,
|
||||||
|
"valA": 170,
|
||||||
|
"datamodel": "spaceball/cameraZoom"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -5,13 +5,7 @@ EditorBuildSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes:
|
m_Scenes:
|
||||||
- enabled: 1
|
|
||||||
path: Assets/Scenes/Menu.unity
|
|
||||||
guid: 1acb71090c3028849a57a2c234e53a6d
|
|
||||||
- enabled: 1
|
- enabled: 1
|
||||||
path: Assets/Scenes/Game.unity
|
path: Assets/Scenes/Game.unity
|
||||||
guid: 2cda990e2423bbf4892e6590ba056729
|
guid: 2cda990e2423bbf4892e6590ba056729
|
||||||
- enabled: 1
|
|
||||||
path: Assets/Scenes/Rating.unity
|
|
||||||
guid: 536b14300e086f04785985e8e915ca09
|
|
||||||
m_configObjects: {}
|
m_configObjects: {}
|
||||||
|
|
Loading…
Reference in a new issue