private void ButtonPressedCallback(CardButton data)
 {
     if (OnButtonPressed != null)
     {
         OnButtonPressed.Invoke(data);
     }
 }
Exemple #2
0
    public void MakeButtonCards(List <CardPokerFace> btnCards)
    {
        GameObject    tGO  = null;
        CardPokerFace tCPF = null;

        for (int i = 0; i < btnCards.Count; i++)
        {
            CardButton cb = UIManager.S.cardButtons[i];
            tGO = Instantiate(btnCards[i].gameObject, cb.transform);
            tGO.transform.localPosition = Vector3.zero;
            Destroy(tGO.GetComponent <Collider>());

            tCPF = tGO.GetComponent <CardPokerFace>();
            Destroy(tCPF.pipGOs[0]);
            tCPF.decoGOs[0].transform.localPosition = new Vector3(0f, 0.35f, 0);
            tCPF.decoGOs[1].transform.localPosition = new Vector3(0f, -0.45f, 0);
            tCPF.spriteRenderer.maskInteraction     = SpriteMaskInteraction.VisibleInsideMask;
            foreach (SpriteRenderer sr in tCPF.spriteRenderers)
            {
                sr.maskInteraction = SpriteMaskInteraction.VisibleInsideMask;
            }
            tCPF.faceUp = true;
            cb.SetPlayerCard(btnCards[i]);
            cb.SetUICard(tCPF);
        }
    }
Exemple #3
0
    public void finishFinalTurn(CardButton discarded)
    {
        if (lastTurn)
        {
            outDeckHandler.CheckForUpdatedOut();
            endRoundScreen.SetActive(true);
            int score = 0;

            // scoring
            if (outDeckHandler.RemoveFromHand(discarded))
            {
                //calulate score
                Debug.Log("I should calculate the score here, card count: " + outDeckHandler.myCurrentHand.Count);
                score = outDeckHandler.CalculateScore();
                nh_network.server.sendMyScore(score);
            }
            else
            {
                //score = 0
                Debug.Log("Your score is 0");
                nh_network.server.sendMyScore(0);
            }

            ScorecardLoader.inst.EnableWait(score);
        }
    }
Exemple #4
0
 public ContentCard()
 {
     InitializeComponent();
     CardHeader.SetBinding(Label.TextProperty, new Binding(nameof(Header), source: this));
     CardButton.SetBinding(Button.TextProperty, new Binding(nameof(ButtonName), source: this));
     CardButton.SetBinding(Button.CommandProperty, new Binding(nameof(Command), source: this));
     CardButton.SetBinding(IsVisibleProperty, new Binding(nameof(ButtonVisible), source: this));
 }
Exemple #5
0
 public void SetEffect(string text, Item item, CardButton cardButton)
 {
     quantityText.text = text;
     normalText.gameObject.SetActive(false);
     inventorySlot.SetSlot(item, true);
     // Make clicking on the inventory slots select the card
     inventorySlot.GetComponent <Button>().onClick = cardButton.GetComponent <Button>().onClick;
 }
    public override void CreateCard(int id)
    {
        CardButton card = Instantiate(prefCard, container.transform).GetComponent <CardButton>();

        card.InitCard(id);
        activeCards.Add(card);
        UpdateWeather(card.cardType);
    }
Exemple #7
0
    public virtual void CreateCard(int id)
    {
        CardButton card = Instantiate(prefCard, container.transform).GetComponent <CardButton>();

        card.InitCard(id);
        activeCards.Add(card);
        UpdateTextDamage();
        GameManager.ins.boardManager.CalculateOvarall();
    }
Exemple #8
0
 public virtual void RemoveCards()
 {
     for (int i = activeCards.Count - 1; i >= 0; i--)
     {
         CardButton card = activeCards[i];
         activeCards.Remove(card);
         Destroy(card.gameObject);
     }
 }
Exemple #9
0
 /// <summary>
 /// Used for selecting a specific for attacking.
 /// </summary>
 public void MarkSelected(CardButton button)
 {
     // Checks if the player which selected the card can select that card.
     if (button.associatedPlayer == currentPlayer)
     {
         canvasManager.cursor.ChangeCursor(1);
         selectedCard = button;
     }
 }
 public void SetCards(List <Card> cards)
 {
     // TODO: frosty optimization: reuse existing cards
     foreach (Card card in cards)
     {
         CardButton cardButton = Instantiate(cardButtonPrefab, cardDisplay);
         cardButton.SetCard(card);
         currCardButtons.Add(cardButton);
     }
 }
