public void AddTrap(Tile tile, EnterTileAction trapAction) { GameObject currentTrap = Instantiate(trap); TileListener listener = currentTrap.GetComponent <TileListener>(); listener.SetEnterAction(trapAction); if (listener != null) { tile.AddTileListener(listener); currentTrap.gameObject.transform.SetParent(tile.gameObject.transform); currentTrap.transform.localPosition = new Vector3(0, 0, 0); } else { Destroy(currentTrap); } }
public void SetEnterAction(EnterTileAction action) { enterAction = action; }