mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-12 10:07:38 +02:00
First Contact, Tap Trial, Air Rally
First Contact - Fixed a bug Tap Trial - All anims and input are implemented Air Rally - Initialization
This commit is contained in:
@ -198,6 +198,8 @@ namespace HeavenStudio
|
||||
// LateUpdate works a bit better(?) but causes some bugs (like issues with bop animations).
|
||||
private void Update()
|
||||
{
|
||||
PlayerInput.UpdateInputControllers();
|
||||
|
||||
if (BeatmapEntities() < 1) //bruh really you forgot to ckeck tempo changes
|
||||
return;
|
||||
if (!Conductor.instance.isPlaying)
|
||||
|
8
Assets/Scripts/Games/AirRally.meta
Normal file
8
Assets/Scripts/Games/AirRally.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8003568095ad4a9479dc75768215a6d0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
564
Assets/Scripts/Games/AirRally/AirRally.cs
Normal file
564
Assets/Scripts/Games/AirRally/AirRally.cs
Normal file
@ -0,0 +1,564 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using NaughtyBezierCurves;
|
||||
using DG.Tweening;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
using static Minigames;
|
||||
|
||||
public static class RvlBadmintonLoader
|
||||
{
|
||||
public static Minigame AddGame(EventCaller e)
|
||||
{
|
||||
return new Minigame("airRally", "Air Rally", "008c97", false, false, new List<GameAction>()
|
||||
{
|
||||
new GameAction("set distance", delegate { AirRally.instance.SetDistance(e.currentEntity.type); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", AirRally.DistanceSound.close, "Type", "How far is Forthington?")
|
||||
}),
|
||||
//new GameAction("start rally", delegate { AirRally.instance.StartRally(true); }, .5f, false),
|
||||
new GameAction("rally", delegate { AirRally.instance.Rally(e.currentEntity.beat, e.currentEntity.toggle, e.currentEntity.length); }, 2f, true, new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Silent", "Make Forthington Silent"),
|
||||
}),
|
||||
new GameAction("ba bum bum bum", delegate { AirRally.instance.BaBumBumBum(e.currentEntity.beat, e.currentEntity.toggle, e.currentEntity.type); }, 7f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Count", "Make Forthington Count"),
|
||||
new Param("type", AirRally.DistanceSound.close, "Type", "How far is Forthington?")
|
||||
}),
|
||||
new GameAction("forthington voice lines", delegate { AirRally.instance.ForthVoice(e.currentEntity.type, e.currentEntity.type2); }, 1f, false, new List<Param>()
|
||||
{
|
||||
new Param("type", AirRally.CountSound.one, "Type", "The number Forthington will say"),
|
||||
new Param("type", AirRally.DistanceSound.close, "Type", "How far is Forthington?")
|
||||
}),
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_AirRally;
|
||||
|
||||
public class AirRally : Minigame
|
||||
{
|
||||
public static AirRally instance { get; set; }
|
||||
|
||||
[Header("Component")]
|
||||
[SerializeField] GameObject Baxter;
|
||||
[SerializeField] GameObject Forthington;
|
||||
[SerializeField] GameObject Shuttlecock;
|
||||
public GameObject ActiveShuttle;
|
||||
[SerializeField] GameObject objHolder;
|
||||
public DistanceSound e_BaBumState;
|
||||
|
||||
[Header("Tween")]
|
||||
Tween tweenForBaxter;
|
||||
Tween tweenForForth;
|
||||
|
||||
[Header("Variables")]
|
||||
public float serveBeat;
|
||||
public bool started;
|
||||
public bool served;
|
||||
bool babum;
|
||||
bool shuttleActive;
|
||||
public bool hasMissed;
|
||||
|
||||
[Header("Waypoint")]
|
||||
[SerializeField] float wayPointZForForth;
|
||||
|
||||
[Header("Curves")]
|
||||
public BezierCurve3D closeRallyCurve;
|
||||
public BezierCurve3D closeRallyReturnCurve;
|
||||
public BezierCurve3D MissCurve;
|
||||
public BezierCurve3D MissReturnCurve;
|
||||
|
||||
[Header("Debug")]
|
||||
public float beatShown;
|
||||
public float lengthHolder;
|
||||
public float lengthShown;
|
||||
public int wantDistance;
|
||||
public bool wantSilent;
|
||||
public float beatHolder;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Baxter.GetComponent<Animator>().Play("Idle");
|
||||
Forthington.GetComponent<Animator>().Play("Idle");
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if(PlayerInput.Pressed() && !IsExpectingInputNow())
|
||||
{
|
||||
Baxter.GetComponent<Animator>().Play("Hit");
|
||||
Jukebox.PlayOneShotGame("airRally/whooshForth_Close", -1f);
|
||||
}
|
||||
|
||||
var cond = Conductor.instance;
|
||||
var currentBeat = cond.songPositionInBeats;
|
||||
var hitBeat = serveBeat;
|
||||
|
||||
if (started)
|
||||
{
|
||||
if (!served)
|
||||
{
|
||||
hitBeat = serveBeat;
|
||||
}
|
||||
|
||||
if(lengthHolder != lengthShown)
|
||||
{
|
||||
started = true;
|
||||
|
||||
Rally(serveBeat + (int)currentBeat, wantSilent, lengthHolder);
|
||||
//Debug.Log("Serve Beat: " + serveBeat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum DistanceSound
|
||||
{
|
||||
close,
|
||||
far,
|
||||
farther,
|
||||
farthest
|
||||
}
|
||||
|
||||
public enum CountSound
|
||||
{
|
||||
one,
|
||||
two,
|
||||
three,
|
||||
four
|
||||
}
|
||||
|
||||
public void SpawnObject(float beat, int type)
|
||||
{
|
||||
BezierCurve3D curve = null;
|
||||
switch (type)
|
||||
{
|
||||
case (int)DistanceSound.close:
|
||||
curve = closeRallyCurve;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!shuttleActive)
|
||||
{
|
||||
ActiveShuttle = GameObject.Instantiate(Shuttlecock, objHolder.transform);
|
||||
ActiveShuttle.AddComponent<Shuttlecock>();
|
||||
}
|
||||
|
||||
var shuttleScript = ActiveShuttle.GetComponent<Shuttlecock>();
|
||||
shuttleScript.flyPos = 0f;
|
||||
shuttleScript.isReturning = false;
|
||||
shuttleScript.startBeat = (int)Conductor.instance.songPositionInBeats;
|
||||
shuttleScript.curve = closeRallyCurve;
|
||||
//float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(beat, 3f);
|
||||
|
||||
//ActiveShuttle.transform.position = curve.GetPoint(normalizedBeatAnim);
|
||||
ActiveShuttle.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
ActiveShuttle.SetActive(true);
|
||||
shuttleActive = true;
|
||||
|
||||
}
|
||||
|
||||
public void ReturnObject(float beat, int type)
|
||||
{
|
||||
BezierCurve3D curve = null;
|
||||
switch (type)
|
||||
{
|
||||
case (int)DistanceSound.close:
|
||||
curve = closeRallyCurve;
|
||||
break;
|
||||
}
|
||||
|
||||
var shuttleScript = ActiveShuttle.GetComponent<Shuttlecock>();
|
||||
shuttleScript.flyPos = 0f;
|
||||
shuttleScript.isReturning = true;
|
||||
shuttleScript.startBeat = beat;
|
||||
shuttleScript.curve = closeRallyReturnCurve;
|
||||
//float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(beat, 3f);
|
||||
|
||||
//ActiveShuttle.transform.position = curve.GetPoint(normalizedBeatAnim);
|
||||
ActiveShuttle.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
}
|
||||
|
||||
//change to something more optimized
|
||||
public void ForthVoice(int type, int type2)
|
||||
{
|
||||
Forthington.GetComponent<Animator>().Play("TalkShort");
|
||||
if (type == 0)
|
||||
{
|
||||
if(type2 == 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn1");
|
||||
}
|
||||
if(type2 == 1)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn1Far");
|
||||
}
|
||||
if(type2 == 2)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn1Farther");
|
||||
}
|
||||
if(type2 == 3)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn1Farthest");
|
||||
}
|
||||
}
|
||||
if(type == 1)
|
||||
{
|
||||
if(type2 == 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn2");
|
||||
}
|
||||
if(type2 == 1)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn2Far");
|
||||
}
|
||||
if(type2 == 2)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn2Farther");
|
||||
}
|
||||
if(type2 == 3)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn2Farthest");
|
||||
}
|
||||
}
|
||||
if(type == 2)
|
||||
{
|
||||
if(type2 == 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn3");
|
||||
}
|
||||
if(type2 == 1)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn3Far");
|
||||
}
|
||||
if(type2 == 2)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn3Farther");
|
||||
}
|
||||
if(type2 == 3)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn3Farthest");
|
||||
}
|
||||
}
|
||||
if(type == 3)
|
||||
{
|
||||
if(type2 == 0)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn4");
|
||||
}
|
||||
if(type2 == 1)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn4Far");
|
||||
}
|
||||
if(type2 == 2)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn4Farther");
|
||||
}
|
||||
if(type2 == 3)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/countIn4Farthest");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDistance(int type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
e_BaBumState = DistanceSound.close;
|
||||
break;
|
||||
case 1:
|
||||
e_BaBumState = DistanceSound.far;
|
||||
break;
|
||||
case 2:
|
||||
e_BaBumState = DistanceSound.farther;
|
||||
break;
|
||||
case 3:
|
||||
e_BaBumState = DistanceSound.farthest;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartRally(bool start)
|
||||
{
|
||||
started = start;
|
||||
}
|
||||
|
||||
public void Rally(float beat, bool silent, float length)
|
||||
{
|
||||
started = true;
|
||||
beatShown = beat;
|
||||
if (started)
|
||||
{
|
||||
wantSilent = silent;
|
||||
serveBeat += 2f;
|
||||
lengthHolder = length;
|
||||
lengthShown += 2f;
|
||||
beatHolder = beat;
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
//new BeatAction.Action(beat, delegate { Forthington.GetComponent<Animator>().Play("Ready");} ),
|
||||
new BeatAction.Action(beat, delegate { Forthington.GetComponent<Animator>().Play("Hit");} ),
|
||||
new BeatAction.Action(beat, delegate { SpawnObject(beat, (int)e_BaBumState); } ),
|
||||
});
|
||||
|
||||
switch (e_BaBumState)
|
||||
{
|
||||
case DistanceSound.close:
|
||||
wayPointZForForth = 3.55f;
|
||||
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Baxter.GetComponent<Animator>().Play("CloseReady"); }),
|
||||
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame("airRally/hitForth_Close"); }),
|
||||
new BeatAction.Action(beat, delegate { if(!silent) { Jukebox.PlayOneShotGame("airRally/nya_Close"); } }),
|
||||
new BeatAction.Action(beat + .25f, delegate { Jukebox.PlayOneShotGame("airRally/whooshForth_Close");}),
|
||||
new BeatAction.Action(beat + 1f, delegate { if(!babum) { Forthington.GetComponent<Animator>().Play("Ready"); } }),
|
||||
});
|
||||
break;
|
||||
|
||||
case DistanceSound.far:
|
||||
wayPointZForForth = 35.16f;
|
||||
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Baxter.GetComponent<Animator>().Play("FarReady"); }),
|
||||
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame("airRally/hitForth_Far"); }),
|
||||
new BeatAction.Action(beat, delegate { if(!silent) { Jukebox.PlayOneShotGame("airRally/nya_Far"); } }),
|
||||
new BeatAction.Action(beat + .25f, delegate { Jukebox.PlayOneShotGame("airRally/whooshForth_Far");}),
|
||||
new BeatAction.Action(beat + 1f, delegate { if(!babum) { Forthington.GetComponent<Animator>().Play("Ready"); } }),
|
||||
});
|
||||
break;
|
||||
|
||||
case DistanceSound.farther:
|
||||
wayPointZForForth = 105.16f;
|
||||
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Baxter.GetComponent<Animator>().Play("FarReady"); }),
|
||||
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame("airRally/hitForth_Farther"); }),
|
||||
new BeatAction.Action(beat, delegate { if(!silent) { Jukebox.PlayOneShotGame("airRally/nya_Farther"); } }),
|
||||
new BeatAction.Action(beat + .25f, delegate { Jukebox.PlayOneShotGame("airRally/whooshForth_Farther");}),
|
||||
new BeatAction.Action(beat + 1f, delegate { if(!babum) { Forthington.GetComponent<Animator>().Play("Ready"); } }),
|
||||
});
|
||||
break;
|
||||
|
||||
case DistanceSound.farthest:
|
||||
wayPointZForForth = 255.16f;
|
||||
|
||||
tweenForForth = Forthington.gameObject.transform.DOMoveZ(wayPointZForForth, .15f);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Baxter.GetComponent<Animator>().Play("FarReady"); }),
|
||||
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame("airRally/hitForth_Farthest"); }),
|
||||
new BeatAction.Action(beat, delegate { if(!silent) { Jukebox.PlayOneShotGame("airRally/nya_Farthest"); } }),
|
||||
new BeatAction.Action(beat + .25f, delegate { Jukebox.PlayOneShotGame("airRally/whooshForth_Farthest");}),
|
||||
new BeatAction.Action(beat + 1f, delegate { if(!babum) { Forthington.GetComponent<Animator>().Play("Ready"); } }),
|
||||
});
|
||||
break;
|
||||
}
|
||||
//SpawnObject(beat, (int)e_BaBumState);
|
||||
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, RallyOnHit, RallyOnMiss, RallyEmpty);
|
||||
|
||||
//restart rally
|
||||
if (lengthShown == lengthHolder || lengthShown >= lengthHolder)
|
||||
{
|
||||
serveBeat = 0f;
|
||||
lengthShown = 0f;
|
||||
lengthHolder = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void BaBumBumBum(float beat, bool count, int type)
|
||||
{
|
||||
//This feels wrong, will keep until I figure out what's wrong
|
||||
babum = true;
|
||||
serveBeat = 0f;
|
||||
lengthShown = 0f;
|
||||
lengthHolder = 0f;
|
||||
string[] sounds = { "", "", "", "", "", ""};
|
||||
string[] sounds2 = { "", "", "" };
|
||||
if (e_BaBumState == DistanceSound.close || type == 0)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Baxter.GetComponent<Animator>().Play("CloseReady");})
|
||||
});
|
||||
sounds[0] = "airRally/baBumBumBum_Close1";
|
||||
sounds[1] = "airRally/baBumBumBum_Close2";
|
||||
sounds[2] = "airRally/baBumBumBum_Close3";
|
||||
sounds[3] = "airRally/baBumBumBum_Close4";
|
||||
sounds[4] = "airRally/hitForth_Close";
|
||||
sounds[5] = "airRally/whooshForth_Close";
|
||||
|
||||
sounds2 = new string[] { "airRally/countIn2", "airRally/countIn3", "airRally/countIn4" };
|
||||
}
|
||||
|
||||
if (e_BaBumState == DistanceSound.far || type == 1)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Baxter.GetComponent<Animator>().Play("FarReady");})
|
||||
});
|
||||
sounds[0] = "airRally/baBumBumBum_Far1";
|
||||
sounds[1] = "airRally/baBumBumBum_Far2";
|
||||
sounds[2] = "airRally/baBumBumBum_Far3";
|
||||
sounds[3] = "airRally/baBumBumBum_Far4";
|
||||
sounds[4] = "airRally/hitForth_Far";
|
||||
sounds[5] = "airRally/whooshForth_Far";
|
||||
|
||||
sounds2 = new string[] { "airRally/countIn2Far", "airRally/countIn3Far", "airRally/countIn4Far" };
|
||||
}
|
||||
|
||||
if (e_BaBumState == DistanceSound.farther || type == 2)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Baxter.GetComponent<Animator>().Play("FarReady");})
|
||||
});
|
||||
sounds[0] = "airRally/baBumBumBum_Farther1";
|
||||
sounds[1] = "airRally/baBumBumBum_Farther2";
|
||||
sounds[2] = "airRally/baBumBumBum_Farther3";
|
||||
sounds[3] = "airRally/baBumBumBum_Farther4";
|
||||
sounds[4] = "airRally/hitForth_Farther";
|
||||
sounds[5] = "airRally/whooshForth_Farther";
|
||||
|
||||
sounds2 = new string[] { "airRally/countIn2Farther", "airRally/countIn3Farther", "airRally/countIn4Farther" };
|
||||
}
|
||||
|
||||
if (e_BaBumState == DistanceSound.farthest || type == 3)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Baxter.GetComponent<Animator>().Play("FarthestReady");})
|
||||
});
|
||||
sounds[0] = "airRally/baBumBumBum_Farthest1";
|
||||
sounds[1] = "airRally/baBumBumBum_Farthest2";
|
||||
sounds[2] = "airRally/baBumBumBum_Farthest3";
|
||||
sounds[3] = "airRally/baBumBumBum_Farthest4";
|
||||
sounds[4] = "airRally/hitForth_Farthest";
|
||||
sounds[5] = "airRally/whooshForth_Farthest";
|
||||
|
||||
sounds2 = new string[] { "airRally/countIn2Farthest", "airRally/countIn3Farthest", "airRally/countIn4Farthest" };
|
||||
}
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 1.5f, delegate { Forthington.GetComponent<Animator>().Play("Ready"); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { if(babum) { Forthington.GetComponent<Animator>().Play("Hit"); } }),
|
||||
new BeatAction.Action(beat + 3.5f, delegate { Forthington.GetComponent<Animator>().Play("TalkShort"); }),
|
||||
new BeatAction.Action(beat + 4f, delegate { if(!count) Forthington.GetComponent<Animator>().Play("TalkShort"); }),
|
||||
new BeatAction.Action(beat + 4.5f, delegate { Forthington.GetComponent<Animator>().Play("Ready"); }),
|
||||
new BeatAction.Action(beat + 7f, delegate { if(babum) { babum = false; } }),
|
||||
});
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>() //MultiSound.Sound sounds weird
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { Jukebox.PlayOneShotGame(sounds[0]); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { Jukebox.PlayOneShotGame(sounds[1]); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { Jukebox.PlayOneShotGame(sounds[2]); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Jukebox.PlayOneShotGame(sounds[3]); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { Jukebox.PlayOneShotGame(sounds[4]); }),
|
||||
new BeatAction.Action(beat + 3f, delegate { Jukebox.PlayOneShotGame(sounds[5]); }),
|
||||
new BeatAction.Action(beat + 3.5f, delegate { if(e_BaBumState == DistanceSound.far) { Jukebox.PlayOneShotGame("airRally/whooshForth_Far2"); } }),
|
||||
});
|
||||
|
||||
if (count)
|
||||
{
|
||||
|
||||
var sound2 = new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound(sounds2[0], beat + 3.5f),
|
||||
new MultiSound.Sound(sounds2[1], beat + 4.3f),
|
||||
new MultiSound.Sound(sounds2[2], beat + 5.4f)
|
||||
};
|
||||
|
||||
MultiSound.Play(sound2);
|
||||
}
|
||||
|
||||
ScheduleInput(beat, 4.5f, InputType.STANDARD_DOWN, RallyOnHit, RallyOnMiss, RallyEmpty);
|
||||
}
|
||||
|
||||
public void RallyOnHit(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Baxter.GetComponent<Animator>().Play("Hit");
|
||||
hasMissed = false;
|
||||
//BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
//{
|
||||
// new BeatAction.Action(beat + .25f, delegate { if(!babum) { Forthington.GetComponent<Animator>().Play("Ready"); } }),
|
||||
//});
|
||||
|
||||
//var shuttleScript = ActiveShuttle.GetComponent<Shuttlecock>();
|
||||
//shuttleScript.isReturning = true;
|
||||
////Debug.Log(beatHolder);
|
||||
//ActiveShuttle.transform.rotation = Quaternion.Euler(0, 0, 0);
|
||||
//shuttleScript.startBeat = (int)Conductor.instance.songPositionInBeats;
|
||||
//shuttleScript.curve = closeRallyReturnCurve;
|
||||
|
||||
ReturnObject((int)Conductor.instance.songPositionInBeats + 1f, 0);
|
||||
//BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
//{
|
||||
// new BeatAction.Action(beat + 1f, delegate { ActiveShuttle.transform.rotation = Quaternion.Euler(0, 0, 0);}),
|
||||
// new BeatAction.Action(beat + 1f, delegate {shuttleScript.startBeat = (int)Conductor.instance.songPositionInBeats; }),
|
||||
// new BeatAction.Action(beat + 1f, delegate {shuttleScript.curve = closeRallyReturnCurve;}),
|
||||
//});
|
||||
|
||||
if (e_BaBumState == DistanceSound.close)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/hitBaxter_Close");
|
||||
}
|
||||
if (e_BaBumState == DistanceSound.far)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/hitBaxter_Far");
|
||||
}
|
||||
if (e_BaBumState == DistanceSound.farther)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/hitBaxter_Farther");
|
||||
}
|
||||
if (e_BaBumState == DistanceSound.farthest)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("airRally/hitBaxter_Farthest");
|
||||
}
|
||||
|
||||
|
||||
served = false;
|
||||
}
|
||||
|
||||
public void RallyOnMiss(PlayerActionEvent caller)
|
||||
{
|
||||
served = false;
|
||||
hasMissed = true;
|
||||
shuttleActive = false;
|
||||
}
|
||||
|
||||
public void RallyEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/Games/AirRally/AirRally.cs.meta
Normal file
11
Assets/Scripts/Games/AirRally/AirRally.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 54f50efea631bab46b56ebad3e63c4e2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
27
Assets/Scripts/Games/AirRally/CircularMotion.cs
Normal file
27
Assets/Scripts/Games/AirRally/CircularMotion.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CircularMotion : MonoBehaviour
|
||||
{
|
||||
[SerializeField] float timeCounter = 0;
|
||||
[SerializeField] Transform rootPos;
|
||||
[SerializeField] float speed;
|
||||
[SerializeField] float width;
|
||||
[SerializeField] float height;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
timeCounter = 0;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
timeCounter += Time.deltaTime * speed;
|
||||
float x = Mathf.Cos(timeCounter) * width + rootPos.position.x;
|
||||
float y = Mathf.Sin(timeCounter) * height + rootPos.position.y;
|
||||
float z = rootPos.position.z;
|
||||
|
||||
transform.position = new Vector3(x, y, z);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/AirRally/CircularMotion.cs.meta
Normal file
11
Assets/Scripts/Games/AirRally/CircularMotion.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd6b3558bb367914eb7c7991d6c93205
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
111
Assets/Scripts/Games/AirRally/Shuttlecock.cs
Normal file
111
Assets/Scripts/Games/AirRally/Shuttlecock.cs
Normal file
@ -0,0 +1,111 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using NaughtyBezierCurves;
|
||||
using HeavenStudio.Util;
|
||||
|
||||
|
||||
namespace HeavenStudio.Games.Scripts_AirRally
|
||||
{
|
||||
public class Shuttlecock : PlayerActionObject
|
||||
{
|
||||
public float startBeat;
|
||||
private float flyBeats;
|
||||
|
||||
public bool flyType;
|
||||
bool miss = false;
|
||||
public float flyPos;
|
||||
public bool isReturning;
|
||||
|
||||
[NonReorderable] public BezierCurve3D curve;
|
||||
AirRally game;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = AirRally.instance;
|
||||
flyBeats = isReturning ? 1.2f : 1.2f;
|
||||
var cond = Conductor.instance;
|
||||
flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
transform.position = curve.GetPoint(flyPos);
|
||||
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
flyBeats = isReturning ? 1.2f : 1.2f;
|
||||
if (flyPos <= 1f)
|
||||
{
|
||||
if (!miss)
|
||||
{
|
||||
flyPos *= 0.95f;
|
||||
}
|
||||
Vector3 lastPos = transform.position;
|
||||
Vector3 nextPos = curve.GetPoint(flyPos);
|
||||
|
||||
if (flyType)
|
||||
{
|
||||
Vector3 direction = (nextPos - lastPos).normalized;
|
||||
float rotation = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
|
||||
this.transform.eulerAngles = new Vector3(0, 0, rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!isReturning)
|
||||
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (360f * Time.deltaTime));
|
||||
else
|
||||
transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + (-360f * Time.deltaTime));
|
||||
}
|
||||
|
||||
transform.position = nextPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
}
|
||||
|
||||
//if (flyPos > 1f)
|
||||
//{
|
||||
// if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
// {
|
||||
// GameObject.Destroy(gameObject);
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
//if(flyPos > 1f)
|
||||
//{
|
||||
// if(Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
// {
|
||||
// if (!isReturning)
|
||||
// {
|
||||
// curve = game.MissCurve;
|
||||
// transform.position = curve.GetPoint(flyPos);
|
||||
// }
|
||||
|
||||
// else
|
||||
// {
|
||||
// curve = game.MissReturnCurve;
|
||||
// transform.position = curve.GetPoint(flyPos);
|
||||
// }
|
||||
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
if (game.hasMissed && flyPos > 1f)
|
||||
{
|
||||
if (Conductor.instance.GetPositionFromBeat(startBeat, flyBeats + 1f) >= 1f)
|
||||
{
|
||||
GameObject.Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
Assets/Scripts/Games/AirRally/Shuttlecock.cs.meta
Normal file
11
Assets/Scripts/Games/AirRally/Shuttlecock.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 59df055286c020b4b812f05e25c0ac08
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -122,6 +122,7 @@ namespace HeavenStudio.Games.Scripts_FanClub
|
||||
{
|
||||
animator.Play("FanFree", -1, 0);
|
||||
stopBeat = false;
|
||||
clappingStartTime = Single.MinValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -204,6 +205,7 @@ namespace HeavenStudio.Games.Scripts_FanClub
|
||||
animator.Play("FanJump", -1, 0);
|
||||
Jukebox.PlayOneShotGame("fanClub/play_jump");
|
||||
jumpStartTime = cond.songPositionInBeats;
|
||||
clappingStartTime = Single.MinValue;
|
||||
stopCharge = false;
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
<<<<<<< HEAD
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
@ -22,11 +23,15 @@ namespace HeavenStudio.Games.Loaders
|
||||
{
|
||||
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 GameAction("look at", delegate { FirstContact.instance.lookAtDirection(eventCaller.currentEntity.type, eventCaller.currentEntity.type); }, .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("live bar beat", delegate { FirstContact.instance.liveBarBeat(eventCaller.currentEntity.toggle); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", true, "On Beat", "If the live bar animation will be on beat or not")
|
||||
}),
|
||||
|
||||
//new GameAction("Version of First Contact", delegate { FirstContact.instance.versionOfFirstContact(eventCaller.currentEntity.type); }, .5f, false, new List<Param>
|
||||
//{
|
||||
@ -66,6 +71,378 @@ namespace HeavenStudio.Games
|
||||
public bool isCorrect, noHitOnce, isSpeaking;
|
||||
//public int version;
|
||||
public float lookAtLength = 1f;
|
||||
bool onBeat;
|
||||
float liveBarBeatOffset;
|
||||
|
||||
|
||||
//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)
|
||||
{
|
||||
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, offset: liveBarBeatOffset))
|
||||
{
|
||||
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 && !missionControl.activeInHierarchy)
|
||||
{
|
||||
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 liveBarBeat(bool onBeat)
|
||||
{
|
||||
if (onBeat)
|
||||
{
|
||||
liveBarBeatOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
liveBarBeatOffset = .5f;
|
||||
}
|
||||
}
|
||||
|
||||
public void lookAtDirection(int alienLookAt, int translatorLookAt)
|
||||
{
|
||||
Debug.Log(alienLookAt);
|
||||
Debug.Log(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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
string[] sfxStrings = { "", "" };
|
||||
string animString = "";
|
||||
|
||||
if (alienSpeakCount == translatorSpeakCount)
|
||||
{
|
||||
sfxStrings[0] = "firstContact/success_1";
|
||||
sfxStrings[1] = "firstContact/success_2";
|
||||
animString = "alien_success";
|
||||
}
|
||||
else if (alienSpeakCount != translatorSpeakCount)
|
||||
{
|
||||
sfxStrings[0] = "firstContact/failAlien_1";
|
||||
sfxStrings[1] = "firstContact/failAlien_2";
|
||||
animString = "alien_fail";
|
||||
}
|
||||
|
||||
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)
|
||||
};
|
||||
|
||||
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;
|
||||
intervalStarted = false;
|
||||
isSpeaking = false;
|
||||
hasMissed = false;
|
||||
noHitOnce = false;
|
||||
}
|
||||
|
||||
public void missionControlDisplay(float beat, bool stay, float length)
|
||||
{
|
||||
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(length, delegate { missionControl.GetComponentInParent<Animator>().Play(textToPut, 0, 0); }),
|
||||
new BeatAction.Action(length, delegate { alien.GetComponentInParent<Animator>().Play("alien_idle", 0, 0); }),
|
||||
new BeatAction.Action(length, delegate { translator.GetComponent<Animator>().Play("translator_idle", 0, 0); }),
|
||||
|
||||
});
|
||||
|
||||
if (!stay)
|
||||
{
|
||||
BeatAction.New(missionControl, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + length, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
=======
|
||||
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, eventCaller.currentEntity.length); }, 1f, true, 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.type); }, .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("live bar beat", delegate { FirstContact.instance.liveBarBeat(eventCaller.currentEntity.toggle); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", true, "On Beat", "If the live bar animation will be on beat or not")
|
||||
}),
|
||||
|
||||
//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 = 0;
|
||||
|
||||
[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;
|
||||
bool onBeat;
|
||||
float liveBarBeatOffset;
|
||||
|
||||
|
||||
//public enum VersionOfContact
|
||||
@ -108,7 +485,7 @@ namespace HeavenStudio.Games
|
||||
private void Update()
|
||||
{
|
||||
//This is taken from the conductor script
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat, offset: liveBarBeatOffset))
|
||||
{
|
||||
liveBar.GetComponent<Animator>().Play("liveBar", 0, 0);
|
||||
}
|
||||
@ -136,8 +513,22 @@ namespace HeavenStudio.Games
|
||||
// version = type;
|
||||
//}
|
||||
|
||||
public void liveBarBeat(bool onBeat)
|
||||
{
|
||||
if (onBeat)
|
||||
{
|
||||
liveBarBeatOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
liveBarBeatOffset = .5f;
|
||||
}
|
||||
}
|
||||
|
||||
public void lookAtDirection(int alienLookAt, int translatorLookAt)
|
||||
{
|
||||
Debug.Log(alienLookAt);
|
||||
Debug.Log(translatorLookAt);
|
||||
switch (alienLookAt)
|
||||
{
|
||||
case 0:
|
||||
@ -230,14 +621,12 @@ namespace HeavenStudio.Games
|
||||
sfxStrings[0] = "firstContact/success_1";
|
||||
sfxStrings[1] = "firstContact/success_2";
|
||||
animString = "alien_success";
|
||||
Debug.Log("success");
|
||||
}
|
||||
else if (alienSpeakCount != translatorSpeakCount)
|
||||
{
|
||||
sfxStrings[0] = "firstContact/failAlien_1";
|
||||
sfxStrings[1] = "firstContact/failAlien_2";
|
||||
animString = "alien_fail";
|
||||
Debug.Log("fail");
|
||||
}
|
||||
|
||||
string[] sounds = new string[] { sfxStrings[0], sfxStrings[0] };
|
||||
@ -294,7 +683,7 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
BeatAction.New(missionControl, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(length + 1f, delegate { missionControl.SetActive(false); }),
|
||||
new BeatAction.Action(length, delegate { missionControl.SetActive(false); }),
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -356,3 +745,4 @@ namespace HeavenStudio.Games
|
||||
}
|
||||
}
|
||||
|
||||
>>>>>>> 92577ae3e26692484725c03508d1652d5ddafb25
|
||||
|
31
Assets/Scripts/Games/TapTrial/ScrollForTap.cs
Normal file
31
Assets/Scripts/Games/TapTrial/ScrollForTap.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ScrollForTap : MonoBehaviour
|
||||
{
|
||||
public float scrollSpeedX;
|
||||
public float scrollSpeedY;
|
||||
Vector3 startPos;
|
||||
|
||||
public float lengthX;
|
||||
public float lengthY = 43.20976f;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
startPos = transform.localPosition;
|
||||
UpdatePos();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdatePos();
|
||||
}
|
||||
|
||||
private void UpdatePos()
|
||||
{
|
||||
float newPosX = Mathf.Repeat(Time.time * scrollSpeedX, lengthX);
|
||||
float newPosY = Mathf.Repeat(Time.time * scrollSpeedY, lengthY);
|
||||
transform.localPosition = startPos + new Vector3(1 * newPosX, 1 * newPosY);
|
||||
}
|
||||
}
|
11
Assets/Scripts/Games/TapTrial/ScrollForTap.cs.meta
Normal file
11
Assets/Scripts/Games/TapTrial/ScrollForTap.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d04c124402523b64abce470b1c6ced10
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
|
||||
using HeavenStudio.Util;
|
||||
|
||||
@ -19,8 +21,19 @@ namespace HeavenStudio.Games.Loaders
|
||||
new GameAction("tap", delegate { TapTrial.instance.Tap(eventCaller.currentEntity.beat); }, 2.0f, false),
|
||||
new GameAction("double tap", delegate { TapTrial.instance.DoubleTap(eventCaller.currentEntity.beat); }, 2.0f, false),
|
||||
new GameAction("triple tap", delegate { TapTrial.instance.TripleTap(eventCaller.currentEntity.beat); }, 4.0f, false),
|
||||
new GameAction("jump tap prep", delegate { TapTrial.instance.JumpTapPrep(eventCaller.currentEntity.beat); }, 1.0f, false),
|
||||
new GameAction("jump tap", delegate { TapTrial.instance.JumpTap(eventCaller.currentEntity.beat); }, 2.0f, false),
|
||||
new GameAction("final jump tap", delegate { TapTrial.instance.FinalJumpTap(eventCaller.currentEntity.beat); }, 2.0f, false),
|
||||
new GameAction("scroll event", delegate { TapTrial.instance.scrollEvent(eventCaller.currentEntity.toggle, eventCaller.currentEntity.toggle); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Scroll FX", "Will scroll"),
|
||||
new Param("toggle", false, "Flash FX", "Will flash to white"),
|
||||
}),
|
||||
new GameAction("giraffe events", delegate { TapTrial.instance.giraffeEvent(eventCaller.currentEntity.toggle, eventCaller.currentEntity.toggle); }, .5f, false, new List<Param>()
|
||||
{
|
||||
new Param("toggle", false, "Enter", "Giraffe will enter the scene"),
|
||||
new Param("toggle", false, "Exit", "Giraffe will exit the scene"),
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -29,15 +42,33 @@ namespace HeavenStudio.Games.Loaders
|
||||
namespace HeavenStudio.Games
|
||||
{
|
||||
using Scripts_TapTrial;
|
||||
using HeavenStudio.Common;
|
||||
|
||||
public class TapTrial : Minigame
|
||||
{
|
||||
[Header("References")]
|
||||
public TapTrialPlayer player;
|
||||
public GameObject tap;
|
||||
//public GameObject tap;
|
||||
[SerializeField] List<Animator> monkeys;
|
||||
bool goBop;
|
||||
[SerializeField] List<GameObject> monkey_roots;
|
||||
[SerializeField] GameObject player_root;
|
||||
//temporary
|
||||
[SerializeField] List<GameObject> monkey_effects;
|
||||
[SerializeField] List<GameObject> player_effects;
|
||||
[SerializeField] Scroll scrollBG;
|
||||
[SerializeField] SpriteRenderer flash;
|
||||
[SerializeField] ScrollForTap scroll;
|
||||
[SerializeField] GameObject giraffe;
|
||||
bool goBop, isPrep;
|
||||
float lastReportedBeat = 0f;
|
||||
bool hasJumped, isFinalJump;
|
||||
public float jumpStartTime = Single.MinValue;
|
||||
float jumpPos;
|
||||
public float time;
|
||||
bool once;
|
||||
public bool crIsRunning;
|
||||
[SerializeField] GameObject bg;
|
||||
bool giraffeIsIn;
|
||||
|
||||
public static TapTrial instance { get; set; }
|
||||
|
||||
@ -48,19 +79,54 @@ namespace HeavenStudio.Games
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (goBop)
|
||||
{
|
||||
if (goBop && !isPrep)
|
||||
{
|
||||
if (Conductor.instance.ReportBeat(ref lastReportedBeat))
|
||||
{
|
||||
monkeys[0].Play("Bop", 0, 0);
|
||||
monkeys[1].Play("Bop", 0, 0);
|
||||
player.anim.Play("Bop", 0, 0);
|
||||
}
|
||||
else if (Conductor.instance.songPositionInBeats < lastReportedBeat)
|
||||
{
|
||||
lastReportedBeat = Mathf.Round(Conductor.instance.songPositionInBeats);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
jumpPos = Conductor.instance.GetPositionFromBeat(jumpStartTime, 1f);
|
||||
if (Conductor.instance.songPositionInBeats >= jumpStartTime && Conductor.instance.songPositionInBeats < jumpStartTime + 1f)
|
||||
{
|
||||
float yMul = jumpPos * 2f - 1f;
|
||||
float yWeight = -(yMul * yMul) + 1f;
|
||||
monkey_roots[0].transform.localPosition = new Vector3(0, 1.5f * yWeight);
|
||||
monkey_roots[1].transform.localPosition = new Vector3(0, 1.5f * yWeight);
|
||||
if (!isFinalJump)
|
||||
{
|
||||
player_root.transform.localPosition = new Vector3(0f, 2.5f * yWeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
player_root.transform.localPosition = new Vector3(0f, 3.5f * yWeight);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
monkey_roots[0].transform.localPosition = new Vector3(0, 0);
|
||||
monkey_roots[1].transform.localPosition = new Vector3(0, 0);
|
||||
player_root.transform.localPosition = new Vector3(0, 0);
|
||||
if (hasJumped)
|
||||
{
|
||||
//Jukebox.PlayOneShotGame("fanClub/landing_impact", pitch: UnityEngine.Random.Range(0.95f, 1f), volume: 1f / 4);
|
||||
}
|
||||
hasJumped = false;
|
||||
}
|
||||
|
||||
if (PlayerInput.Pressed() && !IsExpectingInputNow())
|
||||
{
|
||||
player.anim.Play("Tap", 0, 0);
|
||||
Jukebox.PlayOneShotGame("tapTrial/tonk");
|
||||
}
|
||||
}
|
||||
|
||||
public void Bop(bool isBopping)
|
||||
@ -77,6 +143,7 @@ namespace HeavenStudio.Games
|
||||
|
||||
public void Tap(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
Jukebox.PlayOneShotGame("tapTrial/ook");
|
||||
player.anim.Play("TapPrepare", 0, 0);
|
||||
|
||||
@ -85,37 +152,21 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { monkeys[0].Play("TapPrepare"); }),
|
||||
new BeatAction.Action(beat, delegate { monkeys[1].Play("TapPrepare"); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("Tap"); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("Tap"); particleEffectMonkeys(); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[1].Play("Tap"); }),
|
||||
});
|
||||
//CreateTap(beat);
|
||||
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnTap, OnTapMiss, OnEmpty);
|
||||
}
|
||||
|
||||
public void OnTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("Tap", 0, 0);
|
||||
}
|
||||
|
||||
public void OnDoubleTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("DoubleTap", 0, 0);
|
||||
}
|
||||
|
||||
public void OnTapMiss(PlayerActionEvent caller)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
//empty
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2f, delegate { isPrep = false; })
|
||||
});
|
||||
}
|
||||
|
||||
public void DoubleTap(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("tapTrial/ookook", beat),
|
||||
@ -128,10 +179,10 @@ namespace HeavenStudio.Games
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { monkeys[0].Play("DoubleTapPrepare", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { monkeys[0].Play("DoubleTapPrepare_2", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("DoubleTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { monkeys[0].Play("DoubleTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("DoubleTap", 0, 0); particleEffectMonkeys(); }),
|
||||
new BeatAction.Action(beat + 1.5f, delegate { monkeys[0].Play("DoubleTap", 0, 0); particleEffectMonkeys(); }),
|
||||
});
|
||||
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { monkeys[1].Play("DoubleTapPrepare", 0, 0); }),
|
||||
@ -140,19 +191,24 @@ namespace HeavenStudio.Games
|
||||
new BeatAction.Action(beat + 1.5f, delegate { monkeys[1].Play("DoubleTap", 0, 0); }),
|
||||
});
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 4f, delegate { isPrep = false; })
|
||||
});
|
||||
|
||||
ScheduleInput(beat, 1f, InputType.STANDARD_DOWN, OnDoubleTap, OnTapMiss, OnEmpty);
|
||||
ScheduleInput(beat, 1.5f, InputType.STANDARD_DOWN, OnDoubleTap, OnTapMiss, OnEmpty);
|
||||
}
|
||||
|
||||
public void TripleTap(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
MultiSound.Play(new MultiSound.Sound[]
|
||||
{
|
||||
new MultiSound.Sound("tapTrial/ooki1", beat),
|
||||
new MultiSound.Sound("tapTrial/ooki2", beat + 0.5f)
|
||||
});
|
||||
|
||||
//player.anim.Play("PosePrepare", 0, 0);
|
||||
player.tripleOffset = 0;
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
@ -166,7 +222,7 @@ namespace HeavenStudio.Games
|
||||
new BeatAction.Action(beat, delegate { monkeys[0].Play("PostPrepare_1", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { monkeys[0].Play("PostPrepare_2", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2f, delegate { monkeys[0].Play("PostTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { monkeys[0].Play("PostTap", 0, 0);}),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { monkeys[0].Play("PostTap_2", 0, 0); }),
|
||||
new BeatAction.Action(beat + 3f, delegate { monkeys[0].Play("PostTap", 0, 0);}),
|
||||
});
|
||||
|
||||
@ -175,35 +231,232 @@ namespace HeavenStudio.Games
|
||||
new BeatAction.Action(beat, delegate { monkeys[1].Play("PostPrepare_1", 0, 0); }),
|
||||
new BeatAction.Action(beat + .5f, delegate { monkeys[1].Play("PostPrepare_2", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2f, delegate { monkeys[1].Play("PostTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { monkeys[1].Play("PostTap", 0, 0);}),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { monkeys[1].Play("PostTap_2", 0, 0);}),
|
||||
new BeatAction.Action(beat + 3f, delegate { monkeys[1].Play("PostTap", 0, 0);}),
|
||||
});
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2f, delegate { particleEffectMonkeys(); }),
|
||||
new BeatAction.Action(beat + 2.5f, delegate { particleEffectMonkeys(); }),
|
||||
new BeatAction.Action(beat + 3f, delegate { particleEffectMonkeys(); }),
|
||||
});
|
||||
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
|
||||
ScheduleInput(beat, 2.5f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
|
||||
ScheduleInput(beat, 3f, InputType.STANDARD_DOWN, OnTripleTap, OnTapMiss, OnEmpty);
|
||||
|
||||
ScheduleInput(beat, 2f, InputType.STANDARD_DOWN, OnTap, OnTapMiss, OnEmpty);
|
||||
ScheduleInput(beat, 2.5f, InputType.STANDARD_DOWN, OnDoubleTap, OnTapMiss, OnEmpty);
|
||||
ScheduleInput(beat, 3f, InputType.STANDARD_DOWN, OnTap, OnTapMiss, OnEmpty);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 4f, delegate { isPrep = false; })
|
||||
});
|
||||
}
|
||||
|
||||
public void JumpTap(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
hasJumped = true;
|
||||
Jukebox.PlayOneShotGame("tapTrial/jumptap1");
|
||||
|
||||
player.anim.Play("JumpTap", 0, 0);
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate {jumpStartTime = Conductor.instance.songPositionInBeats;}),
|
||||
new BeatAction.Action(beat, delegate {monkeys[0].Play("JumpTap", 0, 0); }),
|
||||
new BeatAction.Action(beat, delegate {monkeys[1].Play("JumpTap", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { particleEffectMonkeys(); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { particleEffectMonkeys_2(); }),
|
||||
});
|
||||
|
||||
|
||||
|
||||
ScheduleInput(beat, .95f, InputType.STANDARD_DOWN, OnJumpTap, OnJumpTapMiss, OnEmpty); //why .95f? no idea, doesn't sound right w/ 1f
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2f, delegate { isPrep = false; })
|
||||
});
|
||||
}
|
||||
|
||||
public void JumpTapPrep(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
monkeys[0].Play("JumpPrepare", 0, 0);
|
||||
monkeys[1].Play("JumpPrepare", 0, 0);
|
||||
player.anim.Play("JumpPrepare", 0, 0);
|
||||
}
|
||||
|
||||
public void FinalJumpTap(float beat)
|
||||
{
|
||||
isPrep = true;
|
||||
hasJumped = true;
|
||||
isFinalJump = true;
|
||||
Jukebox.PlayOneShotGame("tapTrial/jumptap2");
|
||||
|
||||
player.anim.Play("FinalJump");
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate {jumpStartTime = Conductor.instance.songPositionInBeats;}),
|
||||
new BeatAction.Action(beat, delegate {monkeys[0].Play("Jump", 0, 0); }),
|
||||
new BeatAction.Action(beat, delegate {monkeys[1].Play("Jump", 0, 0); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[0].Play("FinalJumpTap", 0, 0); particleEffectMonkeys(); particleEffectMonkeys_2(); }),
|
||||
new BeatAction.Action(beat + 1f, delegate { monkeys[1].Play("FinalJumpTap", 0, 0); }),
|
||||
});
|
||||
|
||||
|
||||
ScheduleInput(beat, .95f, InputType.STANDARD_DOWN, OnJumpFinalTap, OnFinalJumpTapMiss, OnEmpty);
|
||||
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat + 2f, delegate { isPrep = false; })
|
||||
});
|
||||
}
|
||||
|
||||
public void CreateTap(float beat, int type = 0)
|
||||
public void giraffeEvent(bool enter, bool exit)
|
||||
{
|
||||
GameObject _tap = Instantiate(tap);
|
||||
_tap.transform.parent = tap.transform.parent;
|
||||
_tap.SetActive(true);
|
||||
Tap t = _tap.GetComponent<Tap>();
|
||||
t.startBeat = beat;
|
||||
t.type = type;
|
||||
if (enter && !giraffeIsIn)
|
||||
{
|
||||
giraffe.SetActive(true);
|
||||
giraffe.GetComponent<Animator>().Play("Enter", 0, 0);
|
||||
giraffeIsIn = true;
|
||||
}
|
||||
else if (exit && giraffeIsIn)
|
||||
{
|
||||
giraffe.GetComponent<Animator>().Play("Exit", 0, 0);
|
||||
giraffeIsIn = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void scrollEvent(bool isScrolling, bool flashToWhite)
|
||||
{
|
||||
if (isScrolling)
|
||||
{
|
||||
if (!crIsRunning) // if coroutine is not running, play the following once
|
||||
{
|
||||
if (flashToWhite)
|
||||
{
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
sequence.Append(flash.DOColor(new Color(flash.color.r, flash.color.g, flash.color.b, .8f), 2f));
|
||||
//sequence.Kill();
|
||||
}
|
||||
StartCoroutine(timer());
|
||||
}
|
||||
}
|
||||
else //should be the reverse of the code above
|
||||
{
|
||||
scrollBG.enabled = false;
|
||||
scrollBG.scrollSpeedY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Player Action Scripts
|
||||
public void OnTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("Tap", 0, 0);
|
||||
player_effects[0].GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
public void OnDoubleTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("DoubleTap", 0, 0);
|
||||
player_effects[1].GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
|
||||
public void OnTapMiss(PlayerActionEvent caller)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
|
||||
}
|
||||
|
||||
public void OnJumpTapMiss(PlayerActionEvent caller)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
|
||||
player.anim.Play("JumpTap_Miss", 0, 0);
|
||||
}
|
||||
|
||||
public void OnFinalJumpTapMiss(PlayerActionEvent caller)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tapMonkey", pitch: 1.5f, volume: .3f);
|
||||
player.anim.Play("FinalJump_Miss", 0, 0);
|
||||
}
|
||||
|
||||
public void OnEmpty(PlayerActionEvent caller)
|
||||
{
|
||||
//empty
|
||||
}
|
||||
public void OnTripleTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
if (player.tripleOffset % 2 == 0)
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { player.anim.Play("PoseTap_L", 0, 0); })
|
||||
});
|
||||
player.tripleOffset += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeatAction.New(gameObject, new List<BeatAction.Action>()
|
||||
{
|
||||
new BeatAction.Action(beat, delegate { player.anim.Play("PoseTap_R", 0, 0); })
|
||||
});
|
||||
player.tripleOffset += 1;
|
||||
}
|
||||
player_effects[0].GetComponent<ParticleSystem>().Play();
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
}
|
||||
public void OnJumpTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("JumpTap_Success", 0, 0);
|
||||
player_effects[0].GetComponent<ParticleSystem>().Play();
|
||||
player_effects[1].GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
public void OnJumpFinalTap(PlayerActionEvent caller, float beat)
|
||||
{
|
||||
Jukebox.PlayOneShotGame("tapTrial/tap");
|
||||
player.anim.Play("FinalJump_Tap");
|
||||
player_effects[0].GetComponent<ParticleSystem>().Play();
|
||||
player_effects[1].GetComponent<ParticleSystem>().Play();
|
||||
isFinalJump = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Misc. Functions
|
||||
public void particleEffectMonkeys()
|
||||
{
|
||||
monkey_effects[0].GetComponent<ParticleSystem>().Play();
|
||||
monkey_effects[1].GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
|
||||
public void particleEffectMonkeys_2()
|
||||
{
|
||||
monkey_effects[2].GetComponent<ParticleSystem>().Play();
|
||||
monkey_effects[3].GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
|
||||
IEnumerator timer()
|
||||
{
|
||||
crIsRunning = true;
|
||||
while (scroll.scrollSpeedY < 20)
|
||||
{
|
||||
scroll.scrollSpeedY += 5f;
|
||||
yield return new WaitForSecondsRealtime(.5f);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
//this is the orig way for input handling
|
||||
//public void CreateTap(float beat, int type = 0)
|
||||
//{
|
||||
// GameObject _tap = Instantiate(tap);
|
||||
// _tap.transform.parent = tap.transform.parent;
|
||||
// _tap.SetActive(true);
|
||||
// Tap t = _tap.GetComponent<Tap>();
|
||||
// t.startBeat = beat;
|
||||
// t.type = type;
|
||||
//}
|
||||
}
|
||||
}
|
@ -59,6 +59,7 @@ namespace HeavenStudio
|
||||
DontDestroyOnLoad(this.gameObject);
|
||||
instance = this;
|
||||
Starpelly.OS.ChangeWindowTitle("Heaven Studio DEMO");
|
||||
PlayerInput.InitInputControllers();
|
||||
}
|
||||
|
||||
public static GameObject CreateFade()
|
||||
@ -141,5 +142,11 @@ namespace HeavenStudio
|
||||
MasterVolume = value;
|
||||
AudioListener.volume = MasterVolume;
|
||||
}
|
||||
|
||||
void OnApplicationQuit()
|
||||
{
|
||||
Debug.Log("Disconnecting JoyShocks...");
|
||||
PlayerInput.DisconnectJoyshocks();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
8
Assets/Scripts/InputSystem.meta
Normal file
8
Assets/Scripts/InputSystem.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f0c2ca50a4b8a1b499a3efd717f1daaa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/InputSystem/ControllerTypes.meta
Normal file
8
Assets/Scripts/InputSystem/ControllerTypes.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc30ca18de2bbc24d984b036097fe60d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
430
Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs
Normal file
430
Assets/Scripts/InputSystem/ControllerTypes/InputJoyshock.cs
Normal file
@ -0,0 +1,430 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.Util;
|
||||
|
||||
using static JSL;
|
||||
|
||||
namespace HeavenStudio.InputSystem
|
||||
{
|
||||
public class InputJoyshock : InputController
|
||||
{
|
||||
static string[] joyShockNames =
|
||||
{
|
||||
"Unknown",
|
||||
"Joy-Con (L)",
|
||||
"Joy-Con (R)",
|
||||
"Pro Controller",
|
||||
"DualShock 4",
|
||||
"DualSense"
|
||||
};
|
||||
|
||||
//TODO: see if single joy-con mappings differ from a normal pad (they don't!)
|
||||
int[] mappings = new[]
|
||||
{
|
||||
ButtonMaskUp,
|
||||
ButtonMaskDown,
|
||||
ButtonMaskLeft,
|
||||
ButtonMaskRight,
|
||||
ButtonMaskS,
|
||||
ButtonMaskE,
|
||||
ButtonMaskW,
|
||||
ButtonMaskN,
|
||||
ButtonMaskL,
|
||||
ButtonMaskR,
|
||||
ButtonMaskPlus,
|
||||
};
|
||||
int[] mappingsSplitLeft = new[]
|
||||
{
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
ButtonMaskLeft,
|
||||
ButtonMaskDown,
|
||||
ButtonMaskUp,
|
||||
ButtonMaskRight,
|
||||
ButtonMaskSL,
|
||||
ButtonMaskSR,
|
||||
ButtonMaskMinus,
|
||||
};
|
||||
int[] mappingsSplitRight = new[]
|
||||
{
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
ButtonMaskE,
|
||||
ButtonMaskN,
|
||||
ButtonMaskS,
|
||||
ButtonMaskW,
|
||||
ButtonMaskSL,
|
||||
ButtonMaskSR,
|
||||
ButtonMaskPlus,
|
||||
};
|
||||
|
||||
float stickDeadzone = 0.5f;
|
||||
|
||||
int joyshockHandle;
|
||||
int type;
|
||||
int splitType;
|
||||
string joyshockName;
|
||||
|
||||
//buttons, sticks, triggers
|
||||
JOY_SHOCK_STATE joyBtStateCurrent, joyBtStateLast;
|
||||
//gyro and accelerometer
|
||||
IMU_STATE joyImuStateCurrent, joyImuStateLast;
|
||||
//touchpad
|
||||
TOUCH_STATE joyTouchStateCurrent, joyTouchStateLast;
|
||||
|
||||
InputJoyshock otherHalf;
|
||||
|
||||
public InputJoyshock(int handle)
|
||||
{
|
||||
joyshockHandle = handle;
|
||||
}
|
||||
|
||||
public override void InitializeController()
|
||||
{
|
||||
joyBtStateCurrent = new JOY_SHOCK_STATE();
|
||||
joyBtStateLast = new JOY_SHOCK_STATE();
|
||||
joyImuStateCurrent = new IMU_STATE();
|
||||
joyImuStateLast = new IMU_STATE();
|
||||
joyTouchStateCurrent = new TOUCH_STATE();
|
||||
joyTouchStateLast = new TOUCH_STATE();
|
||||
|
||||
//FUTURE: remappable controls
|
||||
|
||||
type = JslGetControllerType(joyshockHandle);
|
||||
joyshockName = joyShockNames[type];
|
||||
|
||||
splitType = JslGetControllerSplitType(joyshockHandle);
|
||||
}
|
||||
|
||||
public override void UpdateState()
|
||||
{
|
||||
//buttons
|
||||
joyBtStateLast = joyBtStateCurrent;
|
||||
joyBtStateCurrent = JslGetSimpleState(joyshockHandle);
|
||||
|
||||
//stick direction state
|
||||
//split controllers will need to be rotated to compensate
|
||||
//left rotates counterclockwise, right rotates clockwise, all by 90 degrees
|
||||
float xAxis = 0f;
|
||||
float yAxis = 0f;
|
||||
if (otherHalf == null)
|
||||
{
|
||||
switch (splitType)
|
||||
{
|
||||
case SplitLeft:
|
||||
xAxis = -joyBtStateCurrent.stickLY;
|
||||
yAxis = joyBtStateCurrent.stickLX;
|
||||
break;
|
||||
case SplitRight: //use the right stick instead
|
||||
xAxis = joyBtStateCurrent.stickRY;
|
||||
yAxis = -joyBtStateCurrent.stickRX;
|
||||
break;
|
||||
case SplitFull:
|
||||
xAxis = joyBtStateCurrent.stickLX;
|
||||
yAxis = joyBtStateCurrent.stickLY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
xAxis = joyBtStateCurrent.stickLX;
|
||||
yAxis = joyBtStateCurrent.stickLY;
|
||||
}
|
||||
|
||||
directionStateLast = directionStateCurrent;
|
||||
directionStateCurrent = 0;
|
||||
directionStateCurrent |= ((yAxis >= stickDeadzone) ? (1 << ((int) InputDirection.Up)) : 0);
|
||||
directionStateCurrent |= ((yAxis <= -stickDeadzone) ? (1 << ((int) InputDirection.Down)) : 0);
|
||||
directionStateCurrent |= ((xAxis >= stickDeadzone) ? (1 << ((int) InputDirection.Right)) : 0);
|
||||
directionStateCurrent |= ((xAxis <= -stickDeadzone) ? (1 << ((int) InputDirection.Left)) : 0);
|
||||
//Debug.Log("stick direction: " + directionStateCurrent + "| x axis: " + xAxis + " y axis: " + yAxis);
|
||||
}
|
||||
|
||||
public override string GetDeviceName()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
return "Joy-Con Pair";
|
||||
return joyshockName;
|
||||
}
|
||||
|
||||
public override InputFeatures GetFeatures()
|
||||
{
|
||||
InputFeatures features = InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||
switch (type)
|
||||
{
|
||||
case TypeJoyConLeft:
|
||||
features |= InputFeatures.Readable_ShellColour | InputFeatures.Readable_ButtonColour | InputFeatures.Writable_PlayerLED | InputFeatures.Extra_SplitControllerLeft | InputFeatures.Extra_HDRumble;
|
||||
break;
|
||||
case TypeJoyConRight:
|
||||
features |= InputFeatures.Readable_ShellColour | InputFeatures.Readable_ButtonColour | InputFeatures.Writable_PlayerLED | InputFeatures.Extra_SplitControllerRight | InputFeatures.Extra_HDRumble;
|
||||
break;
|
||||
case TypeProController:
|
||||
features |= InputFeatures.Readable_ShellColour | InputFeatures.Readable_ButtonColour | InputFeatures.Readable_LeftGripColour | InputFeatures.Readable_RightGripColour | InputFeatures.Writable_PlayerLED | InputFeatures.Extra_HDRumble;
|
||||
break;
|
||||
case TypeDualShock4:
|
||||
features |= InputFeatures.Readable_AnalogueTriggers | InputFeatures.Readable_Pointer | InputFeatures.Writable_LightBar;
|
||||
break;
|
||||
case TypeDualSense:
|
||||
features |= InputFeatures.Readable_AnalogueTriggers | InputFeatures.Readable_Pointer | InputFeatures.Writable_PlayerLED | InputFeatures.Writable_LightBar;
|
||||
break;
|
||||
}
|
||||
features |= InputFeatures.Readable_MotionSensor | InputFeatures.Extra_Rumble | InputFeatures.Style_Pad | InputFeatures.Style_Baton | InputFeatures.Style_Touch;
|
||||
return features;
|
||||
}
|
||||
|
||||
public override int GetLastButtonDown()
|
||||
{
|
||||
return BitwiseUtils.FirstSetBit(joyBtStateCurrent.buttons & joyBtStateLast.buttons);
|
||||
}
|
||||
|
||||
public override KeyCode GetLastKeyDown()
|
||||
{
|
||||
return KeyCode.None;
|
||||
}
|
||||
|
||||
public override bool GetButton(int button)
|
||||
{
|
||||
int bt = 0;
|
||||
if (otherHalf == null)
|
||||
{
|
||||
if (splitType == SplitLeft)
|
||||
{
|
||||
bt = mappingsSplitLeft[button];
|
||||
}
|
||||
else if (splitType == SplitRight)
|
||||
{
|
||||
bt = mappingsSplitRight[button];
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = mappings[button];
|
||||
}
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << bt);
|
||||
}
|
||||
bt = mappings[button];
|
||||
return BitwiseUtils.WantCurrent(joyBtStateCurrent.buttons, 1 << bt) || BitwiseUtils.WantCurrent(otherHalf.joyBtStateCurrent.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override bool GetButtonDown(int button)
|
||||
{
|
||||
int bt = 0;
|
||||
if (otherHalf == null)
|
||||
{
|
||||
if (splitType == SplitLeft)
|
||||
{
|
||||
bt = mappingsSplitLeft[button];
|
||||
}
|
||||
else if (splitType == SplitRight)
|
||||
{
|
||||
bt = mappingsSplitRight[button];
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = mappings[button];
|
||||
}
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
bt = mappings[button];
|
||||
return BitwiseUtils.WantCurrentAndNotLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt) || BitwiseUtils.WantCurrentAndNotLast(otherHalf.joyBtStateCurrent.buttons, otherHalf.joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override bool GetButtonUp(int button)
|
||||
{
|
||||
int bt = 0;
|
||||
if (otherHalf == null)
|
||||
{
|
||||
if (splitType == SplitLeft)
|
||||
{
|
||||
bt = mappingsSplitLeft[button];
|
||||
}
|
||||
else if (splitType == SplitRight)
|
||||
{
|
||||
bt = mappingsSplitRight[button];
|
||||
}
|
||||
else
|
||||
{
|
||||
bt = mappings[button];
|
||||
}
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
bt = mappings[button];
|
||||
return BitwiseUtils.WantNotCurrentAndLast(joyBtStateCurrent.buttons, joyBtStateLast.buttons, 1 << bt) || BitwiseUtils.WantNotCurrentAndLast(otherHalf.joyBtStateCurrent.buttons, otherHalf.joyBtStateLast.buttons, 1 << bt);
|
||||
}
|
||||
|
||||
public override float GetAxis(InputAxis axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case InputAxis.AxisLTrigger:
|
||||
return joyBtStateCurrent.lTrigger;
|
||||
case InputAxis.AxisRTrigger:
|
||||
return joyBtStateCurrent.rTrigger;
|
||||
case InputAxis.AxisLStickX:
|
||||
return joyBtStateCurrent.stickLX;
|
||||
case InputAxis.AxisLStickY:
|
||||
return joyBtStateCurrent.stickLY;
|
||||
case InputAxis.AxisRStickX:
|
||||
return joyBtStateCurrent.stickRX;
|
||||
case InputAxis.AxisRStickY:
|
||||
return joyBtStateCurrent.stickRY;
|
||||
case InputAxis.TouchpadX: //isn't updated for now, so always returns 0f
|
||||
//return joyTouchStateCurrent.t0X;
|
||||
case InputAxis.TouchpadY:
|
||||
//return joyTouchStateCurrent.t0Y;
|
||||
default:
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return GetButton(bt) || BitwiseUtils.WantCurrent(directionStateCurrent, 1 << (int) direction);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return GetButtonDown(bt) || BitwiseUtils.WantCurrentAndNotLast(directionStateCurrent, directionStateLast, 1 << (int) direction);
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction)
|
||||
{
|
||||
//todo: check analogue stick hat direction too
|
||||
int bt;
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
bt = mappings[0];
|
||||
break;
|
||||
case InputDirection.Down:
|
||||
bt = mappings[1];
|
||||
break;
|
||||
case InputDirection.Left:
|
||||
bt = mappings[2];
|
||||
break;
|
||||
case InputDirection.Right:
|
||||
bt = mappings[3];
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return GetButtonUp(bt) || BitwiseUtils.WantNotCurrentAndLast(directionStateCurrent, directionStateLast, 1 << (int) direction);
|
||||
}
|
||||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
//TODO: dualshock 4 and dualsense lightbar colour support
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
this.playerNum = null;
|
||||
JslSetPlayerNumber(joyshockHandle, 0);
|
||||
return;
|
||||
}
|
||||
this.playerNum = playerNum;
|
||||
int ledMask = (int) this.playerNum;
|
||||
if (type == TypeDualSense)
|
||||
{
|
||||
if (playerNum <= 4)
|
||||
{
|
||||
ledMask = DualSensePlayerMask[(int) this.playerNum];
|
||||
}
|
||||
}
|
||||
JslSetPlayerNumber(joyshockHandle, ledMask);
|
||||
}
|
||||
|
||||
public override int? GetPlayer()
|
||||
{
|
||||
return this.playerNum;
|
||||
}
|
||||
|
||||
public int GetHandle()
|
||||
{
|
||||
return joyshockHandle;
|
||||
}
|
||||
|
||||
public void DisconnectJoyshock()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
{
|
||||
otherHalf = null;
|
||||
}
|
||||
JslSetRumble(joyshockHandle, 0, 0);
|
||||
JslSetLightColour(joyshockHandle, 0);
|
||||
JslSetPlayerNumber(joyshockHandle, 0);
|
||||
}
|
||||
|
||||
public void AssignOtherHalf(InputJoyshock otherHalf, bool force = false)
|
||||
{
|
||||
InputFeatures features = otherHalf.GetFeatures();
|
||||
if (features.HasFlag(InputFeatures.Extra_SplitControllerLeft) || features.HasFlag(InputFeatures.Extra_SplitControllerRight))
|
||||
{
|
||||
//two-way link
|
||||
this.otherHalf = otherHalf;
|
||||
this.otherHalf.UnAssignOtherHalf(); //juste en cas
|
||||
this.otherHalf.otherHalf = this;
|
||||
this.otherHalf.SetPlayer(this.playerNum);
|
||||
}
|
||||
else if (force)
|
||||
{
|
||||
UnAssignOtherHalf();
|
||||
}
|
||||
}
|
||||
|
||||
public void UnAssignOtherHalf()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
{
|
||||
this.otherHalf.otherHalf = null;
|
||||
this.otherHalf.SetPlayer(-1);
|
||||
}
|
||||
otherHalf = null;
|
||||
}
|
||||
|
||||
public InputJoyshock GetOtherHalf()
|
||||
{
|
||||
return otherHalf;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abe9a6a60f8629440a3cae605aca60a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
154
Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs
Normal file
154
Assets/Scripts/InputSystem/ControllerTypes/InputKeyboard.cs
Normal file
@ -0,0 +1,154 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
using static JSL;
|
||||
|
||||
namespace HeavenStudio.InputSystem
|
||||
{
|
||||
public class InputKeyboard : InputController
|
||||
{
|
||||
static KeyCode[] keyCodes = (KeyCode[]) System.Enum.GetValues(typeof(UnityEngine.KeyCode));
|
||||
|
||||
//FUTURE: remappable controls
|
||||
//KeyCode[] mappings = new KeyCode[Enum.GetNames(typeof(ButtonsPad)).Length];
|
||||
KeyCode[] mappings = new KeyCode[]
|
||||
{
|
||||
KeyCode.UpArrow,
|
||||
KeyCode.DownArrow,
|
||||
KeyCode.LeftArrow,
|
||||
KeyCode.RightArrow,
|
||||
KeyCode.X,
|
||||
KeyCode.Z,
|
||||
KeyCode.C,
|
||||
KeyCode.V,
|
||||
KeyCode.S,
|
||||
KeyCode.D,
|
||||
KeyCode.Return,
|
||||
};
|
||||
|
||||
InputDirection hatDirectionCurrent;
|
||||
InputDirection hatDirectionLast;
|
||||
|
||||
public override void InitializeController()
|
||||
{
|
||||
//FUTURE: remappable controls
|
||||
}
|
||||
|
||||
public override void UpdateState()
|
||||
{
|
||||
// Update the state of the controller
|
||||
}
|
||||
|
||||
public override string GetDeviceName()
|
||||
{
|
||||
return "Keyboard";
|
||||
}
|
||||
|
||||
public override InputFeatures GetFeatures()
|
||||
{
|
||||
return InputFeatures.Readable_StringInput | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||
}
|
||||
|
||||
public override int GetLastButtonDown()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public override KeyCode GetLastKeyDown()
|
||||
{
|
||||
for(KeyCode i = keyCodes[1]; i <= KeyCode.Menu; i++) {
|
||||
if (Input.GetKeyDown(i))
|
||||
return i;
|
||||
}
|
||||
return KeyCode.None;
|
||||
}
|
||||
|
||||
public override bool GetButton(int button)
|
||||
{
|
||||
return Input.GetKey(mappings[button]);
|
||||
}
|
||||
|
||||
public override bool GetButtonDown(int button)
|
||||
{
|
||||
return Input.GetKeyDown(mappings[button]);
|
||||
}
|
||||
|
||||
public override bool GetButtonUp(int button)
|
||||
{
|
||||
return Input.GetKeyUp(mappings[button]);
|
||||
}
|
||||
|
||||
public override float GetAxis(InputAxis axis)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//todo: directionals
|
||||
public override bool GetHatDirection(InputDirection direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKey(KeyCode.UpArrow);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKey(KeyCode.DownArrow);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKey(KeyCode.LeftArrow);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKey(KeyCode.RightArrow);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionDown(InputDirection direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKeyDown(KeyCode.UpArrow);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKeyDown(KeyCode.DownArrow);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKeyDown(KeyCode.LeftArrow);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKeyDown(KeyCode.RightArrow);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetHatDirectionUp(InputDirection direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case InputDirection.Up:
|
||||
return Input.GetKeyUp(KeyCode.UpArrow);
|
||||
case InputDirection.Down:
|
||||
return Input.GetKeyUp(KeyCode.DownArrow);
|
||||
case InputDirection.Left:
|
||||
return Input.GetKeyUp(KeyCode.LeftArrow);
|
||||
case InputDirection.Right:
|
||||
return Input.GetKeyUp(KeyCode.RightArrow);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetPlayer(int? playerNum)
|
||||
{
|
||||
if (playerNum == -1 || playerNum == null)
|
||||
{
|
||||
this.playerNum = null;
|
||||
return;
|
||||
}
|
||||
this.playerNum = (int) playerNum;
|
||||
}
|
||||
|
||||
public override int? GetPlayer()
|
||||
{
|
||||
return playerNum;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19bccc8eebf390943a5c6d8bc59f4c7f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
170
Assets/Scripts/InputSystem/InputController.cs
Normal file
170
Assets/Scripts/InputSystem/InputController.cs
Normal file
@ -0,0 +1,170 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.InputSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Generic class to allow adapting any type and combination of HIDs to a universal controller format.
|
||||
/// Specifically designed for Heaven Studio, but can be adapted to any use.
|
||||
/// </summary>
|
||||
public abstract class InputController
|
||||
{
|
||||
//Buttons and Axis used by most controllers
|
||||
public enum InputButtons : int
|
||||
{
|
||||
ButtonPadUp = 0,
|
||||
ButtonPadDown = 1,
|
||||
ButtonPadLeft = 2,
|
||||
ButtonPadRight = 3,
|
||||
ButtonPlus = 4,
|
||||
ButtonOptions = 4,
|
||||
ButtonMinus = 5,
|
||||
ButtonShare = 5,
|
||||
ButtonLClick = 6,
|
||||
ButtonRClick = 7,
|
||||
ButtonL = 8,
|
||||
ButtonR = 9,
|
||||
ButtonZL = 10,
|
||||
ButtonZR = 11,
|
||||
ButtonFaceS = 12,
|
||||
ButtonFaceE = 13,
|
||||
ButtonFaceW = 14,
|
||||
ButtonFaceN = 15,
|
||||
ButtonHome = 16,
|
||||
ButtonPS = 16,
|
||||
ButtonCapture = 17,
|
||||
ButtonTouchpadClick = 17,
|
||||
ButtonSL = 18,
|
||||
ButtonSR = 19,
|
||||
}
|
||||
public enum InputAxis : int
|
||||
{
|
||||
AxisLTrigger = 4,
|
||||
AxisRTrigger = 5,
|
||||
AxisLStickX = 0,
|
||||
AxisLStickY = 1,
|
||||
AxisRStickX = 2,
|
||||
AxisRStickY = 3,
|
||||
TouchpadX = 6,
|
||||
TouchpadY = 7
|
||||
}
|
||||
|
||||
//D-Pad directions, usable to adapt analogue sticks to cardinal directions
|
||||
public enum InputDirection : int
|
||||
{
|
||||
Up = 0,
|
||||
Right = 1,
|
||||
Down = 2,
|
||||
Left = 3,
|
||||
}
|
||||
|
||||
//Common specific controller features
|
||||
[System.Flags]
|
||||
public enum InputFeatures
|
||||
{
|
||||
//readable properties
|
||||
Readable_ShellColour,
|
||||
Readable_ButtonColour,
|
||||
Readable_LeftGripColour,
|
||||
Readable_RightGripColour,
|
||||
Readable_AnalogueTriggers,
|
||||
Readable_StringInput,
|
||||
Readable_Pointer,
|
||||
Readable_MotionSensor,
|
||||
|
||||
//writable properties
|
||||
Writable_PlayerLED,
|
||||
Writable_LightBar,
|
||||
Writable_Chroma,
|
||||
Writable_Speaker,
|
||||
|
||||
//other / "special" properties
|
||||
Extra_SplitControllerLeft,
|
||||
Extra_SplitControllerRight,
|
||||
Extra_Rumble,
|
||||
Extra_HDRumble,
|
||||
|
||||
//supported control styles
|
||||
Style_Pad,
|
||||
Style_Baton,
|
||||
Style_Touch
|
||||
};
|
||||
|
||||
//Following enums are specific to Heaven Studio, can be removed in other applications
|
||||
//Control styles in Heaven Studio
|
||||
public enum ControlStyles
|
||||
{
|
||||
Pad,
|
||||
Baton,
|
||||
Touch
|
||||
}
|
||||
|
||||
//buttons used in Heaven Studio gameplay (Pad Style)
|
||||
public enum ButtonsPad : int
|
||||
{
|
||||
PadUp = 0,
|
||||
PadDown = 1,
|
||||
PadLeft = 2,
|
||||
PadRight = 3,
|
||||
PadS = 4,
|
||||
PadE = 5,
|
||||
PadW = 6,
|
||||
PadN = 7,
|
||||
PadL = 8,
|
||||
PadR = 9,
|
||||
PadPause = 10,
|
||||
}
|
||||
|
||||
//FUTURE: buttons used in Heaven Studio gameplay ("Form Baton" / WiiMote Style)
|
||||
public enum ButtonsBaton : int
|
||||
{
|
||||
BatonS = 0, //-- all these...
|
||||
BatonE = 1, // |
|
||||
BatonW = 2, // |
|
||||
BatonN = 3, //--
|
||||
BatonA = 4, // < ...map to this, but are directional
|
||||
BatonB = 5, // should never be used alone
|
||||
Baton1 = 6,
|
||||
Baton2 = 7,
|
||||
BatonPause = 8,
|
||||
}
|
||||
|
||||
//FUTURE: buttons used in Heaven Studio gameplay (Touch Style)
|
||||
public enum ButtonsTouch : int
|
||||
{
|
||||
TouchL = 0,
|
||||
TouchR = 1,
|
||||
TouchTap = 2,
|
||||
TouchFlick = 3,
|
||||
TouchButtonL = 4,
|
||||
TouchButtonR = 4,
|
||||
}
|
||||
|
||||
protected int? playerNum;
|
||||
protected int directionStateCurrent = 0;
|
||||
protected int directionStateLast = 0;
|
||||
|
||||
public abstract void InitializeController();
|
||||
public abstract void UpdateState(); // Update the state of the controller
|
||||
|
||||
public abstract string GetDeviceName(); // Get the name of the controller
|
||||
public abstract InputFeatures GetFeatures(); // Get the features of the controller
|
||||
|
||||
public abstract int GetLastButtonDown(); // Get the last button down
|
||||
public abstract KeyCode GetLastKeyDown(); // Get the last key down (used for keyboards and other devices that use Keycode)
|
||||
public abstract bool GetButton(int button); // is button currently pressed?
|
||||
public abstract bool GetButtonDown(int button); // is button just pressed?
|
||||
public abstract bool GetButtonUp(int button); // is button just released?
|
||||
public abstract float GetAxis(InputAxis axis); // Get the value of an axis
|
||||
public abstract bool GetHatDirection(InputDirection direction); // is direction active?
|
||||
public abstract bool GetHatDirectionDown(InputDirection direction); // direction just became active?
|
||||
public abstract bool GetHatDirectionUp(InputDirection direction); // direction just became inactive?
|
||||
|
||||
public abstract void SetPlayer(int? playerNum); // Set the player number (starts at 1, set to -1 or null for no player)
|
||||
public abstract int? GetPlayer(); // Get the player number (null if no player)
|
||||
|
||||
//public abstract Sprite GetDisplayIcon(); //"big icon" for the controller in the settings menu
|
||||
//public abstract Sprite GetPlaybackIcon(); //"small icon" for the controller during playback
|
||||
}
|
||||
}
|
11
Assets/Scripts/InputSystem/InputController.cs.meta
Normal file
11
Assets/Scripts/InputSystem/InputController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f940937684f598749af06c1297727c4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
247
Assets/Scripts/InputSystem/PlayerInput.cs
Normal file
247
Assets/Scripts/InputSystem/PlayerInput.cs
Normal file
@ -0,0 +1,247 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using HeavenStudio.InputSystem;
|
||||
|
||||
using static JSL;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
public class PlayerInput
|
||||
{
|
||||
//Clockwise
|
||||
public const int UP = 0;
|
||||
public const int RIGHT = 1;
|
||||
public const int DOWN = 2;
|
||||
public const int LEFT = 3;
|
||||
|
||||
///////////////////////////////
|
||||
////TEMPORARY JSL FUNCTIONS////
|
||||
///////////////////////////////
|
||||
|
||||
static int jslDevicesFound = 0;
|
||||
static int jslDevicesConnected = 0;
|
||||
static int[] jslDeviceHandles;
|
||||
|
||||
static List<InputController> inputDevices;
|
||||
|
||||
public static int InitInputControllers()
|
||||
{
|
||||
inputDevices = new List<InputController>();
|
||||
//Keyboard setup
|
||||
InputKeyboard keyboard = new InputKeyboard();
|
||||
keyboard.SetPlayer(1);
|
||||
keyboard.InitializeController();
|
||||
inputDevices.Add(keyboard);
|
||||
//end Keyboard setup
|
||||
|
||||
//JoyShock setup
|
||||
Debug.Log("Flushing possible JoyShocks...");
|
||||
DisconnectJoyshocks();
|
||||
|
||||
jslDevicesFound = JslConnectDevices();
|
||||
if (jslDevicesFound > 0)
|
||||
{
|
||||
jslDeviceHandles = new int[jslDevicesFound];
|
||||
jslDevicesConnected = JslGetConnectedDeviceHandles(jslDeviceHandles, jslDevicesFound);
|
||||
if (jslDevicesConnected < jslDevicesFound)
|
||||
{
|
||||
Debug.Log("Found " + jslDevicesFound + " JoyShocks, but only " + jslDevicesConnected + " are connected.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Found " + jslDevicesFound + " JoyShocks.");
|
||||
Debug.Log("Connected " + jslDevicesConnected + " JoyShocks.");
|
||||
}
|
||||
|
||||
foreach (int i in jslDeviceHandles)
|
||||
{
|
||||
Debug.Log("Setting up JoyShock: ( Handle " + i + ", type " + JslGetControllerType(i) + " )");
|
||||
InputJoyshock joyshock = new InputJoyshock(i);
|
||||
joyshock.InitializeController();
|
||||
joyshock.SetPlayer(inputDevices.Count + 1);
|
||||
inputDevices.Add(joyshock);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("No JoyShocks found.");
|
||||
}
|
||||
//end JoyShock setup
|
||||
|
||||
//TODO: XInput setup (boo)
|
||||
//end XInput setup
|
||||
|
||||
return inputDevices.Count;
|
||||
}
|
||||
|
||||
public static int GetNumControllersConnected()
|
||||
{
|
||||
return inputDevices.Count;
|
||||
}
|
||||
|
||||
public static List<InputController> GetInputControllers()
|
||||
{
|
||||
return inputDevices;
|
||||
}
|
||||
|
||||
public static InputController GetInputController(int player)
|
||||
{
|
||||
//select input controller that has player field set to player
|
||||
//this will return the first controller that has that player number in the case of controller pairs (eg. Joy-Cons)
|
||||
//so such controllers should have a reference to the other controller in the pair
|
||||
foreach (InputController i in inputDevices)
|
||||
{
|
||||
if (i.GetPlayer() == player)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int GetInputControllerId(int player)
|
||||
{
|
||||
//select input controller id that has player field set to player
|
||||
//this will return the first controller that has that player number in the case of controller pairs (eg. Joy-Cons)
|
||||
//so such controllers should have a reference to the other controller in the pair
|
||||
//controller IDs are determined by connection order (the Keyboard is always first)
|
||||
for (int i = 0; i < inputDevices.Count; i++)
|
||||
{
|
||||
if (inputDevices[i].GetPlayer() == player)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static void UpdateInputControllers()
|
||||
{
|
||||
foreach (InputController i in inputDevices)
|
||||
{
|
||||
i.UpdateState();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DisconnectJoyshocks()
|
||||
{
|
||||
if (jslDeviceHandles != null && jslDevicesConnected > 0 && jslDeviceHandles.Length > 0)
|
||||
{
|
||||
foreach (InputController i in inputDevices)
|
||||
{
|
||||
if (typeof(InputJoyshock) == i.GetType())
|
||||
{
|
||||
InputJoyshock joy = (InputJoyshock)i;
|
||||
joy.DisconnectJoyshock();
|
||||
}
|
||||
}
|
||||
}
|
||||
JslDisconnectAndDisposeAll();
|
||||
jslDevicesFound = 0;
|
||||
jslDevicesConnected = 0;
|
||||
}
|
||||
|
||||
// The autoplay isn't activated AND
|
||||
// The song is actually playing AND
|
||||
// The GameManager allows you to Input
|
||||
public static bool playerHasControl()
|
||||
{
|
||||
return !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
/*--------------------*/
|
||||
/* MAIN INPUT METHODS */
|
||||
/*--------------------*/
|
||||
|
||||
// BUTTONS
|
||||
//TODO: refactor for controller and custom binds, currently uses temporary button checks
|
||||
|
||||
public static bool Pressed(bool includeDPad = false)
|
||||
{
|
||||
bool keyDown = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadE) || (includeDPad && GetAnyDirectionDown());
|
||||
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput ;
|
||||
}
|
||||
|
||||
public static bool PressedUp(bool includeDPad = false)
|
||||
{
|
||||
bool keyUp = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadE) || (includeDPad && GetAnyDirectionUp());
|
||||
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
public static bool Pressing(bool includeDPad = false)
|
||||
{
|
||||
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.PadE) || (includeDPad && GetAnyDirection());
|
||||
return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
|
||||
public static bool AltPressed()
|
||||
{
|
||||
bool down = GetInputController(1).GetButtonDown((int) InputController.ButtonsPad.PadS);
|
||||
return down && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool AltPressedUp()
|
||||
{
|
||||
bool up = GetInputController(1).GetButtonUp((int) InputController.ButtonsPad.PadS);
|
||||
return up && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool AltPressing()
|
||||
{
|
||||
bool pressing = GetInputController(1).GetButton((int) InputController.ButtonsPad.PadS);
|
||||
return pressing && playerHasControl();
|
||||
}
|
||||
|
||||
//Directions
|
||||
|
||||
public static bool GetAnyDirectionDown()
|
||||
{
|
||||
InputController c = GetInputController(1);
|
||||
return (c.GetHatDirectionDown((InputController.InputDirection) UP)
|
||||
|| c.GetHatDirectionDown((InputController.InputDirection) DOWN)
|
||||
|| c.GetHatDirectionDown((InputController.InputDirection) LEFT)
|
||||
|| c.GetHatDirectionDown((InputController.InputDirection) RIGHT)
|
||||
) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetAnyDirectionUp()
|
||||
{
|
||||
InputController c = GetInputController(1);
|
||||
return (c.GetHatDirectionUp((InputController.InputDirection) UP)
|
||||
|| c.GetHatDirectionUp((InputController.InputDirection) DOWN)
|
||||
|| c.GetHatDirectionUp((InputController.InputDirection) LEFT)
|
||||
|| c.GetHatDirectionUp((InputController.InputDirection) RIGHT)
|
||||
) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetAnyDirection()
|
||||
{
|
||||
InputController c = GetInputController(1);
|
||||
return (c.GetHatDirection((InputController.InputDirection) UP)
|
||||
|| c.GetHatDirection((InputController.InputDirection) DOWN)
|
||||
|| c.GetHatDirection((InputController.InputDirection) LEFT)
|
||||
|| c.GetHatDirection((InputController.InputDirection) RIGHT)
|
||||
) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetSpecificDirection(int direction)
|
||||
{
|
||||
return GetInputController(1).GetHatDirection((InputController.InputDirection) direction) && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool GetSpecificDirectionDown(int direction)
|
||||
{
|
||||
return GetInputController(1).GetHatDirectionDown((InputController.InputDirection) direction) && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool GetSpecificDirectionUp(int direction)
|
||||
{
|
||||
return GetInputController(1).GetHatDirectionUp((InputController.InputDirection) direction) && playerHasControl();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9503627b14bba414cae0fbc5da9e4120
|
||||
guid: ff41ce113a3b89f4892e362c8ef3d773
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -49,12 +49,13 @@ 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;
|
||||
|
||||
@ -104,12 +105,12 @@ 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);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,263 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using TMPro;
|
||||
|
||||
using HeavenStudio;
|
||||
using HeavenStudio.Util;
|
||||
using HeavenStudio.InputSystem;
|
||||
using static JSL;
|
||||
|
||||
namespace HeavenStudio.Editor
|
||||
{
|
||||
public class ControllerSettings : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text numConnectedLabel;
|
||||
[SerializeField] private TMP_Text currentControllerLabel;
|
||||
[SerializeField] private TMP_Dropdown controllersDropdown;
|
||||
[SerializeField] private GameObject pairSearchItem;
|
||||
[SerializeField] private GameObject autoSearchLabel;
|
||||
[SerializeField] private GameObject pairSearchLabel;
|
||||
[SerializeField] private TMP_Text pairingLabel;
|
||||
[SerializeField] private List<GameObject> controllerIcons;
|
||||
|
||||
[SerializeField] private Material controllerMat;
|
||||
|
||||
private bool isAutoSearching = false;
|
||||
private bool isPairSearching = false;
|
||||
private bool pairSelectLR = false; //true = left, false = right
|
||||
|
||||
private void Start() {
|
||||
numConnectedLabel.text = "Connected: " + PlayerInput.GetNumControllersConnected();
|
||||
currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName();
|
||||
PopulateControllersDropdown();
|
||||
|
||||
ShowControllerIcon(PlayerInput.GetInputController(1));
|
||||
|
||||
controllersDropdown.onValueChanged.AddListener(delegate
|
||||
{
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
InputController newController = PlayerInput.GetInputControllers()[controllersDropdown.value];
|
||||
lastController.SetPlayer(-1);
|
||||
newController.SetPlayer(1);
|
||||
|
||||
if (typeof(InputJoyshock) == lastController.GetType()) {
|
||||
InputJoyshock con = (InputJoyshock) lastController;
|
||||
con.UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
if (typeof(InputJoyshock) == newController.GetType()) {
|
||||
InputJoyshock con = (InputJoyshock) newController;
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
con.UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
currentControllerLabel.text = "Current Controller: " + newController.GetDeviceName();
|
||||
ShowControllerIcon(newController);
|
||||
|
||||
InputController.InputFeatures features = newController.GetFeatures();
|
||||
if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft) || features.HasFlag(InputController.InputFeatures.Extra_SplitControllerRight))
|
||||
{
|
||||
pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft);
|
||||
pairSearchItem.SetActive(true);
|
||||
StartPairSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
pairSearchItem.SetActive(false);
|
||||
CancelPairSearch();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (isAutoSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
foreach (var controller in controllers) {
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputController lastController = PlayerInput.GetInputController(1);
|
||||
lastController.SetPlayer(-1);
|
||||
controller.SetPlayer(1);
|
||||
isAutoSearching = false;
|
||||
autoSearchLabel.SetActive(false);
|
||||
controllersDropdown.value = PlayerInput.GetInputControllerId(1);
|
||||
|
||||
if (typeof(InputJoyshock) == lastController.GetType()) {
|
||||
((InputJoyshock)lastController).UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
if (typeof(InputJoyshock) == controller.GetType()) {
|
||||
InputJoyshock con = (InputJoyshock) controller;
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
con.UnAssignOtherHalf();
|
||||
}
|
||||
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
InputController.InputFeatures features = controller.GetFeatures();
|
||||
if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft) || features.HasFlag(InputController.InputFeatures.Extra_SplitControllerRight))
|
||||
{
|
||||
pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft);
|
||||
pairSearchItem.SetActive(true);
|
||||
StartPairSearch();
|
||||
}
|
||||
else
|
||||
{
|
||||
pairSearchItem.SetActive(false);
|
||||
CancelPairSearch();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (isPairSearching) {
|
||||
var controllers = PlayerInput.GetInputControllers();
|
||||
InputController.InputFeatures lrFlag = pairSelectLR ? InputController.InputFeatures.Extra_SplitControllerLeft : InputController.InputFeatures.Extra_SplitControllerRight;
|
||||
foreach (var controller in controllers) {
|
||||
if (controller == PlayerInput.GetInputController(1)) continue;
|
||||
InputController.InputFeatures features = controller.GetFeatures();
|
||||
if (!features.HasFlag(lrFlag)) continue;
|
||||
if (controller.GetLastButtonDown() > 0 || controller.GetLastKeyDown() > 0) {
|
||||
InputJoyshock con = (InputJoyshock) PlayerInput.GetInputController(1);
|
||||
con.AssignOtherHalf((InputJoyshock) controller);
|
||||
isPairSearching = false;
|
||||
pairSearchLabel.SetActive(false);
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Successful!";
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
StartCoroutine(SelectionVibrate((InputJoyshock) controller));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAutoSearch() {
|
||||
if (!isPairSearching)
|
||||
{
|
||||
autoSearchLabel.SetActive(true);
|
||||
isAutoSearching = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void StartPairSearch() {
|
||||
if (!isAutoSearching) {
|
||||
pairSearchLabel.SetActive(true);
|
||||
isPairSearching = true;
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Second Joy-Con...";
|
||||
}
|
||||
}
|
||||
|
||||
public void CancelPairSearch() {
|
||||
if (isPairSearching) {
|
||||
pairSearchLabel.SetActive(false);
|
||||
isPairSearching = false;
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing was cancelled.";
|
||||
}
|
||||
}
|
||||
|
||||
public void SearchAndConnectControllers()
|
||||
{
|
||||
int connected = PlayerInput.InitInputControllers();
|
||||
numConnectedLabel.text = "Connected: " + connected;
|
||||
currentControllerLabel.text = "Current Controller: " + PlayerInput.GetInputController(1).GetDeviceName();
|
||||
PopulateControllersDropdown();
|
||||
}
|
||||
|
||||
public void PopulateControllersDropdown()
|
||||
{
|
||||
List<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
|
||||
var vals = PlayerInput.GetInputControllers();
|
||||
for (int i = 0; i < vals.Count; i++)
|
||||
{
|
||||
TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData();
|
||||
optionData.text = vals[i].GetDeviceName();
|
||||
dropDownData.Add(optionData);
|
||||
}
|
||||
controllersDropdown.AddOptions(dropDownData);
|
||||
controllersDropdown.value = 0;
|
||||
}
|
||||
|
||||
public void ShowControllerIcon(InputController controller)
|
||||
{
|
||||
string name = controller.GetDeviceName();
|
||||
foreach (var icon in controllerIcons)
|
||||
{
|
||||
if (icon.name == name)
|
||||
{
|
||||
icon.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
icon.SetActive(false);
|
||||
}
|
||||
}
|
||||
//setup material
|
||||
Color colour;
|
||||
switch (name)
|
||||
{
|
||||
case "Keyboard":
|
||||
controllerMat.SetColor("_BodyColor", ColorUtility.TryParseHtmlString("#F4F4F4", out colour) ? colour : Color.white);
|
||||
break;
|
||||
case "Joy-Con (L)":
|
||||
case "Joy-Con (R)":
|
||||
InputJoyshock joy = (InputJoyshock) controller;
|
||||
controllerMat.SetColor("_BodyColor", BitwiseUtils.IntToRgb(JslGetControllerColour(joy.GetHandle())));
|
||||
controllerMat.SetColor("_BtnColor", BitwiseUtils.IntToRgb(JslGetControllerButtonColour(joy.GetHandle())));
|
||||
controllerMat.SetColor("_LGripColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_RGripColor", ColorUtility.TryParseHtmlString("#2F353A", out colour) ? colour : Color.white);
|
||||
break;
|
||||
case "Joy-Con Pair":
|
||||
joy = (InputJoyshock) controller;
|
||||
int joySide = JslGetControllerSplitType(joy.GetHandle());
|
||||
controllerMat.SetColor("_BodyColor", BitwiseUtils.IntToRgb(joySide == SplitRight ? JslGetControllerButtonColour(joy.GetHandle()) : JslGetControllerButtonColour(joy.GetOtherHalf().GetHandle())));
|
||||
controllerMat.SetColor("_BtnColor", BitwiseUtils.IntToRgb(joySide == SplitLeft ? JslGetControllerButtonColour(joy.GetHandle()) : JslGetControllerButtonColour(joy.GetOtherHalf().GetHandle())));
|
||||
controllerMat.SetColor("_LGripColor", BitwiseUtils.IntToRgb(joySide == SplitLeft ? JslGetControllerColour(joy.GetHandle()) : JslGetControllerColour(joy.GetOtherHalf().GetHandle())));
|
||||
controllerMat.SetColor("_RGripColor", BitwiseUtils.IntToRgb(joySide == SplitRight ? JslGetControllerColour(joy.GetHandle()) : JslGetControllerColour(joy.GetOtherHalf().GetHandle())));
|
||||
break;
|
||||
case "Pro Controller":
|
||||
joy = (InputJoyshock) controller;
|
||||
controllerMat.SetColor("_BodyColor", BitwiseUtils.IntToRgb(JslGetControllerColour(joy.GetHandle())));
|
||||
controllerMat.SetColor("_BtnColor", BitwiseUtils.IntToRgb(JslGetControllerButtonColour(joy.GetHandle())));
|
||||
controllerMat.SetColor("_LGripColor", BitwiseUtils.IntToRgb(JslGetControllerLeftGripColour(joy.GetHandle())));
|
||||
controllerMat.SetColor("_RGripColor", BitwiseUtils.IntToRgb(JslGetControllerRightGripColour(joy.GetHandle())));
|
||||
break;
|
||||
//TODO: dualshock 4 and dualsense lightbar colour support
|
||||
case "DualShock 4":
|
||||
controllerMat.SetColor("_BodyColor", ColorUtility.TryParseHtmlString("#E1E2E4", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_BtnColor", ColorUtility.TryParseHtmlString("#414246", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_LGripColor", ColorUtility.TryParseHtmlString("#1E6EFA", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_RGripColor", ColorUtility.TryParseHtmlString("#1E6EFA", out colour) ? colour : Color.white);
|
||||
break;
|
||||
case "DualSense":
|
||||
controllerMat.SetColor("_BodyColor", ColorUtility.TryParseHtmlString("#DEE0EB", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_BtnColor", ColorUtility.TryParseHtmlString("#272D39", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_LGripColor", ColorUtility.TryParseHtmlString("#1E6EFA", out colour) ? colour : Color.white);
|
||||
controllerMat.SetColor("_RGripColor", ColorUtility.TryParseHtmlString("#1E6EFA", out colour) ? colour : Color.white);
|
||||
break;
|
||||
default:
|
||||
controllerMat.SetColor("_BodyColor", new Color(1, 1, 1, 1));
|
||||
controllerMat.SetColor("_BtnColor", new Color(1, 1, 1, 1));
|
||||
controllerMat.SetColor("_LGripColor", new Color(1, 1, 1, 1));
|
||||
controllerMat.SetColor("_RGripColor", new Color(1, 1, 1, 1));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator SelectionVibrate(InputJoyshock controller)
|
||||
{
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.4f, 0.3f, 80f, 160f);
|
||||
yield return new WaitForSeconds(0.15f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
|
||||
yield return new WaitForSeconds(0.05f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.45f, 0.45f, 160f, 320f);
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 10d59ed8edc40a448a61794f93c74ccd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -68,7 +68,7 @@ namespace HeavenStudio.Editor
|
||||
|
||||
public void OnVolLabelChanged()
|
||||
{
|
||||
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text), 2);
|
||||
volSlider.value = (float)System.Math.Round(System.Convert.ToSingle(volLabel.text) / 100f, 2);
|
||||
GlobalGameManager.ChangeMasterVolume(volSlider.value);
|
||||
}
|
||||
}
|
||||
|
@ -1,127 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio
|
||||
{
|
||||
public class PlayerInput
|
||||
{
|
||||
|
||||
//Clockwise
|
||||
public const int UP = 0;
|
||||
public const int RIGHT = 1;
|
||||
public const int DOWN = 2;
|
||||
public const int LEFT = 3;
|
||||
|
||||
// The autoplay isn't activated AND
|
||||
// The song is actually playing AND
|
||||
// The GameManager allows you to Input
|
||||
public static bool playerHasControl()
|
||||
{
|
||||
return !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
/*--------------------*/
|
||||
/* MAIN INPUT METHODS */
|
||||
/*--------------------*/
|
||||
|
||||
// BUTTONS
|
||||
|
||||
public static bool Pressed(bool includeDPad = false)
|
||||
{
|
||||
bool keyDown = Input.GetKeyDown(KeyCode.Z) || (includeDPad && GetAnyDirectionDown());
|
||||
return keyDown && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput ;
|
||||
}
|
||||
|
||||
public static bool PressedUp(bool includeDPad = false)
|
||||
{
|
||||
bool keyUp = Input.GetKeyUp(KeyCode.Z) || (includeDPad && GetAnyDirectionUp());
|
||||
return keyUp && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
public static bool Pressing(bool includeDPad = false)
|
||||
{
|
||||
bool pressing = Input.GetKey(KeyCode.Z) || (includeDPad && GetAnyDirection());
|
||||
return pressing && !GameManager.instance.autoplay && Conductor.instance.isPlaying && GameManager.instance.canInput;
|
||||
}
|
||||
|
||||
|
||||
public static bool AltPressed()
|
||||
{
|
||||
return Input.GetKeyDown(KeyCode.X) && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool AltPressedUp()
|
||||
{
|
||||
return Input.GetKeyUp(KeyCode.X) && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool AltPressing()
|
||||
{
|
||||
return Input.GetKey(KeyCode.X) && playerHasControl();
|
||||
}
|
||||
|
||||
//Directions
|
||||
|
||||
public static bool GetAnyDirectionDown()
|
||||
{
|
||||
return (Input.GetKeyDown(KeyCode.UpArrow)
|
||||
|| Input.GetKeyDown(KeyCode.DownArrow)
|
||||
|| Input.GetKeyDown(KeyCode.LeftArrow)
|
||||
|| Input.GetKeyDown(KeyCode.RightArrow)) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetAnyDirectionUp()
|
||||
{
|
||||
return (Input.GetKeyUp(KeyCode.UpArrow)
|
||||
|| Input.GetKeyUp(KeyCode.DownArrow)
|
||||
|| Input.GetKeyUp(KeyCode.LeftArrow)
|
||||
|| Input.GetKeyUp(KeyCode.RightArrow)) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetAnyDirection()
|
||||
{
|
||||
return (Input.GetKey(KeyCode.UpArrow)
|
||||
|| Input.GetKey(KeyCode.DownArrow)
|
||||
|| Input.GetKey(KeyCode.LeftArrow)
|
||||
|| Input.GetKey(KeyCode.RightArrow)) && playerHasControl();
|
||||
|
||||
}
|
||||
|
||||
public static bool GetSpecificDirectionDown(int direction)
|
||||
{
|
||||
KeyCode targetCode = getKeyCode(direction);
|
||||
if (targetCode == KeyCode.None) return false;
|
||||
|
||||
return Input.GetKeyDown(targetCode) && playerHasControl();
|
||||
}
|
||||
|
||||
public static bool GetSpecificDirectionUp(int direction)
|
||||
{
|
||||
KeyCode targetCode = getKeyCode(direction);
|
||||
if (targetCode == KeyCode.None) return false;
|
||||
|
||||
return Input.GetKeyUp(targetCode) && playerHasControl();
|
||||
}
|
||||
|
||||
|
||||
private static KeyCode getKeyCode(int direction)
|
||||
{
|
||||
KeyCode targetKeyCode;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case PlayerInput.UP: targetKeyCode = KeyCode.UpArrow; break;
|
||||
case PlayerInput.DOWN: targetKeyCode = KeyCode.DownArrow; break;
|
||||
case PlayerInput.LEFT: targetKeyCode = KeyCode.LeftArrow; break;
|
||||
case PlayerInput.RIGHT: targetKeyCode = KeyCode.RightArrow; break;
|
||||
default: targetKeyCode = KeyCode.None; break;
|
||||
}
|
||||
|
||||
return targetKeyCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
63
Assets/Scripts/Util/BitwiseUtils.cs
Normal file
63
Assets/Scripts/Util/BitwiseUtils.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace HeavenStudio.Util
|
||||
{
|
||||
public static class BitwiseUtils
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the value of the lowest set bit in the given integer.
|
||||
/// </summary>
|
||||
/// <param name="num">The integer to check.</param>
|
||||
public static int FirstSetBit(int num)
|
||||
{
|
||||
return num & (-num);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is set in the given integer.
|
||||
/// </summary>
|
||||
/// <param name="num">The integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantCurrent(int num, int want)
|
||||
{
|
||||
if (want <= 0) return false;
|
||||
return (num & want) == want;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is set in the first integer, and not in the second.
|
||||
/// </summary>
|
||||
/// <param name="num1">The first integer to check.</param>
|
||||
/// <param name="num2">The second integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantCurrentAndNotLast(int num1, int num2, int want)
|
||||
{
|
||||
if (want <= 0) return false;
|
||||
return ((num1 & want) == want) && ((num2 & want) != want);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the wanted bit is not set in the first integer, but set in the second.
|
||||
/// </summary>
|
||||
/// <param name="num1">The first integer to check.</param>
|
||||
/// <param name="num2">The second integer to check.</param>
|
||||
/// <param name="want">The bit(s) to check for.</param>
|
||||
public static bool WantNotCurrentAndLast(int num1, int num2, int want)
|
||||
{
|
||||
if (want <= 0) return false;
|
||||
return ((num1 & want) != want) && ((num2 & want) == want);
|
||||
}
|
||||
|
||||
public static Color IntToRgb(int value)
|
||||
{
|
||||
var red = ( value >> 16 ) & 255;
|
||||
var green = ( value >> 8 ) & 255;
|
||||
var blue = ( value >> 0 ) & 255;
|
||||
return new Color(red/255f, green/255f, blue/255f);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Util/BitwiseUtils.cs.meta
Normal file
11
Assets/Scripts/Util/BitwiseUtils.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 18f088a4c3c17b143a1985f3cee5d90a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user