Added functional strength points

This commit is contained in:
Alicja 2022-11-15 12:32:28 +01:00
parent fbe444689f
commit cf353876ea
2 changed files with 46 additions and 7 deletions

View File

@ -9,7 +9,7 @@ public class FollowingPatrollingEnemy : Enemy
public Transform currentGoal; public Transform currentGoal;
public AStarPathfindingAgent agent; public AStarPathfindingAgent agent;
public Transform target; public Transform target;
public float chaseRadius; public float chaseRadius;
public float attackRadius; public float attackRadius;
@ -42,12 +42,14 @@ public class FollowingPatrollingEnemy : Enemy
public float expValue; public float expValue;
public float dmgValue;
void Awake() void Awake()
{ {
//agent = GetComponent<AStarPathfindingAgent>(); //agent = GetComponent<AStarPathfindingAgent>();
} }
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
@ -104,7 +106,8 @@ public class FollowingPatrollingEnemy : Enemy
{ {
if (timerHit >= hitWaitTime) if (timerHit >= hitWaitTime)
{ {
TakeDamage(1.0f); dmgValue = PlayerPrefs.GetFloat("attackValue");
TakeDamage(dmgValue);
hit = false; hit = false;
timerHit = 0f; timerHit = 0f;
TakeKnockback(); TakeKnockback();
@ -123,7 +126,7 @@ public class FollowingPatrollingEnemy : Enemy
StopAllCoroutines(); StopAllCoroutines();
if (Vector2.Distance(target.position, transform.position) <= chaseRadius && Vector2.Distance(target.position, transform.position) > attackRadius) if (Vector2.Distance(target.position, transform.position) <= chaseRadius && Vector2.Distance(target.position, transform.position) > attackRadius)
{ {
//Debug.Log(agent); //Debug.Log(agent);
agent.FindPath(); agent.FindPath();
//transform.position = Vector2.MoveTowards(transform.position, target.position, moveSpeed * Time.deltaTime); //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) else if (Vector2.Distance(target.position, transform.position) > chaseRadius)
{ {
//Debug.Log(Vector2.Distance(transform.position, path[currentPoint].position)); //Debug.Log(Vector2.Distance(transform.position, path[currentPoint].position));
if (Vector2.Distance(transform.position, path[currentPoint].position) > roundingDistance) if (Vector2.Distance(transform.position, path[currentPoint].position) > roundingDistance)
{ {
StopAllCoroutines(); StopAllCoroutines();
@ -161,7 +164,7 @@ public class FollowingPatrollingEnemy : Enemy
firstAttack = false; firstAttack = false;
} }
if (collision.tag == "AttackHitbox" || collision.tag == "PickaxeHitbox") if (collision.tag == "AttackHitbox" || collision.tag == "PickaxeHitbox")
{ {
hit = true; hit = true;
} }

View File

@ -49,6 +49,8 @@ public class Player : MonoBehaviour
public LevelBar levelBar; public LevelBar levelBar;
public FloatValue minPlayerExp; public FloatValue minPlayerExp;
public float attackValue;
public static void putPlayerInCollider() public static void putPlayerInCollider()
{ {
playerInCollider = true; playerInCollider = true;
@ -218,6 +220,7 @@ public class Player : MonoBehaviour
void Update() void Update()
{ {
if (lvlUp == true) if (lvlUp == true)
{ {
PlayerPrefs.SetInt("LvlUpPopUp", 1); PlayerPrefs.SetInt("LvlUpPopUp", 1);
@ -353,7 +356,40 @@ public class Player : MonoBehaviour
public void ManageStrength() 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"); 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() public void AddStrengthPoint()