Scriptum/Assets/Scripts/Enemies' Scprits/Enemy.cs

45 lines
1.1 KiB
C#
Raw Normal View History

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")
2022-05-18 13:58:41 +02:00
public FloatValue maxHealth;
public float health;
public float baseAttack;
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()
{
2023-01-03 22:44:24 +01:00
health = maxHealth.initialValue;
}
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-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
public void SaveCheckpoint()
{
PlayerPrefs.SetInt(enemyName + "-S", isKilled);
PlayerPrefs.SetFloat(enemyName + "-S.health", health);
}
}