Skip to content

Commit

Permalink
Some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamieyello committed May 14, 2023
1 parent 6104f6b commit e6357a8
Show file tree
Hide file tree
Showing 11 changed files with 781 additions and 52 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ sysinfo.txt
# Builds
*.apk
*.unitypackage

# Added
/Logs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using UnityEngine;
using UnityEngine.InputSystem;

using static UnityEngine.InputSystem.InputAction;

public class InputEventsController : MonoBehaviour
{
[SerializeField] private BaseEventHandler EventHandler;
Expand All @@ -9,6 +12,8 @@ public class InputEventsController : MonoBehaviour

private InputBindingsController input = null;

void UpdateKeyPressedSprint(CallbackContext ctx) => inputConfigs.KeyPressedSprint = ctx.ReadValueAsButton();

private void OnEnable()
{
input.Character.Movement.performed += ctx => characterConfigs.MovementDirection = ctx.ReadValue<Vector2>();
Expand All @@ -34,7 +39,7 @@ private void OnEnable()
input.Enable();
}

private void OnDisbale()
private void OnDisable()
{
input.Character.Movement.performed -= ctx => characterConfigs.MovementDirection = ctx.ReadValue<Vector2>();
input.Character.Movement.canceled -= ctx => characterConfigs.MovementDirection = Vector2.zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@ public class BaseEventHandler : ScriptableObject

[SerializeField] private BaseCharacterControllerConfiguration[] IDs;


public BaseCharacterControllerConfiguration CurrentCharacterConfigs
{
get { return currentCharacterConfigs; }
get => currentCharacterConfigs;

set
{
if (currentCharacterConfigs != value)
{
currentCharacterConfigs = value;
onCharacterSwitchedEvent.Invoke(value);
}
if (currentCharacterConfigs == value) return;

currentCharacterConfigs = value;
onCharacterSwitchedEvent.Invoke(value);
}
}

public BaseInputControllerConfiguration CurrentInputConfigs
{
get { return currentInputConfigs; }
get => currentInputConfigs;

set
{
Expand All @@ -44,7 +42,7 @@ public BaseInputControllerConfiguration CurrentInputConfigs

public BaseGunControllerConfiguration CurrentWeaponConfigs
{
get { return currentWeaponConfigs; }
get => currentWeaponConfigs;

set
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,38 @@

public class ModuleAttack : MonoBehaviour
{
/*

public void GunShoot(GameObject bulletPrefab, Vector3 ShootPointPosition, Quaternion shootPointRotation, Vector3 gunOffsetPosition, float recoilCurrent, float gunShootAccuracy)
{
{
recoilCurrent = recoilCurrent / 50;

float accuracyOffset = recoilCurrent * ((100 - gunShootAccuracy) / 100);

float gunOffset = -gunOffsetPosition.x / 10;

float range = Random.Range(-accuracyOffset - gunOffset, accuracyOffset + gunOffset);

shootPointRotation = new Quaternion(shootPointRotation.x, shootPointRotation.y, shootPointRotation.z + range, shootPointRotation.w);

Instantiate(bulletPrefab, ShootPointPosition, shootPointRotation);
}*/
}

public void GunShootModified(GameObject bulletPrefab, Vector3 shootPointPosition, Transform characterT, Vector3 cursorR, float recoilCurrent, float gunShootAccuracy)
{
recoilCurrent = recoilCurrent / 50;
//public void GunShootModified(GameObject bulletPrefab, Vector3 shootPointPosition, Transform characterT, Vector3 cursorR, float recoilCurrent, float gunShootAccuracy)
//{
// recoilCurrent /= 50;

float accuracyOffset = recoilCurrent * ((100 - gunShootAccuracy) / 100);
// float accuracyOffset = recoilCurrent * ((100 - gunShootAccuracy) / 100);

float range = Random.Range(-accuracyOffset, accuracyOffset);

Vector3 bulletDirection = characterT.TransformDirection(cursorR.normalized);
// float range = Random.Range(-accuracyOffset, accuracyOffset);

Quaternion bulletRotation = Quaternion.LookRotation(bulletDirection);
// Vector3 bulletDirection = characterT.TransformDirection(cursorR.normalized);

Quaternion shootPointRotation = new Quaternion(bulletRotation.x, bulletRotation.y, bulletRotation.z + range, transform.rotation.w);
// Quaternion bulletRotation = Quaternion.LookRotation(bulletDirection);

Instantiate(bulletPrefab, shootPointPosition, shootPointRotation);
}
// Quaternion shootPointRotation = new Quaternion(bulletRotation.x, bulletRotation.y, bulletRotation.z + range, transform.rotation.w);

// Instantiate(bulletPrefab, shootPointPosition, shootPointRotation);
//}

public void MeleeAttack()
{
Expand Down
34 changes: 20 additions & 14 deletions Assets/C-Game/x05-Scripts/Environment/Weapon/WeaponController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class WeaponController : MonoBehaviour

private Collider2D collision;

public GunController Gun => gun;

private void Awake()
{
characterConfigs = EventHandler.CurrentCharacterConfigs;
Expand Down Expand Up @@ -99,10 +101,15 @@ private void Update()
onReload?.Invoke(currentGunConfigs.GunReloadTime);
}

_currentShootCooldownTime -= Time.fixedDeltaTime;
_currentShootCooldownTime -= Time.deltaTime;
}
}

public void FixedUpdate()
{

}

#region Event Listeners
private void OnCharacterValueChanged(BaseCharacterControllerConfiguration value)
{
Expand All @@ -115,28 +122,27 @@ private void OnInputValueChanged(BaseInputControllerConfiguration value)
}

private void HandleReloadEvent(float duration)
{
{
inputConfigs.SetBoolean("KeyPressedReload", false);
StartCoroutine(duration.SetCoroutineWait());
}

private void HandleShootEvent()
{
if (_currentShootCooldownTime <= 0.0f && gun.GunMagCurrentAmmo > 0.0f)
{
// NOTE : USELESS PIECE OF CODE, FOR NOW...
Vector3 rotation = transform.GetRotationFromToCursor();
{
if (_currentShootCooldownTime > 0.0f || gun.GunMagCurrentAmmo <= 0.0f) return;

// NOTE : USELESS PIECE OF CODE, FOR NOW...
Vector3 rotation = transform.GetRotationFromToCursor();

//moduleShoot.GunShoot(currentGunConfigs.GunBulletPrefab, gun.GunShootPoint.transform.position, gun.GunShootPoint.transform.rotation, currentGunConfigs.GunOffset, characterConfigs.RecoilCurrent, characterConfigs.GunShootAccuracy);
moduleShoot.GunShootModified(currentGunConfigs.GunBulletPrefab, gun.GunShootPoint.transform.position, this.transform, rotation, characterConfigs.RecoilCurrent, characterConfigs.GunShootAccuracy);
characterConfigs.RecoilCurrent = characterConfigs.RecoilCurrent < currentGunConfigs.RecoilMaximum ? characterConfigs.RecoilCurrent += currentGunConfigs.GunOnShootRecoilIncrease : characterConfigs.RecoilCurrent;
moduleShoot.GunShoot(currentGunConfigs.GunBulletPrefab, gun.GunShootPoint.transform.position, gun.GunShootPoint.transform.rotation, currentGunConfigs.GunOffset, characterConfigs.RecoilCurrent, characterConfigs.GunShootAccuracy);
//moduleShoot.GunShootModified(currentGunConfigs.GunBulletPrefab, gun.GunShootPoint.transform.position, this.transform, rotation, characterConfigs.RecoilCurrent, characterConfigs.GunShootAccuracy);
characterConfigs.RecoilCurrent = characterConfigs.RecoilCurrent < currentGunConfigs.RecoilMaximum ? characterConfigs.RecoilCurrent += currentGunConfigs.GunOnShootRecoilIncrease : characterConfigs.RecoilCurrent;

inputConfigs.KeyPressedShoot = currentGunConfigs.GunAutoEnabled;
inputConfigs.KeyPressedShoot = currentGunConfigs.GunAutoEnabled;

_currentShootCooldownTime = currentGunConfigs.GunShootCooldown;
_currentShootCooldownTime = currentGunConfigs.GunShootCooldown;

gun.GunMagCurrentAmmo -= 1;
}
gun.GunMagCurrentAmmo -= 1;
}

private void HandlePickupEvent()
Expand Down
4 changes: 2 additions & 2 deletions Assets/C-Game/x05-Scripts/Managers/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
public class GameManager : MonoBehaviour
{
public UIManager uimanager;
public CharacterController charcter;
public CharacterController character;

// gun switched
// call the update the ui managers stuff
Expand All @@ -15,6 +15,6 @@ public class GameManager : MonoBehaviour

public void Update()
{
uimanager.UpdateCharcterGun(character);
uimanager.UpdateValues(this);
}
}
20 changes: 10 additions & 10 deletions Assets/C-Game/x05-Scripts/Managers/UIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ public class UIManager : MonoBehaviour
[SerializeField] private BaseEventHandler EventHandler;
private BaseCharacterControllerConfiguration characterConfigs;

private GunController gunController;

private void Awake()
{
characterConfigs = EventHandler.CurrentCharacterConfigs;
Expand All @@ -26,19 +24,21 @@ private void Awake()
[SerializeField] private TextMeshProUGUI _ammoTotal;
[SerializeField] private TextMeshProUGUI _ammoMag;

public void UpdateCharcterGun(characterGun)
{
gunController = characterGun;
}

public void Update()
public void UpdateValues(GameManager gameManager)
{
_statsHealth.fillAmount = characterConfigs.HealthCurrentAmount / characterConfigs.HealthMaximumAmount;
_statsStamina.fillAmount = characterConfigs.StaminaCurrentAmount / characterConfigs.StaminaMaximumAmount;
_statsShield.fillAmount = characterConfigs.ShieldCurrentAmount / characterConfigs.ShieldMaximumAmount;

_ammoTotal.text = "value";
_ammoMag.text = "value";
var weapon = gameManager.character.gameObject.GetComponent<WeaponController>();

_ammoTotal.text = weapon?.Gun?.GunMagCurrentAmmo.ToString();
_ammoMag.text = weapon?.Gun?.GunMagCurrentAmmo.ToString();
}

public void Update()
{

}

private void OnCharacterValueChanged(BaseCharacterControllerConfiguration value)
Expand Down
28 changes: 28 additions & 0 deletions UserSettings/EditorUserSettings.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!162 &1
EditorUserSettings:
m_ObjectHideFlags: 0
serializedVersion: 4
m_ConfigSettings:
RecentlyUsedSceneGuid-0:
value: 0603030555075e0a5b0c0e75427a5c4710151e292f7823677e2b4f66e6b76360
flags: 0
vcSharedLogLevel:
value: 0d5e400f0650
flags: 0
m_VCAutomaticAdd: 1
m_VCDebugCom: 0
m_VCDebugCmd: 0
m_VCDebugOut: 0
m_SemanticMergeMode: 2
m_DesiredImportWorkerCount: 4
m_StandbyImportWorkerCount: 2
m_IdleImportWorkerShutdownDelay: 60000
m_VCShowFailedCheckout: 1
m_VCOverwriteFailedCheckoutAssets: 1
m_VCProjectOverlayIcons: 1
m_VCHierarchyOverlayIcons: 1
m_VCOtherOverlayIcons: 1
m_VCAllowAsyncUpdate: 1
m_ArtifactGarbageCollection: 1
Loading

0 comments on commit e6357a8

Please sign in to comment.