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 AddTileListener(TileListener tileListener) { tileListener.Init(tileListeners.Remove); tileListeners.Add(tileListener); }