2022-04-07 19:22:29 +02:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class Enemy : MonoBehaviour
|
|
|
|
{
|
|
|
|
public float moveSpeed;
|
2023-01-03 22:44:24 +01:00
|
|
|
public string enemyName; // var for name (must be unique (playerPrefs.set/get string "enemyName - s")
|
2023-01-15 23:15:59 +01:00
|
|
|
public float maxHealth;
|
2022-05-18 13:58:41 +02:00
|
|
|
public float health;
|
2022-06-06 16:21:26 +02:00
|
|
|
public float baseAttack;
|
2022-04-07 19:22:29 +02:00
|
|
|
|
2023-01-04 21:23:02 +01:00
|
|
|
public int isKilled;
|
|
|
|
|
2023-01-03 22:44:24 +01:00
|
|
|
public string MinionName; // var used for multiplied name - for mission poroggress (kill condition)
|
|
|
|
|
2022-05-18 13:58:41 +02:00
|
|
|
private void Awake()
|
2022-04-07 19:22:29 +02:00
|
|
|
{
|
2023-01-15 23:15:59 +01:00
|
|
|
health = maxHealth;
|
2022-04-07 19:22:29 +02:00
|
|
|
}
|
|
|
|
|
2023-01-15 23:15:59 +01:00
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
PlayerPrefs.SetFloat("WizardMaxHealth", maxHealth);
|
|
|
|
PlayerPrefs.SetFloat("WizardCurrentHealth", health);
|
|
|
|
}
|
2022-10-02 18:45:58 +02:00
|
|
|
|
|
|
|
//TODO
|
|
|
|
/* public void Start()
|
|
|
|
{
|
|
|
|
enemyName = gameObject.name; //Objects Enemy will be created with an assigned name
|
|
|
|
}*/
|
|
|
|
|
2022-06-11 17:49:19 +02:00
|
|
|
public void TakeDamage(float damage)
|
2022-04-07 19:22:29 +02:00
|
|
|
{
|
2022-05-18 13:58:41 +02:00
|
|
|
health -= damage;
|
2022-05-26 13:30:59 +02:00
|
|
|
if (health <= 0)
|
2022-05-18 13:58:41 +02:00
|
|
|
{
|
|
|
|
this.gameObject.SetActive(false);
|
|
|
|
}
|
2022-05-26 13:30:59 +02:00
|
|
|
}
|
2022-05-18 13:58:41 +02:00
|
|
|
|
2023-01-04 21:23:02 +01:00
|
|
|
public void SaveCheckpoint()
|
|
|
|
{
|
|
|
|
PlayerPrefs.SetInt(enemyName + "-S", isKilled);
|
|
|
|
PlayerPrefs.SetFloat(enemyName + "-S.health", health);
|
|
|
|
}
|
|
|
|
|
2022-04-07 19:22:29 +02:00
|
|
|
}
|