feat: tackle response differentiation, announcement queue
This commit is contained in:
parent
b8ce591b70
commit
a720ce0e68
@ -47,7 +47,7 @@ SphereCollider:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 0
|
m_Bits: 0
|
||||||
m_LayerOverridePriority: 0
|
m_LayerOverridePriority: 0
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 1
|
||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
@ -302,8 +302,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
cameraOperator: {fileID: 0}
|
|
||||||
playerId: 2
|
playerId: 2
|
||||||
|
playerName: Blue Bilboa
|
||||||
|
cameraOperator: {fileID: 0}
|
||||||
thrustAcceleration: 1500
|
thrustAcceleration: 1500
|
||||||
steerVelocity: 300
|
steerVelocity: 300
|
||||||
normalMaxVelocity: 25
|
normalMaxVelocity: 25
|
||||||
@ -318,9 +319,11 @@ MonoBehaviour:
|
|||||||
boostMagnitude: 2.5
|
boostMagnitude: 2.5
|
||||||
outsideBoostRate: 0
|
outsideBoostRate: 0
|
||||||
boostAntiGravityFactor: 0.8
|
boostAntiGravityFactor: 0.8
|
||||||
tackleStunFactor: 0.1
|
stunLooseControlFactor: 0.1
|
||||||
tackleStunTime: 0.6
|
tackleCriticalStunTime: 0.6
|
||||||
tacklePowerFactor: 30
|
tackleBodyStunTime: 0.3
|
||||||
|
criticalTacklePowerFactor: 234
|
||||||
|
normalTacklePowerFactor: 10
|
||||||
boostUI: {fileID: 4200181511080825266}
|
boostUI: {fileID: 4200181511080825266}
|
||||||
playerInput: {fileID: 0}
|
playerInput: {fileID: 0}
|
||||||
instanceID: 0
|
instanceID: 0
|
||||||
@ -417,6 +420,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 6166152332587307364}
|
- component: {fileID: 6166152332587307364}
|
||||||
- component: {fileID: 1551560316097652998}
|
- component: {fileID: 1551560316097652998}
|
||||||
|
- component: {fileID: 3630649017457658103}
|
||||||
m_Layer: 7
|
m_Layer: 7
|
||||||
m_Name: BodyArea
|
m_Name: BodyArea
|
||||||
m_TagString: Vulnerable
|
m_TagString: Vulnerable
|
||||||
@ -459,9 +463,25 @@ CapsuleCollider:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 0.57511306
|
m_Radius: 0.57511306
|
||||||
m_Height: 2.3651605
|
m_Height: 2
|
||||||
m_Direction: 1
|
m_Direction: 1
|
||||||
m_Center: {x: 0, y: -0.2, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &3630649017457658103
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7665455622387539610}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3c7fe3de71657ad45a715b48cce00faa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
tackleKind: 1
|
||||||
|
TackleResponse:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
--- !u!1 &8319233940171307812
|
--- !u!1 &8319233940171307812
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -555,6 +575,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 5758221365909025383}
|
- component: {fileID: 5758221365909025383}
|
||||||
- component: {fileID: 7759512979313569539}
|
- component: {fileID: 7759512979313569539}
|
||||||
|
- component: {fileID: 1265162896801572869}
|
||||||
m_Layer: 7
|
m_Layer: 7
|
||||||
m_Name: VulnerableArea
|
m_Name: VulnerableArea
|
||||||
m_TagString: Vulnerable
|
m_TagString: Vulnerable
|
||||||
@ -596,10 +617,26 @@ CapsuleCollider:
|
|||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 0.56869245
|
m_Radius: 0.24395981
|
||||||
m_Height: 1.1373849
|
m_Height: 1.101471
|
||||||
m_Direction: 1
|
m_Direction: 0
|
||||||
m_Center: {x: -0.0013287067, y: 0.115499854, z: 0}
|
m_Center: {x: 0.012868404, y: -0.077233285, z: 0}
|
||||||
|
--- !u!114 &1265162896801572869
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 9173867352853251920}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3c7fe3de71657ad45a715b48cce00faa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
tackleKind: 0
|
||||||
|
TackleResponse:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
--- !u!1001 &1930064064740072725
|
--- !u!1001 &1930064064740072725
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -248,8 +248,9 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
m_Script: {fileID: 11500000, guid: 2b6244fd2a6ceee4ab8504fadf75ae20, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
cameraOperator: {fileID: 0}
|
|
||||||
playerId: 1
|
playerId: 1
|
||||||
|
playerName: Gray Gustav
|
||||||
|
cameraOperator: {fileID: 0}
|
||||||
thrustAcceleration: 1500
|
thrustAcceleration: 1500
|
||||||
steerVelocity: 300
|
steerVelocity: 300
|
||||||
normalMaxVelocity: 25
|
normalMaxVelocity: 25
|
||||||
@ -264,9 +265,11 @@ MonoBehaviour:
|
|||||||
boostMagnitude: 2.5
|
boostMagnitude: 2.5
|
||||||
outsideBoostRate: 0
|
outsideBoostRate: 0
|
||||||
boostAntiGravityFactor: 0.8
|
boostAntiGravityFactor: 0.8
|
||||||
tackleStunFactor: 0.1
|
stunLooseControlFactor: 0.1
|
||||||
tackleStunTime: 0.6
|
tackleCriticalStunTime: 0.6
|
||||||
tacklePowerFactor: 30
|
tackleBodyStunTime: 0.3
|
||||||
|
criticalTacklePowerFactor: 183
|
||||||
|
normalTacklePowerFactor: 10
|
||||||
boostUI: {fileID: 3576024133074538910}
|
boostUI: {fileID: 3576024133074538910}
|
||||||
playerInput: {fileID: 0}
|
playerInput: {fileID: 0}
|
||||||
instanceID: 0
|
instanceID: 0
|
||||||
@ -317,11 +320,11 @@ SphereCollider:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Bits: 0
|
m_Bits: 0
|
||||||
m_LayerOverridePriority: 0
|
m_LayerOverridePriority: 0
|
||||||
m_IsTrigger: 0
|
m_IsTrigger: 1
|
||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_Radius: 0.4807241
|
m_Radius: 0.5
|
||||||
m_Center: {x: 0, y: -0.15, z: 0}
|
m_Center: {x: 0, y: -0.15, z: 0}
|
||||||
--- !u!1 &3792860668480113901
|
--- !u!1 &3792860668480113901
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -416,6 +419,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 3900807414520724371}
|
- component: {fileID: 3900807414520724371}
|
||||||
- component: {fileID: 2877831592369095334}
|
- component: {fileID: 2877831592369095334}
|
||||||
|
- component: {fileID: 6578531240251070333}
|
||||||
m_Layer: 7
|
m_Layer: 7
|
||||||
m_Name: VulnerableArea
|
m_Name: VulnerableArea
|
||||||
m_TagString: Vulnerable
|
m_TagString: Vulnerable
|
||||||
@ -457,10 +461,26 @@ CapsuleCollider:
|
|||||||
m_ProvidesContacts: 0
|
m_ProvidesContacts: 0
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 0.38593757
|
m_Radius: 0.24395981
|
||||||
m_Height: 1.3338675
|
m_Height: 1.101471
|
||||||
m_Direction: 0
|
m_Direction: 0
|
||||||
m_Center: {x: -0.000009298325, y: -0.025820732, z: 0}
|
m_Center: {x: 0.012868404, y: -0.077233285, z: 0}
|
||||||
|
--- !u!114 &6578531240251070333
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 4131857668379936813}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3c7fe3de71657ad45a715b48cce00faa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
tackleKind: 0
|
||||||
|
TackleResponse:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
--- !u!1 &7085924197508447212
|
--- !u!1 &7085924197508447212
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -471,6 +491,7 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 2323253733787261421}
|
- component: {fileID: 2323253733787261421}
|
||||||
- component: {fileID: 7345168250516523601}
|
- component: {fileID: 7345168250516523601}
|
||||||
|
- component: {fileID: 1618336731388176427}
|
||||||
m_Layer: 7
|
m_Layer: 7
|
||||||
m_Name: BodyArea
|
m_Name: BodyArea
|
||||||
m_TagString: Vulnerable
|
m_TagString: Vulnerable
|
||||||
@ -513,9 +534,25 @@ CapsuleCollider:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Radius: 0.57511306
|
m_Radius: 0.57511306
|
||||||
m_Height: 2.3651605
|
m_Height: 2
|
||||||
m_Direction: 1
|
m_Direction: 1
|
||||||
m_Center: {x: 0, y: -0.2, z: 0}
|
m_Center: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &1618336731388176427
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7085924197508447212}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 3c7fe3de71657ad45a715b48cce00faa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
tackleKind: 1
|
||||||
|
TackleResponse:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
--- !u!1001 &8054534206256546014
|
--- !u!1001 &8054534206256546014
|
||||||
PrefabInstance:
|
PrefabInstance:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -365,6 +365,14 @@ PrefabInstance:
|
|||||||
propertyPath: cameraOperator
|
propertyPath: cameraOperator
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 963194229}
|
objectReference: {fileID: 963194229}
|
||||||
|
- target: {fileID: 8932415214367391550, guid: 105162f72bf50c84aaf92b1ca494ed3b, type: 3}
|
||||||
|
propertyPath: normalTacklePowerFactor
|
||||||
|
value: 10
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8932415214367391550, guid: 105162f72bf50c84aaf92b1ca494ed3b, type: 3}
|
||||||
|
propertyPath: criticalTacklePowerFactor
|
||||||
|
value: 25
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
@ -454,8 +462,8 @@ MonoBehaviour:
|
|||||||
m_faceColor:
|
m_faceColor:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4294967295
|
rgba: 4294967295
|
||||||
m_fontSize: 32
|
m_fontSize: 28
|
||||||
m_fontSizeBase: 32
|
m_fontSizeBase: 28
|
||||||
m_fontWeight: 400
|
m_fontWeight: 400
|
||||||
m_enableAutoSizing: 0
|
m_enableAutoSizing: 0
|
||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 18
|
||||||
@ -757,6 +765,14 @@ PrefabInstance:
|
|||||||
propertyPath: cameraOperator
|
propertyPath: cameraOperator
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 963194229}
|
objectReference: {fileID: 963194229}
|
||||||
|
- target: {fileID: 7382138887082377466, guid: d247a5257c4a6774399dc902f311b653, type: 3}
|
||||||
|
propertyPath: normalTacklePowerFactor
|
||||||
|
value: 10
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 7382138887082377466, guid: d247a5257c4a6774399dc902f311b653, type: 3}
|
||||||
|
propertyPath: criticalTacklePowerFactor
|
||||||
|
value: 25
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
m_AddedGameObjects: []
|
m_AddedGameObjects: []
|
||||||
|
|||||||
@ -9,21 +9,34 @@ public class Announcments : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[SerializeField] TextMeshProUGUI announcementText;
|
[SerializeField] TextMeshProUGUI announcementText;
|
||||||
|
|
||||||
|
public Queue<Tuple<string, float>> announcementQueue = new Queue<Tuple<string, float>>();
|
||||||
|
private bool workingOnQueue = false;
|
||||||
private float remainingTime;
|
private float remainingTime;
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
if (!workingOnQueue && announcementQueue.Count != 0)
|
||||||
|
{
|
||||||
|
workingOnQueue = true;
|
||||||
|
Tuple<string, float> announcement = announcementQueue.Dequeue();
|
||||||
|
AnnounceText(announcement.Item1, announcement.Item2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (remainingTime > 0)
|
if (remainingTime > 0)
|
||||||
{
|
{
|
||||||
remainingTime -= Time.deltaTime;
|
remainingTime -= Time.deltaTime;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
workingOnQueue = false;
|
||||||
announcementText.enabled = false;
|
announcementText.enabled = false;
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
|
if (announcementQueue.Count == 0)
|
||||||
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AnnounceText(string text, float time)
|
public void AnnounceText(string text, float time)
|
||||||
{
|
{
|
||||||
@ -33,15 +46,23 @@ public class Announcments : MonoBehaviour
|
|||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void QueueAnnounceText(string text, float time)
|
||||||
|
{
|
||||||
|
announcementQueue.Enqueue(new Tuple<string, float>(text, time));
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
public void AnnounceText(string text)
|
public void AnnounceText(string text)
|
||||||
{
|
{
|
||||||
announcementText.text = text;
|
announcementText.text = text;
|
||||||
announcementText.enabled = true;
|
announcementText.enabled = true;
|
||||||
|
announcementQueue.Clear();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopAnnouncement()
|
public void StopAnnouncement()
|
||||||
{
|
{
|
||||||
|
announcementQueue.Clear();
|
||||||
announcementText.text = String.Empty;
|
announcementText.text = String.Empty;
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
announcementText.enabled = false;
|
announcementText.enabled = false;
|
||||||
|
|||||||
@ -75,7 +75,7 @@ public class GameManager : MonoBehaviour
|
|||||||
controlSchemeDetector = new ControlSchemeDetection();
|
controlSchemeDetector = new ControlSchemeDetection();
|
||||||
controlSchemeDetector.ControlSchemeDetected += DetectPlayerControls;
|
controlSchemeDetector.ControlSchemeDetected += DetectPlayerControls;
|
||||||
controlSchemeDetector.EnableDetection();
|
controlSchemeDetector.EnableDetection();
|
||||||
announcements.AnnounceText("You both press a key \n on your control scheme of choice \n to start the match");
|
announcements.AnnounceText("Choose your control schemes \n Each player press a button \n to start the match \n (see description for controls)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartMatch()
|
void StartMatch()
|
||||||
@ -87,7 +87,7 @@ public class GameManager : MonoBehaviour
|
|||||||
if (announcements != null)
|
if (announcements != null)
|
||||||
{
|
{
|
||||||
announcements.StopAnnouncement();
|
announcements.StopAnnouncement();
|
||||||
announcements.AnnounceText("Match Start", 1.6f);
|
announcements.QueueAnnounceText("Match Start", 1.6f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,10 +95,11 @@ public class GameManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
if (!go.CompareTag("Player") || currentState == GameState.End)
|
if (!go.CompareTag("Player") || currentState == GameState.End)
|
||||||
return;
|
return;
|
||||||
|
PlayerController pc = go.GetComponent<PlayerController>();
|
||||||
currentState = GameState.End;
|
currentState = GameState.End;
|
||||||
zone.onPlayZoneExited -= CheckLosingCondition;
|
zone.onPlayZoneExited -= CheckLosingCondition;
|
||||||
|
announcements.AnnounceText(pc.playerName + " has lost the match", 2f);
|
||||||
Destroy(go);
|
Destroy(go);
|
||||||
announcements.AnnounceText(go.name + " has lost the match", 2f);
|
|
||||||
restartMatchTime = 2.2f;
|
restartMatchTime = 2.2f;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ using static AffectingForcesManager;
|
|||||||
public class PlayerController : MonoBehaviour
|
public class PlayerController : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] public int playerId = 1;
|
[SerializeField] public int playerId = 1;
|
||||||
|
[SerializeField] public string playerName = "gray";
|
||||||
// Private variables
|
// Private variables
|
||||||
[SerializeField] private CameraOperator cameraOperator;
|
[SerializeField] private CameraOperator cameraOperator;
|
||||||
[SerializeField] private float thrustAcceleration = 400;
|
[SerializeField] private float thrustAcceleration = 400;
|
||||||
@ -24,9 +25,11 @@ public class PlayerController : MonoBehaviour
|
|||||||
[SerializeField] private float boostMagnitude = 1.5f;
|
[SerializeField] private float boostMagnitude = 1.5f;
|
||||||
[SerializeField] private float outsideBoostRate = 0.5f;
|
[SerializeField] private float outsideBoostRate = 0.5f;
|
||||||
[SerializeField, Range(0, 1)] private float boostAntiGravityFactor = 0.2f;
|
[SerializeField, Range(0, 1)] private float boostAntiGravityFactor = 0.2f;
|
||||||
[SerializeField] private float tackleStunFactor = 0.1f;
|
[SerializeField] private float stunLooseControlFactor = 0.1f;
|
||||||
[SerializeField] private float tackleStunTime = 0.6f;
|
[SerializeField] private float tackleCriticalStunTime = 0.6f;
|
||||||
[SerializeField, Range(0, 1000)] private float tacklePowerFactor = 10f;
|
[SerializeField] private float tackleBodyStunTime = 0.3f;
|
||||||
|
[SerializeField, Range(0, 300)] private float criticalTacklePowerFactor = 10f;
|
||||||
|
[SerializeField, Range(0, 300)] private float normalTacklePowerFactor = 10f;
|
||||||
[SerializeField] private BoostCapacityUI boostUI;
|
[SerializeField] private BoostCapacityUI boostUI;
|
||||||
private AffectingForcesManager forceManager;
|
private AffectingForcesManager forceManager;
|
||||||
public PlayerInput playerInput;
|
public PlayerInput playerInput;
|
||||||
@ -39,6 +42,8 @@ public class PlayerController : MonoBehaviour
|
|||||||
// Saves the current input for steering
|
// Saves the current input for steering
|
||||||
private float currentSteerInput = 0;
|
private float currentSteerInput = 0;
|
||||||
private bool canBoost = true;
|
private bool canBoost = true;
|
||||||
|
private TackleDetection[] tackleDetectors;
|
||||||
|
private bool isCriticalTackle = false;
|
||||||
private bool isTackled = false;
|
private bool isTackled = false;
|
||||||
private float tackledTime = 0f;
|
private float tackledTime = 0f;
|
||||||
// Current Zone the player occupies
|
// Current Zone the player occupies
|
||||||
@ -63,6 +68,20 @@ public class PlayerController : MonoBehaviour
|
|||||||
boostUI.SetMinBoostRatio(minBoostCapacity / maxBoostCapacity);
|
boostUI.SetMinBoostRatio(minBoostCapacity / maxBoostCapacity);
|
||||||
GameManager.GM.RegisterPlayer(this);
|
GameManager.GM.RegisterPlayer(this);
|
||||||
cameraOperator.AddPlayer(gameObject);
|
cameraOperator.AddPlayer(gameObject);
|
||||||
|
|
||||||
|
tackleDetectors = GetComponentsInChildren<TackleDetection>();
|
||||||
|
foreach (TackleDetection td in tackleDetectors)
|
||||||
|
{
|
||||||
|
td.TackleResponse.AddListener(StartTackleResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnDestroy()
|
||||||
|
{
|
||||||
|
foreach (TackleDetection td in tackleDetectors)
|
||||||
|
{
|
||||||
|
td.TackleResponse.RemoveAllListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
@ -79,7 +98,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
UpdateMovement();
|
UpdateMovement();
|
||||||
// TODO Always full thrust when boosting?
|
// TODO Always full thrust when boosting?
|
||||||
BoostStateUpdate(Time.deltaTime);
|
BoostStateUpdate(Time.deltaTime);
|
||||||
UpdateTackleResponse();
|
UpdateTackleResponse(isCriticalTackle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMovement()
|
void UpdateMovement()
|
||||||
@ -93,7 +112,7 @@ public class PlayerController : MonoBehaviour
|
|||||||
currentGravity = forceManager.GetGravityForInstance(instanceID)(transform.position);
|
currentGravity = forceManager.GetGravityForInstance(instanceID)(transform.position);
|
||||||
body.AddForce(currentGravity, ForceMode.Acceleration);
|
body.AddForce(currentGravity, ForceMode.Acceleration);
|
||||||
|
|
||||||
float tackleFactor = isTackled ? tackleStunFactor : 1f;
|
float tackleFactor = isCriticalTackle ? stunLooseControlFactor : 1f;
|
||||||
|
|
||||||
Vector3 acceleration = thrustAcceleration * currentThrustInput * Time.deltaTime
|
Vector3 acceleration = thrustAcceleration * currentThrustInput * Time.deltaTime
|
||||||
* Vector3.up * tackleFactor;
|
* Vector3.up * tackleFactor;
|
||||||
@ -102,15 +121,18 @@ public class PlayerController : MonoBehaviour
|
|||||||
|
|
||||||
Vector3 boostedAcceleration = BoostAcceleration(acceleration, currentGravity);
|
Vector3 boostedAcceleration = BoostAcceleration(acceleration, currentGravity);
|
||||||
|
|
||||||
if (!isTackled)
|
if (!isCriticalTackle)
|
||||||
{
|
{
|
||||||
// Add drag
|
// Add drag
|
||||||
Vector3 dragDecceleration = DragDecceleration(currentVelocity, zone);
|
Vector3 dragDecceleration = DragDecceleration(currentVelocity, zone);
|
||||||
body.AddForce(dragDecceleration, ForceMode.Acceleration);
|
body.AddForce(dragDecceleration, ForceMode.Acceleration);
|
||||||
|
|
||||||
|
if (!isTackled)
|
||||||
|
{
|
||||||
// Add anti drift acceleration
|
// Add anti drift acceleration
|
||||||
Vector3 driftDampeningAcceleration = DriftDampeningAcceleration(currentVelocity, zone);
|
Vector3 driftDampeningAcceleration = DriftDampeningAcceleration(currentVelocity, zone);
|
||||||
body.AddForce(driftDampeningAcceleration, ForceMode.Acceleration);
|
body.AddForce(driftDampeningAcceleration, ForceMode.Acceleration);
|
||||||
|
}
|
||||||
|
|
||||||
if (currentVelocity.magnitude <= normalMaxVelocity || IsBoosting() || zone != Zone.NimbleZone)
|
if (currentVelocity.magnitude <= normalMaxVelocity || IsBoosting() || zone != Zone.NimbleZone)
|
||||||
{
|
{
|
||||||
@ -216,13 +238,14 @@ public class PlayerController : MonoBehaviour
|
|||||||
if (gotTackled)
|
if (gotTackled)
|
||||||
{
|
{
|
||||||
isTackled = true;
|
isTackled = true;
|
||||||
tackledTime = tackleStunTime;
|
tackledTime = isCriticalTackle ? tackleCriticalStunTime : tackleBodyStunTime;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tackledTime -= Time.deltaTime;
|
tackledTime -= Time.deltaTime;
|
||||||
if (tackledTime <= 0)
|
if (tackledTime <= 0)
|
||||||
{
|
{
|
||||||
isTackled = false;
|
isTackled = false;
|
||||||
|
isCriticalTackle = false;
|
||||||
tackledTime = 0;
|
tackledTime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,15 +275,20 @@ public class PlayerController : MonoBehaviour
|
|||||||
SceneManager.LoadScene(currentSceneName);
|
SceneManager.LoadScene(currentSceneName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void OnTriggerEnter(Collider collider)
|
void StartTackleResponse(TackleKind tackleKind, Collider collider)
|
||||||
{
|
{
|
||||||
if (collider.tag != "Spike")
|
float tacklePowerFactor = criticalTacklePowerFactor;
|
||||||
|
if (tackleKind == TackleKind.Critical)
|
||||||
{
|
{
|
||||||
return;
|
isCriticalTackle = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
isCriticalTackle = false;
|
||||||
|
tacklePowerFactor = normalTacklePowerFactor;
|
||||||
}
|
}
|
||||||
Vector3 colliderVelocity = collider.attachedRigidbody.velocity;
|
Vector3 colliderVelocity = collider.attachedRigidbody.velocity;
|
||||||
Vector3 tackleDirection = body.transform.position - collider.transform.position;
|
Vector3 tackleDirection = body.transform.position - collider.transform.position;
|
||||||
float colliderMass = collider.attachedRigidbody.mass;
|
|
||||||
body.AddForce(colliderVelocity.magnitude * tackleDirection * tacklePowerFactor, ForceMode.Acceleration);
|
body.AddForce(colliderVelocity.magnitude * tackleDirection * tacklePowerFactor, ForceMode.Acceleration);
|
||||||
UpdateTackleResponse(true);
|
UpdateTackleResponse(true);
|
||||||
}
|
}
|
||||||
|
|||||||
22
Assets/Scripts/TackleDetection.cs
Normal file
22
Assets/Scripts/TackleDetection.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor.AdaptivePerformance.Editor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Events;
|
||||||
|
|
||||||
|
public class TackleDetection : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private TackleKind tackleKind;
|
||||||
|
public UnityEvent<TackleKind, Collider> TackleResponse;
|
||||||
|
void OnTriggerEnter(Collider collider)
|
||||||
|
{
|
||||||
|
if (collider.tag != "Spike")
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TackleResponse.Invoke(tackleKind, collider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TackleKind { Critical, Normal }
|
||||||
11
Assets/Scripts/TackleDetection.cs.meta
Normal file
11
Assets/Scripts/TackleDetection.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3c7fe3de71657ad45a715b48cce00faa
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
Loading…
Reference in New Issue
Block a user