Example #1
0
    private void ShowUserChoices(object[] dataObjects)
    {
        activeCard.HideCard();
        activeCards     = new GameObject[dataObjects.Length];
        optionsSelected = new bool[dataObjects.Length];
        float startingOffset = 0;

        switch (dataObjects.Length)
        {
        case 2:
            startingOffset = .5f * (CARD_WIDTH + CARD_SPACE);
            break;

        case 3:
            startingOffset = CARD_WIDTH + CARD_SPACE;
            break;
        }
        for (int i = 0; i < dataObjects.Length; i++)
        {
            optionsSelected[i] = false;
            float offset = -startingOffset + i * (CARD_WIDTH + CARD_SPACE);
            activeCards[i] = Instantiate(prefab);
            SelectableCard card = activeCards[i].GetComponent <SelectableCard>();
            card.transform.position = new Vector3(offset, CARD_HEIGHT);
            card.transform.SetParent(canvas.transform, false);
            card.ShowCard(dataObjects[i], true);
        }
    }
Example #2
0
 public void SelectCard(SelectableCard selected)
 {
     foreach (var reward in _cardRewards)
     {
         reward.IsSelected = (selected == reward) && !reward.IsSelected;
     }
 }
Example #3
0
 public void CardSelected()
 {
     if (!multiSelect)
     {
         foreach (GameObject cardObject in activeCards)
         {
             SelectableCard card = cardObject.GetComponent <SelectableCard>();
             card.CardSelected(false);
         }
     }
 }
Example #4
0
 private void OptionsSelected()
 {
     for (int i = 0; i < activeCards.Length; i++)
     {
         SelectableCard card = activeCards[i].GetComponent <SelectableCard>();
         if (card.IsSelected())
         {
             logic.InteractWithActiveCard(i);
             break;
         }
     }
 }
Example #5
0
 private void ShowSelectedCard()
 {
     for (int i = 0; i < activeCards.Length; i++)
     {
         SelectableCard card = activeCards[i].GetComponent <SelectableCard>();
         if (card.IsSelected())
         {
             card.ShowCard((int)CardType.OPAL, false);
             break;
         }
     }
 }
Example #6
0
 private void Start()
 {
     logic          = new AdventureLogic();
     storyGenerator = new AdventureStoryGenerator();
     logic.StartGame();
     UpdatePanel();
     activeCard = Instantiate(prefab).GetComponent <SelectableCard>();
     activeCard.transform.position = new Vector3(0, 100f);
     activeCard.transform.SetParent(canvas.transform, false);
     activeCard.HideCard();
     multiSelect = false;
     stage       = 0;
 }
Example #7
0
        public void AddCardToCurrentDeck(SelectableCard selectableCard)
        {
            Debug.Log($"Added a card: {selectableCard.name}");
            var _currentCard = CurrentCards.FirstOrDefault(c => c.CardData == selectableCard.CardData);

            if (_currentCard != null)
            {
                _currentCard.GetComponentInChildren <Quantity>().Count++;
            }
            else
            {
                AddCurrentCard(selectableCard.CardData, 1);
            }

            DeckHolder.CurrentDeck.Add(selectableCard.CardData);
        }
Example #8
0
        public void RemoveCard(SelectableCard selectableCard)
        {
            Debug.Log($"Removed a card: {selectableCard.name}");
            var qty = selectableCard.GetComponentInChildren <Quantity>();

            if (qty.Count <= 0)
            {
                //TODO: Shouldn't be happening here
                var c = CurrentCards.FirstOrDefault(c => c == selectableCard);
                Destroy(c.gameObject);
            }

            var _availableCard = AvailableCards.FirstOrDefault(c => c.CardData == selectableCard.CardData);

            _availableCard.GetComponentInChildren <Quantity>().Count++;

            DeckHolder.CurrentDeck.Remove(selectableCard.CardData);
        }
    // Play other player cards
    private void EventPlayOPCards(Transform playerTransform, string[] cards)
    {
        int multipler = (int)Mathf.Ceil(cards.Length / 2);

        for (int i = 0; i < cards.Length; i++)
        {
            SelectableCard card = NGUITools.AddChild(playedCardHolder.gameObject,
                                                     Resources.Load(Global.SCREEN_PATH + "/GameScreen/SelectableCard", typeof(GameObject)) as GameObject).GetComponent <SelectableCard>();
            playedCards.Add(card);
            card.Init(GetCardTexture(cards[i]));
            card.transform.position = playerTransform.position;
            float rotateZ = Random.Range(0, cardMaxRotateZ);
            if (i < multipler)
            {
                card.PlayCard(playedCardHolder, new Vector3(-(multipler - i) * cardSpaceX, 0, 0), new Vector3(0, 0, rotateZ), false);
            }
            else
            {
                card.PlayCard(playedCardHolder, new Vector3((i - multipler) * cardSpaceX, 0, 0), new Vector3(0, 0, -rotateZ), false);
            }
        }
        SortCardDepth(playedCards);
    }
 public override void StartNewGame()
 {
     // Init user cards
     for (int i = 0; i < userCards.Count; i++)
     {
         GameObject tempCard = NGUITools.AddChild(cardHolder.gameObject, Resources.Load(Global.SCREEN_PATH + "/GameScreen/SelectableCard", typeof(GameObject)) as GameObject);
         tempCard.name = i.ToString();
         // UI2DSprite card = tempCard.GetComponent<UI2DSprite>();
         // card.sprite2D = GetCardTexture(userCards[i]);
         SelectableCard tempSelectableCard = tempCard.GetComponent <SelectableCard>();
         tempSelectableCard.Init(GetCardTexture(userCards[i]), true);
         userSelectableCards.Add(tempSelectableCard);
         tempSelectableCard.eventTrigger.inputParams = new object[] { tempSelectableCard };
         EventDelegate.Set(tempSelectableCard.eventTrigger.onClick, delegate() { SelectCard((SelectableCard)tempSelectableCard.eventTrigger.inputParams[0]); });
     }
     // Sort card depth to display (card on the right is on top)
     SortCardDepth(userSelectableCards);
     cardHolder.Reposition();
     for (int i = 0; i < userSelectableCards.Count; i++)
     {
         Utils.SetActive(userSelectableCards[i].gameObject, false);
         StartCoroutine(ShowCard(i));
     }
 }
Example #11
0
 public virtual void SelectCard(SelectableCard card)
 {
     card.SelectCard();
 }
Example #12
0
 public virtual void SelectCard(SelectableCard card) {
   card.SelectCard();
 }
Example #13
0
 public SelectableCardViewModel(SelectableCard card)
 {
     this.card = card;
     SetBackground();
 }