mirror of
https://github.com/DerTyp7/defrain-shooter-unity.git
synced 2025-10-29 12:52:07 +01:00
SearchForNext Overhaul
This commit is contained in:
@@ -38,7 +38,7 @@ RenderSettings:
|
|||||||
m_ReflectionIntensity: 1
|
m_ReflectionIntensity: 1
|
||||||
m_CustomReflection: {fileID: 0}
|
m_CustomReflection: {fileID: 0}
|
||||||
m_Sun: {fileID: 705507994}
|
m_Sun: {fileID: 705507994}
|
||||||
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
|
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
|
||||||
m_UseRadianceAmbientProbe: 0
|
m_UseRadianceAmbientProbe: 0
|
||||||
--- !u!157 &3
|
--- !u!157 &3
|
||||||
LightmapSettings:
|
LightmapSettings:
|
||||||
@@ -2375,7 +2375,7 @@ PrefabInstance:
|
|||||||
- target: {fileID: 5784756223373504909, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
- target: {fileID: 5784756223373504909, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
||||||
propertyPath: playerPrefab
|
propertyPath: playerPrefab
|
||||||
value:
|
value:
|
||||||
objectReference: {fileID: 6272346181302961293, guid: 2935eead9a075fd489d6a6dc273a5999, type: 3}
|
objectReference: {fileID: 6272346181302961293, guid: a14d876ac00bdf6498e30b3e58b68fdf, type: 3}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 5cd2e2b44dc49ae44b48fc76a1e09712, type: 3}
|
||||||
--- !u!1001 &3454029965885532949
|
--- !u!1001 &3454029965885532949
|
||||||
|
|||||||
@@ -124,8 +124,6 @@ public class PlayerController : NetworkBehaviour
|
|||||||
|
|
||||||
if(isGrounded && velocity.y < -fallDamageSpeed)
|
if(isGrounded && velocity.y < -fallDamageSpeed)
|
||||||
{
|
{
|
||||||
Debug.Log(velocity.y);
|
|
||||||
Debug.Log("Fall Damage");
|
|
||||||
CmdFallDamage((int)Mathf.Abs(velocity.y));
|
CmdFallDamage((int)Mathf.Abs(velocity.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,13 +27,15 @@ public class WeaponManager : NetworkBehaviour
|
|||||||
if (isLocalPlayer) {
|
if (isLocalPlayer) {
|
||||||
if (Input.GetAxis("Mouse ScrollWheel") > 0f) { // Scroll up
|
if (Input.GetAxis("Mouse ScrollWheel") > 0f) { // Scroll up
|
||||||
lastWeaponIndex = currentWeaponIndex;
|
lastWeaponIndex = currentWeaponIndex;
|
||||||
|
activeWeapons[currentWeaponIndex].SetActive(false);
|
||||||
switchWeapon(-1);
|
switchWeapon(-1);
|
||||||
}
|
}
|
||||||
else if (Input.GetAxis("Mouse ScrollWheel") < 0f) { // Scroll down
|
else if (Input.GetAxis("Mouse ScrollWheel") < 0f) { // Scroll down
|
||||||
lastWeaponIndex = currentWeaponIndex;
|
lastWeaponIndex = currentWeaponIndex;
|
||||||
|
activeWeapons[currentWeaponIndex].SetActive(false);
|
||||||
switchWeapon(1);
|
switchWeapon(1);
|
||||||
}
|
}
|
||||||
|
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||||
if (Input.GetButtonDown("Interact")) { // e
|
if (Input.GetButtonDown("Interact")) { // e
|
||||||
PickupWeapon();
|
PickupWeapon();
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ public class WeaponManager : NetworkBehaviour
|
|||||||
if (activeWeapons[currentWeaponIndex] != null) {
|
if (activeWeapons[currentWeaponIndex] != null) {
|
||||||
dropWeapon(); // Throws weapon away
|
dropWeapon(); // Throws weapon away
|
||||||
switchWeapon(1);
|
switchWeapon(1);
|
||||||
|
activeWeapons[currentWeaponIndex].SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,21 +51,46 @@ public class WeaponManager : NetworkBehaviour
|
|||||||
|
|
||||||
|
|
||||||
private bool switchWeapon(int direction) {
|
private bool switchWeapon(int direction) {
|
||||||
|
|
||||||
int nextActive = searchForNext(activeWeapons, lastWeaponIndex, direction);
|
int nextActive = searchForNext(activeWeapons, lastWeaponIndex, direction);
|
||||||
if (nextActive != -1) { // -1 no next found
|
|
||||||
currentWeaponIndex = nextActive;
|
currentWeaponIndex = nextActive;
|
||||||
activeWeapons[currentWeaponIndex].SetActive(true);
|
|
||||||
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
|
procedualAnimationController.OnSwitchWeapon(activeWeapons[currentWeaponIndex]);
|
||||||
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
|
shoot.setWeapon(activeWeapons[currentWeaponIndex]);
|
||||||
Weapon weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
|
Weapon weaponData = activeWeapons[currentWeaponIndex].GetComponent<Weapon>();
|
||||||
procedualAnimationController.GunRightHandREF = weaponData.GunRightREF;
|
procedualAnimationController.GunRightHandREF = weaponData.GunRightREF;
|
||||||
procedualAnimationController.GunLeftHandREF = weaponData.GunLeftREF;
|
procedualAnimationController.GunLeftHandREF = weaponData.GunLeftREF;
|
||||||
// play weapon switch animation
|
// play weapon switch animation
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private int searchForNext(List<GameObject> l, int lastActive = 0, int direction = 1) {
|
|
||||||
|
private int searchForNext(List<GameObject> l, int lastActive = 0, int direction = 1)
|
||||||
|
{
|
||||||
|
int current = lastActive + direction;
|
||||||
|
|
||||||
|
for (int trys = 0; trys < l.Count; trys++)
|
||||||
|
{
|
||||||
|
//Check if you are at the start or end of the list and loop around accordingly
|
||||||
|
if (current < 0) current = l.Count - 1;
|
||||||
|
else if (current >= l.Count) current = 0;
|
||||||
|
|
||||||
|
//Check if in the current position is a gun or not
|
||||||
|
if (l[current] != null)
|
||||||
|
{
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
//if there is no gun go to the next
|
||||||
|
current = current + direction;
|
||||||
|
}
|
||||||
|
//If no next gun can be found return the index of the gun that was already selected
|
||||||
|
return lastActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private int searchForNextOld(List<GameObject> l, int lastActive = 0, int direction = 1) {
|
||||||
int size = l.Count;
|
int size = l.Count;
|
||||||
bool condition = true;
|
bool condition = true;
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
m_EditorVersion: 2021.2.0f1
|
m_EditorVersion: 2021.2.3f1
|
||||||
m_EditorVersionWithRevision: 2021.2.0f1 (4bf1ec4b23c9)
|
m_EditorVersionWithRevision: 2021.2.3f1 (32358a8527b4)
|
||||||
|
|||||||
Reference in New Issue
Block a user