Exemple #11
0
 public virtual void SetEffectsSummary(CardEffectsSummary summary, CardButton cardButton)
 {
     foreach (CardEffect effect in cardEffectsSet.cardEffects)
     {
         if (effect.quantity != 0)
         {
             summary.AddEffect(effect.quantity, effect.item, cardButton);
         }
     }
 }
Exemple #12
0
 /// <summary>
 /// Rolls a new card for the player.
 /// </summary>
 public void RollNewCard(Turn turn)
 {
     Player player = currentTurn == Turn.Defender ? defender : attacker;
     // Rolls new cards if the player still has new cards.
     if(player.deck.Count > 0)
     {
         ICard card = player.GetCard();
         CardButton newHandCard = canvasManager.CreateCardButton(card, player);
         player.hand.Add(newHandCard);
     }
 }
Exemple #13
0
 public void MonsterRemoved(CardButton card)
 {
     card.Remaining++;
     if (card.Remaining == 1)
     {
         Debug.Log(card.cardInfo.Name + " is back on the menu, boys!");
         //do a thing?
     }
     card.UpdateView();
     RefreshButtonColors();
 }
    IEnumerator disappear(CardButton card)
    {
        // @todo: 뭔가아쉬운 연출...
        for (int i = 0; i < 1; ++i)
        {
            yield return(_waitForSeconds);
        }

        card.gameObject.SetActive(false);
        Manager.Instance.Object.BoardGameMode.JudgeIter();
    }
Exemple #15
0
        public static CardButton ButtonCard(string argName = null)
        {
            var cardButton = new CardButton();

            if (argName != null)
            {
                cardButton.Text = argName;
            }
            //button.Style = Application.Current.TryFindResource("CardButton") as Style;
            cardButton.Margin = new Thickness(MarginBetweenButtons);
            return(cardButton);
        }
Exemple #16
0
 public void ReturnToHand(CardButton cardAdded)
 {
     if (!myCurrentHand.Contains(cardAdded))
     {
         print($"Returning card to hand {cardAdded.myCard.suit} - {cardAdded.myCard.number}");
         myCurrentHand.Add(cardAdded);
     }
     else
     {
         Debug.LogWarning("Card already exists in hand", cardAdded.gameObject);
     }
 }
Exemple #17
0
 public void MonsterPlaced(CardButton card)
 {
     card.Remaining--;
     if (card.Remaining <= 0)
     {
         card.Remaining = 0;//just in case
         //Debug.Log($"Fresh out of {type}!");//well that sucks... stupid unity using super outdated versions of C#
         Debug.Log("Fresh out of " + card.cardInfo.Name + "!");
         selectedMonster = null;
     }
     card.UpdateView();
     RefreshButtonColors();
 }
Exemple #18
0
 public Action PickupCard(CardButton card)
 {
     return () => {
         if (Selected != null || TargetingMode != TargetingMode.Inactive) {
             return;
         }
         TargetingMode = TargetingMode.Transitional;
         Selected = card;
         Selected.OnPickup();
         ActiveCard = card.GetCard();
         StartCoroutine(Select());
     };
 }
Exemple #19
0
    public void AddEffect(int quantity, Item item, CardButton cardButton)
    {
        if (quantity == 0)
        {
            Debug.LogWarning("Tried to add an effect with 0 quantity");
            return;
        }
        string text = "";

        text += (quantity > 0 ? "+" : "") + quantity;
        CardEffectLine line = Instantiate(cardEffectLinePrefab, transform);

        line.SetEffect(text, item, cardButton);
    }
Exemple #20
0
    public override void SetEffectsSummary(CardEffectsSummary summary, CardButton cardButton)
    {
        base.SetEffectsSummary(summary, cardButton);
        int currIntegrity = GameManager.instance.shipIntegrity;
        int newIntegrity  = GameManager.instance.CalculateShipIntegrityChange(repair);

        if (repair)
        {
            summary.AddEffect("increases ship integrity from " + currIntegrity + "% to " + newIntegrity + "%");
        }
        else
        {
            summary.AddEffect("decreases ship integrity from " + currIntegrity + "% to " + newIntegrity + "%");
        }
    }
Exemple #21
0
    public void LoadCurrentRoundHeroes()
    {
        currentSelection = 1;

        clearRoundButton.SetActive(true);

        content.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, 1.25f);

        for (int i = 0; i < currentRoundHeroes.Count; i++)
        {
            string     pathFolder = currentRoundHeroes[i].heroFaction.ToString();
            CardButton btn        = Instantiate(cardBtnPrefab) as CardButton;
            btn.Init(currentRoundHeroes[i], pathFolder);
            btn.transform.SetParent(content, false);
        }
    }
