public static FreePositionView InstantiateWithParent(TilePosition p_position, Transform p_parent, Player p_owner) { try { // Creation of the new instance. GameObject _new_instance = UnityEngine.Object.Instantiate(RESOURCE) as GameObject; _new_instance.transform.parent = p_parent; // Get the script associated with the new tile. FreePositionView _this = _new_instance.AddComponent <FreePositionView> (); // Set the common properties _this.m_position = p_position; _this.m_player = p_owner; if (_this.m_position != null) { // TODO Rework this Duplicate from TileView. Vector3 position = new Vector3(_this.m_position.x * 1.5f * TileView.OffsetX, 0, (_this.m_position.y + 1) * TileView.OffsetY); _this.transform.position = p_parent.TransformPoint(position); } else { Debug.LogError("Position for FreePositionView null !"); } return(_this); } catch (Exception) { Debug.LogError("Error while instantiating FreePosition! Prefab not found !"); return(null); } }
public void HandleClickOnTileFromREM(EventClickOnTileFromREM p_event) { if (m_free_positions.Count > 0) { return; } if (m_player == p_event.current) { foreach (TilePosition pos in Suburbia.Manager.GetFreePositionsForPlayer(m_player)) { m_free_positions.Add(FreePositionView.InstantiateWithParent(pos, this.transform, this.m_player)); } } }