From 896cb6391fa041cd2938c329b2268b0dab2a00ef Mon Sep 17 00:00:00 2001
From: sumertayoga <13520021@std.stei.itb.ac.id>
Date: Sat, 15 Apr 2023 13:06:13 +0700
Subject: [PATCH] change buff mechanism

---
 .../Scripts/Controllers/StateController.cs    |  2 ++
 My project/Assets/Scripts/Pet/PetMovement.cs  |  3 +--
 My project/Assets/Scripts/Pet/RobotSkill.cs   | 25 +++----------------
 .../Assets/Scripts/Player/PlayerShooting.cs   |  4 +--
 My project/Assets/Scripts/Weapon/Arrow.cs     |  5 ++--
 .../Assets/Scripts/Weapon/ShotgunBullet.cs    |  4 +--
 My project/Assets/Scripts/Weapon/Sword.cs     |  4 +--
 README.md                                     |  2 +-
 8 files changed, 17 insertions(+), 32 deletions(-)

diff --git a/My project/Assets/Scripts/Controllers/StateController.cs b/My project/Assets/Scripts/Controllers/StateController.cs
index bb22e4d..75320ca 100644
--- a/My project/Assets/Scripts/Controllers/StateController.cs	
+++ b/My project/Assets/Scripts/Controllers/StateController.cs	
@@ -24,6 +24,7 @@ public class StateController : MonoBehaviour
     public static bool showSaveUI = true;
     public static int playerHealth = 100;
     public static string saveSlotName;
+    public static int attBuff = 0;
 
     public static void reset()
     {
@@ -44,6 +45,7 @@ public class StateController : MonoBehaviour
         petTag = 3;
         petCurrentHealth = 0;
         slot = "0";
+        attBuff = 0;
         resetShop();
     }
 
diff --git a/My project/Assets/Scripts/Pet/PetMovement.cs b/My project/Assets/Scripts/Pet/PetMovement.cs
index f534e19..42750c2 100644
--- a/My project/Assets/Scripts/Pet/PetMovement.cs	
+++ b/My project/Assets/Scripts/Pet/PetMovement.cs	
@@ -54,7 +54,7 @@ public class PetMovement : MonoBehaviour
             return;
         }
         
