private static EnemyMovement InitComponents(GameObject instance, Unit unit) { EnemyController enemyController = instance.GetComponent <EnemyController>(); EnemyMovement enemyMovement = instance.GetComponent <EnemyMovement>(); EnemyHealth enemyHealth = instance.GetComponent <EnemyHealth>(); UnitView unitView = instance.GetComponent <UnitView>(); enemyController.Init(unit); enemyMovement.Init(unit); enemyHealth.Init(unit); unitView.Init(unit); return(enemyMovement); }
public static UnitView CreateUnitView(Transform parent, MapView mapView, Unit unit, string prefabName) { var unitPrefab = Resources.Load <UnitView>("Units/" + prefabName); if (unitPrefab == null) { Debug.LogError("Can't load unit " + prefabName); return(null); } UnitView unitView = Instantiate(unitPrefab); unitView.gameObject.SetActive(true); unitView.transform.parent = parent; unitView.Init(unit, mapView.CellCoordToPosition(unit.Coordinate)); return(unitView); }