From 8b90074199887740be0a079fcbe103b9552cc6a7 Mon Sep 17 00:00:00 2001 From: Nat10k <110515021+Nat10k@users.noreply.github.com> Date: Tue, 7 May 2024 17:39:14 +0700 Subject: [PATCH] feat : difficulty implemented and fix grenade cd --- Assets/Prefabs/Enemies/Jenderal.prefab | 6 +++--- Assets/Prefabs/Enemies/Kepala Keroco.prefab | 2 +- Assets/Prefabs/Enemies/Keroco.prefab | 3 ++- Assets/Prefabs/Enemies/Raja.prefab | 4 ++-- Assets/Prefabs/Player.prefab | 7 +++++-- Assets/Prefabs/Weapons/Shotgun.prefab | 3 ++- Assets/Scripts/Enemy/EnemyAttack.cs | 10 ++++++++++ Assets/Scripts/Enemy/EnemyHealth.cs | 11 +++++++++++ Assets/Scripts/Managers/EnemyManager.cs | 9 +++++++++ Assets/Scripts/Player/PlayerShooting.cs | 15 ++++++++++----- Assets/Scripts/Quest.cs | 17 +++++++++++++++++ 11 files changed, 72 insertions(+), 15 deletions(-) diff --git a/Assets/Prefabs/Enemies/Jenderal.prefab b/Assets/Prefabs/Enemies/Jenderal.prefab index f839474..c98e1c7 100644 --- a/Assets/Prefabs/Enemies/Jenderal.prefab +++ b/Assets/Prefabs/Enemies/Jenderal.prefab @@ -324,7 +324,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 0.5 - attackDamage: 15 + attackDamage: 10 --- !u!114 &11489230 MonoBehaviour: m_ObjectHideFlags: 0 @@ -338,9 +338,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: type: 2 - startingHealth: 100 + startingHealth: 150 sinkSpeed: 2.5 - scoreValue: 12 + scoreValue: 50 deathClip: {fileID: 8300000, guid: 1d3bfb9269f136947bf8ac164cace1ff, type: 3} increaseDamageOrbPrefab: {fileID: 5928907673800009345, guid: eb4274969abbb7944acd2b2888294bba, type: 3} restoreHealthOrbPrefab: {fileID: 108012326883433976, guid: cbc7c018424f013499d4f4feb5ff52db, type: 3} diff --git a/Assets/Prefabs/Enemies/Kepala Keroco.prefab b/Assets/Prefabs/Enemies/Kepala Keroco.prefab index 5b8bc9b..4bb890f 100644 --- a/Assets/Prefabs/Enemies/Kepala Keroco.prefab +++ b/Assets/Prefabs/Enemies/Kepala Keroco.prefab @@ -152,7 +152,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 2 - attackDamage: 8 + attackDamage: 6 --- !u!114 &11400002 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Enemies/Keroco.prefab b/Assets/Prefabs/Enemies/Keroco.prefab index e9dfc1f..bbcdca1 100644 --- a/Assets/Prefabs/Enemies/Keroco.prefab +++ b/Assets/Prefabs/Enemies/Keroco.prefab @@ -259,7 +259,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: timeBetweenAttacks: 0.5 - attackDamage: 5 + attackDamage: 3 --- !u!114 &11400002 MonoBehaviour: m_ObjectHideFlags: 0 @@ -272,6 +272,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: aa10cc87aff30c04dbe0aa648f5b6adc, type: 3} m_Name: m_EditorClassIdentifier: + type: 0 startingHealth: 50 sinkSpeed: 2.5 scoreValue: 7 diff --git a/Assets/Prefabs/Enemies/Raja.prefab b/Assets/Prefabs/Enemies/Raja.prefab index 0d81cdd..702d8ca 100644 --- a/Assets/Prefabs/Enemies/Raja.prefab +++ b/Assets/Prefabs/Enemies/Raja.prefab @@ -10231,9 +10231,9 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: type: 3 - startingHealth: 2000 + startingHealth: 1500 sinkSpeed: 2.5 - scoreValue: 77 + scoreValue: 500 deathClip: {fileID: 8300000, guid: 8c615fd0429f34edf85539d70279360d, type: 3} increaseDamageOrbPrefab: {fileID: 5928907673800009345, guid: eb4274969abbb7944acd2b2888294bba, type: 3} restoreHealthOrbPrefab: {fileID: 108012326883433976, guid: cbc7c018424f013499d4f4feb5ff52db, type: 3} diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 164f395..15bee37 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -163,7 +163,8 @@ MonoBehaviour: m_EditorClassIdentifier: grenade: {fileID: 1105787354104060, guid: 41a4c48eef428174cb5039adb608d30c, type: 3} grenadeSpeed: 400 - grenadeFireDelay: 0.75 + grenadeFireDelay: 3 + damagePercent: 1 weaponsList: - {fileID: 6517554577502634727, guid: 654eb4aab37345147a96aba1eaf65063, type: 3} - {fileID: 7075423823514085712, guid: 541fd80819fc7354bb855fe83c2eab55, type: 3} @@ -250,7 +251,7 @@ MonoBehaviour: deathClip: {fileID: 8300000, guid: d36a393bca4582043982db9089e1694f, type: 3} flashSpeed: 5 flashColour: {r: 1, g: 0, b: 0, a: 0.09803922} - godMode: 0 + isCheatNoDamage: 0 --- !u!54 &5400000 Rigidbody: m_ObjectHideFlags: 0 @@ -291,6 +292,8 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: speed: 6 + originalSpeed: 6 + prevSpeed: 0 --- !u!136 &13600000 CapsuleCollider: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Weapons/Shotgun.prefab b/Assets/Prefabs/Weapons/Shotgun.prefab index 1d2eba3..6a02d7d 100644 --- a/Assets/Prefabs/Weapons/Shotgun.prefab +++ b/Assets/Prefabs/Weapons/Shotgun.prefab @@ -243,10 +243,11 @@ MonoBehaviour: m_EditorClassIdentifier: weaponModel: {fileID: 7278376730888836428} damagePerShot: 50 - timeBetweenBullets: 2 + timeBetweenBullets: 1.5 range: 3 effectsDisplayTime: 0.5 shootableMask: 0 + isEnemyWeapon: 0 triggerAudio: {fileID: 0} --- !u!199 &1667718078436812581 ParticleSystemRenderer: diff --git a/Assets/Scripts/Enemy/EnemyAttack.cs b/Assets/Scripts/Enemy/EnemyAttack.cs index 4c3d0d5..d3355ba 100644 --- a/Assets/Scripts/Enemy/EnemyAttack.cs +++ b/Assets/Scripts/Enemy/EnemyAttack.cs @@ -25,6 +25,16 @@ namespace Nightmare anim = GetComponent <Animator> (); heldWeapon = GetComponentInChildren<Weapons>(); + int difficultyLvl = PlayerPrefs.GetInt("Difficulty", 0); + if (difficultyLvl == 1) + { + attackDamage = Mathf.RoundToInt(attackDamage * 1.5f); + } + else if (difficultyLvl == 2) + { + attackDamage = Mathf.RoundToInt(attackDamage * 2f); + } + StartPausible(); } diff --git a/Assets/Scripts/Enemy/EnemyHealth.cs b/Assets/Scripts/Enemy/EnemyHealth.cs index 7cb679d..166cbda 100644 --- a/Assets/Scripts/Enemy/EnemyHealth.cs +++ b/Assets/Scripts/Enemy/EnemyHealth.cs @@ -31,6 +31,17 @@ namespace Nightmare hitParticles = GetComponentInChildren <ParticleSystem> (); capsuleCollider = GetComponent <CapsuleCollider> (); enemyMovement = this.GetComponent<EnemyMovement>(); + + int difficultyLvl = PlayerPrefs.GetInt("Difficulty", 0); + if (difficultyLvl == 1) + { + startingHealth = Mathf.RoundToInt(startingHealth * 1.5f); + scoreValue *= 2; + } else if (difficultyLvl == 2) + { + startingHealth = Mathf.RoundToInt(startingHealth * 2f); + scoreValue *= 3; + } } void OnEnable() diff --git a/Assets/Scripts/Managers/EnemyManager.cs b/Assets/Scripts/Managers/EnemyManager.cs index 3cd0f06..3b12f24 100644 --- a/Assets/Scripts/Managers/EnemyManager.cs +++ b/Assets/Scripts/Managers/EnemyManager.cs @@ -14,6 +14,15 @@ namespace Nightmare void Start () { + int difficultyLvl = PlayerPrefs.GetInt("Difficulty", 0); + if (difficultyLvl == 1) + { + spawnTime /= 1.5f; + } + else if (difficultyLvl == 2) + { + spawnTime /= 2f; + } timer = spawnTime; } diff --git a/Assets/Scripts/Player/PlayerShooting.cs b/Assets/Scripts/Player/PlayerShooting.cs index ca39058..c1e05cc 100644 --- a/Assets/Scripts/Player/PlayerShooting.cs +++ b/Assets/Scripts/Player/PlayerShooting.cs @@ -15,7 +15,7 @@ namespace Nightmare public float damagePercent = 1; int grenadeStock = 99; - float timer; + float timer, grenadeTimer; public List<GameObject> weaponsList; private Weapons currWeapon; private int currWeaponIdx; @@ -27,6 +27,7 @@ namespace Nightmare void Awake () { timer = 0; + grenadeTimer = 0; ChangeWeapon(0); AdjustGrenadeStock(0); @@ -50,6 +51,7 @@ namespace Nightmare // Add the time since Update was last called to the timer. timer += Time.deltaTime; + grenadeTimer += Time.deltaTime; currWeapon.damagePerShot = Mathf.RoundToInt(realWeaponDamage * damagePercent); @@ -71,7 +73,7 @@ namespace Nightmare } #if !MOBILE_INPUT - if (timer >= currWeapon.timeBetweenBullets && Time.timeScale != 0) + if (grenadeTimer >= grenadeFireDelay && Time.timeScale != 0) { // If the Fire1 button is being press and it's time to fire... if (Input.GetButton("Fire2") && grenadeStock > 0) @@ -79,9 +81,12 @@ namespace Nightmare // ... shoot a grenade. ShootGrenade(); } + } + if (timer >= currWeapon.timeBetweenBullets && Time.timeScale != 0) + { // If the Fire1 button is being press and it's time to fire... - else if (Input.GetButton("Fire1")) + if (Input.GetButton("Fire1")) { // ... shoot the gun. Shoot(); @@ -167,7 +172,7 @@ namespace Nightmare void ShootGrenade() { AdjustGrenadeStock(-1); - timer = currWeapon.timeBetweenBullets - grenadeFireDelay; + grenadeTimer = 0; GameObject clone = PoolManager.Pull("Grenade", transform.position, Quaternion.identity); EventManager.TriggerEvent("ShootGrenade", grenadeSpeed * transform.forward); //GameObject clone = Instantiate(grenade, transform.position, Quaternion.identity); @@ -182,7 +187,7 @@ namespace Nightmare public void ActivateCheatOneHitKill() { - damagePercent = 900; + damagePercent = 100000; } } } \ No newline at end of file diff --git a/Assets/Scripts/Quest.cs b/Assets/Scripts/Quest.cs index 2e69ce5..e48068c 100644 --- a/Assets/Scripts/Quest.cs +++ b/Assets/Scripts/Quest.cs @@ -7,4 +7,21 @@ public class Quest : MonoBehaviour public double timeLimit; public bool winIfTimeLimit; public int kerocoReq, kepalaReq, jenderalReq, rajaReq; + + private void Awake() + { + int difficultyLvl = PlayerPrefs.GetInt("Difficulty", 0); + if (difficultyLvl == 1) + { + kerocoReq *= 2; + kepalaReq *= 2; + jenderalReq *= 2; + } + else if (difficultyLvl == 2) + { + kerocoReq *= 3; + kepalaReq *= 3; + jenderalReq *= 3; + } + } } -- GitLab