mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-10 11:45:09 +00:00
Update repo to latest
This commit is contained in:
parent
180fea7832
commit
938580b880
11 changed files with 820 additions and 767 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b7506008d0590bb43b83146e346e76a8
|
||||
guid: 81da809b3fd51eb46a30b4e0facdc1d3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d7a937de053f9824daf68b049d7676ed
|
||||
guid: c7b0aefc20b1440439c0a3686f7331a6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
|
|
|
@ -3984,7 +3984,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 0}
|
||||
m_AnchoredPosition: {x: -289.15005, y: 2}
|
||||
m_AnchoredPosition: {x: -289.15002, y: 2}
|
||||
m_SizeDelta: {x: -578.29, y: 49.92}
|
||||
m_Pivot: {x: 0.5, y: 0}
|
||||
--- !u!114 &156962255
|
||||
|
@ -13464,7 +13464,7 @@ MonoBehaviour:
|
|||
m_HandleRect: {fileID: 704039020}
|
||||
m_Direction: 0
|
||||
m_Value: 0
|
||||
m_Size: 0.032871276
|
||||
m_Size: 0.03287128
|
||||
m_NumberOfSteps: 0
|
||||
m_OnValueChanged:
|
||||
m_PersistentCalls:
|
||||
|
@ -24808,7 +24808,7 @@ RectTransform:
|
|||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0.5}
|
||||
m_AnchorMax: {x: 1, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 83.22952}
|
||||
m_AnchoredPosition: {x: 0, y: 129.85194}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &1154875944
|
||||
|
|
|
@ -70,13 +70,14 @@ namespace HeavenStudio.Games
|
|||
public bool hasMissed;
|
||||
|
||||
[Header("Waypoint")]
|
||||
[SerializeField] float wayPointZForForth;
|
||||
public float wayPointZForForth;
|
||||
|
||||
[Header("Curves")]
|
||||
public BezierCurve3D closeRallyCurve;
|
||||
public BezierCurve3D farRallyCurve;
|
||||
public BezierCurve3D fartherRallyCurve;
|
||||
public BezierCurve3D farthestRallyCurve;
|
||||
public BezierCurve3D closeRallyReturnCurve;
|
||||
public BezierCurve3D MissCurve;
|
||||
public BezierCurve3D MissReturnCurve;
|
||||
|
||||
[Header("Debug")]
|
||||
public float beatShown;
|
||||
|
@ -85,6 +86,7 @@ namespace HeavenStudio.Games
|
|||
public int wantDistance;
|
||||
public bool wantSilent;
|
||||
public float beatHolder;
|
||||
public Transform holderPos;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
@ -120,8 +122,11 @@ namespace HeavenStudio.Games
|
|||
if(lengthHolder != lengthShown)
|
||||
{
|
||||
started = true;
|
||||
|
||||
Rally(serveBeat + (int)currentBeat, wantSilent, lengthHolder);
|
||||
//convert to 2 decimal places
|
||||
var f = currentBeat;
|
||||
//f = Mathf.Round(f * 10.0f) * 0.1f;
|
||||
Rally(serveBeat + (int)f, wantSilent, lengthHolder);
|
||||
//Debug.Log("Beat Loop: " + serveBeat + f);
|
||||
//Debug.Log("Serve Beat: " + serveBeat);
|
||||
}
|
||||
}
|
||||
|
@ -146,13 +151,25 @@ namespace HeavenStudio.Games
|
|||
public void SpawnObject(float beat, int type)
|
||||
{
|
||||
BezierCurve3D curve = null;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case (int)DistanceSound.close:
|
||||
curve = closeRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.far:
|
||||
curve = farRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.farther:
|
||||
curve = fartherRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.farthest:
|
||||
curve = farthestRallyCurve;
|
||||
break;
|
||||
}
|
||||
|
||||
//curve.KeyPoints[0].transform.position = new Vector3(holderPos.position.x, holderPos.position.y, wayPointZForForth);
|
||||
|
||||
if (!shuttleActive)
|
||||
{
|
||||
ActiveShuttle = GameObject.Instantiate(Shuttlecock, objHolder.transform);
|
||||
|
@ -163,7 +180,7 @@ namespace HeavenStudio.Games
|
|||
shuttleScript.flyPos = 0f;
|
||||
shuttleScript.isReturning = false;
|
||||
shuttleScript.startBeat = (int)Conductor.instance.songPositionInBeats;
|
||||
shuttleScript.curve = closeRallyCurve;
|
||||
shuttleScript.curve = curve;
|
||||
//float normalizedBeatAnim = Conductor.instance.GetPositionFromBeat(beat, 3f);
|
||||
|
||||
//ActiveShuttle.transform.position = curve.GetPoint(normalizedBeatAnim);
|
||||
|
@ -175,23 +192,36 @@ namespace HeavenStudio.Games
|
|||
|
||||
public void ReturnObject(float beat, int type)
|
||||
{
|
||||
|
||||
BezierCurve3D curve = null;
|
||||
switch (type)
|
||||
{
|
||||
case (int)DistanceSound.close:
|
||||
curve = closeRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.far:
|
||||
curve = farRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.farther:
|
||||
curve = fartherRallyCurve;
|
||||
break;
|
||||
case (int)DistanceSound.farthest:
|
||||
curve = farthestRallyCurve;
|
||||
break;
|
||||
}
|
||||
|
||||
ActiveShuttle.transform.localPosition = curve.KeyPoints[0].transform.position;
|
||||
var shuttleScript = ActiveShuttle.GetComponent<Shuttlecock>();
|
||||
shuttleScript.flyPos = 0f;
|
||||
shuttleScript.isReturning = true;
|
||||
shuttleScript.startBeat = beat;
|
||||
shuttleScript.curve = closeRallyReturnCurve;
|
||||
//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
|
||||
|
@ -316,7 +346,7 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
//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); } ),
|
||||
//new BeatAction.Action(beat, delegate { SpawnObject(beat, (int)e_BaBumState); } ),
|
||||
});
|
||||
|
||||
switch (e_BaBumState)
|
||||
|
@ -388,8 +418,6 @@ namespace HeavenStudio.Games
|
|||
lengthHolder = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -400,6 +428,12 @@ namespace HeavenStudio.Games
|
|||
serveBeat = 0f;
|
||||
lengthShown = 0f;
|
||||
lengthHolder = 0f;
|
||||
|
||||
//if (!ActiveShuttle)
|
||||
//{
|
||||
// SpawnObject(beat, (int)e_BaBumState);
|
||||
//}
|
||||
|
||||
string[] sounds = { "", "", "", "", "", ""};
|
||||
string[] sounds2 = { "", "", "" };
|
||||
if (e_BaBumState == DistanceSound.close || type == 0)
|
||||
|
@ -507,25 +541,6 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
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)
|
||||
{
|
||||
|
@ -543,8 +558,20 @@ namespace HeavenStudio.Games
|
|||
{
|
||||
Jukebox.PlayOneShotGame("airRally/hitBaxter_Farthest");
|
||||
}
|
||||
|
||||
if (beatHolder % 2 == 0)
|
||||
{
|
||||
//ReturnObject(beatHolder + 1, 0);
|
||||
//Debug.Log("a");
|
||||
}
|
||||
else
|
||||
{
|
||||
//ReturnObject(beatHolder + 1, 0);
|
||||
//Debug.Log("b");
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Debug.Log("BeatHolder: " + beatHolder);
|
||||
served = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
|
||||
[NonReorderable] public BezierCurve3D curve;
|
||||
AirRally game;
|
||||
Vector3 nextPos;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
game = AirRally.instance;
|
||||
flyBeats = isReturning ? 1.2f : 1.2f;
|
||||
flyBeats = 1f;
|
||||
var cond = Conductor.instance;
|
||||
flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
transform.position = curve.GetPoint(flyPos);
|
||||
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
|
@ -38,16 +38,26 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
void Update()
|
||||
{
|
||||
var cond = Conductor.instance;
|
||||
//flyBeats = isReturning ? 1.2f : 1.2f;
|
||||
float flyPos = cond.GetPositionFromBeat(startBeat, flyBeats);
|
||||
flyBeats = isReturning ? 1.2f : 1.2f;
|
||||
if (flyPos <= 1f)
|
||||
{
|
||||
if (!miss)
|
||||
{
|
||||
flyPos *= 0.95f;
|
||||
flyPos *= .8f;
|
||||
}
|
||||
|
||||
Vector3 lastPos = transform.position;
|
||||
Vector3 nextPos = curve.GetPoint(flyPos);
|
||||
nextPos = curve.GetPoint(flyPos);
|
||||
curve.KeyPoints[0].transform.position = new Vector3(game.holderPos.position.x, game.holderPos.position.y, game.wayPointZForForth);
|
||||
if (isReturning)
|
||||
{
|
||||
curve.transform.localScale = new Vector3(-1, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
curve.transform.localScale = new Vector3(1, 1);
|
||||
}
|
||||
|
||||
if (flyType)
|
||||
{
|
||||
|
@ -57,7 +67,8 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!isReturning)
|
||||
|
||||
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));
|
||||
|
@ -65,10 +76,10 @@ namespace HeavenStudio.Games.Scripts_AirRally
|
|||
|
||||
transform.position = nextPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// transform.position = curve.GetPoint(miss ? 1f : 0.95f);
|
||||
//}
|
||||
|
||||
//if (flyPos > 1f)
|
||||
//{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
@ -19,6 +20,17 @@ namespace HeavenStudio.InputSystem
|
|||
"DualSense"
|
||||
};
|
||||
|
||||
static int[] dsPlayerColours = new[]
|
||||
{
|
||||
0xd41817,
|
||||
0x04d4fa,
|
||||
0x05ff08,
|
||||
0xffdd01,
|
||||
0xe906c9,
|
||||
0xcc6020,
|
||||
0x888888
|
||||
};
|
||||
|
||||
//TODO: see if single joy-con mappings differ from a normal pad (they don't!)
|
||||
int[] mappings = new[]
|
||||
{
|
||||
|
@ -68,6 +80,7 @@ namespace HeavenStudio.InputSystem
|
|||
int joyshockHandle;
|
||||
int type;
|
||||
int splitType;
|
||||
int lightbarColour;
|
||||
string joyshockName;
|
||||
|
||||
//buttons, sticks, triggers
|
||||
|
@ -107,6 +120,14 @@ namespace HeavenStudio.InputSystem
|
|||
joyBtStateLast = joyBtStateCurrent;
|
||||
joyBtStateCurrent = JslGetSimpleState(joyshockHandle);
|
||||
|
||||
//gyro and accelerometer
|
||||
joyImuStateLast = joyImuStateCurrent;
|
||||
joyImuStateCurrent = JslGetIMUState(joyshockHandle);
|
||||
|
||||
//touchpad
|
||||
joyTouchStateLast = joyTouchStateCurrent;
|
||||
joyTouchStateCurrent = JslGetTouchState(joyshockHandle);
|
||||
|
||||
//stick direction state
|
||||
//split controllers will need to be rotated to compensate
|
||||
//left rotates counterclockwise, right rotates clockwise, all by 90 degrees
|
||||
|
@ -154,7 +175,7 @@ namespace HeavenStudio.InputSystem
|
|||
|
||||
public override InputFeatures GetFeatures()
|
||||
{
|
||||
InputFeatures features = InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||
InputFeatures features = InputFeatures.Readable_MotionSensor | InputFeatures.Extra_Rumble | InputFeatures.Style_Pad | InputFeatures.Style_Baton;
|
||||
switch (type)
|
||||
{
|
||||
case TypeJoyConLeft:
|
||||
|
@ -173,7 +194,6 @@ namespace HeavenStudio.InputSystem
|
|||
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;
|
||||
}
|
||||
|
||||
|
@ -360,6 +380,7 @@ namespace HeavenStudio.InputSystem
|
|||
{
|
||||
this.playerNum = null;
|
||||
JslSetPlayerNumber(joyshockHandle, 0);
|
||||
JslSetLightColour(joyshockHandle, 0);
|
||||
return;
|
||||
}
|
||||
this.playerNum = playerNum;
|
||||
|
@ -372,6 +393,8 @@ namespace HeavenStudio.InputSystem
|
|||
}
|
||||
}
|
||||
JslSetPlayerNumber(joyshockHandle, ledMask);
|
||||
lightbarColour = GetLightbarColourForPlayer((int) this.playerNum);
|
||||
JslSetLightColour(joyshockHandle, lightbarColour);
|
||||
}
|
||||
|
||||
public override int? GetPlayer()
|
||||
|
@ -379,6 +402,61 @@ namespace HeavenStudio.InputSystem
|
|||
return this.playerNum;
|
||||
}
|
||||
|
||||
public Color GetBodyColor()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
{
|
||||
// gets the colour of the right controller if is split
|
||||
return BitwiseUtils.IntToRgb(splitType == SplitRight ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
||||
}
|
||||
return BitwiseUtils.IntToRgb(JslGetControllerColour(joyshockHandle));
|
||||
}
|
||||
|
||||
public Color GetButtonColor()
|
||||
{
|
||||
return BitwiseUtils.IntToRgb(JslGetControllerButtonColour(joyshockHandle));
|
||||
}
|
||||
|
||||
public Color GetLeftGripColor()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
{
|
||||
return BitwiseUtils.IntToRgb(splitType == SplitLeft ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
||||
}
|
||||
return BitwiseUtils.IntToRgb(JslGetControllerLeftGripColour(joyshockHandle));
|
||||
}
|
||||
|
||||
public Color GetRightGripColor()
|
||||
{
|
||||
if (otherHalf != null)
|
||||
{
|
||||
return BitwiseUtils.IntToRgb(splitType == SplitRight ? JslGetControllerColour(joyshockHandle) : JslGetControllerColour(GetOtherHalf().GetHandle()));
|
||||
}
|
||||
return BitwiseUtils.IntToRgb(JslGetControllerRightGripColour(joyshockHandle));
|
||||
}
|
||||
|
||||
public Color GetLightbarColour()
|
||||
{
|
||||
return BitwiseUtils.IntToRgb(lightbarColour);
|
||||
}
|
||||
|
||||
public void SetLightbarColour(Color color)
|
||||
{
|
||||
lightbarColour = BitwiseUtils.RgbToInt(color);
|
||||
JslSetLightColour(joyshockHandle, lightbarColour);
|
||||
}
|
||||
|
||||
public static int GetLightbarColourForPlayer(int playerNum = 0)
|
||||
{
|
||||
if (playerNum < 0)
|
||||
{
|
||||
return dsPlayerColours[dsPlayerColours.Length - 1];
|
||||
}
|
||||
|
||||
playerNum = Math.Min(playerNum, dsPlayerColours.Length - 1);
|
||||
return dsPlayerColours[playerNum];
|
||||
}
|
||||
|
||||
public int GetHandle()
|
||||
{
|
||||
return joyshockHandle;
|
||||
|
|
|
@ -64,31 +64,31 @@ namespace HeavenStudio.InputSystem
|
|||
public enum InputFeatures
|
||||
{
|
||||
//readable properties
|
||||
Readable_ShellColour,
|
||||
Readable_ButtonColour,
|
||||
Readable_LeftGripColour,
|
||||
Readable_RightGripColour,
|
||||
Readable_AnalogueTriggers,
|
||||
Readable_StringInput,
|
||||
Readable_Pointer,
|
||||
Readable_MotionSensor,
|
||||
Readable_ShellColour = 1 << 0,
|
||||
Readable_ButtonColour = 1 << 1,
|
||||
Readable_LeftGripColour = 1 << 2,
|
||||
Readable_RightGripColour = 1 << 3,
|
||||
Readable_AnalogueTriggers = 1 << 4,
|
||||
Readable_StringInput = 1 << 5,
|
||||
Readable_Pointer = 1 << 6,
|
||||
Readable_MotionSensor = 1 << 7,
|
||||
|
||||
//writable properties
|
||||
Writable_PlayerLED,
|
||||
Writable_LightBar,
|
||||
Writable_Chroma,
|
||||
Writable_Speaker,
|
||||
Writable_PlayerLED = 1 << 8,
|
||||
Writable_LightBar = 1 << 9,
|
||||
Writable_Chroma = 1 << 10,
|
||||
Writable_Speaker = 1 << 11,
|
||||
|
||||
//other / "special" properties
|
||||
Extra_SplitControllerLeft,
|
||||
Extra_SplitControllerRight,
|
||||
Extra_Rumble,
|
||||
Extra_HDRumble,
|
||||
Extra_SplitControllerLeft = 1 << 12,
|
||||
Extra_SplitControllerRight = 1 << 13,
|
||||
Extra_Rumble = 1 << 14,
|
||||
Extra_HDRumble = 1 << 15,
|
||||
|
||||
//supported control styles
|
||||
Style_Pad,
|
||||
Style_Baton,
|
||||
Style_Touch
|
||||
Style_Pad = 1 << 16,
|
||||
Style_Baton = 1 << 17,
|
||||
Style_Touch = 1 << 18,
|
||||
};
|
||||
|
||||
//Following enums are specific to Heaven Studio, can be removed in other applications
|
||||
|
|
|
@ -40,36 +40,8 @@ namespace HeavenStudio.Editor
|
|||
{
|
||||
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();
|
||||
}
|
||||
|
||||
AssignController(newController, lastController);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -79,38 +51,11 @@ namespace HeavenStudio.Editor
|
|||
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);
|
||||
AssignController(controller, lastController);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +72,7 @@ namespace HeavenStudio.Editor
|
|||
isPairSearching = false;
|
||||
pairSearchLabel.SetActive(false);
|
||||
currentControllerLabel.text = "Current Controller: " + controller.GetDeviceName();
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Successful!";
|
||||
pairingLabel.text = "Joy-Con Pair Selected\nPairing Successful!";
|
||||
ShowControllerIcon(controller);
|
||||
|
||||
StartCoroutine(SelectionVibrate(con));
|
||||
|
@ -137,6 +82,46 @@ namespace HeavenStudio.Editor
|
|||
}
|
||||
}
|
||||
|
||||
void AssignController(InputController newController, InputController lastController)
|
||||
{
|
||||
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)) {
|
||||
pairingLabel.text = "Joy-Con (L) Selected\nPress A to pair with Joy-Con (R)";
|
||||
|
||||
pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft);
|
||||
pairSearchItem.SetActive(true);
|
||||
StartPairSearch();
|
||||
}
|
||||
else if (features.HasFlag(InputController.InputFeatures.Extra_SplitControllerRight)) {
|
||||
pairingLabel.text = "Joy-Con (R) Selected\nPress A to pair with Joy-Con (L)";
|
||||
|
||||
pairSelectLR = !features.HasFlag(InputController.InputFeatures.Extra_SplitControllerLeft);
|
||||
pairSearchItem.SetActive(true);
|
||||
StartPairSearch();
|
||||
}
|
||||
else {
|
||||
CancelPairSearch();
|
||||
pairSearchItem.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAutoSearch() {
|
||||
if (!isPairSearching)
|
||||
{
|
||||
|
@ -149,7 +134,6 @@ namespace HeavenStudio.Editor
|
|||
if (!isAutoSearching) {
|
||||
pairSearchLabel.SetActive(true);
|
||||
isPairSearching = true;
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing Second Joy-Con...";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +141,7 @@ namespace HeavenStudio.Editor
|
|||
if (isPairSearching) {
|
||||
pairSearchLabel.SetActive(false);
|
||||
isPairSearching = false;
|
||||
pairingLabel.text = "Joy-Con (L / R) Selected\nPairing was cancelled.";
|
||||
pairingLabel.text = "Joy-Con Selected\nPairing was cancelled.";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,6 +163,7 @@ namespace HeavenStudio.Editor
|
|||
optionData.text = vals[i].GetDeviceName();
|
||||
dropDownData.Add(optionData);
|
||||
}
|
||||
controllersDropdown.ClearOptions();
|
||||
controllersDropdown.AddOptions(dropDownData);
|
||||
controllersDropdown.value = 0;
|
||||
}
|
||||
|
@ -207,55 +192,56 @@ namespace HeavenStudio.Editor
|
|||
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("_BodyColor", joy.GetBodyColor());
|
||||
controllerMat.SetColor("_BtnColor", joy.GetButtonColor());
|
||||
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())));
|
||||
controllerMat.SetColor("_BodyColor", joySide == SplitRight ? joy.GetButtonColor() : joy.GetOtherHalf().GetButtonColor());
|
||||
controllerMat.SetColor("_BtnColor", joySide == SplitLeft ? joy.GetButtonColor() : joy.GetOtherHalf().GetButtonColor());
|
||||
controllerMat.SetColor("_LGripColor", joy.GetLeftGripColor());
|
||||
controllerMat.SetColor("_RGripColor", joy.GetRightGripColor());
|
||||
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())));
|
||||
controllerMat.SetColor("_BodyColor", joy.GetBodyColor());
|
||||
controllerMat.SetColor("_BtnColor", joy.GetButtonColor());
|
||||
controllerMat.SetColor("_LGripColor", joy.GetLeftGripColor());
|
||||
controllerMat.SetColor("_RGripColor", joy.GetRightGripColor());
|
||||
break;
|
||||
//TODO: dualshock 4 and dualsense lightbar colour support
|
||||
case "DualShock 4":
|
||||
joy = (InputJoyshock) controller;
|
||||
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);
|
||||
controllerMat.SetColor("_LGripColor", joy.GetLightbarColour());
|
||||
controllerMat.SetColor("_RGripColor", joy.GetLightbarColour());
|
||||
break;
|
||||
case "DualSense":
|
||||
joy = (InputJoyshock) controller;
|
||||
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);
|
||||
controllerMat.SetColor("_LGripColor", joy.GetLightbarColour());
|
||||
controllerMat.SetColor("_RGripColor", joy.GetLightbarColour());
|
||||
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));
|
||||
controllerMat.SetColor("_BodyColor", Color.white);
|
||||
controllerMat.SetColor("_BtnColor", Color.white);
|
||||
controllerMat.SetColor("_LGripColor", Color.white);
|
||||
controllerMat.SetColor("_RGripColor", Color.white);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator SelectionVibrate(InputJoyshock controller)
|
||||
{
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.4f, 0.3f, 80f, 160f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.4f, 0.4f, 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);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0.5f, 0.5f, 160f, 320f);
|
||||
yield return new WaitForSeconds(0.25f);
|
||||
JslSetRumbleFrequency(controller.GetHandle(), 0f, 0f, 0f, 0f);
|
||||
}
|
||||
|
|
|
@ -59,5 +59,13 @@ namespace HeavenStudio.Util
|
|||
var blue = ( value >> 0 ) & 255;
|
||||
return new Color(red/255f, green/255f, blue/255f);
|
||||
}
|
||||
|
||||
public static int RgbToInt(Color color)
|
||||
{
|
||||
var red = (int)(color.r * 255);
|
||||
var green = (int)(color.g * 255);
|
||||
var blue = (int)(color.b * 255);
|
||||
return (red << 16) | (green << 8) | blue;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue