mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 09:57:38 +02:00
Merge remote-tracking branch 'upstream/master'
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -11,7 +11,11 @@ namespace HeavenStudio.Games.Loaders
|
||||
public static Minigame AddGame(EventCaller eventCaller) {
|
||||
return new Minigame("djSchool", "DJ School", "008c97", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("bop", delegate { DJSchool.instance.Bop(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 0.5f, true),
|
||||
//new GameAction("bop", delegate { DJSchool.instance.Bop(eventCaller.currentEntity.beat, eventCaller.currentEntity.length); }, 0.5f, true),
|
||||
new GameAction("bop", delegate { DJSchool.instance.Bop(eventCaller.currentEntity.toggle); }, 0.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", true, "Bop", "Whether both will bop to the beat or not")
|
||||
}),
|
||||
new GameAction("and stop ooh", delegate { var e = eventCaller.currentEntity; DJSchool.instance.AndStop(e.beat, e.toggle); }, 2.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", true, "Ooh", "Whether or not the \"ooh\" sound should be played")
|
||||
@ -25,6 +29,14 @@ namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
new Param("type", DJSchool.DJVoice.Standard, "Voice", "The voice line to play"),
|
||||
}),
|
||||
new GameAction("dj voice lines", delegate { DJSchool.instance.voiceLines(eventCaller.currentEntity.beat, eventCaller.currentEntity.type); }, 2f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", DJSchool.DJVoiceLines.CheckItOut, "Voice Lines", "The voice line to play"),
|
||||
}),
|
||||
new GameAction("sound FX", delegate { DJSchool.instance.soundFX(eventCaller.currentEntity.toggle); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Radio FX", "Toggle on and off for Radio Effects")
|
||||
})
|
||||
},
|
||||
new List<string>() {"ntr", "normal"},
|
||||
"ntrdj", "en",
|
||||
@ -47,16 +59,31 @@ namespace HeavenStudio.Games
|
||||
Hyped
|
||||
}
|
||||
|
||||
public enum DJVoiceLines
|
||||
{
|
||||
CheckItOut,
|
||||
LetsGo,
|
||||
OhYeah,
|
||||
OhYeahAlt,
|
||||
Yay
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private Student student;
|
||||
[SerializeField] private GameObject djYellow;
|
||||
private Animator djYellowAnim;
|
||||
[SerializeField] private SpriteRenderer headSprite;
|
||||
[SerializeField] private Sprite[] headSprites;
|
||||
private float lastReportedBeat = 0f;
|
||||
|
||||
[Header("Properties")]
|
||||
public GameEvent bop = new GameEvent();
|
||||
private bool djYellowHolding;
|
||||
public bool andStop;
|
||||
public bool goBop;
|
||||
public float beatOfInstance;
|
||||
|
||||
public static DJSchool instance { get; private set; }
|
||||
|
||||
@ -65,53 +92,117 @@ namespace HeavenStudio.Games
|
||||
instance = this;
|
||||
djYellowAnim = djYellow.GetComponent<Animator>();
|
||||
student.Init();
|
||||
goBop = true;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
#region old script
|
||||
//var cond = Conductor.instance;
|
||||
|
||||
if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
//if (cond.ReportBeat(ref bop.lastReportedBeat, bop.startBeat % 1))
|
||||
//{
|
||||
// if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length)
|
||||
// {
|
||||
// if (student.anim.IsAnimationNotPlaying())
|
||||
// {
|
||||
// if (student.isHolding)
|
||||
// {
|
||||
// student.anim.Play("HoldBop", 0, 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// student.anim.Play("IdleBop", 0, 0);
|
||||
// }
|
||||
// }
|
||||
// if (djYellowAnim.IsAnimationNotPlaying())
|
||||
// {
|
||||
// var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
|
||||
// if (yellowState.IsName("Hey"))
|
||||
// {
|
||||
// PostScratchoFace();
|
||||
// }
|
||||
|
||||
// if (djYellowHolding)
|
||||
// {
|
||||
// djYellowAnim.Play("HoldBop", 0, 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // todo: split between left and right bop based on beat
|
||||
// djYellowAnim.Play("IdleBop", 0, 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
{
|
||||
if (cond.songPositionInBeats >= bop.startBeat && cond.songPositionInBeats < bop.startBeat + bop.length)
|
||||
if (goBop)
|
||||
{
|
||||
if (student.anim.IsAnimationNotPlaying())
|
||||
if (student.isHolding)
|
||||
{
|
||||
if (student.isHolding)
|
||||
{
|
||||
student.anim.Play("HoldBop", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
student.anim.Play("IdleBop", 0, 0);
|
||||
}
|
||||
student.anim.Play("HoldBop", 0, 0);
|
||||
}
|
||||
if (djYellowAnim.IsAnimationNotPlaying())
|
||||
else if (!student.swiping && student.anim.IsAnimationNotPlaying())
|
||||
{
|
||||
var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
|
||||
if (yellowState.IsName("Hey"))
|
||||
{
|
||||
PostScratchoFace();
|
||||
}
|
||||
student.anim.Play("IdleBop", 0, 0);
|
||||
}
|
||||
|
||||
if (djYellowHolding)
|
||||
{
|
||||
djYellowAnim.Play("HoldBop", 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// todo: split between left and right bop based on beat
|
||||
djYellowAnim.Play("IdleBop", 0, 0);
|
||||
}
|
||||
var yellowState = djYellowAnim.GetCurrentAnimatorStateInfo(0);
|
||||
if (yellowState.IsName("Hey"))
|
||||
{
|
||||
PostScratchoFace();
|
||||
}
|
||||
if (!andStop && !djYellowHolding)
|
||||
{
|
||||
djYellowAnim.Play("IdleBop", 0, 0);
|
||||
|
||||
}
|
||||
else if (djYellowHolding)
|
||||
{
|
||||
djYellowAnim.Play("HoldBop", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (Conductor.instance.songPositionInBeats < lastReportedBeat)
|
||||
{
|
||||
lastReportedBeat = Mathf.Round(Conductor.instance.songPositionInBeats);
|
||||
}
|
||||
|
||||
if(PlayerInput.Pressed() && !IsExpectingInputNow() && !student.isHolding) //Start hold miss
|
||||
{
|
||||
student.OnMissHoldForPlayerInput();
|
||||
student.isHolding = true;
|
||||
}
|
||||
else if(PlayerInput.PressedUp() && !IsExpectingInputNow() && student.isHolding) //Let go during hold
|
||||
{
|
||||
student.UnHold();
|
||||
}
|
||||
//else if(PlayerInput.PressedUp() && !IsExpectingInputNow() && !student.isHolding)
|
||||
//{
|
||||
// student.OnMissSwipeForPlayerInput();
|
||||
//}
|
||||
}
|
||||
|
||||
public void Bop(float beat, float length)
|
||||
//public void Bop(float beat, float length)
|
||||
//{
|
||||
// bop.startBeat = beat;
|
||||
// bop.length = length;
|
||||
//}
|
||||
|
||||
public void Bop(bool isBopping)
|
||||
{
|
||||
bop.startBeat = beat;
|
||||
bop.length = length;
|
||||
if (isBopping)
|
||||
{
|
||||
goBop = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
goBop = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void BreakCmon(float beat, int type, bool ooh)
|
||||
@ -148,19 +239,20 @@ namespace HeavenStudio.Games
|
||||
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); SetupCue(beat, false); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2f, delegate
|
||||
{
|
||||
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
||||
djYellowHolding = true;
|
||||
}),
|
||||
});
|
||||
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, student.OnHitHold, student.OnMissHold, student.OnEmpty);
|
||||
}
|
||||
|
||||
public void AndStop(float beat, bool ooh)
|
||||
{
|
||||
if (djYellowHolding) return;
|
||||
|
||||
var sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("djSchool/andStop1", beat),
|
||||
@ -175,13 +267,16 @@ namespace HeavenStudio.Games
|
||||
|
||||
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 0.5f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); SetupCue(beat - 0.5f, false); }),
|
||||
new BeatAction.Action(beat + 0.5f, delegate { djYellow.GetComponent<Animator>().Play("BreakCmon", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate
|
||||
{
|
||||
djYellow.GetComponent<Animator>().Play("Hold", 0, 0);
|
||||
djYellowHolding = true;
|
||||
}),
|
||||
});
|
||||
andStop = true;
|
||||
|
||||
ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, student.OnHitHold, student.OnMissHold, student.OnEmpty);
|
||||
}
|
||||
|
||||
public void ScratchoHey(float beat, int type)
|
||||
@ -213,25 +308,34 @@ namespace HeavenStudio.Games
|
||||
BeatAction.New(djYellow, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { djYellow.GetComponent<Animator>().Play("Scratcho", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("Scratcho2", 0, 0); SetupCue(beat, true); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { djYellow.GetComponent<Animator>().Play("Scratcho2", 0, 0); }),
|
||||
//new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("Scratcho", 0, 0); SetupCue(beat, true); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { djYellow.GetComponent<Animator>().Play("Scratcho", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2.05f, delegate
|
||||
{
|
||||
djYellow.GetComponent<Animator>().Play("Hey", 0, 0);
|
||||
djYellowHolding = false;
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
beatOfInstance = beat;
|
||||
|
||||
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_UP, student.OnHitSwipe, student.OnMissSwipe, student.OnEmpty);
|
||||
andStop = false;
|
||||
}
|
||||
|
||||
void SetupCue(float beat, bool swipe)
|
||||
{
|
||||
if (swipe)
|
||||
student.swipeBeat = beat;
|
||||
else
|
||||
student.holdBeat = beat;
|
||||
//void SetupCue(float beat, bool swipe)
|
||||
//{
|
||||
// if (swipe)
|
||||
// student.swipeBeat = beat;
|
||||
// else
|
||||
// student.holdBeat = beat;
|
||||
|
||||
student.eligible = true;
|
||||
student.ResetState();
|
||||
}
|
||||
// student.eligible = true;
|
||||
// student.ResetState();
|
||||
//}
|
||||
|
||||
public void SetDJYellowHead(int type, bool resetAfterBeats = false)
|
||||
{
|
||||
@ -268,5 +372,67 @@ namespace HeavenStudio.Games
|
||||
SetDJYellowHead(2, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void soundFX(bool toggle)
|
||||
{
|
||||
student.soundFX = toggle;
|
||||
}
|
||||
public void voiceLines(float beat, int type)
|
||||
{
|
||||
string[] sounds;
|
||||
var sound = new MultiSound.Sound[] { };
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
sounds = new string[] { "djSchool/checkItOut1", "djSchool/checkItOut2", "djSchool/checkItOut3" };
|
||||
sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .25f),
|
||||
new MultiSound.Sound(sounds[2], beat + .5f),
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sounds = new string[] { "djSchool/letsGo1", "djSchool/letsGo2" };
|
||||
sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .5f),
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sounds = new string[] { "djSchool/ohYeah1", "djSchool/ohYeah2" };
|
||||
sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .5f),
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
sounds = new string[] { "djSchool/ohYeahAlt1", "djSchool/ohYeahAlt2", "djSchool/ohYeahAlt3" };
|
||||
sound = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds[0], beat),
|
||||
new MultiSound.Sound(sounds[1], beat + .5f),
|
||||
new MultiSound.Sound(sounds[2], beat + 1f),
|
||||
};
|
||||
|
||||
MultiSound.Play(sound);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
Jukebox.PlayOneShotGame("djSchool/yay");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
using DG.Tweening;
|
||||
using HeavenStudio.Util;
|
||||
@ -19,6 +20,8 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
public bool shouldBeHolding;
|
||||
public bool eligible;
|
||||
public bool missed;
|
||||
public bool swiping;
|
||||
public bool soundFX;
|
||||
|
||||
[Header("Components")]
|
||||
[SerializeField] private SpriteRenderer flash;
|
||||
@ -26,6 +29,7 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
[SerializeField] private GameObject flashFXInverse;
|
||||
[SerializeField] private GameObject TurnTable;
|
||||
[SerializeField] private GameObject slamFX;
|
||||
AudioMixerGroup mixer;
|
||||
|
||||
private Animator tableAnim;
|
||||
|
||||
@ -37,103 +41,91 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
anim = GetComponent<Animator>();
|
||||
tableAnim = TurnTable.GetComponent<Animator>();
|
||||
tableAnim.speed = 0;
|
||||
mixer = Resources.Load<AudioMixer>("MainMixer").FindMatchingGroups("Music")[0];
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float beatToUse = shouldBeHolding ? swipeBeat : holdBeat;
|
||||
float normalizedBeat = Conductor.instance.GetPositionFromMargin(beatToUse + 2, 1);
|
||||
|
||||
if (eligible)
|
||||
{
|
||||
StateCheck(normalizedBeat);
|
||||
|
||||
if (normalizedBeat > Minigame.LateTime())
|
||||
{
|
||||
eligible = false;
|
||||
missed = true;
|
||||
|
||||
if (shouldBeHolding)
|
||||
{
|
||||
shouldBeHolding = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isHolding)
|
||||
{
|
||||
if (PlayerInput.Pressed())
|
||||
{
|
||||
if (!shouldBeHolding && state.perfect && eligible)
|
||||
{
|
||||
Hold(true);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!shouldBeHolding)
|
||||
eligible = false;
|
||||
|
||||
Hold(false);
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (PlayerInput.PressedUp())
|
||||
{
|
||||
if (shouldBeHolding && state.perfect && eligible)
|
||||
{
|
||||
Swipe(true);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shouldBeHolding)
|
||||
{
|
||||
Swipe(false);
|
||||
eligible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
UnHold();
|
||||
}
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Hold(bool ace)
|
||||
#region old hold
|
||||
//public void Hold(bool ace)
|
||||
//{
|
||||
// isHolding = true;
|
||||
|
||||
// if (ace)
|
||||
// {
|
||||
// missed = false;
|
||||
// shouldBeHolding = true;
|
||||
// game.SetDJYellowHead(1);
|
||||
// }
|
||||
|
||||
// Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
// anim.Play("Hold", 0, 0);
|
||||
// tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
// if (ace)
|
||||
// {
|
||||
// if (soundFX)
|
||||
// {
|
||||
// Conductor.instance.djSchoolHold.TransitionTo(.01f);
|
||||
// }
|
||||
|
||||
// FlashFX(true);
|
||||
// }
|
||||
|
||||
// // Settings.GetMusicMixer().audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(0.15f);
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region onHold
|
||||
public void OnHitHold(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
isHolding = true;
|
||||
|
||||
if (ace)
|
||||
{
|
||||
missed = false;
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(1);
|
||||
}
|
||||
|
||||
missed = false;
|
||||
shouldBeHolding = true;
|
||||
game.SetDJYellowHead(1);
|
||||
|
||||
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
anim.Play("Hold", 0, 0);
|
||||
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
|
||||
if (ace)
|
||||
if (soundFX)
|
||||
{
|
||||
FlashFX(true);
|
||||
mixer.audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(.01f);
|
||||
}
|
||||
FlashFX(true);
|
||||
}
|
||||
|
||||
// Settings.GetMusicMixer().audioMixer.FindSnapshot("DJSchool_Hold").TransitionTo(0.15f);
|
||||
public void OnMissHold(PlayerActionEvent caller)
|
||||
{
|
||||
//isHolding = true;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
}
|
||||
|
||||
public void OnMissHoldForPlayerInput()
|
||||
{
|
||||
isHolding = true;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3, true);
|
||||
|
||||
Jukebox.PlayOneShotGame("djSchool/recordStop");
|
||||
|
||||
anim.Play("Hold", 0, 0);
|
||||
//tableAnim.Play("Student_Turntable_Hold", 0, 0);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void OnEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
|
||||
public void UnHold()
|
||||
@ -141,50 +133,125 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
isHolding = false;
|
||||
|
||||
anim.Play("Unhold", 0, 0);
|
||||
|
||||
// Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
|
||||
missed = true;
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
public void Swipe(bool ace)
|
||||
#region onSwipe
|
||||
public void OnHitSwipe(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
if (ace)
|
||||
if (!missed)
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
missed = false;
|
||||
shouldBeHolding = false;
|
||||
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
FlashFX(false);
|
||||
swiping = true;
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { anim.Play("Swipe", 0, 0); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { swiping = false; }),
|
||||
});
|
||||
//anim.Play("Swipe", 0, 0);
|
||||
|
||||
tableAnim.speed = 1;
|
||||
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
Instantiate(slamFX).SetActive(true);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Missed record swipe sound should play here.
|
||||
OnMissSwipeForPlayerInput();
|
||||
Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { anim.Play("Swipe", 0, 0); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { swiping = false; }),
|
||||
});
|
||||
//anim.Play("Swipe", 0, 0);
|
||||
|
||||
tableAnim.speed = 1;
|
||||
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
Instantiate(slamFX).SetActive(true);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
anim.Play("Swipe", 0, 0);
|
||||
|
||||
tableAnim.speed = 1;
|
||||
tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
Instantiate(slamFX).SetActive(true);
|
||||
|
||||
// Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
|
||||
|
||||
}
|
||||
|
||||
public override void OnAce()
|
||||
public void OnMissSwipe(PlayerActionEvent caller)
|
||||
{
|
||||
if (!shouldBeHolding)
|
||||
{
|
||||
Hold(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
Swipe(true);
|
||||
}
|
||||
|
||||
eligible = false;
|
||||
isHolding = false;
|
||||
//swiping = false;
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
|
||||
public void OnMissSwipeForPlayerInput()
|
||||
{
|
||||
isHolding = false;
|
||||
|
||||
missed = true;
|
||||
game.SetDJYellowHead(3);
|
||||
//swiping = false;
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region old swipe
|
||||
//public void Swipe(bool ace)
|
||||
//{
|
||||
// isHolding = false;
|
||||
|
||||
// if (ace)
|
||||
// {
|
||||
// missed = false;
|
||||
// shouldBeHolding = false;
|
||||
// Jukebox.PlayOneShotGame("djSchool/recordSwipe");
|
||||
// FlashFX(false);
|
||||
// swiping = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Missed record swipe sound should play here.
|
||||
// }
|
||||
|
||||
// anim.Play("Swipe", 0, 0);
|
||||
|
||||
// tableAnim.speed = 1;
|
||||
// tableAnim.Play("Student_Turntable_Swipe", 0, 0);
|
||||
|
||||
// Instantiate(slamFX).SetActive(true);
|
||||
// Conductor.instance.normal.TransitionTo(.01f);
|
||||
// // Settings.GetMusicMixer().audioMixer.FindSnapshot("Main").TransitionTo(0.15f);
|
||||
// swiping = false;
|
||||
|
||||
//}
|
||||
|
||||
//public override void OnAce()
|
||||
//{
|
||||
// if (!shouldBeHolding)
|
||||
// {
|
||||
// //Hold(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Conductor.instance.normal.TransitionTo(.01f);
|
||||
// //Swipe(true);
|
||||
// }
|
||||
|
||||
// eligible = false;
|
||||
//}
|
||||
|
||||
#endregion
|
||||
|
||||
private void FlashFX(bool inverse)
|
||||
{
|
||||
GameObject prefab = flashFX;
|
||||
@ -194,11 +261,10 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
|
||||
GameObject flashFX_ = Instantiate(prefab, this.transform.parent);
|
||||
flashFX_.SetActive(true);
|
||||
Destroy(flashFX_, 0.5f);
|
||||
|
||||
flash.color = "D0FBFF".Hex2RGB();
|
||||
flash.color = new Color(flash.color.r, flash.color.g, flash.color.b, 0.85f);
|
||||
flash.DOColor(new Color(flash.color.r, flash.color.g, flash.color.b, 0), 0.15f);
|
||||
Destroy(flashFX_, 0.5f);
|
||||
}
|
||||
|
||||
public void TransitionBackToIdle()
|
||||
@ -210,5 +276,12 @@ namespace HeavenStudio.Games.Scripts_DJSchool
|
||||
anim.Play("Idle", 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Not sure but will do?
|
||||
private void OnDestroy()
|
||||
{
|
||||
mixer.audioMixer.FindSnapshot("Main").TransitionTo(.01f);
|
||||
}
|
||||
}
|
||||
}
|
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:
|
420
Assets/Scripts/Games/FirstContact/FirstContact.cs
Normal file
420
Assets/Scripts/Games/FirstContact/FirstContact.cs
Normal file
@ -0,0 +1,420 @@
|
||||
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, eventCaller.currentEntity.valA); }, 0.5f, false, new List<Param>()
|
||||
{
|
||||
new Param("valA", new EntityTypes.Float(.8f, 1.5f, 1f), "Pitch")
|
||||
}),
|
||||
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] GameObject 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;
|
||||
}
|
||||
|
||||
public void SetIntervalStart(float beat, float interval = 4f)
|
||||
{
|
||||
if (!intervalStarted)
|
||||
{
|
||||
//alienSpeakCount = 0;
|
||||
//translatorSpeakCount = 0;
|
||||
intervalStarted = true;
|
||||
}
|
||||
|
||||
//intervalStartBeat = beat;
|
||||
beatInterval = interval;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow() && !noHitOnce && !isSpeaking)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
|
||||
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}),
|
||||
});
|
||||
}
|
||||
if ((PlayerInput.Pressed() && !IsExpectingInputNow() && isSpeaking))
|
||||
{
|
||||
hasMissed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//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, float pitch)
|
||||
{
|
||||
//if (!intervalStarted)
|
||||
//{
|
||||
// SetIntervalStart(beat, beatInterval);
|
||||
//}
|
||||
//missionControl.SetActive(false);
|
||||
Jukebox.PlayOneShotGame("firstContact/alien", beat, pitch);
|
||||
++alienSpeakCount;
|
||||
var random = Random.Range(0, 2);
|
||||
string textToPut = "";
|
||||
if(random == 0)
|
||||
{
|
||||
textToPut = "translator_lookAtAlien";
|
||||
}
|
||||
else
|
||||
{
|
||||
textToPut = "translator_lookAtAlien_nod";
|
||||
}
|
||||
|
||||
ScheduleInput(beat, beatInterval, InputType.STANDARD_DOWN, alienTapping, alienOnMiss, AlienEmpty);
|
||||
|
||||
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
|
||||
{
|
||||
if (!isSpeaking)
|
||||
{
|
||||
translator.GetComponent<Animator>().Play(textToPut, 0, 0);
|
||||
}
|
||||
}),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void alienTurnOver(float beat)
|
||||
{
|
||||
if (!intervalStarted)
|
||||
{
|
||||
SetIntervalStart(beat, beatInterval);
|
||||
}
|
||||
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
|
||||
{
|
||||
if (!isSpeaking)
|
||||
{
|
||||
translator.GetComponent<Animator>().Play("translator_idle", 0, 0);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
isSpeaking = true;
|
||||
}
|
||||
|
||||
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 + .5f, 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 + .5f, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
|
||||
});
|
||||
}
|
||||
|
||||
alienSpeakCount = 0;
|
||||
translatorSpeakCount = 0;
|
||||
isSpeaking = false;
|
||||
hasMissed = false;
|
||||
noHitOnce = false;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public void alienTapping(PlayerActionEvent caller, float beat) //OnHit
|
||||
{
|
||||
if (!noHitOnce)
|
||||
{
|
||||
++translatorSpeakCount;
|
||||
Jukebox.PlayOneShotGame("firstContact/" + randomizerLines());
|
||||
isCorrect = true;
|
||||
|
||||
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_speak", 0, 0);}),
|
||||
});
|
||||
}
|
||||
else if (noHitOnce)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("firstContact/slightlyFail");
|
||||
BeatAction.New(this.gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(.5f, delegate { translator.GetComponent<Animator>().Play("translator_eh", 0, 0);}),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void alienOnMiss(PlayerActionEvent caller) //OnMiss
|
||||
{
|
||||
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 AlienEmpty(PlayerActionEvent caller) //OnEmpty
|
||||
{
|
||||
//empty
|
||||
}
|
||||
|
||||
public int randomizerLines()
|
||||
{
|
||||
return Random.Range(1, 11);
|
||||
}
|
||||
|
||||
//public void alienSuccessTest(PlayerActionEvent caller, float beat)
|
||||
//{
|
||||
// string[] sfxStrings = { "", "" };
|
||||
// string animString = "";
|
||||
// float off = 0f;
|
||||
// if (alienSpeakCount == translatorSpeakCount)
|
||||
// {
|
||||
// sfxStrings[0] = "firstContact/success_1";
|
||||
// sfxStrings[1] = "firstContact/success_2";
|
||||
// animString = "alien_success";
|
||||
// off = .15f;
|
||||
// }
|
||||
// else if(alienSpeakCount != translatorSpeakCount)
|
||||
// {
|
||||
// sfxStrings[0] = "firstContact/failAlien_1";
|
||||
// sfxStrings[1] = "firstContact/failAlien_2";
|
||||
// animString = "alien_fail";
|
||||
// off = .5f;
|
||||
// }
|
||||
|
||||
// string[] sounds = new string[] { sfxStrings[0], sfxStrings[0] };
|
||||
// var sound = new MultiSound.Sound[]
|
||||
// {
|
||||
// new MultiSound.Sound(sounds[0], beat),
|
||||
// new MultiSound.Sound(sounds[1], beat + .5f, offset: off)
|
||||
// };
|
||||
|
||||
// MultiSound.Play(sound);
|
||||
|
||||
// BeatAction.New(alien, new List<BeatAction.Action>()
|
||||
// {
|
||||
// new BeatAction.Action(beat, delegate { alien.GetComponent<Animator>().Play(animString, 0, 0); }),
|
||||
// new BeatAction.Action(beat + .5f, delegate { alien.GetComponent<Animator>().Play(animString, 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;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
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:
|
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 FixedUpdate()
|
||||
{
|
||||
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:
|
@ -378,7 +378,7 @@ namespace HeavenStudio.Games.Scripts_PajamaParty
|
||||
}
|
||||
),
|
||||
new BeatAction.Action(
|
||||
beat + 8f,
|
||||
beat + (longSleep ? 4f : 8f),
|
||||
delegate {
|
||||
canCharge = true;
|
||||
canJump = true;
|
||||
|
@ -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
|
||||
|
@ -132,7 +132,7 @@ namespace HeavenStudio.Games.Scripts_TrickClass
|
||||
{
|
||||
//just
|
||||
game.PlayerDodge();
|
||||
Jukebox.PlayOneShotGame("trickClass/player_dodge_success", volume: 0.8f, pitch: UnityEngine.Random.Range(0.95f, 1.15f));
|
||||
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),
|
||||
});
|
||||
|
@ -96,6 +96,7 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
var e = tossEvents[i];
|
||||
float timeToEvent = e.beat - cond.songPositionInBeats;
|
||||
warnAnim.Play("NoPose", -1, 0);
|
||||
if (timeToEvent > 0f && timeToEvent <= 1f)
|
||||
{
|
||||
string anim = "WarnBall";
|
||||
|
@ -21,6 +21,13 @@ namespace HeavenStudio
|
||||
public static string levelLocation;
|
||||
public static bool officialLevel;
|
||||
|
||||
public static int CustomScreenWidth = 1280;
|
||||
public static int CustomScreenHeight = 720;
|
||||
|
||||
public static readonly (int width, int height)[] DEFAULT_SCREEN_SIZES = new[] { (1280, 720), (1920, 1080), (2560, 1440), (3840, 2160)};
|
||||
public static readonly string[] DEFAULT_SCREEN_SIZES_STRING = new[] { "1280x720", "1920x1080", "2560x1440", "3840x2160", "Custom" };
|
||||
public static int ScreenSizeIndex = 0;
|
||||
|
||||
public enum Scenes : int
|
||||
{
|
||||
SplashScreen = 0,
|
||||
@ -97,6 +104,34 @@ namespace HeavenStudio
|
||||
fade.GetComponent<SpriteRenderer>().color = new Color(0, 0, 0, 0);
|
||||
fade.GetComponent<SpriteRenderer>().DOColor(Color.black, fadeDuration).OnComplete(() => { SceneManager.LoadScene(loadedScene); fade.GetComponent<SpriteRenderer>().DOColor(new Color(0, 0, 0, 0), fadeDuration).OnComplete(() => { Destroy(fade); }); });
|
||||
}
|
||||
}
|
||||
|
||||
public static void WindowFullScreen()
|
||||
{
|
||||
Debug.Log("WindowFullScreen");
|
||||
if (!Screen.fullScreen)
|
||||
{
|
||||
// Set the resolution to the display's current resolution
|
||||
Screen.SetResolution(Display.main.systemWidth, Display.main.systemHeight, FullScreenMode.FullScreenWindow);
|
||||
Screen.fullScreen = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.SetResolution(1280, 720, FullScreenMode.Windowed);
|
||||
Screen.fullScreen = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ChangeScreenSize()
|
||||
{
|
||||
FullScreenMode mode = Screen.fullScreenMode;
|
||||
if (ScreenSizeIndex == DEFAULT_SCREEN_SIZES_STRING.Length - 1)
|
||||
{
|
||||
Screen.SetResolution(CustomScreenWidth, CustomScreenHeight, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
Screen.SetResolution(DEFAULT_SCREEN_SIZES[ScreenSizeIndex].width, DEFAULT_SCREEN_SIZES[ScreenSizeIndex].height, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -171,4 +171,38 @@ namespace HeavenStudio.Editor.Commands
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Duplicate : IAction
|
||||
{
|
||||
List<TimelineEventObj> eventObjs;
|
||||
List<TimelineEventObj> copiedObjs;
|
||||
|
||||
public Duplicate(List<TimelineEventObj> eventObjs)
|
||||
{
|
||||
this.eventObjs = eventObjs;
|
||||
}
|
||||
|
||||
public void Execute()
|
||||
{
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
{
|
||||
for (int i = 0; i < copiedObjs.Count; i++)
|
||||
{
|
||||
Beatmap.Entity e = copiedObjs[i].entity;
|
||||
eventObjs[i] = Timeline.instance.AddEventObject(e.datamodel, false, new Vector3(e.beat, -e.track * Timeline.instance.LayerHeight()), e, true, e.eventObj.eventObjID);
|
||||
}
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
{
|
||||
copiedObjs = eventObjs;
|
||||
for (int i = 0; i < eventObjs.Count; i++)
|
||||
{
|
||||
Selections.instance.Deselect(eventObjs[i]);
|
||||
Timeline.instance.DestroyEventObject(eventObjs[i].entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,10 +9,8 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
public EventParameterManager eventParameterManager;
|
||||
|
||||
// this is programmed on duct tape https://youtu.be/zMWA0ipQ94w?t=868
|
||||
private void LateUpdate()
|
||||
{
|
||||
eventParameterManager.canDisable = true;
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
if (Editor.MouseInRectTransform(transform.GetChild(i).GetComponent<RectTransform>()))
|
||||
|
@ -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))
|
||||
@ -172,7 +199,8 @@ namespace HeavenStudio.Editor
|
||||
|
||||
for (int i = 0; i < selectedEvents.Count; i++)
|
||||
{
|
||||
if (selectedEvents[i].isCreating == false)
|
||||
//TODO: this is in LateUpdate, so this will never run! change this to something that works properly
|
||||
if (!(selectedEvents[i].isCreating || selectedEvents[i].wasDuplicated))
|
||||
{
|
||||
result.Add(selectedEvents[i]);
|
||||
}
|
||||
@ -182,37 +210,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 +438,7 @@ namespace HeavenStudio.Editor
|
||||
{
|
||||
if (fullscreen == false)
|
||||
{
|
||||
EditorLetterbox.SetActive(false);
|
||||
// EditorLetterbox.SetActive(false);
|
||||
GameLetterbox.SetActive(true);
|
||||
|
||||
MainCanvas.enabled = false;
|
||||
@ -453,7 +450,7 @@ namespace HeavenStudio.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorLetterbox.SetActive(true);
|
||||
// EditorLetterbox.SetActive(true);
|
||||
GameLetterbox.SetActive(false);
|
||||
|
||||
MainCanvas.enabled = true;
|
||||
@ -466,6 +463,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;
|
||||
|
||||
@ -49,6 +49,7 @@ namespace HeavenStudio.Editor
|
||||
Disable();
|
||||
}
|
||||
}
|
||||
canDisable = true;
|
||||
}
|
||||
|
||||
public void Disable()
|
||||
|
@ -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:
|
@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Editor.Track;
|
||||
|
||||
using TMPro;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class DispAudioSettings : MonoBehaviour
|
||||
{
|
||||
public TMP_Dropdown resolutionsDropdown;
|
||||
public GameObject customSetter;
|
||||
public TMP_InputField widthInputField, heightInputField;
|
||||
|
||||
private void Start() {
|
||||
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
|
||||
var vals = GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING;
|
||||
for (int i = 0; i < vals.Length; i++)
|
||||
{
|
||||
TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData();
|
||||
optionData.text = vals[i];
|
||||
dropDownData.Add(optionData);
|
||||
}
|
||||
resolutionsDropdown.AddOptions(dropDownData);
|
||||
resolutionsDropdown.value = GlobalGameManager.ScreenSizeIndex;
|
||||
|
||||
resolutionsDropdown.onValueChanged.AddListener(delegate
|
||||
{
|
||||
GlobalGameManager.ScreenSizeIndex = resolutionsDropdown.value;
|
||||
|
||||
customSetter.SetActive(resolutionsDropdown.value == GlobalGameManager.DEFAULT_SCREEN_SIZES_STRING.Length - 1);
|
||||
});
|
||||
|
||||
widthInputField.onEndEdit.AddListener(delegate
|
||||
{
|
||||
GlobalGameManager.CustomScreenWidth = System.Math.Max(int.Parse(widthInputField.text), 64);
|
||||
widthInputField.text = GlobalGameManager.CustomScreenWidth.ToString();
|
||||
});
|
||||
heightInputField.onEndEdit.AddListener(delegate
|
||||
{
|
||||
GlobalGameManager.CustomScreenHeight = System.Math.Max(int.Parse(heightInputField.text), 64);
|
||||
heightInputField.text = GlobalGameManager.CustomScreenHeight.ToString();
|
||||
});
|
||||
}
|
||||
|
||||
public void WindowFullScreen()
|
||||
{
|
||||
GlobalGameManager.WindowFullScreen();
|
||||
}
|
||||
|
||||
public void WindowConfirmSize()
|
||||
{
|
||||
GlobalGameManager.ChangeScreenSize();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 752cb90567101a545ab1e2aeae732a9f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
28
Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
Normal file
28
Assets/Scripts/LevelEditor/SettingsDialog/SettingsDialog.cs
Normal file
@ -0,0 +1,28 @@
|
||||
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;
|
||||
//this may all be moved to a different script in the future
|
||||
|
||||
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:
|
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,30 +287,53 @@ 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))
|
||||
{
|
||||
movingPlayback = true;
|
||||
}
|
||||
else if (Input.GetMouseButtonUp(1))
|
||||
else if (Input.GetMouseButtonUp(1) || Conductor.instance.isPlaying)
|
||||
{
|
||||
movingPlayback = false;
|
||||
}
|
||||
|
||||
if (movingPlayback)
|
||||
{
|
||||
RectTransformUtility.ScreenPointToLocalPointInRectangle(TimelineContent, Input.mousePosition, Editor.instance.EditorCamera, out lastMousePos);
|
||||
@ -304,21 +345,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 +352,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()
|
||||
@ -526,7 +553,7 @@ namespace HeavenStudio.Editor.Track
|
||||
else
|
||||
{
|
||||
entity.eventObj = g.GetComponent<TimelineEventObj>();
|
||||
entity.track = (int)(g.transform.localPosition.y / LayerHeight() * -1);
|
||||
entity.track = entity.eventObj.GetTrack();
|
||||
}
|
||||
|
||||
|
||||
@ -544,36 +571,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 +610,22 @@ namespace HeavenStudio.Editor.Track
|
||||
return eventObj;
|
||||
}
|
||||
|
||||
private List<TimelineEventObj> duplicatedEventObjs = new List<TimelineEventObj>();
|
||||
public TimelineEventObj CopyEventObject(TimelineEventObj e)
|
||||
{
|
||||
Beatmap.Entity clone = e.entity.DeepCopy();
|
||||
TimelineEventObj dup = AddEventObject(clone.datamodel, false, new Vector3(clone.beat, -clone.track * Timeline.instance.LayerHeight()), clone, true, RandomID());
|
||||
duplicatedEventObjs.Add(dup);
|
||||
|
||||
return dup;
|
||||
}
|
||||
|
||||
public void FinalizeDuplicateEventStack()
|
||||
{
|
||||
CommandManager.instance.Execute(new Commands.Duplicate(duplicatedEventObjs));
|
||||
duplicatedEventObjs = new List<TimelineEventObj>();
|
||||
}
|
||||
|
||||
public void DestroyEventObject(Beatmap.Entity entity)
|
||||
{
|
||||
if (EventParameterManager.instance.entity == entity)
|
||||
@ -609,12 +652,12 @@ namespace HeavenStudio.Editor.Track
|
||||
public float SnapToLayer(float y)
|
||||
{
|
||||
float size = LayerHeight();
|
||||
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3, 0);
|
||||
return Mathf.Clamp(Mathp.Round2Nearest(y, size), -size * 3f, 0f);
|
||||
}
|
||||
|
||||
public float LayerHeight()
|
||||
{
|
||||
return LayersRect.rect.height / 4;
|
||||
return LayersRect.rect.height / 4f;
|
||||
}
|
||||
|
||||
public void SetPlaybackSpeed(float speed)
|
||||
|
@ -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;
|
||||
@ -38,10 +38,10 @@ namespace HeavenStudio.Editor.Track
|
||||
public bool resizable;
|
||||
public bool resizing;
|
||||
public bool moving;
|
||||
public bool wasDuplicated;
|
||||
private bool resizingLeft;
|
||||
private bool resizingRight;
|
||||
private bool inResizeRegion;
|
||||
public Vector2 lastMovePos;
|
||||
public bool isCreating;
|
||||
public string eventObjID;
|
||||
|
||||
@ -59,10 +59,9 @@ namespace HeavenStudio.Editor.Track
|
||||
Destroy(resizeGraphic.gameObject);
|
||||
}
|
||||
|
||||
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 +104,7 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
#endregion
|
||||
|
||||
SetColor(GetTrack());
|
||||
SetColor(entity.track);
|
||||
|
||||
if (selected)
|
||||
{
|
||||
@ -118,7 +117,10 @@ namespace HeavenStudio.Editor.Track
|
||||
selectedImage.gameObject.SetActive(true);
|
||||
for (int i = 0; i < outline.childCount; i++)
|
||||
{
|
||||
outline.GetChild(i).GetComponent<Image>().color = Color.cyan;
|
||||
if (moving)
|
||||
outline.GetChild(i).GetComponent<Image>().color = Color.magenta;
|
||||
else
|
||||
outline.GetChild(i).GetComponent<Image>().color = Color.cyan;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -132,39 +134,61 @@ 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;
|
||||
}
|
||||
|
||||
if (!resizing)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0) && Timeline.instance.timelineState.selected)
|
||||
{
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.mouseHovering).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.moving).Count == 0 && !BoxSelection.instance.selecting && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
|
||||
{
|
||||
if (!Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
// Selections.instance.Deselect(this);
|
||||
}
|
||||
}
|
||||
|
||||
// OnUp();
|
||||
}
|
||||
|
||||
if (Timeline.instance.eventObjs.FindAll(c => c.moving).Count > 0 && selected)
|
||||
{
|
||||
Vector3 mousePos = Editor.instance.EditorCamera.ScreenToWorldPoint(Input.mousePosition);
|
||||
//duplicate the entity if holding alt or m-click
|
||||
if ((!wasDuplicated) && (Input.GetKey(KeyCode.LeftAlt) || Input.GetMouseButton(2)))
|
||||
{
|
||||
Selections.instance.Deselect(this);
|
||||
this.wasDuplicated = false;
|
||||
this.moving = false;
|
||||
|
||||
var te = Timeline.instance.CopyEventObject(this);
|
||||
|
||||
Selections.instance.DragSelect(te);
|
||||
|
||||
te.wasDuplicated = true;
|
||||
te.transform.localPosition = transform.localPosition;
|
||||
te.lastPos_ = transform.localPosition;
|
||||
|
||||
for (int i = 0; i < Timeline.instance.eventObjs.Count; i++)
|
||||
{
|
||||
Timeline.instance.eventObjs[i].startPosX = mousePos.x - Timeline.instance.eventObjs[i].transform.position.x;
|
||||
Timeline.instance.eventObjs[i].startPosY = mousePos.y - Timeline.instance.eventObjs[i].transform.position.y;
|
||||
}
|
||||
|
||||
te.moving = true;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
@ -172,6 +196,9 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
else if (resizingLeft)
|
||||
{
|
||||
if (moving)
|
||||
moving = false;
|
||||
|
||||
SetPivot(new Vector2(1, rectTransform.pivot.y));
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
@ -187,6 +214,9 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
else if (resizingRight)
|
||||
{
|
||||
if (moving)
|
||||
moving = false;
|
||||
|
||||
Vector2 sizeDelta = rectTransform.sizeDelta;
|
||||
|
||||
Vector2 mousePos;
|
||||
@ -211,10 +241,18 @@ namespace HeavenStudio.Editor.Track
|
||||
if (resizable)
|
||||
Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/horizontal_resize"), new Vector2(8, 8), CursorMode.Auto);
|
||||
}
|
||||
else if (Timeline.instance.eventObjs.FindAll(c => c.inResizeRegion).Count == 0 && Timeline.instance.eventObjs.FindAll(c => c.resizing).Count == 0)
|
||||
// should consider adding this someday
|
||||
// else if (moving && selected || mouseHovering && selected)
|
||||
// {
|
||||
// Cursor.SetCursor(Resources.Load<Texture2D>("Cursors/move"), new Vector2(8, 8), CursorMode.Auto);
|
||||
// }
|
||||
else
|
||||
{
|
||||
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
|
||||
@ -253,8 +291,6 @@ namespace HeavenStudio.Editor.Track
|
||||
}
|
||||
|
||||
moving = true;
|
||||
// lastMovePos = transform.localPosition;
|
||||
// OnComplete();
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButton(1))
|
||||
@ -270,6 +306,11 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
if (selected && Timeline.instance.timelineState.selected)
|
||||
{
|
||||
if (wasDuplicated)
|
||||
{
|
||||
Timeline.instance.FinalizeDuplicateEventStack();
|
||||
wasDuplicated = false;
|
||||
}
|
||||
if (eligibleToMove)
|
||||
{
|
||||
OnComplete(true);
|
||||
@ -366,7 +407,7 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
private void OnMove()
|
||||
{
|
||||
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack()).Count > 0)
|
||||
if (GameManager.instance.Beatmap.entities.FindAll(c => c.beat == this.transform.localPosition.x && c.track == GetTrack() && c != this.entity).Count > 0)
|
||||
{
|
||||
eligibleToMove = false;
|
||||
}
|
||||
@ -427,7 +468,7 @@ namespace HeavenStudio.Editor.Track
|
||||
|
||||
public int GetTrack()
|
||||
{
|
||||
return (int)(this.transform.localPosition.y / Timeline.instance.LayerHeight()) * -1;
|
||||
return (int)Mathf.Round(this.transform.localPosition.y / Timeline.instance.LayerHeight()) * -1;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
|
@ -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