mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 10:17:37 +02:00
Tram&Pauline
Animation mostly done perfectly
This commit is contained in:
@ -20,6 +20,7 @@ namespace HeavenStudio
|
||||
|
||||
public List<Entity> entities = new List<Entity>();
|
||||
public List<TempoChange> tempoChanges = new List<TempoChange>();
|
||||
public List<VolumeChange> volumeChanges = new List<VolumeChange>();
|
||||
public float firstBeatOffset;
|
||||
|
||||
[Serializable]
|
||||
@ -53,6 +54,12 @@ namespace HeavenStudio
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
|
||||
public Entity DeepCopy()
|
||||
{
|
||||
//lol the AI generated this
|
||||
return JsonConvert.DeserializeObject<Entity>(JsonConvert.SerializeObject(this));
|
||||
}
|
||||
|
||||
public object this[string propertyName]
|
||||
{
|
||||
get
|
||||
@ -85,5 +92,18 @@ namespace HeavenStudio
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class VolumeChange : ICloneable
|
||||
{
|
||||
public float beat;
|
||||
public float length;
|
||||
public float volume;
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return this.MemberwiseClone();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/Games/FirstContact.meta
Normal file
8
Assets/Scripts/Games/FirstContact.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb2fdb673d6d1c34ab348b9c0da08705
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
113
Assets/Scripts/Games/FirstContact/AlienFirstContact.cs
Normal file
113
Assets/Scripts/Games/FirstContact/AlienFirstContact.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_FirstContact
|
||||
{
|
||||
public class AlienFirstContact : PlayerActionObject
|
||||
{
|
||||
public float createBeat;
|
||||
FirstContact game;
|
||||
Translator translator;
|
||||
bool hasSpoke;
|
||||
public float stateBeat;
|
||||
public bool prefabHolder;
|
||||
bool missed;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = FirstContact.instance;
|
||||
translator = GameObject.Find("Games/firstContact/Translator").GetComponent<Translator>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (hasSpoke)
|
||||
{
|
||||
return;
|
||||
}
|
||||
stateBeat = Conductor.instance.GetPositionFromMargin(createBeat + game.beatInterval, 1f);
|
||||
StateCheck(stateBeat);
|
||||
if (PlayerInput.Pressed(true))
|
||||
{
|
||||
if (state.eligible())
|
||||
{
|
||||
if (!game.hasMissed)
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
else
|
||||
{
|
||||
Eh();
|
||||
}
|
||||
|
||||
}
|
||||
else if (state.notPerfect() && game.translatorSpeakCount > 0)
|
||||
{
|
||||
Eh();
|
||||
}
|
||||
//else if (stateBeat > Minigame.LateTime() && game.translatorSpeakCount == 0)
|
||||
//{
|
||||
// //Debug.Log("OW");
|
||||
// Miss();
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
if (stateBeat > Minigame.LateTime())
|
||||
{
|
||||
if (!missed)
|
||||
{
|
||||
MissNoHit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void Ace()
|
||||
{
|
||||
translator.successTranslation(true);
|
||||
game.isCorrect = true;
|
||||
game.translatorSpeakCount++;
|
||||
hasSpoke = true;
|
||||
missed = false;
|
||||
}
|
||||
|
||||
public void Miss()
|
||||
{
|
||||
translator.successTranslation(false);
|
||||
game.isCorrect = false;
|
||||
hasSpoke = true;
|
||||
missed = false;
|
||||
}
|
||||
|
||||
|
||||
public void MissNoHit()
|
||||
{
|
||||
game.alienNoHit();
|
||||
game.isCorrect = false;
|
||||
missed = true;
|
||||
game.hasMissed = true;
|
||||
}
|
||||
|
||||
public void Eh()
|
||||
{
|
||||
translator.ehTranslation();
|
||||
hasSpoke = true;
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
{
|
||||
Ace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/Games/FirstContact/AlienFirstContact.cs.meta
Normal file
11
Assets/Scripts/Games/FirstContact/AlienFirstContact.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47ef82bd935047f42b39142f4a1b1d32
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
311
Assets/Scripts/Games/FirstContact/FirstContact.cs
Normal file
311
Assets/Scripts/Games/FirstContact/FirstContact.cs
Normal file
@ -0,0 +1,311 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
|
||||
public static class CtrFirstContact
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller)
|
||||
{
|
||||
return new Minigame("firstContact", "First Contact", "008c97", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("beat intervals", delegate { FirstContact.instance.SetIntervalStart(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 4f, true),
|
||||
new GameAction("alien speak", delegate { FirstContact.instance.alienSpeak(eventCaller.currentEntity.beat); }, 0.5f, false),
|
||||
new GameAction("alien turnover", delegate { FirstContact.instance.alienTurnOver(eventCaller.currentEntity.beat); }, 0.5f, false),
|
||||
new GameAction("alien success", delegate { FirstContact.instance.alienSuccess(eventCaller.currentEntity.beat); }, 1f, false),
|
||||
new GameAction("mission control", delegate { FirstContact.instance.missionControlDisplay(eventCaller.currentEntity.beat, eventCaller.currentEntity.toggle); }, 1f, false, new List<Param>
|
||||
{
|
||||
new Param("toggle", false, "Stay", "If it's the end of the remix/song")
|
||||
}),
|
||||
new GameAction("look at", delegate { FirstContact.instance.lookAtDirection(eventCaller.currentEntity.type, eventCaller.currentEntity.type2); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", FirstContact.alienLookAt.lookAtTranslator, "alien look at what", "[Alien] will look at what"),
|
||||
new Param("type", FirstContact.translatorLookAt.lookAtAlien, "translator look at what", "[Translator] will look at what"),
|
||||
}),
|
||||
|
||||
//new GameAction("Version of First Contact", delegate { FirstContact.instance.versionOfFirstContact(eventCaller.currentEntity.type); }, .5f, false, new List<Param>
|
||||
//{
|
||||
// new Param("type", FirstContact.VersionOfContact.FirstContact, "Version", "Version of First Contact to play"),
|
||||
//}),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_FirstContact;
|
||||
|
||||
public class FirstContact : Minigame
|
||||
{
|
||||
public static FirstContact instance { get; private set; }
|
||||
|
||||
[Header("Properties")]
|
||||
public int alienSpeakCount;
|
||||
public int translatorSpeakCount;
|
||||
public bool hasMissed;
|
||||
private float lastReportedBeat = 0f;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] GameObject alien;
|
||||
[SerializeField] Translator translator;
|
||||
[SerializeField] GameObject alienSpeech;
|
||||
[SerializeField] GameObject dummyHolder;
|
||||
[SerializeField] GameObject missionControl;
|
||||
[SerializeField] GameObject liveBar;
|
||||
|
||||
[Header("Variables")]
|
||||
public bool intervalStarted;
|
||||
//float intervalStartBeat;
|
||||
public float beatInterval = 4f;
|
||||
public bool isCorrect, noHitOnce, isSpeaking;
|
||||
//public int version;
|
||||
public float lookAtLength = 1f;
|
||||
|
||||
//public enum VersionOfContact
|
||||
//{
|
||||
// FirstContact,
|
||||
// CitrusRemix,
|
||||
// SecondContact
|
||||
//}
|
||||
|
||||
public enum alienLookAt
|
||||
{
|
||||
lookAtTranslator,
|
||||
idle
|
||||
}
|
||||
|
||||
public enum translatorLookAt
|
||||
{
|
||||
lookAtAlien,
|
||||
idle
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
translator.Init();
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
//This is taken from the conductor script
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
{
|
||||
liveBar.GetComponent<Animator>().Play("liveBar", 0, 0);
|
||||
}
|
||||
else if(Conductor.instance.songPositionInBeats < lastReportedBeat)
|
||||
{
|
||||
lastReportedBeat = Mathf.Round(Conductor.instance.songPositionInBeats);
|
||||
}
|
||||
}
|
||||
|
||||
//public void versionOfFirstContact(int type)
|
||||
//{
|
||||
// version = type;
|
||||
//}
|
||||
|
||||
public void lookAtDirection(int alienLookAt, int translatorLookAt)
|
||||
{
|
||||
switch (alienLookAt)
|
||||
{
|
||||
case 0:
|
||||
alien.GetComponent<Animator>().Play("alien_lookAt", 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
alien.GetComponent<Animator>().Play("alien_idle", 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (translatorLookAt)
|
||||
{
|
||||
case 0:
|
||||
translator.GetComponent<Animator>().Play("translator_lookAtAlien", 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
translator.GetComponent<Animator>().Play("translator_idle", 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void alienSpeak(float beat)
|
||||
{
|
||||
//if (!intervalStarted)
|
||||
//{
|
||||
// SetIntervalStart(beat, beatInterval);
|
||||
//}
|
||||
//missionControl.SetActive(false);
|
||||
Jukebox.PlayOneShotGame("firstContact/alien");
|
||||
|
||||
var random = Random.Range(0, 2);
|
||||
string textToPut = "";
|
||||
if(random == 0)
|
||||
{
|
||||
textToPut = "translator_lookAtAlien";
|
||||
}
|
||||
else
|
||||
{
|
||||
textToPut = "translator_lookAtAlien_nod";
|
||||
}
|
||||
|
||||
|
||||
BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_talk", 0, 0); }),
|
||||
new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play(textToPut, 0, 0); }),
|
||||
});
|
||||
|
||||
AlienFirstContact a = Instantiate(alienSpeech, dummyHolder.transform).GetComponent<AlienFirstContact>();
|
||||
a.GetComponent<AlienFirstContact>().createBeat = beat;
|
||||
alienSpeakCount++;
|
||||
}
|
||||
|
||||
public void alienTurnOver(float beat)
|
||||
{
|
||||
//if (!intervalStarted)
|
||||
//{
|
||||
// SetIntervalStart(beat, beatInterval);
|
||||
//}
|
||||
|
||||
Jukebox.PlayOneShotGame("firstContact/turnover");
|
||||
|
||||
BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_point", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play("alien_idle", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); })
|
||||
});
|
||||
|
||||
isSpeaking = true;
|
||||
}
|
||||
|
||||
public void SetIntervalStart(float beat, float interval = 4f)
|
||||
{
|
||||
if (!intervalStarted)
|
||||
{
|
||||
alienSpeakCount = 0;
|
||||
translatorSpeakCount = 0;
|
||||
intervalStarted = true;
|
||||
}
|
||||
|
||||
//intervalStartBeat = beat;
|
||||
beatInterval = interval;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void alienSuccess(float beat)
|
||||
{
|
||||
//Make this codeblock smaller
|
||||
if (alienSpeakCount == translatorSpeakCount)
|
||||
{
|
||||
string[] sounds = new string[] { "firstContact/success_1", "firstContact/success_2" };
|
||||
var sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .5f, offset: .15f)
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
|
||||
BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_success", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play("alien_success", 0, 0); })
|
||||
});
|
||||
|
||||
BeatAction.New(translator.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
|
||||
});
|
||||
}
|
||||
else if (alienSpeakCount != translatorSpeakCount)
|
||||
{
|
||||
string[] sounds = new string[] { "firstContact/failAlien_1", "firstContact/failAlien_2" };
|
||||
var sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .5f)
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
|
||||
BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play("alien_fail", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play("alien_fail", 0, 0); })
|
||||
});
|
||||
|
||||
BeatAction.New(translator.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
|
||||
});
|
||||
}
|
||||
|
||||
alienSpeakCount = 0;
|
||||
translatorSpeakCount = 0;
|
||||
isSpeaking = false;
|
||||
hasMissed = false;
|
||||
noHitOnce = false;
|
||||
}
|
||||
|
||||
public void alienNoHit()
|
||||
{
|
||||
if (!noHitOnce)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("firstContact/alienNoHit");
|
||||
noHitOnce = true;
|
||||
}
|
||||
BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { alien.GetComponent<Animator>().Play("alien_noHit", 0, 0); }),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void missionControlDisplay(float beat, bool stay)
|
||||
{
|
||||
missionControl.SetActive(true);
|
||||
string textToPut = "";
|
||||
|
||||
if (alienSpeakCount == translatorSpeakCount)
|
||||
{
|
||||
textToPut = "missionControl_success";
|
||||
}
|
||||
else
|
||||
{
|
||||
textToPut = "missionControl_fail";
|
||||
}
|
||||
|
||||
BeatAction.New(missionControl, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0); }),
|
||||
new BeatAction.Action(beat, delegate { alien.GetComponentInParent<Animator>().Play("alien_idle", 0, 0); }),
|
||||
new BeatAction.Action(beat, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
|
||||
|
||||
});
|
||||
|
||||
if (!stay)
|
||||
{
|
||||
BeatAction.New(missionControl, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 1f, delegate { missionControl.SetActive(false); }),
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
missionControl.SetActive(true);
|
||||
}
|
||||
|
||||
alienSpeakCount = 0;
|
||||
translatorSpeakCount = 0;
|
||||
isSpeaking = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/Games/FirstContact/FirstContact.cs.meta
Normal file
11
Assets/Scripts/Games/FirstContact/FirstContact.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3f2575369f43af4419d4d92d0de9e23b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
70
Assets/Scripts/Games/FirstContact/Translator.cs
Normal file
70
Assets/Scripts/Games/FirstContact/Translator.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
using HeavenStudio.Util;
|
||||
using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_FirstContact
|
||||
{
|
||||
public class Translator : PlayerActionObject
|
||||
{
|
||||
public Animator anim;
|
||||
|
||||
FirstContact game;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
game = FirstContact.instance;
|
||||
//anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
////IF YOU WANT TO PLAY NOTES ANYTIME W/O CONSTRAINTS
|
||||
//if (PlayerInput.Pressed(true) && !game.isSpeaking)
|
||||
//{
|
||||
// successTranslation(true);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void successTranslation(bool ace)
|
||||
{
|
||||
if (ace)
|
||||
{
|
||||
//if(game.version == 1)
|
||||
//{
|
||||
// Jukebox.PlayOneShotGame("firstContact/citrusRemix/1_r");
|
||||
//}
|
||||
Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
|
||||
}
|
||||
else
|
||||
{
|
||||
Jukebox.PlayOneShotGame("firstContact/failContact");
|
||||
}
|
||||
|
||||
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { anim.Play("translator_speak", 0, 0);}),
|
||||
});
|
||||
}
|
||||
|
||||
public void ehTranslation()
|
||||
{
|
||||
Jukebox.PlayOneShotGame("firstContact/slightlyFail");
|
||||
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { anim.Play("translator_eh", 0, 0);}),
|
||||
});
|
||||
}
|
||||
|
||||
public int randomizerLines()
|
||||
{
|
||||
return Random.Range(1, 11);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/FirstContact/Translator.cs.meta
Normal file
11
Assets/Scripts/Games/FirstContact/Translator.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 090e2309a1a03314d93714e9c1ed5a99
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
86
Assets/Scripts/Games/FirstContact/WhiteLines.cs
Normal file
86
Assets/Scripts/Games/FirstContact/WhiteLines.cs
Normal file
@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class WhiteLines : MonoBehaviour
|
||||
{
|
||||
float speed;
|
||||
float startAt = 4.80f;
|
||||
float endAt = -3.1f;
|
||||
[SerializeField] SpriteRenderer line;
|
||||
public int rngEarlyGone, rngMiddleLine;
|
||||
[SerializeField] bool isRandomLineMiddle;
|
||||
bool checkAnother, checkOnce;
|
||||
|
||||
void Start()
|
||||
{
|
||||
//speed = Random.Range(0.005f, 0.007f);
|
||||
speed = Random.Range(0.005f, 0.009f);
|
||||
rngEarlyGone = Random.Range(0, 5);
|
||||
if (isRandomLineMiddle)
|
||||
{
|
||||
rngMiddleLine = Random.Range(0, 101);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if(transform.position.y > endAt && !isRandomLineMiddle)
|
||||
{
|
||||
transform.position += new Vector3(0, -speed * 1f, 0);
|
||||
}
|
||||
else if(transform.position.y <= endAt && !isRandomLineMiddle)
|
||||
{
|
||||
speed = Random.Range(0.005f, 0.009f);
|
||||
transform.position = new Vector3(0, startAt, 0);
|
||||
rngEarlyGone = Random.Range(0, 5);
|
||||
}
|
||||
|
||||
if(rngEarlyGone > 0 && !isRandomLineMiddle)
|
||||
{
|
||||
line.color += new Color(1f, 1f, 1f, -0.01f);
|
||||
if(line.color.a <= 0)
|
||||
{
|
||||
rngEarlyGone = Random.Range(0, 5);
|
||||
line.color = new Color(1f, 1f, 1f, .10f);
|
||||
transform.position = new Vector3(0, startAt, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (isRandomLineMiddle)
|
||||
{
|
||||
if(rngMiddleLine > 1 && !checkAnother)
|
||||
{
|
||||
rngMiddleLine = Random.Range(0, 101);
|
||||
}
|
||||
if(rngMiddleLine <= 1)
|
||||
{
|
||||
line.color += new Color(1f, 1f, 1f, 0.01f);
|
||||
checkAnother = true;
|
||||
|
||||
if(!checkOnce && line.color.a > .5f)
|
||||
{
|
||||
checkOnce = true;
|
||||
}
|
||||
}
|
||||
if(checkOnce)
|
||||
{
|
||||
line.color -= new Color(1f, 1f, 1f, 0.02f);
|
||||
if (line.color.a <= 0)
|
||||
{
|
||||
line.color = new Color(1f, 1f, 1f, 0f);
|
||||
rngMiddleLine = Random.Range(0, 101);
|
||||
transform.position = new Vector3(0, Random.Range(-1, 5));
|
||||
checkAnother = false;
|
||||
checkOnce = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/FirstContact/WhiteLines.cs.meta
Normal file
11
Assets/Scripts/Games/FirstContact/WhiteLines.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7756ed68ef3b4a468bd034afafba0cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -23,17 +23,18 @@ namespace HeavenStudio.Games
|
||||
|
||||
public List<PlayerActionEvent> scheduledInputs = new List<PlayerActionEvent>();
|
||||
|
||||
/**
|
||||
* Schedule an Input for a later time in the minigame. Executes the methods put in parameters
|
||||
*
|
||||
* float startBeat : When the scheduling started (In beats)
|
||||
* float timer : How many beats later should the input be expected
|
||||
* InputType inputType : The type of the input that's expected (Press, release, A, B, Directions..) (Check InputType class for a list)
|
||||
* ActionEventCallbackState OnHit : Method to run if the Input has been Hit
|
||||
* ActionEventCallback OnMiss : Method to run if the Input has been Missed
|
||||
* ActionEventCallback OnBlank : Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much)
|
||||
*/
|
||||
public PlayerActionEvent ScheduleInput(float startBeat,
|
||||
/// <summary>
|
||||
/// Schedule an Input for a later time in the minigame. Executes the methods put in parameters
|
||||
/// </summary>
|
||||
/// <param name="startBeat">When the scheduling started (in beats)</param>
|
||||
/// <param name="timer">How many beats later should the input be expected</param>
|
||||
/// <param name="inputType">The type of the input that's expected (Press, Release, A, B, Directions>)</param>
|
||||
/// <param name="OnHit">Method to run if the Input has been Hit</param>
|
||||
/// <param name="OnMiss">Method to run if the Input has been Missed</param>
|
||||
/// <param name="OnBlank">Method to run whenever there's an Input while this is Scheduled (Shouldn't be used too much)</param>
|
||||
/// <returns></returns>
|
||||
public PlayerActionEvent ScheduleInput(
|
||||
float startBeat,
|
||||
float timer,
|
||||
InputType inputType,
|
||||
PlayerActionEvent.ActionEventCallbackState OnHit,
|
||||
@ -207,4 +208,4 @@ namespace HeavenStudio.Games
|
||||
return sameTime;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ namespace HeavenStudio.Games.Scripts_PajamaParty
|
||||
}
|
||||
),
|
||||
new BeatAction.Action(
|
||||
beat + 8f,
|
||||
beat + (longSleep ? 4f : 8f),
|
||||
delegate {
|
||||
canCharge = true;
|
||||
canJump = true;
|
||||
|
8
Assets/Scripts/Games/RhythmSomen.meta
Normal file
8
Assets/Scripts/Games/RhythmSomen.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e4f027c28e1d79c4490cdb624dc5dc04
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
156
Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs
Normal file
156
Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs
Normal file
@ -0,0 +1,156 @@
|
||||
using HeavenStudio.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
public static class PcoSomenLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("rhythmSomen", "Rhythm Sōmen \n<color=#eb5454>[WIP don't use]</color>", "000000", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("crane (far)", delegate { RhythmSomen.instance.DoFarCrane(eventCaller.currentEntity.beat); }, 4.0f, false),
|
||||
new GameAction("crane (close)", delegate { RhythmSomen.instance.DoCloseCrane(eventCaller.currentEntity.beat); }, 3.0f, false),
|
||||
new GameAction("crane (both)", delegate { RhythmSomen.instance.DoBothCrane(eventCaller.currentEntity.beat); }, 4.0f, false),
|
||||
new GameAction("offbeat bell", delegate { RhythmSomen.instance.DoBell(eventCaller.currentEntity.beat); }, 1.0f, false),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
// using Scripts_RhythmSomen;
|
||||
public class RhythmSomen : Minigame
|
||||
{
|
||||
public Animator SomenPlayer;
|
||||
public Animator FrontArm;
|
||||
public Animator EffectHit;
|
||||
public Animator EffectSweat;
|
||||
public Animator EffectExclam;
|
||||
public Animator EffectShock;
|
||||
public Animator CloseCrane;
|
||||
public Animator FarCrane;
|
||||
public GameObject Player;
|
||||
|
||||
public GameEvent bop = new GameEvent();
|
||||
|
||||
public static RhythmSomen instance;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
{
|
||||
SomenPlayer.Play("HeadBob", -1, 0);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow())
|
||||
{
|
||||
Jukebox.PlayOneShotGame("rhythmSomen/somen_mistake");
|
||||
FrontArm.Play("ArmPluck", -1, 0);
|
||||
EffectSweat.Play("BlobSweating", -1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void DoFarCrane(float beat)
|
||||
{
|
||||
//Far Drop Multisound
|
||||
ScheduleInput(beat, 3f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound("rhythmSomen/somen_lowerfar", beat),
|
||||
new MultiSound.Sound("rhythmSomen/somen_drop", beat + 1f),
|
||||
new MultiSound.Sound("rhythmSomen/somen_woosh", beat + 1.5f),
|
||||
});
|
||||
|
||||
BeatAction.New(Player, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { FarCrane.Play("Drop", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { FarCrane.Play("Open", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { FarCrane.Play("Lift", -1, 0);}),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void DoCloseCrane(float beat)
|
||||
{
|
||||
//Close Drop Multisound
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound("rhythmSomen/somen_lowerclose", beat),
|
||||
new MultiSound.Sound("rhythmSomen/somen_drop", beat + 1f),
|
||||
new MultiSound.Sound("rhythmSomen/somen_woosh", beat + 1.5f),
|
||||
});
|
||||
|
||||
BeatAction.New(Player, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { CloseCrane.Play("DropClose", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { CloseCrane.Play("OpenClose", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { CloseCrane.Play("LiftClose", -1, 0);}),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void DoBothCrane(float beat)
|
||||
{
|
||||
//Both Drop Multisound
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
|
||||
ScheduleInput(beat, 3f, InputType.STANDARD_DOWN, CatchSuccess, CatchMiss, CatchEmpty);
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound("rhythmSomen/somen_lowerfar", beat),
|
||||
new MultiSound.Sound("rhythmSomen/somen_doublealarm", beat),
|
||||
new MultiSound.Sound("rhythmSomen/somen_drop", beat + 1f),
|
||||
new MultiSound.Sound("rhythmSomen/somen_woosh", beat + 1.5f),
|
||||
});
|
||||
|
||||
BeatAction.New(Player, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { CloseCrane.Play("DropClose", -1, 0);}),
|
||||
new BeatAction.Action(beat, delegate { FarCrane.Play("Drop", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { CloseCrane.Play("OpenClose", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.0f, delegate { FarCrane.Play("Open", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { CloseCrane.Play("LiftClose", -1, 0);}),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { FarCrane.Play("Lift", -1, 0);}),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void DoBell(float beat)
|
||||
{
|
||||
//Bell Sound lol
|
||||
Jukebox.PlayOneShotGame("rhythmSomen/somen_bell");
|
||||
|
||||
BeatAction.New(Player, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { EffectExclam.Play("ExclamAppear", -1, 0);}),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void CatchSuccess(PlayerActionEvent caller, float state)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("rhythmSomen/somen_catch");
|
||||
FrontArm.Play("ArmPluck", -1, 0);
|
||||
EffectHit.Play("HitAppear", -1, 0);
|
||||
}
|
||||
|
||||
public void CatchMiss(PlayerActionEvent caller)
|
||||
{
|
||||
EffectShock.Play("ShockAppear", -1, 0);
|
||||
}
|
||||
|
||||
public void CatchEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs.meta
Normal file
11
Assets/Scripts/Games/RhythmSomen/RhythmSomen.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4384b197a2c57c64e80f2c6f10afdba2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -116,7 +116,7 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
get
|
||||
{
|
||||
ColorUtility.TryParseHtmlString("#D8FFC1", out _defaultBgColor);
|
||||
ColorUtility.TryParseHtmlString("#A14FA1", out _defaultBgColor);
|
||||
return _defaultBgColor;
|
||||
}
|
||||
}
|
||||
|
@ -5,9 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_NtrSamurai
|
||||
{
|
||||
public class NtrSamuraiChild : MonoBehaviour
|
||||
|
@ -5,9 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using DG.Tweening;
|
||||
using NaughtyBezierCurves;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_NtrSamurai
|
||||
{
|
||||
public class NtrSamuraiObject : MonoBehaviour
|
||||
|
27
Assets/Scripts/Games/Tram&Pauline/Curtains.cs
Normal file
27
Assets/Scripts/Games/Tram&Pauline/Curtains.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TramAndPauline
|
||||
{
|
||||
public class Curtains : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
11
Assets/Scripts/Games/Tram&Pauline/Curtains.cs.meta
Normal file
11
Assets/Scripts/Games/Tram&Pauline/Curtains.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e986f325614dad34f99276dcf3bd61ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/Games/Tram&Pauline/Pauline.cs
Normal file
18
Assets/Scripts/Games/Tram&Pauline/Pauline.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Pauline : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/Tram&Pauline/Pauline.cs.meta
Normal file
11
Assets/Scripts/Games/Tram&Pauline/Pauline.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c9740a191998b7429be1f4ebee714f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/Games/Tram&Pauline/Tram.cs
Normal file
18
Assets/Scripts/Games/Tram&Pauline/Tram.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Tram : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/Tram&Pauline/Tram.cs.meta
Normal file
11
Assets/Scripts/Games/Tram&Pauline/Tram.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6d9f0a0c395f5774abebc63146dd3534
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -3,20 +3,72 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
public static class AgbTramLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller)
|
||||
{
|
||||
return new Minigame("tram&Pauline", "Tram&Pauline \n<color=#eb5454>[WIP don't use]</color>", "000000", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("curtains", delegate { TramAndPauline.instance.Curtains(eventCaller.currentEntity.beat); }, 0.5f),
|
||||
new GameAction("SFX", delegate { var e = eventCaller.currentEntity; TramAndPauline.instance.SFX(e.beat, e.toggle); }, 2.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", TramAndPauline.SoundEffects.Henge, "calls", "the sound effects to choose from"),
|
||||
}),
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_TramAndPauline;
|
||||
|
||||
public class TramAndPauline : Minigame
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
public enum CurtainState
|
||||
{
|
||||
Raised,
|
||||
Lower
|
||||
}
|
||||
|
||||
}
|
||||
public enum SoundEffects
|
||||
{
|
||||
Henge, //Shapeshift
|
||||
Henshin, //Transform
|
||||
Jump,
|
||||
Seino //One Two Three Go
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
}
|
||||
public static TramAndPauline instance;
|
||||
|
||||
[Header("Animators")]
|
||||
public Animator RaiseCurtains;
|
||||
public Animator LowerCurtains;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void Curtains(float beat)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SFX(float beat, bool playSound)
|
||||
{
|
||||
playSound = false;
|
||||
var sound = new[]
|
||||
{
|
||||
new MultiSound.Sound("tram&Pauline/trampoline_unused_henge", beat),
|
||||
new MultiSound.Sound("tram&Pauline/trampoline_unused_henshin", beat + 1f),
|
||||
new MultiSound.Sound("tram&Pauline/trampoline_unused_jump", beat + 2f),
|
||||
new MultiSound.Sound("tram&Pauline/trampoline_unused_senio", beat + 3f)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8850749af64f82b44a728e2c273157e1
|
||||
guid: c993077b9c10749aabaa7f201b552653
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
18
Assets/Scripts/Games/Tram&Pauline/Trampoline.cs
Normal file
18
Assets/Scripts/Games/Tram&Pauline/Trampoline.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Trampoline : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/Tram&Pauline/Trampoline.cs.meta
Normal file
11
Assets/Scripts/Games/Tram&Pauline/Trampoline.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ac862c09eaeaa64083a07ef7ca089f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/Games/TrickClass.meta
Normal file
8
Assets/Scripts/Games/TrickClass.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4365eafd06922a34eb4f69c2c020cc75
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
152
Assets/Scripts/Games/TrickClass/MobTrickObj.cs
Normal file
152
Assets/Scripts/Games/TrickClass/MobTrickObj.cs
Normal file
@ -0,0 +1,152 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using NaughtyBezierCurves;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
{
|
||||
public class MobTrickObj : PlayerActionObject
|
||||
{
|
||||
public bool flyType;
|
||||
public float startBeat;
|
||||
bool miss = false;
|
||||
|
||||
float flyBeats;
|
||||
float dodgeBeats;
|
||||
public int type;
|
||||
|
||||
[NonSerialized] public BezierCurve3D curve;
|
||||
PlayerActionEvent hitProg;
|
||||
|
||||
private TrickClass game;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = TrickClass.instance;
|
||||
flyBeats = flyType ? 4f : 2f;
|
||||
dodgeBeats = flyType ? 2f : 1f;
|
||||
|
||||
var cond = Conductor.instance;
|
||||
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
transform.position = curve.GetPoint(flyPos);
|
||||
hitProg = game.ScheduleInput(startBeat, dodgeBeats, InputType.STANDARD_DOWN, DodgeJustOrNg, DodgeMiss, DodgeThrough);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
|
||||
if (flyPos <= 1f)
|
||||
{
|
||||
if (!miss)
|
||||
{
|
||||
flyPos *= 0.95f;
|
||||
}
|
||||
Vector3 lastPos = transform.position;
|
||||
Vector3 nextPos = curve.GetPoint(flyPos);
|
||||
|
||||
if (flyType)
|
||||
{
|
||||
Vector3 direction = (nextPos - lastPos).normalized;
|
||||
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
this.transform.eulerAngles = new Vector3(0, 0, rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (360f * Time.deltaTime));
|
||||
}
|
||||
|
||||
transform.position = nextPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
}
|
||||
|
||||
if (flyPos > 1f)
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
{
|
||||
GameObject.Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string GetDodgeSound()
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
default:
|
||||
return "trickClass/ball_impact";
|
||||
}
|
||||
}
|
||||
|
||||
public void DoObjMiss()
|
||||
{
|
||||
miss = true;
|
||||
switch (type)
|
||||
{
|
||||
case (int) TrickClass.TrickObjType.Plane:
|
||||
curve = game.planeMissCurve;
|
||||
flyBeats = 4f;
|
||||
|
||||
Vector3 lastPos = curve.GetPoint(0);
|
||||
Vector3 nextPos = curve.GetPoint(0.000001f);
|
||||
Vector3 direction = (nextPos - lastPos).normalized;
|
||||
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
this.transform.eulerAngles = new Vector3(0, 0, rotation);
|
||||
|
||||
transform.position = nextPos;
|
||||
break;
|
||||
default:
|
||||
curve = game.ballMissCurve;
|
||||
flyBeats = 1.25f;
|
||||
break;
|
||||
}
|
||||
startBeat += dodgeBeats;
|
||||
}
|
||||
|
||||
public void DodgeJustOrNg(PlayerActionEvent caller, float state)
|
||||
{
|
||||
if (game.playerCanDodge <= Conductor.instance.songPositionInBeats)
|
||||
{
|
||||
if (state <= -1f || state >= 1f)
|
||||
{
|
||||
//NG
|
||||
game.PlayerDodgeNg();
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetDodgeSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
});
|
||||
Jukebox.PlayOneShotGame(GetDodgeSound(), volume: 0.6f);
|
||||
Jukebox.PlayOneShot("miss");
|
||||
DoObjMiss();
|
||||
}
|
||||
else
|
||||
{
|
||||
//just
|
||||
game.PlayerDodge();
|
||||
Jukebox.PlayOneShotGame("trickClass/player_dodge_success", volume: 0.8f, pitch: UnityEngine.Random.Range(0.85f, 1.15f));
|
||||
MultiSound.Play(new MultiSound.Sound[] {
|
||||
new MultiSound.Sound(GetDodgeSound(), startBeat + flyBeats, volume: 0.4f),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void DodgeMiss(PlayerActionEvent caller)
|
||||
{
|
||||
Jukebox.PlayOneShotGame(GetDodgeSound());
|
||||
DoObjMiss();
|
||||
game.PlayerThrough();
|
||||
}
|
||||
|
||||
public void DodgeThrough(PlayerActionEvent caller) {}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/TrickClass/MobTrickObj.cs.meta
Normal file
11
Assets/Scripts/Games/TrickClass/MobTrickObj.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb420e9087e23a64eb3ca43a7620c211
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
194
Assets/Scripts/Games/TrickClass/TrickClass.cs
Normal file
194
Assets/Scripts/Games/TrickClass/TrickClass.cs
Normal file
@ -0,0 +1,194 @@
|
||||
using DG.Tweening;
|
||||
using NaughtyBezierCurves;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
public static class MobTrickLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("trickClass", "Trick on the Class\n<color=#eb5454>[WIP]</color>", "C0171D", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("toss", delegate
|
||||
{
|
||||
TrickClass.instance.TossObject(eventCaller.currentEntity.beat, eventCaller.currentEntity.type);
|
||||
}, 3, false, new List<Param>()
|
||||
{
|
||||
new Param("type", TrickClass.TrickObjType.Ball, "Object", "The object to toss")
|
||||
}),
|
||||
new GameAction("bop", delegate { var e = eventCaller.currentEntity; TrickClass.instance.Bop(e.beat, e.length); }, 1, true, hidden: true),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
/**
|
||||
mob_Trick
|
||||
**/
|
||||
|
||||
using Scripts_TrickClass;
|
||||
public class TrickClass : Minigame
|
||||
{
|
||||
public enum TrickObjType {
|
||||
Ball,
|
||||
Plane,
|
||||
}
|
||||
|
||||
[Header("Objects")]
|
||||
public Animator playerAnim;
|
||||
public Animator girlAnim;
|
||||
public Animator warnAnim;
|
||||
|
||||
[Header("References")]
|
||||
public GameObject ballPrefab;
|
||||
public GameObject planePrefab;
|
||||
public GameObject shockPrefab;
|
||||
public Transform objHolder;
|
||||
|
||||
[Header("Curves")]
|
||||
public BezierCurve3D ballTossCurve;
|
||||
public BezierCurve3D ballMissCurve;
|
||||
public BezierCurve3D planeTossCurve;
|
||||
public BezierCurve3D planeMissCurve;
|
||||
public BezierCurve3D shockTossCurve;
|
||||
|
||||
public static TrickClass instance;
|
||||
public GameEvent bop = new GameEvent();
|
||||
|
||||
public float playerCanDodge = Single.MinValue;
|
||||
float playerBopStart = Single.MinValue;
|
||||
float girlBopStart = Single.MinValue;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
{
|
||||
if (cond.songPositionInBeats > playerBopStart)
|
||||
playerAnim.DoScaledAnimationAsync("Bop");
|
||||
|
||||
if (cond.songPositionInBeats > girlBopStart)
|
||||
girlAnim.DoScaledAnimationAsync("Bop");
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow() && (playerCanDodge <= Conductor.instance.songPositionInBeats))
|
||||
{
|
||||
PlayerDodge(true);
|
||||
playerCanDodge = Conductor.instance.songPositionInBeats + 0.6f;
|
||||
}
|
||||
|
||||
// bruh
|
||||
var tossEvents = GameManager.instance.Beatmap.entities.FindAll(en => en.datamodel == "trickClass/toss");
|
||||
for (int i = 0; i < tossEvents.Count; i++)
|
||||
{
|
||||
var e = tossEvents[i];
|
||||
float timeToEvent = e.beat - cond.songPositionInBeats;
|
||||
warnAnim.Play("NoPose", -1, 0);
|
||||
if (timeToEvent > 0f && timeToEvent <= 1f)
|
||||
{
|
||||
string anim = "WarnBall";
|
||||
switch (e.type)
|
||||
{
|
||||
case (int) TrickObjType.Plane:
|
||||
anim = "WarnPlane";
|
||||
break;
|
||||
default:
|
||||
anim = "WarnBall";
|
||||
break;
|
||||
}
|
||||
warnAnim.DoScaledAnimation(anim, e.beat - 1f, 1f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Bop(float beat, float length)
|
||||
{
|
||||
bop.startBeat = beat;
|
||||
bop.length = length;
|
||||
}
|
||||
|
||||
public void TossObject(float beat, int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case (int) TrickObjType.Plane:
|
||||
Jukebox.PlayOneShotGame("trickClass/girl_toss_plane");
|
||||
break;
|
||||
default:
|
||||
Jukebox.PlayOneShotGame("trickClass/girl_toss_ball");
|
||||
break;
|
||||
}
|
||||
SpawnObject(beat, type);
|
||||
|
||||
girlAnim.DoScaledAnimationAsync("Throw");
|
||||
girlBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
||||
}
|
||||
|
||||
public void SpawnObject(float beat, int type)
|
||||
{
|
||||
GameObject objectToSpawn;
|
||||
BezierCurve3D curve;
|
||||
bool isPlane = false;
|
||||
switch (type)
|
||||
{
|
||||
case (int) TrickObjType.Plane:
|
||||
objectToSpawn = planePrefab;
|
||||
curve = planeTossCurve;
|
||||
isPlane = true;
|
||||
break;
|
||||
default:
|
||||
objectToSpawn = ballPrefab;
|
||||
curve = ballTossCurve;
|
||||
break;
|
||||
}
|
||||
var mobj = GameObject.Instantiate(objectToSpawn, objHolder);
|
||||
var thinker = mobj.GetComponent<MobTrickObj>();
|
||||
|
||||
thinker.startBeat = beat;
|
||||
thinker.flyType = isPlane;
|
||||
thinker.curve = curve;
|
||||
thinker.type = type;
|
||||
|
||||
mobj.SetActive(true);
|
||||
}
|
||||
|
||||
public void PlayerDodge(bool slow = false)
|
||||
{
|
||||
if (playerCanDodge > Conductor.instance.songPositionInBeats) return;
|
||||
|
||||
//anim
|
||||
Jukebox.PlayOneShotGame("trickClass/player_dodge");
|
||||
playerAnim.DoScaledAnimationAsync("Dodge", slow ? 0.6f : 1f);
|
||||
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
||||
|
||||
}
|
||||
|
||||
public void PlayerDodgeNg()
|
||||
{
|
||||
playerAnim.DoScaledAnimationAsync("DodgeNg");
|
||||
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
||||
playerCanDodge = Conductor.instance.songPositionInBeats + 0.15f;
|
||||
}
|
||||
|
||||
public void PlayerThrough()
|
||||
{
|
||||
playerAnim.DoScaledAnimationAsync("Through");
|
||||
playerBopStart = Conductor.instance.songPositionInBeats + 0.75f;
|
||||
playerCanDodge = Conductor.instance.songPositionInBeats + 0.15f;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/TrickClass/TrickClass.cs.meta
Normal file
11
Assets/Scripts/Games/TrickClass/TrickClass.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c32cb0e1f34c12c4f9440880fee8ff29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -23,6 +23,9 @@ namespace HeavenStudio.Editor
|
||||
private bool clickedInTimeline = false;
|
||||
|
||||
private TMPro.TMP_Text sizeText;
|
||||
private RectTransform text;
|
||||
|
||||
private float timelineLastX;
|
||||
|
||||
public static BoxSelection instance { get; private set; }
|
||||
|
||||
@ -40,10 +43,19 @@ namespace HeavenStudio.Editor
|
||||
boxVisual.transform.GetChild(0).GetComponent<Image>().color = EditorTheme.theme.properties.BoxSelectionOutlineCol.Hex2RGB();
|
||||
|
||||
sizeText = boxVisual.transform.GetChild(1).GetComponent<TMPro.TMP_Text>();
|
||||
text = boxVisual.transform.GetChild(1).GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float deltaTimelineX = timelineContent.transform.localPosition.x - timelineLastX;
|
||||
|
||||
Camera camera = Editor.instance.EditorCamera;
|
||||
Vector3 scale = Editor.instance.MainCanvas.transform.localScale;
|
||||
|
||||
boxVisual.transform.localScale = new Vector2(0.01f/scale.x, 1f/scale.y);
|
||||
text.transform.localScale = scale;
|
||||
|
||||
if (Selections.instance.eventsSelected.Count > 0 && Timeline.instance.InteractingWithEvents())
|
||||
{
|
||||
startPosition = Vector2.zero;
|
||||
@ -60,10 +72,11 @@ namespace HeavenStudio.Editor
|
||||
return;
|
||||
}
|
||||
|
||||
if (boxVisual.rect.width * boxVisual.transform.localScale.x >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", boxVisual.rect.width * boxVisual.transform.localScale.x)}";
|
||||
float beatLen = boxVisual.rect.width * boxVisual.transform.localScale.x;
|
||||
if (beatLen >= 0.5f)
|
||||
sizeText.text = $"{string.Format("{0:0.000}", beatLen)}";
|
||||
else
|
||||
sizeText.text = string.Empty; // i'm lazy
|
||||
sizeText.text = string.Empty;
|
||||
|
||||
|
||||
// click
|
||||
@ -78,9 +91,11 @@ namespace HeavenStudio.Editor
|
||||
// dragging
|
||||
if (Input.GetMouseButton(0) && clickedInTimeline)
|
||||
{
|
||||
startPosition.x += deltaTimelineX * scale.x;
|
||||
endPosition = MousePosition();
|
||||
DrawVisual();
|
||||
DrawSelection();
|
||||
SelectEvents(); //kek
|
||||
DrawVisual();
|
||||
}
|
||||
|
||||
// release click
|
||||
@ -92,9 +107,7 @@ namespace HeavenStudio.Editor
|
||||
DrawVisual();
|
||||
}
|
||||
|
||||
// selecting = (selectionBox.size != Vector2.zero); -- doesn't work really
|
||||
|
||||
// for real time selection just move SelectEvents() to here, but that breaks some shit. might fix soon idk --pelly
|
||||
timelineLastX = timelineContent.transform.localPosition.x;
|
||||
}
|
||||
|
||||
private void DrawVisual()
|
||||
@ -102,15 +115,12 @@ namespace HeavenStudio.Editor
|
||||
Vector2 boxStart = startPosition;
|
||||
Vector2 boxEnd = endPosition;
|
||||
|
||||
// boxEnd = new Vector2(Mathf.Clamp(boxEnd.x, -5.78f, Mathf.Infinity), boxEnd.y);
|
||||
|
||||
Vector2 boxCenter = (boxStart + boxEnd) / 2;
|
||||
boxVisual.position = boxCenter;
|
||||
|
||||
Vector2 boxSize = new Vector2(Mathf.Abs(boxStart.x - boxEnd.x), Mathf.Abs(boxStart.y - boxEnd.y));
|
||||
|
||||
// boxVisual.sizeDelta = new Vector2(boxSize.x / boxVisual.localScale.x, boxSize.y / boxVisual.localScale.y);
|
||||
boxVisual.sizeDelta = new Vector2(boxSize.x, boxSize.y);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, boxSize.x);
|
||||
boxVisual.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, boxSize.y);
|
||||
}
|
||||
|
||||
private void DrawSelection()
|
||||
@ -168,7 +178,7 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
var mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
// var mousePos = new Vector2();
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Camera.main, out mousePos);
|
||||
// RectTransformUtility.ScreenPointToLocalPointInRectangle(timelineContent, Input.mousePosition, Editor.instance.EditorCamera, out mousePos);
|
||||
return new Vector3(mousePos.x, mousePos.y, 0);
|
||||
}
|
||||
|
||||
|
@ -25,10 +25,10 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
private Initializer Initializer;
|
||||
|
||||
[SerializeField] private Canvas MainCanvas;
|
||||
[SerializeField] public Canvas MainCanvas;
|
||||
[SerializeField] public Camera EditorCamera;
|
||||
|
||||
[SerializeField] public GameObject EditorLetterbox;
|
||||
// [SerializeField] public GameObject EditorLetterbox;
|
||||
[SerializeField] public GameObject GameLetterbox;
|
||||
|
||||
[Header("Rect")]
|
||||
@ -48,10 +48,12 @@ namespace HeavenStudio.Editor
|
||||
[SerializeField] private Button UndoBTN;
|
||||
[SerializeField] private Button RedoBTN;
|
||||
[SerializeField] private Button MusicSelectBTN;
|
||||
[SerializeField] private Button EditorSettingsBTN;
|
||||
[SerializeField] private Button EditorThemeBTN;
|
||||
[SerializeField] private Button FullScreenBTN;
|
||||
[SerializeField] private Button TempoFinderBTN;
|
||||
[SerializeField] private Button SnapDiagBTN;
|
||||
|
||||
[SerializeField] private Button EditorThemeBTN;
|
||||
[SerializeField] private Button EditorSettingsBTN;
|
||||
|
||||
[Header("Tooltip")]
|
||||
public TMP_Text tooltipText;
|
||||
@ -101,31 +103,79 @@ namespace HeavenStudio.Editor
|
||||
Tooltip.AddTooltip(UndoBTN.gameObject, "Undo <color=#adadad>[Ctrl+Z]</color>");
|
||||
Tooltip.AddTooltip(RedoBTN.gameObject, "Redo <color=#adadad>[Ctrl+Y or Ctrl+Shift+Z]</color>");
|
||||
Tooltip.AddTooltip(MusicSelectBTN.gameObject, "Music Select");
|
||||
Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
|
||||
Tooltip.AddTooltip(EditorThemeBTN.gameObject, "Editor Theme");
|
||||
Tooltip.AddTooltip(FullScreenBTN.gameObject, "Preview <color=#adadad>[Tab]</color>");
|
||||
Tooltip.AddTooltip(TempoFinderBTN.gameObject, "Tempo Finder");
|
||||
Tooltip.AddTooltip(SnapDiagBTN.gameObject, "Snap Settings");
|
||||
|
||||
Tooltip.AddTooltip(EditorSettingsBTN.gameObject, "Editor Settings <color=#adadad>[Ctrl+Shift+O]</color>");
|
||||
UpdateEditorStatus(true);
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
#region Keyboard Shortcuts
|
||||
if (!editingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Tab))
|
||||
{
|
||||
Fullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.Delete))
|
||||
{
|
||||
List<TimelineEventObj> ev = new List<TimelineEventObj>();
|
||||
for (int i = 0; i < Selections.instance.eventsSelected.Count; i++) ev.Add(Selections.instance.eventsSelected[i]);
|
||||
CommandManager.instance.Execute(new Commands.Deletion(ev));
|
||||
}
|
||||
|
||||
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.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (CommandManager.instance.canUndo())
|
||||
UndoBTN.transform.GetChild(0).GetComponent<Image>().color = "BD8CFF".Hex2RGB();
|
||||
@ -137,29 +187,6 @@ namespace HeavenStudio.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.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.D))
|
||||
{
|
||||
ToggleDebugCam();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Timeline.instance.timelineState.selected && Editor.instance.canSelect)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
@ -182,37 +209,6 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
LoadRemix("");
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.O))
|
||||
{
|
||||
OpenRemix();
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.LeftAlt))
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(true);
|
||||
}
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
SaveRemix(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (Application.isEditor)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.S))
|
||||
{
|
||||
// SaveRemix(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Sprite GameIcon(string name)
|
||||
@ -441,7 +437,7 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
if (fullscreen == false)
|
||||
{
|
||||
EditorLetterbox.SetActive(false);
|
||||
// EditorLetterbox.SetActive(false);
|
||||
GameLetterbox.SetActive(true);
|
||||
|
||||
MainCanvas.enabled = false;
|
||||
@ -453,7 +449,7 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorLetterbox.SetActive(true);
|
||||
// EditorLetterbox.SetActive(true);
|
||||
GameLetterbox.SetActive(false);
|
||||
|
||||
MainCanvas.enabled = true;
|
||||
@ -466,6 +462,7 @@ namespace HeavenStudio.Editor
|
||||
GameCamera.instance.camera.rect = new Rect(0, 0, 1, 1);
|
||||
GameManager.instance.CursorCam.rect = new Rect(0, 0, 1, 1);
|
||||
GameManager.instance.OverlayCamera.rect = new Rect(0, 0, 1, 1);
|
||||
EditorCamera.rect = new Rect(0, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public Beatmap.Entity entity;
|
||||
|
||||
private bool active;
|
||||
public bool active;
|
||||
|
||||
private int childCountAtStart;
|
||||
|
||||
|
@ -20,6 +20,8 @@ namespace HeavenStudio.Editor
|
||||
public GameObject GameEventSelector;
|
||||
public GameObject EventRef;
|
||||
public GameObject CurrentSelected;
|
||||
public RectTransform GameEventSelectorCanScroll;
|
||||
private RectTransform GameEventSelectorRect;
|
||||
private RectTransform eventsParent;
|
||||
|
||||
[Header("Properties")]
|
||||
@ -29,9 +31,15 @@ namespace HeavenStudio.Editor
|
||||
private int dragTimes;
|
||||
public float posDif;
|
||||
public int ignoreSelectCount;
|
||||
private float selectorHeight;
|
||||
private float eventSize;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameEventSelectorRect = GameEventSelector.GetComponent<RectTransform>();
|
||||
selectorHeight = GameEventSelectorRect.rect.height;
|
||||
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
|
||||
|
||||
eventsParent = EventRef.transform.parent.GetChild(2).GetComponent<RectTransform>();
|
||||
SelectGame("Game Manager", 1);
|
||||
|
||||
@ -40,7 +48,7 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(!Conductor.instance.NotStopped())
|
||||
if(!(EventParameterManager.instance.active || Conductor.instance.NotStopped()))
|
||||
{
|
||||
if (gameOpen)
|
||||
{
|
||||
@ -54,11 +62,14 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.mouseScrollDelta.y != 0)
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(GameEventSelectorCanScroll, Input.mousePosition, Editor.instance.EditorCamera) && Input.mouseScrollDelta.y != 0)
|
||||
{
|
||||
UpdateIndex(currentEventIndex - Mathf.RoundToInt(Input.mouseScrollDelta.y));
|
||||
}
|
||||
}
|
||||
|
||||
//moved here so this updates dynamically with window scale
|
||||
UpdateScrollPosition();
|
||||
}
|
||||
|
||||
#region Functions
|
||||
@ -75,26 +86,32 @@ namespace HeavenStudio.Editor
|
||||
else if (currentEventIndex > eventsParent.childCount - 1)
|
||||
currentEventIndex = 0;
|
||||
|
||||
if (currentEventIndex > 2 && eventsParent.childCount >= 8)
|
||||
{
|
||||
if (eventsParent.childCount - 4 > currentEventIndex)
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (currentEventIndex - 2), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((EventRef.GetComponent<RectTransform>().sizeDelta.y) * (eventsParent.childCount - 7), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
}
|
||||
else
|
||||
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
|
||||
|
||||
CurrentSelected.transform.DOLocalMoveY(eventsParent.transform.GetChild(currentEventIndex).localPosition.y + eventsParent.transform.localPosition.y, 0.35f).SetEase(Ease.OutExpo);
|
||||
|
||||
if (updateCol)
|
||||
SetColors(currentEventIndex);
|
||||
}
|
||||
|
||||
private void UpdateScrollPosition()
|
||||
{
|
||||
selectorHeight = GameEventSelectorRect.rect.height;
|
||||
eventSize = EventRef.GetComponent<RectTransform>().rect.height;
|
||||
|
||||
if (currentEventIndex * eventSize >= selectorHeight/2 && eventsParent.childCount * eventSize >= selectorHeight)
|
||||
{
|
||||
if (currentEventIndex * eventSize < eventsParent.childCount * eventSize - selectorHeight/2)
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((currentEventIndex * eventSize) - selectorHeight/2, 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
else
|
||||
{
|
||||
EventRef.transform.parent.DOLocalMoveY((eventsParent.childCount * eventSize) - selectorHeight + (eventSize*0.33f), 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
}
|
||||
else
|
||||
EventRef.transform.parent.DOLocalMoveY(0, 0.35f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
|
||||
public void SelectGame(string gameName, int index)
|
||||
{
|
||||
if (SelectedGameIcon != null)
|
||||
|
8
Assets/Scripts/LevelEditor/SettingsDialog.meta
Normal file
8
Assets/Scripts/LevelEditor/SettingsDialog.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 907f7d1eb5d90af408aa531ea366e63e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
Normal file
27
Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SettingsDialog : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject settingsMenu;
|
||||
|
||||
private void Start() {}
|
||||
|
||||
public void SwitchSettingsDialog()
|
||||
{
|
||||
if(settingsMenu.activeSelf) {
|
||||
settingsMenu.SetActive(false);
|
||||
} else {
|
||||
settingsMenu.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update() {}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d82cc04699de2e54483ca0e0468d9ed2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/LevelEditor/SnapDialog.meta
Normal file
8
Assets/Scripts/LevelEditor/SnapDialog.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 537580972fcefa548bd9ee5e8254cbfc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
Assets/Scripts/LevelEditor/SnapDialog/SnapChangeButton.cs
Normal file
22
Assets/Scripts/LevelEditor/SnapDialog/SnapChangeButton.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SnapChangeButton : Button, IPointerDownHandler
|
||||
{
|
||||
public SnapDialog SnapDialog;
|
||||
public bool isDown;
|
||||
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
SnapDialog.ChangeCommon(isDown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7e0cac45de7228a4c8f7bc6adb0751a2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
52
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs
Normal file
52
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class SnapDialog : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject snapSetter;
|
||||
[SerializeField] private TMP_Text snapText;
|
||||
private Timeline timeline;
|
||||
|
||||
private static float[] CommonDenominators = { 1, 2, 3, 4, 6, 8, 12, 16};
|
||||
private int currentCommon = 3;
|
||||
private void Start()
|
||||
{
|
||||
timeline = Timeline.instance;
|
||||
}
|
||||
|
||||
public void SwitchSnapDialog()
|
||||
{
|
||||
if(snapSetter.activeSelf) {
|
||||
snapSetter.SetActive(false);
|
||||
} else {
|
||||
snapSetter.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeCommon(bool down = false)
|
||||
{
|
||||
if(down) {
|
||||
currentCommon--;
|
||||
} else {
|
||||
currentCommon++;
|
||||
}
|
||||
if(currentCommon < 0) {
|
||||
currentCommon = 0;
|
||||
} else if(currentCommon >= CommonDenominators.Length) {
|
||||
currentCommon = CommonDenominators.Length - 1;
|
||||
}
|
||||
timeline.SetSnap(1f / CommonDenominators[currentCommon]);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
snapText.text = $"1/{CommonDenominators[currentCommon]}";
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/SnapDialog/SnapDialog.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f32d53b1d58c64e41b71bd7520435169
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/LevelEditor/TempoFinder.meta
Normal file
8
Assets/Scripts/LevelEditor/TempoFinder.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36b14c8563ea37442aa7a2f0342549b5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
43
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs
Normal file
43
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class TempoFinder : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject tempoFinder;
|
||||
private bool pressed;
|
||||
private float timePressed;
|
||||
[SerializeField] private BPMText bpmText;
|
||||
private void Awake()
|
||||
{
|
||||
pressed = false;
|
||||
timePressed = 0f;
|
||||
}
|
||||
public void SwitchTempoDialog()
|
||||
{
|
||||
if(tempoFinder.activeSelf) {
|
||||
tempoFinder.SetActive(false);
|
||||
timePressed = 0;
|
||||
bpmText.ResetText();
|
||||
} else {
|
||||
tempoFinder.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void TapBPM()
|
||||
{
|
||||
pressed = true;
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
timePressed += Time.deltaTime;
|
||||
if(pressed)
|
||||
{
|
||||
pressed = false;
|
||||
bpmText.ChangeText(timePressed);
|
||||
timePressed = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/TempoFinder/TempoFinder.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1b489f3aef16a65499f9596abda39c35
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
20
Assets/Scripts/LevelEditor/TempoFinder/TempoFinderButton.cs
Normal file
20
Assets/Scripts/LevelEditor/TempoFinder/TempoFinderButton.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class TempoFinderButton : Button, IPointerDownHandler
|
||||
{
|
||||
public TempoFinder tempoFinder;
|
||||
public override void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
if (eventData.button == PointerEventData.InputButton.Left)
|
||||
{
|
||||
tempoFinder.TapBPM();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9557e460670800e458d7bb141135de55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
36
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs
Normal file
36
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
using TMPro;
|
||||
using Starpelly;
|
||||
|
||||
namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
public class LayerLabel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RectTransform rect;
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//convert timeline layer scale to screen space
|
||||
Camera cam;
|
||||
//"your program can't crash if you put everything in a try block"
|
||||
try
|
||||
{
|
||||
cam = Editor.instance.EditorCamera;
|
||||
float layerScaleDist = cam.WorldToScreenPoint(Timeline.instance.LayerCorners[1]).y - Camera.main.WorldToScreenPoint(Timeline.instance.LayerCorners[0]).y;
|
||||
float modScale = Timeline.GetScaleModifier();
|
||||
rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, layerScaleDist/4 * (1/modScale));
|
||||
}
|
||||
catch (System.NullReferenceException)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
11
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs.meta
Normal file
11
Assets/Scripts/LevelEditor/Timeline/LayerLabel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b90b6b57a843c2245bfdae87a3e8fb21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -72,6 +72,7 @@ namespace HeavenStudio.Editor.Track
|
||||
GameManager.instance.Beatmap.bpm += increase;
|
||||
UpdateStartingBPMText();
|
||||
UpdateStartingBPMFromText(); // In case the scrolled-to value is invalid.
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +110,8 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
// In case the newBPM ended up differing from the inputted string.
|
||||
UpdateStartingBPMText();
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
|
||||
public void UpdateOffsetFromText()
|
||||
@ -128,7 +131,16 @@ namespace HeavenStudio.Editor.Track
|
||||
UpdateOffsetText();
|
||||
}
|
||||
|
||||
private void AddTempoChange(bool create, Beatmap.TempoChange tempoChange_ = null)
|
||||
public void ClearTempoTimeline()
|
||||
{
|
||||
foreach (TempoTimelineObj tempoTimelineObj in tempoTimelineObjs)
|
||||
{
|
||||
Destroy(tempoTimelineObj.gameObject);
|
||||
}
|
||||
tempoTimelineObjs.Clear();
|
||||
}
|
||||
|
||||
public void AddTempoChange(bool create, Beatmap.TempoChange tempoChange_ = null)
|
||||
{
|
||||
GameObject tempoChange = Instantiate(RefTempoChange.gameObject, this.transform);
|
||||
|
||||
@ -160,6 +172,8 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
|
||||
tempoTimelineObjs.Add(tempoTimelineObj);
|
||||
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,10 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
tempoChange.tempo += newTempo;
|
||||
|
||||
//make sure tempo is positive
|
||||
if (tempoChange.tempo < 1)
|
||||
tempoChange.tempo = 1;
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
@ -96,6 +100,7 @@ namespace HeavenStudio.Editor.Track
|
||||
private void UpdateTempo()
|
||||
{
|
||||
tempoTXT.text = $"{tempoChange.tempo} BPM";
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,8 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
public static float SnapInterval() { return instance.snapInterval; }
|
||||
|
||||
public void SetSnap(float snap) { snapInterval = snap; }
|
||||
|
||||
public class CurrentTimelineState
|
||||
{
|
||||
public bool selected;
|
||||
@ -68,6 +70,7 @@ namespace HeavenStudio.Editor.Track
|
||||
[SerializeField] private RectTransform TimelineSongPosLineRef;
|
||||
[SerializeField] private RectTransform TimelineEventObjRef;
|
||||
[SerializeField] private RectTransform LayersRect;
|
||||
|
||||
public TempoTimeline TempoInfo;
|
||||
public VolumeTimeline VolumeInfo;
|
||||
private RectTransform TimelineSongPosLine;
|
||||
@ -83,6 +86,8 @@ namespace HeavenStudio.Editor.Track
|
||||
public Button MusicVolumeBTN;
|
||||
public Slider PlaybackSpeed;
|
||||
|
||||
public Vector3[] LayerCorners = new Vector3[4];
|
||||
|
||||
public static Timeline instance { get; private set; }
|
||||
|
||||
public bool userIsEditingInputField
|
||||
@ -98,6 +103,7 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
public void LoadRemix()
|
||||
{
|
||||
// beatmap entities
|
||||
for (int i = 0; i < eventObjs.Count; i++)
|
||||
{
|
||||
Destroy(eventObjs[i].gameObject);
|
||||
@ -106,11 +112,21 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.entities.Count; i++)
|
||||
{
|
||||
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, RandomID());
|
||||
}
|
||||
|
||||
//tempo changes
|
||||
TempoInfo.ClearTempoTimeline();
|
||||
for (int i = 0; i < GameManager.instance.Beatmap.tempoChanges.Count; i++)
|
||||
{
|
||||
var t = GameManager.instance.Beatmap.tempoChanges[i];
|
||||
|
||||
TempoInfo.AddTempoChange(false, t);
|
||||
}
|
||||
|
||||
//volume changes
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@ -256,9 +272,11 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
SliderControl();
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
#region Keyboard Shortcuts
|
||||
if (!userIsEditingInputField)
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
@ -269,20 +287,44 @@ namespace HeavenStudio.Editor.Track
|
||||
PlayCheck(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.P))
|
||||
{
|
||||
AutoPlayToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
if (!Editor.instance.editingInputField)
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
MetronomeToggle();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1))
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2))
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3))
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (Input.GetMouseButton(1) && !Conductor.instance.isPlaying && Editor.MouseInRectTransform(TimelineGridSelect))
|
||||
{
|
||||
@ -304,21 +346,6 @@ namespace HeavenStudio.Editor.Track
|
||||
lastBeatPos = TimelineSlider.localPosition.x;
|
||||
}
|
||||
|
||||
float moveSpeed = 750;
|
||||
if (Input.GetKey(KeyCode.LeftShift)) moveSpeed *= 2;
|
||||
|
||||
if (!Editor.instance.editingInputField)
|
||||
{
|
||||
if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
else if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
|
||||
{
|
||||
TimelineContent.transform.localPosition += new Vector3(-moveSpeed * Time.deltaTime, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Conductor.instance.isPlaying)
|
||||
TimelineContent.transform.localPosition = new Vector3((-Conductor.instance.songPositionInBeats * 100) + 200, TimelineContent.transform.localPosition.y);
|
||||
|
||||
@ -326,18 +353,19 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
CurrentTempo.text = $" = {Conductor.instance.songBpm}";
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Alpha1) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(true, false, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha2) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, true, false);
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.Alpha3) && !userIsEditingInputField)
|
||||
{
|
||||
timelineState.SetState(false, false, true);
|
||||
}
|
||||
LayersRect.GetWorldCorners(LayerCorners);
|
||||
}
|
||||
|
||||
public static float GetScaleModifier()
|
||||
{
|
||||
Camera cam = Editor.instance.EditorCamera;
|
||||
return Mathf.Pow(cam.pixelWidth/1280f, 1f) * Mathf.Pow(cam.pixelHeight/720f, 0f);
|
||||
}
|
||||
|
||||
public Vector2 LayerCornersToDist()
|
||||
{
|
||||
Vector3[] v = LayerCorners;
|
||||
return new Vector2(Mathf.Abs(v[1].x - v[2].x), Mathf.Abs(v[3].y - v[1].y));
|
||||
}
|
||||
|
||||
private void SliderControl()
|
||||
@ -544,36 +572,36 @@ namespace HeavenStudio.Editor.Track
|
||||
GameManager.instance.SortEventsList();
|
||||
|
||||
tempEntity = en;
|
||||
|
||||
// default param value
|
||||
var game = EventCaller.instance.GetMinigame(eventName.Split(0));
|
||||
var ep = EventCaller.instance.GetGameAction(game, eventName.Split(1)).parameters;
|
||||
|
||||
if (ep != null)
|
||||
{
|
||||
for (int i = 0; i < ep.Count; i++)
|
||||
{
|
||||
object returnVal = ep[i].parameter;
|
||||
|
||||
var propertyType = returnVal.GetType();
|
||||
if (propertyType == typeof(EntityTypes.Integer))
|
||||
{
|
||||
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
||||
}
|
||||
else if (propertyType == typeof(EntityTypes.Float))
|
||||
{
|
||||
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
||||
}
|
||||
|
||||
tempEntity[ep[i].propertyName] = returnVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.instance.Beatmap.entities.Add(entity);
|
||||
GameManager.instance.SortEventsList();
|
||||
}
|
||||
|
||||
// default param value
|
||||
var game = EventCaller.instance.GetMinigame(eventName.Split(0));
|
||||
var ep = EventCaller.instance.GetGameAction(game, eventName.Split(1)).parameters;
|
||||
|
||||
if (ep != null)
|
||||
{
|
||||
for (int i = 0; i < ep.Count; i++)
|
||||
{
|
||||
object returnVal = ep[i].parameter;
|
||||
|
||||
var propertyType = returnVal.GetType();
|
||||
if (propertyType == typeof(EntityTypes.Integer))
|
||||
{
|
||||
returnVal = ((EntityTypes.Integer)ep[i].parameter).val;
|
||||
}
|
||||
else if (propertyType == typeof(EntityTypes.Float))
|
||||
{
|
||||
returnVal = ((EntityTypes.Float)ep[i].parameter).val;
|
||||
}
|
||||
|
||||
tempEntity[ep[i].propertyName] = returnVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
eventObjs.Add(eventObj);
|
||||
@ -583,6 +611,14 @@ namespace HeavenStudio.Editor.Track
|
||||
return eventObj;
|
||||
}
|
||||
|
||||
public TimelineEventObj CopyEventObject(Beatmap.Entity e)
|
||||
{
|
||||
Beatmap.Entity clone = e.DeepCopy();
|
||||
TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
public void DestroyEventObject(Beatmap.Entity entity)
|
||||
{
|
||||
if (EventParameterManager.instance.entity == entity)
|
||||
|
@ -26,7 +26,7 @@ namespace HeavenStudio.Editor.Track
|
||||
[SerializeField] private RectTransform resizeGraphic;
|
||||
[SerializeField] private RectTransform leftDrag;
|
||||
[SerializeField] private RectTransform rightDrag;
|
||||
private GameObject moveTemp;
|
||||
// private GameObject moveTemp;
|
||||
|
||||
[Header("Properties")]
|
||||
public Beatmap.Entity entity;
|
||||
@ -41,6 +41,7 @@ namespace HeavenStudio.Editor.Track
|
||||
private bool resizingLeft;
|
||||
private bool resizingRight;
|
||||
private bool inResizeRegion;
|
||||
private bool wasDuplicated;
|
||||
public Vector2 lastMovePos;
|
||||
public bool isCreating;
|
||||
public string eventObjID;
|
||||
@ -61,8 +62,9 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
lastMovePos = transform.localPosition;
|
||||
|
||||
moveTemp = new GameObject();
|
||||
moveTemp.transform.SetParent(this.transform.parent);
|
||||
// what the fuck????
|
||||
// moveTemp = new GameObject();
|
||||
// moveTemp.transform.SetParent(this.transform.parent);
|
||||
|
||||
bool visible = rectTransform.IsVisibleFrom(Editor.instance.EditorCamera);
|
||||
for (int i = 0; i < this.transform.childCount; i++)
|
||||
@ -105,7 +107,7 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
#endregion
|
||||
|
||||
SetColor(GetTrack());
|
||||
SetColor(entity.track);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
@ -132,6 +134,20 @@ namespace HeavenStudio.Editor.Track
|
||||
if (Conductor.instance.NotStopped())
|
||||
{
|
||||
Cancel();
|
||||
|
||||
if (moving)
|
||||
moving = false;
|
||||
|
||||
if (selected)
|
||||
{
|
||||
selected = false;
|
||||
selectedImage.gameObject.SetActive(false);
|
||||
for (int i = 0; i < outline.childCount; i++)
|
||||
outline.GetChild(i).GetComponent<Image>().color = new Color32(0, 0, 0, 51);
|
||||
}
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Timeline.instance.LayerHeight());
|
||||
this.transform.localPosition = new Vector3(this.transform.localPosition.x, -entity.track * Timeline.instance.LayerHeight());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -152,19 +168,23 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
|
||||
{
|
||||
//duplicate the entity if holding alt or r-click
|
||||
if ((!wasDuplicated) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetMouseButton(1)))
|
||||
{
|
||||
wasDuplicated = true;
|
||||
var te = Timeline.instance.CopyEventObject(entity);
|
||||
}
|
||||
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
lastPos_ = transform.localPosition;
|
||||
|
||||
this.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
this.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(this.transform.localPosition.x, Timeline.SnapInterval()), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
// moveTemp.transform.position = new Vector3(mousePos.x - startPosX, mousePos.y - startPosY - 0.40f, 0);
|
||||
// moveTemp.transform.localPosition = new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y));
|
||||
this.transform.localPosition = new Vector3(Mathf.Max(Mathp.Round2Nearest(this.transform.localPosition.x, Timeline.SnapInterval()), 0), Timeline.instance.SnapToLayer(this.transform.localPosition.y));
|
||||
|
||||
if (lastPos != transform.localPosition)
|
||||
{
|
||||
OnMove();
|
||||
// this.transform.DOLocalMove(new Vector3(Mathf.Clamp(Mathp.Round2Nearest(moveTemp.transform.localPosition.x, 0.25f), 0, Mathf.Infinity), Timeline.instance.SnapToLayer(moveTemp.transform.localPosition.y)), 0.15f).SetEase(Ease.OutExpo);
|
||||
}
|
||||
|
||||
lastPos = transform.localPosition;
|
||||
@ -215,6 +235,9 @@ namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
|
||||
}
|
||||
|
||||
rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Timeline.instance.LayerHeight());
|
||||
this.transform.localPosition = new Vector3(this.transform.localPosition.x, -entity.track * Timeline.instance.LayerHeight());
|
||||
}
|
||||
|
||||
#region ClickEvents
|
||||
@ -276,6 +299,7 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
|
||||
moving = false;
|
||||
wasDuplicated = false;
|
||||
|
||||
Cancel();
|
||||
if (isCreating == true)
|
||||
|
@ -16,6 +16,8 @@ namespace HeavenStudio.Editor.Track
|
||||
public TMP_InputField StartingVolume;
|
||||
private RectTransform StartingVolumeRect;
|
||||
|
||||
public List<VolumeTimelineObj> volumeTimelineObjs = new List<VolumeTimelineObj>();
|
||||
|
||||
private bool firstUpdate;
|
||||
|
||||
void Start()
|
||||
@ -74,8 +76,8 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
else if (newVol < 0)
|
||||
{
|
||||
StartingVolume.text = "1";
|
||||
newVol = 1;
|
||||
StartingVolume.text = "0";
|
||||
newVol = 0;
|
||||
}
|
||||
|
||||
GameManager.instance.Beatmap.musicVolume = newVol;
|
||||
|
105
Assets/Scripts/LevelEditor/Timeline/VolumeTimelineObj.cs
Normal file
105
Assets/Scripts/LevelEditor/Timeline/VolumeTimelineObj.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using TMPro;
|
||||
|
||||
using DG.Tweening;
|
||||
|
||||
namespace HeavenStudio.Editor.Track
|
||||
{
|
||||
public class VolumeTimelineObj : MonoBehaviour
|
||||
{
|
||||
[Header("Components")]
|
||||
[SerializeField] private RectTransform rectTransform;
|
||||
[SerializeField] private TMP_Text volumeTXT;
|
||||
[SerializeField] private RectTransform raycastRect;
|
||||
|
||||
public Beatmap.VolumeChange volumeChange;
|
||||
|
||||
private float startPosX;
|
||||
private bool moving = false;
|
||||
|
||||
public bool hovering;
|
||||
|
||||
private float lastPosX;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
rectTransform = GetComponent<RectTransform>();
|
||||
volumeTXT = transform.GetChild(2).GetComponent<TMP_Text>();
|
||||
UpdateVolume();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Timeline.instance.timelineState.musicVolume && !Conductor.instance.NotStopped())
|
||||
{
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(raycastRect, Input.mousePosition, Editor.instance.EditorCamera))
|
||||
{
|
||||
float newVolume = Input.mouseScrollDelta.y;
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift))
|
||||
newVolume *= 5f;
|
||||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
newVolume /= 100f;
|
||||
|
||||
volumeChange.volume += newVolume;
|
||||
|
||||
//make sure volume is positive
|
||||
volumeChange.volume = Mathf.Clamp(volumeChange.volume, 0, 100);
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
startPosX = mousePos.x - transform.position.x;
|
||||
moving = true;
|
||||
lastPosX = transform.localPosition.x;
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
GameManager.instance.Beatmap.volumeChanges.Remove(volumeChange);
|
||||
transform.parent.GetComponent<VolumeTimeline>().volumeTimelineObjs.Remove(this);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
hovering = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
hovering = false;
|
||||
}
|
||||
|
||||
if (moving)
|
||||
{
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
|
||||
transform.position = new Vector3(mousePos.x - startPosX, transform.position.y, 0);
|
||||
transform.localPosition = new Vector3(Mathf.Clamp(Starpelly.Mathp.Round2Nearest(transform.localPosition.x, Timeline.SnapInterval()), 0, Mathf.Infinity), transform.localPosition.y);
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if (transform.parent.GetComponent<VolumeTimeline>().volumeTimelineObjs.Find(c => c.gameObject.transform.localPosition.x == this.transform.localPosition.x && c != this) != null)
|
||||
{
|
||||
transform.localPosition = new Vector3(lastPosX, transform.localPosition.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
volumeChange.beat = transform.localPosition.x;
|
||||
}
|
||||
|
||||
moving = false;
|
||||
lastPosX = transform.localPosition.x;
|
||||
}
|
||||
|
||||
UpdateVolume();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateVolume()
|
||||
{
|
||||
volumeTXT.text = $"{volumeChange.volume}%";
|
||||
Timeline.instance.FitToSong();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86bb8f2f290876a4387f1ea6fedf332b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -27,27 +27,33 @@ namespace HeavenStudio.Editor
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Vector2 anchoredPosition = Input.mousePosition;
|
||||
Vector3 anchoredPosition = Input.mousePosition;
|
||||
Camera camera = Editor.instance.EditorCamera;
|
||||
Vector3 canvasScale = Editor.instance.MainCanvas.transform.localScale;
|
||||
Vector2 scale = new Vector2(canvasScale.x, canvasScale.y);
|
||||
float toolTipScale = camera.pixelWidth / 1280f;
|
||||
|
||||
if (anchoredPosition.x + background.rect.width > canvasRect.rect.width)
|
||||
if (anchoredPosition.x + background.rect.width * toolTipScale > camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = canvasRect.rect.width - background.rect.width;
|
||||
anchoredPosition.x = camera.pixelWidth - background.rect.width * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.x < 0)
|
||||
if (anchoredPosition.x < -camera.pixelWidth)
|
||||
{
|
||||
anchoredPosition.x = 0;
|
||||
anchoredPosition.x = -camera.pixelWidth;
|
||||
}
|
||||
|
||||
if (anchoredPosition.y + background.rect.height > canvasRect.rect.height)
|
||||
if (anchoredPosition.y + background.rect.height * toolTipScale > camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = canvasRect.rect.height - background.rect.height;
|
||||
anchoredPosition.y = camera.pixelHeight - background.rect.height * toolTipScale;
|
||||
}
|
||||
if (anchoredPosition.y < 0)
|
||||
if (anchoredPosition.y < -camera.pixelHeight)
|
||||
{
|
||||
anchoredPosition.y = 0;
|
||||
anchoredPosition.y = -camera.pixelHeight;
|
||||
}
|
||||
|
||||
rectTransform.anchoredPosition = anchoredPosition;
|
||||
anchoredPosition.z = camera.nearClipPlane;
|
||||
anchoredPosition = camera.ScreenToWorldPoint(anchoredPosition);
|
||||
rectTransform.anchoredPosition = anchoredPosition / scale;
|
||||
}
|
||||
|
||||
public static void OnEnter(string tooltipText, string altTooltipText)
|
||||
|
94
Assets/Scripts/Util/UiScrollRectEventBubbling.cs
Normal file
94
Assets/Scripts/Util/UiScrollRectEventBubbling.cs
Normal file
@ -0,0 +1,94 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using static UnityEngine.EventSystems.ExecuteEvents;
|
||||
|
||||
namespace kamgam
|
||||
{
|
||||
/// <summary>
|
||||
/// Bubbles events to the parent. Use this to overcome EventTriggers which stop scroll and drag events from bubbling.
|
||||
///
|
||||
/// If an EventTrigger component is attached and other code is listening for
|
||||
/// onPointer events then these will NOT be triggered while dragging if DisableEventTriggerWhileDragging
|
||||
/// is true.
|
||||
/// </summary>
|
||||
public class UiScrollRectEventBubbling : MonoBehaviour,
|
||||
IBeginDragHandler,
|
||||
IDragHandler,
|
||||
IEndDragHandler,
|
||||
IScrollHandler
|
||||
|
||||
{
|
||||
[Tooltip("Should the scroll and drag events be forwarded (bubble up) to the parent?")]
|
||||
public bool Bubble = true;
|
||||
|
||||
[Tooltip("Stop EventTriggers from executing events while dragging?")]
|
||||
public bool DisableEventTriggerWhileDragging = true;
|
||||
|
||||
protected EventTrigger eventTrigger;
|
||||
public EventTrigger EventTrigger
|
||||
{
|
||||
get
|
||||
{
|
||||
if (eventTrigger == null)
|
||||
{
|
||||
eventTrigger = this.GetComponent<EventTrigger>();
|
||||
}
|
||||
return eventTrigger;
|
||||
}
|
||||
}
|
||||
|
||||
protected bool dragging = false;
|
||||
|
||||
protected void HandleEventPropagation<T>(Transform goTransform, BaseEventData eventData, EventFunction<T> callbackFunction) where T : IEventSystemHandler
|
||||
{
|
||||
if (Bubble && goTransform.parent != null)
|
||||
{
|
||||
ExecuteEvents.ExecuteHierarchy(goTransform.parent.gameObject, eventData, callbackFunction);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnScroll(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.scrollHandler);
|
||||
}
|
||||
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.beginDragHandler);
|
||||
|
||||
dragging = true;
|
||||
if (DisableEventTriggerWhileDragging && EventTrigger != null)
|
||||
{
|
||||
EventTrigger.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.dragHandler);
|
||||
}
|
||||
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
HandleEventPropagation(transform, eventData, ExecuteEvents.endDragHandler);
|
||||
|
||||
dragging = false;
|
||||
if (DisableEventTriggerWhileDragging && EventTrigger != null)
|
||||
{
|
||||
EventTrigger.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the object is disabled while being dragged then the EventTrigger would remain disabled.
|
||||
/// </summary>
|
||||
public void OnDisable()
|
||||
{
|
||||
if (DisableEventTriggerWhileDragging && dragging && EventTrigger != null)
|
||||
{
|
||||
dragging = false;
|
||||
EventTrigger.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Util/UiScrollRectEventBubbling.cs.meta
Normal file
11
Assets/Scripts/Util/UiScrollRectEventBubbling.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3ed2b8848b1a2c40819efeb60cbf9ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user