From cf353876ea57f6bfdeaa1568ca23d6a818868a86 Mon Sep 17 00:00:00 2001 From: Alicja Date: Tue, 15 Nov 2022 12:32:28 +0100 Subject: [PATCH] Added functional strength points --- .../FollowingPatrollingEnemy.cs | 17 +++++---- Assets/Scripts/Player.cs | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs b/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs index 98dfbe08..8e90c9bd 100644 --- a/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs +++ b/Assets/Scripts/Enemies' Scprits/FollowingPatrollingEnemy.cs @@ -9,7 +9,7 @@ public class FollowingPatrollingEnemy : Enemy public Transform currentGoal; public AStarPathfindingAgent agent; - + public Transform target; public float chaseRadius; public float attackRadius; @@ -42,12 +42,14 @@ public class FollowingPatrollingEnemy : Enemy public float expValue; + public float dmgValue; + void Awake() { //agent = GetComponent(); } - + // Start is called before the first frame update void Start() { @@ -104,7 +106,8 @@ public class FollowingPatrollingEnemy : Enemy { if (timerHit >= hitWaitTime) { - TakeDamage(1.0f); + dmgValue = PlayerPrefs.GetFloat("attackValue"); + TakeDamage(dmgValue); hit = false; timerHit = 0f; TakeKnockback(); @@ -123,7 +126,7 @@ public class FollowingPatrollingEnemy : Enemy StopAllCoroutines(); if (Vector2.Distance(target.position, transform.position) <= chaseRadius && Vector2.Distance(target.position, transform.position) > attackRadius) { - + //Debug.Log(agent); agent.FindPath(); //transform.position = Vector2.MoveTowards(transform.position, target.position, moveSpeed * Time.deltaTime); @@ -131,9 +134,9 @@ public class FollowingPatrollingEnemy : Enemy } else if (Vector2.Distance(target.position, transform.position) > chaseRadius) { - + //Debug.Log(Vector2.Distance(transform.position, path[currentPoint].position)); - + if (Vector2.Distance(transform.position, path[currentPoint].position) > roundingDistance) { StopAllCoroutines(); @@ -161,7 +164,7 @@ public class FollowingPatrollingEnemy : Enemy firstAttack = false; } - if (collision.tag == "AttackHitbox" || collision.tag == "PickaxeHitbox") + if (collision.tag == "AttackHitbox" || collision.tag == "PickaxeHitbox") { hit = true; } diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 4ba831db..62ce55b2 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -49,6 +49,8 @@ public class Player : MonoBehaviour public LevelBar levelBar; public FloatValue minPlayerExp; + public float attackValue; + public static void putPlayerInCollider() { playerInCollider = true; @@ -218,6 +220,7 @@ public class Player : MonoBehaviour void Update() { + if (lvlUp == true) { PlayerPrefs.SetInt("LvlUpPopUp", 1); @@ -353,7 +356,40 @@ public class Player : MonoBehaviour public void ManageStrength() { + if (!EquipmentManager.Instance._weapon) + { + attackValue = 0f; + } + else if (EquipmentManager.Instance._weapon.Name.Equals("pickaxe_test")) + { + attackValue = 0.5f; + PlayerPrefs.SetFloat("attackValue", attackValue); + } + else if (EquipmentManager.Instance._weapon.Name.Equals("Basic_Sword")) + { + attackValue = 1.0f; + PlayerPrefs.SetFloat("attackValue", attackValue); + } + strengthPoints = PlayerPrefs.GetInt("strengthPoints"); + if(strengthPoints == 1) + { + attackValue = PlayerPrefs.GetFloat("attackValue"); + attackValue = attackValue * 1.1f; + PlayerPrefs.SetFloat("attackValue", attackValue); + } + else if(strengthPoints == 2) + { + attackValue = PlayerPrefs.GetFloat("attackValue"); + attackValue = attackValue * 1.2f; + PlayerPrefs.SetFloat("attackValue", attackValue); + } + else if(strengthPoints == 3) + { + attackValue = PlayerPrefs.GetFloat("attackValue"); + attackValue = attackValue * 1.3f; + PlayerPrefs.SetFloat("attackValue", attackValue); + } } public void AddStrengthPoint()