Exemple #22
0
    public void RemoveFromHand(CardButton cardRemoved)
    {
        if (!hasGoneOut)
        {
            if (handCopy.Contains(cardRemoved))
            {
                handCopy.Remove(cardRemoved);
            }
            else
            {
                Debug.LogWarning("Card not found in hand", cardRemoved.gameObject);
            }

            CheckForOut();
        }
    }
Exemple #23
0
    public void AddCardToCurrentRound()
    {
        if (currentCard != null)
        {
            currentRoundHeroes.Add(currentCard);
            addCardButton.interactable    = false;
            removeCardButton.interactable = true;

            if (currentSelection == 1)
            {
                string     pathFolder = currentCard.heroFaction.ToString();
                CardButton btn        = Instantiate(cardBtnPrefab) as CardButton;
                btn.Init(currentCard, pathFolder);
                btn.transform.SetParent(content, false);
            }
        }
    }
Exemple #24
0
    public void ReturnToHand(CardButton cardAdded)
    {
        if (!hasGoneOut)
        {
            if (!handCopy.Contains(cardAdded))
            {
                print($"Returning card to hand {cardAdded.myCard.suit} - {cardAdded.myCard.number}");
                handCopy.Add(cardAdded);
            }
            else
            {
                Debug.LogWarning("Card already exists in hand", cardAdded.gameObject);
            }

            CheckForOut();
        }
    }
Exemple #25
0
 public override void SetEffectsSummary(CardEffectsSummary summary, CardButton cardButton)
 {
     foreach (CardEffect effect in cardEffectsSet.cardEffects)
     {
         if (effect.quantity != 0)
         {
             if (effect.item == GameManager.instance.foodItem)
             {
                 summary.AddEffect(ApplyFoodBonuses(effect.quantity), effect.item, cardButton);
             }
             else
             {
                 summary.AddEffect(effect.quantity, effect.item, cardButton);
             }
         }
     }
 }
Exemple #26
0
    /// <summary>
    /// Rolls a first hand for each of the players.
    /// </summary>
    private void RollFirstHand(ref Player player)
    {
        // Gets the player object to fetch the cards from.
        List<ICard> startingHand = new List<ICard>();

        // Does a loop for the first card hand.
        for(int i = 0; i < startingCards; i++)
        {
            startingHand.Add(player.GetCard());
        }
        
        // Does a loop to create cards for each hand.
        foreach(ICard card in startingHand)
        {
            CardButton newHandCard = canvasManager.CreateCardButton(card, player);
            player.hand.Add(newHandCard);
        }
    }
Exemple #27
0
    /// <summary>
    /// Creates the card on the actual scene.
    /// </summary>
    public CardButton CreateCardButton(ICard card, Player player)
    {
        // Creates a new card asset from the prefab.
        GameObject newCard = Instantiate(cardPrefab, player.handTransform);

        // Sets the card info.
        newCard.transform.GetChild(0).GetComponent <Text>().text           = card.GetCardName();
        newCard.transform.GetChild(1).GetComponent <Text>().text           = card.GetCardTooltip();
        newCard.transform.GetChild(2).GetComponent <Image>().sprite        = card.GetCardSprite();
        newCard.transform.GetChild(3).GetComponentInChildren <Text>().text = card.ReturnHealth().ToString();
        newCard.transform.GetChild(4).GetComponentInChildren <Text>().text = card.ReturnAttack().ToString();

        // Associates the button with the card.
        CardButton newCardButton = newCard.GetComponent <CardButton>();

        newCardButton.SetCard(card, player);
        return(newCardButton);
    }
        private void DisplayImage(MWCard card)
        {
            CardButton button = new CardButton();

            Binding bind = new Binding();

            bind.Source = card;
            bind.Mode   = BindingMode.OneWay;

            button.SetBinding(DataContextProperty, bind);
            button.Tapped += Button_Tapped;

            //cardPopup.Margin = new Thickness(100);
            cardPopup.VerticalOffset   = (this.Frame.ActualHeight / 2) - (255);
            cardPopup.HorizontalOffset = (this.Frame.ActualWidth / 2) - (183);

            cardPopup.Child  = button;
            cardPopup.IsOpen = true;
        }
