/// <summary> /// Get playable id and send it to player UI controller. /// </summary> public void OnPointerClick(PointerEventData eventData) { if (this.Clickable) { Playable card = this.GetComponent <Playable>(); if (PlayerBoardController.SelectCardToBuild(card.id)) { Transform newParent = GameObject.Find("build_zones").transform.GetChild((int)card.buildType); if (card.buildType == Card.CardType.RESOURCE) { ShiftLayout layout = newParent.GetComponent <ShiftLayout>(); newParent = layout.Shift(this.gameObject); } this.ParentToReturnTo = newParent; this.ZoomOnComponent(false); this.StopDraggable(); } } }
/// <summary> /// Sort the card according to its type and define its new location accordingly. /// </summary> /// <param name="card">The card to sort.</param> /// <returns>The new card location.</returns> private Transform RegularBuild(GameObject card) { Playable playable = card.GetComponent <Playable>(); Card building = Player.Hand.Select(o => o).Where(o => o.ID == playable.id).First(); if (Player.City.Build(building, false)) { PlayerBoardController.RefreshCoinAmount(); Transform newParent = GameObject.Find("build_zones").transform.GetChild((int)playable.buildType); if (playable.buildType == Card.CardType.RESOURCE) { ShiftLayout layout = newParent.GetComponent <ShiftLayout>(); newParent = layout.Shift(card); } return(newParent); } else { Debug.Log("Build impossible: build conditions are not met."); return(null); } }