using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
class MinionRespowner : MonoBehaviour
{
///
/// Function to determine if object nad respown object
///
public bool Blocked = false;
private void Start()
{
}
private void Update()
{
}
public void Respown(GameObject enemyModel)
{
// Change position
var newPosition = new Vector3(
gameObject.transform.position.x + UnityEngine.Random.Range(-3.8f, 3.8f),
gameObject.transform.position.y + UnityEngine.Random.Range(-3.8f, 3.8f),
10
);
BuildMinion(enemyModel, newPosition);
}
public void BuildMinion(GameObject minion, Vector3 coord)
{
var sceneGui = GameObject.FindGameObjectWithTag("EnemyCollection");
if (sceneGui == null)
{
throw new Exception("GUI not found on scene!!!");
return;
}
var newMinion = Instantiate(minion, coord, Quaternion.identity, sceneGui.transform);
newMinion.name = minion.name;
// newMinion.transform.SetParent(sceneGui.transform);
newMinion.GetComponent().sortingOrder = 3;
newMinion.AddComponent();
newMinion.GetComponent().SetParentRespowner(GameObject.FindObjectOfType().gameObject);
}
}