Exemple #29
0
    /// <summary>
    /// Returns true is card is discarded
    /// </summary>
    public bool DiscardCard(CardButton card)
    {
        string cardName = CardParser.deparseCard(card.GetComponent <CardButton>().myCard);

        if (GameManager.instance.discardCard(cardName))
        {
            GameManager.instance.finishFinalTurn(card);

            GameManager.instance.myHand.Remove(card);
            CardPooler.instance.PushCard(card.gameObject);

            NotificationManager.instance.myTurn(false);
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #30
0
    public bool RemoveFromHand(CardButton card)
    {
        if (myCurrentHand.Contains(card))
        {
            myCurrentHand.Remove(card);
            return(true);
        }
        else
        {
            // they were first out
            if (myCurrentHand.Count == 0)
            {
                return(false);
            }

            Debug.LogWarning("Card " + card.name + " not found in hand copy.", card.gameObject);
            return(false);
        }
    }
Exemple #31
0
    /// <summary>
    /// Ends the current turn, if called by the player.
    /// </summary>
    public void EndTurn()
    {
        // Clears the selected card.
        selectedCard = null;
        canvasManager.cursor.ChangeCursor(0);

        // Checks whose turn to switch too.
        switch (currentTurn)
        {
            case Turn.Defender:
                attacker.ChangeTurn(true);
                defender.ChangeTurn(false);
                RollNewCard(currentTurn);
                canvasManager.EnableDecks(defender, false);
                canvasManager.EnableDecks(attacker, true);
                currentTurn = Turn.Attacker;
                currentPlayer = attacker;

                // Clears the cards that attacker has attacked with.
                foreach(CardButton button in attacker.attack)
                {
                    button.hasAttacked = false;
                }
                break;

            case Turn.Attacker:
                defender.ChangeTurn(true);
                attacker.ChangeTurn(false);
                RollNewCard(currentTurn);
                canvasManager.EnableDecks(defender, true);
                canvasManager.EnableDecks(attacker, false);
                currentTurn = Turn.Defender;
                currentPlayer = defender;

                // Clears the cards that defender has attacked with.
                foreach (CardButton button in defender.attack)
                {
                    button.hasAttacked = false;
                }
                break;
        }
    }
Exemple #32
0
    protected IEnumerator Select()
    {
        Region testRegion = new Region () {
            Left = (int)Input.mousePosition.x - DRAG_SIZE,
            Top = Screen.height - (int)Input.mousePosition.y - DRAG_SIZE,
            Width = DRAG_SIZE * 2,
            Height = DRAG_SIZE * 2
        };
        float startTime = DRAG_TIMER;

        while (true) {
            startTime -= Time.deltaTime;
            if (!Input.GetMouseButton(0)) {
                TargetingMode = TargetingMode.ClickTargeting;
                break;
            }
            if (testRegion.ContainsMouse() == null || startTime <= 0) {
                TargetingMode = TargetingMode.DragTargeting;
                break;
            }
            yield return 0;
        }

        bool cancel = false;
        while (
            (Input.GetMouseButton(0) && TargetingMode == TargetingMode.DragTargeting) ||
            (!Input.GetMouseButton(0) && TargetingMode == TargetingMode.ClickTargeting)
        ) {
            if (Input.GetMouseButton(1)) {
                cancel = true;
                break;
            }
            yield return 0;
            if (ActiveCard.TargetingType == TargetingType.All ||
                ClickRaycast.MouseOverThis(LeftSide)
            ) {
                ReticleController.Shown = false;
                Selected.SuspendDrag = false;
            } else {
                ReticleController.Shown = true;
                Selected.SuspendDrag = true;
            }
        }
        if (ClickRaycast.MouseOverThis(LeftSide)) {
            cancel = true;
        }
        foreach (SelectionRegion pickedRegion in Sprites
                 .Where(x => typeof(SelectionRegion).IsAssignableFrom(x.GetType()))
                 .Cast<SelectionRegion>()
                 .Where(x => x.ContainsMouse())
        ) {
            Target.SetTarget(pickedRegion);
            if (
                !cancel &&
                Selected.GetCard().Cost <= Morphid.LocalPlayer.Morphium &&
                ActiveCard.TargetableGuids != null &&
                ((ActiveCard.TargetableGuids.Contains(Target.GUID)) || ActiveCard.TargetingType != TargetingType.Single)
            ) {
                Morphid.PlayLocalCard(Selected.GetCard(), Target.GUID);
                break;
            }
        }
        Selected.SuspendDrag = false;
        ReticleController.Shown = false;
        TargetingMode = TargetingMode.Inactive;
        ActiveCard = null;
        Selected.OnDrop();
        Selected.Enabled = true;
        Selected = null;
    }