-        if(nav.remainingDistance > 3){
+        if(nav.remainingDistance > nav.stoppingDistance){
             anim.SetBool("isWalking", true);
         }
         else{
@@ -62,7 +62,6 @@ public class PetMovement : MonoBehaviour
         }
 
         playerCurrentPosition = player.position;
-        Debug.Log(StateController.petCurrentHealth);
         if(petHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
         {
             if(playerCurrentPosition != playerLastPosition)
diff --git a/My project/Assets/Scripts/Pet/RobotSkill.cs b/My project/Assets/Scripts/Pet/RobotSkill.cs
index 114eb29..56ff36c 100644
--- a/My project/Assets/Scripts/Pet/RobotSkill.cs	
+++ b/My project/Assets/Scripts/Pet/RobotSkill.cs	
@@ -21,48 +21,31 @@ public class RobotSkill : MonoBehaviour
     void Awake()
     {
         player = GameObject.FindGameObjectWithTag("Player");
-        playerShooting = player.GetComponentInChildren<PlayerShooting>();
-        sword = player.GetComponentInChildren<Sword>();
-        arrow = player.GetComponentInChildren<Arrow>();
-        shotgun = player.GetComponentInChildren<ShotgunBullet>();
-        initialDamageGun = playerShooting.damagePerShot;
-        initialDamageSword = sword.attackDamage;
-        initialDamageArrow = arrow.damage;
-        initialDamageShotgun = shotgun.damagePerShot;
         playerSkin = GameObject.FindGameObjectWithTag("PlayerMaterial");
         skinnedMeshRenderer = playerSkin?.GetComponent<SkinnedMeshRenderer>();
         material = skinnedMeshRenderer?.material;
+        StateController.attBuff = 50;
     }
 
     void Update()
     {
-        playerShooting.damagePerShot = 50 + initialDamageGun;
-        sword.attackDamage = 70 + initialDamageSword;
-        arrow.damage = 30 + initialDamageArrow;
-        shotgun.damagePerShot = 30 + initialDamageShotgun;
-
+        StateController.attBuff = 50;
         if(player != null)
         {
             if(playerSkin != null) material.color = new Color(0.992f, 0.506f, 0.423f, 1.0f);
             float distance = Vector3.Distance(player.transform.position, transform.position);
             if(distance > 10)
             {
+                StateController.attBuff = 0;
                 if(playerSkin != null) material.color = new Color(1f, 1f, 1f, 1.0f);
-                playerShooting.damagePerShot = initialDamageGun;
-                sword.attackDamage = initialDamageSword;
-                arrow.damage = initialDamageArrow;
-                shotgun.damagePerShot = initialDamageShotgun;
             }
         }
     }
 
     void OnDestroy()
     {
-        playerShooting.damagePerShot = initialDamageGun;
-        sword.attackDamage = initialDamageSword;
-        arrow.damage = initialDamageArrow;
-        shotgun.damagePerShot = initialDamageShotgun;
         if(playerSkin != null) material.color = new Color(1f, 1f, 1f, 1.0f);
+        StateController.attBuff = 0;
     }
 
 
diff --git a/My project/Assets/Scripts/Player/PlayerShooting.cs b/My project/Assets/Scripts/Player/PlayerShooting.cs
index 30248c1..feda2fa 100644
--- a/My project/Assets/Scripts/Player/PlayerShooting.cs	
+++ b/My project/Assets/Scripts/Player/PlayerShooting.cs	
@@ -69,14 +69,14 @@ public class PlayerShooting : MonoBehaviour
 
             if (enemyHealth != null)
             {
-                enemyHealth.TakeDamage((int)(damagePerShot * StateController.gunMultiplier), shootHit.point);
+                enemyHealth.TakeDamage((int)(damagePerShot * StateController.gunMultiplier + StateController.attBuff), shootHit.point);
             }
 
             BossHealth bossHealth = shootHit.collider.GetComponent<BossHealth>();
 
             if (bossHealth != null)
             {
-                bossHealth.TakeDamage((int)(damagePerShot * StateController.gunMultiplier), shootHit.point);
+                bossHealth.TakeDamage((int)(damagePerShot * StateController.gunMultiplier + StateController.attBuff), shootHit.point);
             }
 
             gunLine.SetPosition(1, shootHit.point);
diff --git a/My project/Assets/Scripts/Weapon/Arrow.cs b/My project/Assets/Scripts/Weapon/Arrow.cs
index aa6347c..42afe9d 100644
--- a/My project/Assets/Scripts/Weapon/Arrow.cs	
+++ b/My project/Assets/Scripts/Weapon/Arrow.cs	
@@ -38,18 +38,19 @@ public class Arrow : MonoBehaviour
     {
         if (hit || flying == false) return;
         hit = true;
+        Debug.Log(damage);
 
         EnemyHealth enemy = other.GetComponent<EnemyHealth>();
 
         if (enemy != null)
         {
-            enemy.TakeDamage((int)(damage * StateController.bowMultiplier), other.ClosestPointOnBounds(transform.position));
+            enemy.TakeDamage((int)(damage * StateController.bowMultiplier + StateController.attBuff), other.ClosestPointOnBounds(transform.position));
         }
 
         BossHealth boss = other.GetComponent<BossHealth>();
         if (boss != null)
         {
-            boss.TakeDamage((int)(damage * StateController.bowMultiplier), other.ClosestPointOnBounds(transform.position));
+            boss.TakeDamage((int)(damage * StateController.bowMultiplier + StateController.attBuff), other.ClosestPointOnBounds(transform.position));
         }
 
         rigidbody.velocity = Vector3.zero;
diff --git a/My project/Assets/Scripts/Weapon/ShotgunBullet.cs b/My project/Assets/Scripts/Weapon/ShotgunBullet.cs
index 30748a5..2d3d0fc 100644
--- a/My project/Assets/Scripts/Weapon/ShotgunBullet.cs	
+++ b/My project/Assets/Scripts/Weapon/ShotgunBullet.cs	
@@ -72,13 +72,13 @@ public class ShotgunBullet : MonoBehaviour
 
             if (enemyHealth != null)
             {
-                enemyHealth.TakeDamage((int) (damagePerShot * StateController.shotGunMultiplier), shootHit.point);
+                enemyHealth.TakeDamage((int) (damagePerShot * StateController.shotGunMultiplier + StateController.attBuff), shootHit.point);
             }
 
             BossHealth bossHealth = shootHit.collider.GetComponent<BossHealth>();
             if (bossHealth != null)
             {
-                bossHealth.TakeDamage((int)(damagePerShot * StateController.shotGunMultiplier), shootHit.point);
+                bossHealth.TakeDamage((int)(damagePerShot * StateController.shotGunMultiplier + StateController.attBuff), shootHit.point);
             }
 
             gunLine.SetPosition(1, shootHit.point);
diff --git a/My project/Assets/Scripts/Weapon/Sword.cs b/My project/Assets/Scripts/Weapon/Sword.cs
index 5432192..bc00695 100644
--- a/My project/Assets/Scripts/Weapon/Sword.cs	
+++ b/My project/Assets/Scripts/Weapon/Sword.cs	
@@ -56,13 +56,13 @@ public class Sword : MonoBehaviour
             EnemyHealth enemyHealth = enemy.GetComponent<EnemyHealth>();
             if (enemyHealth != null)
             {
-                enemyHealth.TakeDamage(attackDamage, enemy.ClosestPointOnBounds(transform.position));
+                enemyHealth.TakeDamage(attackDamage + StateController.attBuff, enemy.ClosestPointOnBounds(transform.position));
             }
 
             BossHealth bossHealth = enemy.GetComponent<BossHealth>();
             if (bossHealth != null)
             {
-                bossHealth.TakeDamage(attackDamage, enemy.ClosestPointOnBounds(transform.position));
+                bossHealth.TakeDamage(attackDamage + StateController.attBuff, enemy.ClosestPointOnBounds(transform.position));
             }
         }
 
diff --git a/README.md b/README.md
index 5fd4376..cc3d7f4 100644
--- a/README.md
+++ b/README.md
@@ -165,7 +165,7 @@ Adapun aplikasi ini memiliki beberapa spesifikasi , yaitu :
 
 NIM | Nama | Tugas | Jam Persiapan | Jam Pengerjaan
 --- | --- | --- | --- | ---
-13520021 | Gede Sumerta Yoga | inisialisasi game, pet |  |
+13520021 | Gede Sumerta Yoga | inisialisasi game, pet | 9 jam | 16 jam
 13520090 | Rahmat Rafid Akbar | Cheat, Main Menu, Game Over, Local Scoreboard, Bug Tester | 10 jam | 24 jam
 13520133 | Jevant Jedidia Augustine | Inisialisasi game, story mode, Save & Load, Integrasi | 10 jam | 36 jam
 13520141 | Yoseph Alexander Siregar | Shop, Bonus Upgrade Weapon | 9 jam | 15 jam
-- 
GitLab