private void OnEnemySpawn(EnemySaveModel save) { if (save.enemy == enemy.name) { GameObject obj = Instantiate(enemy); obj.transform.position = save.position; obj.GetComponent <EnemyHealth>().Load(save); obj.GetComponent <EnemyAttack>().Load(save); } }
List <EnemySaveModel> SaveEnemyState() { GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); List <EnemySaveModel> enemiesSavedState = new List <EnemySaveModel>(); for (int i = 0; i < enemies.Length; i++) { if (!enemies[i].GetComponent <EnemyHealth>().isDead) { EnemySaveModel state = new EnemySaveModel(); state.position = enemies[i].transform.position; state.health = enemies[i].GetComponent <EnemyHealth>().CurrentHealth; state.timer = enemies[i].GetComponent <EnemyAttack>().timer; state.enemy = enemies[i].GetComponent <EnemyAttack>().enemyType; enemiesSavedState.Add(state); } } return(enemiesSavedState); }
public void Load(EnemySaveModel save) { timer = save.timer; }
public void Load(EnemySaveModel save) { currentHealth = save.health; }