public static void SetupCardView( PlayerHandView handView, int handSlot, CardData cardData, Action <CardView> onBeginDrag, Action onEndDrag) { if (cardData == null) { Debug.LogWarning("Card Data is null!"); handView.RemoveCardByIndex(handSlot); // TODO: Do this On card slam instead of after the fact return; } CardView view = handView.GetCardAtIndex(handSlot); if (view == null) { view = Singleton.instance.cardResourceBank.CreateCardView( cardData, handView.cardSlotList[handSlot]); } view.cardData = cardData; handView.SetCardAtIndex(handSlot, view); }
public override void AddCard(Card card) { base.AddCard(card); PlayerHandView handView = (PlayerHandView)PlayerView.HandView; handView.AddCard(card, () => CollectCard(card), () => OnClicked(card)); }
public HandItem(AbilityCardView cardView, Button button, int index, PlayerHandView handView) { CardView = cardView; ItemButton = button; Index = index; HandView = handView; Obj = cardView.gameObject; ItemButton.onClick.AddListener(() => { HandView.UseCard(Index); }); ColorBlock colors = button.colors; colors.highlightedColor = new Color(140, 140, 140); ItemButton.colors = colors; }
private void _createPlayerHandView( int localPlayerIndex, Transform handParent) { if (_playerHandView) { viewFactory.RemoveView(_playerHandView, true); } viewFactory.CreateAsync <PlayerHandView>("PlayerHandView", (view) => { _playerHandView = view as PlayerHandView; _setupHandViewFromPlayer(localPlayerIndex); }, handParent); }
public void Start(TuckMatchState state, Action onViewsLoaded) { _matchState = state; var assetList = new List <AssetRequest>() { new AssetRequest("GUI/GamePlay/BoardView", Singleton.instance.sceneRoot), new AssetRequest("GUI/GamePlay/PlayerHandView"), new AssetRequest("GUI/GamePlay/GameHudView") }; viewFactory.CreateAsyncFromList(assetList, (uiMap) => { foreach (var keyValue in uiMap) { switch (keyValue.Key) { case "GUI/GamePlay/BoardView": _boardView = keyValue.Value as BoardView; _boardView.board = _matchState.board; _boardView.AddListener(GameEventType.PEG_TAP, onPegTapped); _boardView.AddListener(GameEventType.PIECE_TAP, onPieceTapped); break; case "GUI/GamePlay/PlayerHandView": _playerHandView = keyValue.Value as PlayerHandView; _playerHandView.AddListener(GameEventType.TRADE_CARD, onTradeCardDrop); _playerHandView.AddListener(GameEventType.PLAY_CARD, onPlayCardDrop); _setupPlayerHand(activePlayer.index); break; case "GUI/GamePlay/GameHudView": _gameHudView = keyValue.Value as GameHudView; _gameHudView.AddListener(GameEventType.UNDO, onForwardEventAndRefreshHand); _gameHudView.AddListener(GameEventType.REDO, onForwardEventAndRefreshHand); _gameHudView.AddListener(GameEventType.FINISH_TURN, onForwardEventAndRefreshHand); break; } } if (onViewsLoaded != null) { onViewsLoaded(); } }); }
public static void SetupIngredientView( PlayerHandView handView, int handSlot, IngredientCardData cardData, Action <IngredientCardView> onBeginDrag, Action onEndDrag) { if (cardData == null) { Debug.LogWarning("Card Data is null!"); handView.RemoveCardByIndex(handSlot); // TODO: Do this On card slam instead of after the fact return; } IngredientCardView view = handView.GetCardAtIndex(handSlot); if (view == null) { view = Singleton.instance.cardResourceBank.CreateCardView( cardData, handView.cardSlotList[handSlot]) as IngredientCardView; } view.cardData = cardData; view.eventTrigger.triggers.Clear(); EventTrigger.Entry OnBeginDrag = new EventTrigger.Entry(); OnBeginDrag.eventID = EventTriggerType.BeginDrag; OnBeginDrag.callback.AddListener((e) => onBeginDrag(view)); view.eventTrigger.triggers.Add(OnBeginDrag); EventTrigger.Entry OnEndDrag = new EventTrigger.Entry(); OnEndDrag.eventID = EventTriggerType.EndDrag; OnEndDrag.callback.AddListener((e) => onEndDrag()); view.eventTrigger.triggers.Add(OnEndDrag); handView.SetCardAtIndex(handSlot, view); }