Наследование: MonoBehaviour
Пример #1
0
 public void SetEndPointAndCardSlot(Card card, CardSlot cardSlot)
 {
     endPoint       = cardSlot.GetComponent <RectTransform>().localPosition;
     futureCardSlot = cardSlot;
     flyingCard.SetCard(card);
     cardSlot.SetCardFly(this);
 }
Пример #2
0
    private CardSlot CardUnderMouse()
    {
        Vector3 cameraPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 mousePosition  = new Vector2(cameraPosition.x, cameraPosition.y);

        RaycastHit2D[] hit             = Physics2D.RaycastAll(mousePosition, Vector2.zero);
        CardSlot       closestCardSlot = null;
        int            sortOrder       = int.MinValue;

        for (int i = 0; i < hit.Length; i++)
        {
            SpriteRenderer layer    = hit[i].transform.GetComponent <SpriteRenderer>();
            CardSlot       cardSlot = hit[i].transform.GetComponent <CardSlot>();

            if (hit[i].collider != null &&
                cardSlot != null &&
                layer != null &&
                sortOrder < layer.sortingOrder)
            {
                sortOrder       = layer.sortingOrder;
                closestCardSlot = cardSlot;
            }
        }
        return(closestCardSlot);
    }
    public void ModifyDeck(Deck userDeck)
    {
        deckBuilderCreationUI.SetActiveStatusPanel();
        deckBuilderCreationManager.ModifyDeck(userDeck);
        deckBuilderUserDeckUI.ClearUserDeckDisplay();
        btnSave.onClick.RemoveAllListeners();
        btnSave.onClick.AddListener(Modify);
        nameInputFiled.text = userDeck.name;
        gameMenuManager.LoadVisualDeckBuilder();
        Dictionary <CardData, CardDisplaySlot> cardSlotUIDisplay;

        cardSlotUIDisplay = cardCollectionVisualManager.GetCardDisplaySlotDictionary();
        for (int i = 0; i < userDeck.userDeck.Count; i++)
        {
            var item = userDeck.userDeck.ElementAt(i);
            for (int j = 0; j < cardSlotUIDisplay.Count; j++)
            {
                var itnDis = cardSlotUIDisplay.ElementAt(j);
                if (item.Key.ID == itnDis.Key.ID)
                {
                    CardSlotUI cSlot = cardSlotUIDisplay[itnDis.Key].cardSlotUI;
                    CardSlot   slot  = cSlot.cardSlot;
                    slot.AddDeckAmount(item.Value.Amount);
                    //cSlot.ChangeSlotData();
                    RibbonData ribbonData = new RibbonData(item.Key.CardName, item.Value.Amount, item.Key, cSlot);
                    ribbonManager.AddRibbon(ribbonData, deckBuilderCreationManager);
                    break;
                }
            }
        }
        cardCollectionSearchManager.ClearAllFiltters();
    }
Пример #4
0
 void AssignSlot(CardSlot newSlot)
 {
     fieldSlot          = newSlot;
     transform.position = fieldSlot.transform.position;
     transform.SetParent(fieldSlot.transform);
     fieldSlot.filled = true;
 }
Пример #5
0
    public void BindCards(Deck deck)
    {
        var cards = deck.GetCards();

        for (int i = 0; i < cards.Count; i++)
        {
            GameObject newCardObject = Instantiate(cardPrefab, cardSlotsInitial[i].CardObject.transform.position, transform.rotation) as GameObject;
            if (cardSlots[i] != null)
            {
                Destroy(cardSlots[i].CardObject);
            }

            cardSlots[i]      = new CardSlot(newCardObject);
            cardSlots[i].Card = cards[i];

            newCardObject.transform.parent   = this.transform;
            newCardObject.transform.position = cardSlotsInitial[i].CardObject.transform.position;
            SpriteRenderer newSpriteRenderer = newCardObject.GetComponent <SpriteRenderer>();
            if (i < 7)
            {
                newSpriteRenderer.sortingOrder = i + 8;
            }
            else
            {
                newSpriteRenderer.sortingOrder = i - 5;
            }
            UICard newCard = newCardObject.GetComponent <UICard>();
            newCard.BindCard(cards[i]);
        }
    }
Пример #6
0
    public void DrawCard()
    {
        int nextID = deck.DrawCard();

        CardSlot nextSlot = null;

        foreach (CardSlot slot in cardSlots)
        {
            if (slot.card == null)
            {
                nextSlot = slot;
                break;
            }
        }
        if (nextSlot == null)
        {
            return;
        }

        Card card = Instantiate(cardPrefab, deck.transform.position, Quaternion.identity);

        card.SetID(nextID);

        nextSlot.AssignCard(card);

        cards.Add(card);
    }
Пример #7
0
        public void ReDo()
        {
            ClickableToRemove = new List <IClickable>();
            Clickable.ForEach(p =>
            {
                if (p is Card || p is CardSlot)
                {
                    ClickableToRemove.Add(p);
                }
            });
            ClickableToRemove.ForEach(p => Clickable.Remove(p));
            grid.RemoveChildren();
            slots = new List <CardSlot>();
            for (int row = 0; row < 3; row++)
            {
                for (int column = 0; column < 5; column++)
                {
                    CardSlot c = new CardSlot(CardWidth, CardHeight, Game1.self.GraphicsDevice, Gui);
                    grid.AddChild(c, row, column);
                    c.clickEvent += CardSlotClick;
                    slots.Add(c);
                    Clickable.Add(c);
                }
            }
            var autoEvent = new AutoResetEvent(false);

            time  = 0;
            timer = new Timer(timerStart, autoEvent, 0, 1000);
            grid.UpdateP();
        }
Пример #8
0
 private void SyncCardWithSlot(ref List <CharacterCard> targetCardList, ref List <CardSlot> cardSlotList)
 {
     for (int i = 0; i < targetCardList.Count; ++i)
     {
         CharacterCard targetCardObject = targetCardList[i];
         for (int j = 0; j < cardSlotList.Count; ++j)
         {
             int      rowOfSlot      = (j / 2) + 1;
             CardSlot cardSlotObject = cardSlotList[j];
             if (cardSlotObject.SlotObject == null)
             {
                 targetCardObject.transform.position = cardSlotObject.SlotPosition;
                 cardSlotObject.SlotObject           = targetCardObject;
                 break;
             }
             else
             {
                 if (targetCardObject == cardSlotObject.SlotObject)
                 {
                     targetCardObject.transform.position = cardSlotObject.SlotPosition;
                     break;
                 }
             }
         }
     }
 }
        public void CardSlotClick(object sender)
        {
            CardSlot c = (CardSlot)sender;

            if (CurrentCard != null && LineDifference(CurrentCard.line, c.line) == 1 && CurrentCard.CanMove)
            {
                if (CurrentCard.Parent == yourGrid)
                {
                    CurrentCard.CanMove = false;
                    CurrentCard.Status  = Card.status.hasMove;
                    ShipPosition origin = getShipPosition(CurrentCard.GetShip());
                    move.MoveList.Add(new Tuple <ShipPosition, Line>(origin, c.line));
                    c.Active = false;
                    SetSlots(false);
                    if (!readyToSend)
                    {
                        defendingShips.Remove(CurrentCard.GetShip());
                    }
                    LastCard    = null;
                    CurrentCard = null;
                }
            }

            UpdateButtonNull();
        }
Пример #10
0
 void PlaceCardInSlot(CardObject card, CardSlot slot)
 {
     card._slot = slot;
     slot._card = card;
     card.transform.SetParent(slot.transform);
     card.transform.localPosition = Vector3.zero;
 }
Пример #11
0
    CardSlot MakeSlot(string name)
    {
        CardSlot s = Instantiate(_gameManager._prefabCardSlot, _tray.transform);

        s.SetTray(this, name);
        return(s);
    }
Пример #12
0
        public virtual Card GetSlotCard(CardSlot slotNumber)
        {
            Card card = null;

            switch (slotNumber)
            {
            case CardSlot.NertzPile:
                card = GetNertzTopCard();
                break;

            case CardSlot.SlotOne:
                card = nertzHand.CardSlot1;
                break;

            case CardSlot.SlotTwo:
                card = nertzHand.CardSlot2;
                break;

            case CardSlot.SlotThree:
                card = nertzHand.CardSlot3;
                break;

            case CardSlot.SlotFour:
                card = nertzHand.CardSlot4;
                break;
            }
            return(card);
        }
Пример #13
0
 public void highlightSlot(CardSlot cs)
 {
     slotHighlight.transform.position = cs.getPosition();
     slotHighlight.transform.rotation = new Quaternion(0, 0, 0, 0);
     slotHighlight.transform.Rotate(90, 0, 0);
     slotHighlight.SetActive(true);
 }
Пример #14
0
        public void CardSlotClick(object sender)
        {
            CardSlot c = (CardSlot)sender;

            if (CurrentCard != null)
            {
                if (c.Card == null)
                {
                    cardsGrid.RemoveChild(CurrentCard);
                    CurrentCard.Status = Card.status.clear;
                    var list = slots.Where(p => p.Card == CurrentCard).ToList();
                    if (list.Count > 0)
                    {
                        slots.Where(p => p.Card == CurrentCard).ToList().ForEach(p => { p.RemoveCard(); });
                    }

                    c.SetCard(CurrentCard);
                    slots.ForEach(p => p.CardClicked = false);
                    CurrentCard = null;
                }
            }
            else
            {
                if (c.HasCard)
                {
                    c.Card.OnClick();
                }
            }
        }
Пример #15
0
        public void ShouldSetCardInsertedToFalse()
        {
            Display  display  = new Display();
            Keypad   keypad   = new Keypad();
            CardSlot cardSlot = new CardSlot(display, keypad);

            Assert.AreEqual(false, cardSlot.cardInserted);
        }
Пример #16
0
 // Use this for initialization
 void Start()
 {
     _slot = GetComponentInChildren <CardSlot>();
     _slot.GetComponent <CanvasGroup>().blocksRaycasts = false;
     _slot.GetComponent <CanvasGroup>().interactable   = false;
     _finished = false;
     _animator = GetComponent <Animator>();
 }
Пример #17
0
    public void DispayCardInTray(CardData c)
    {
        CardSlot   targetSlot = GetFirstFreeCardSlot();
        CardObject cardObject = Instantiate(_gameManager._prefabCard, targetSlot.transform);

        targetSlot._card = cardObject;
        cardObject.SetCard(_gameManager, c, targetSlot);
    }
Пример #18
0
    public void addTempCard(CardSlot cs)
    {
        playerBoard.addCard(tempCard.GetComponent <Card>(), cs);
        GameObject tmp = Instantiate(cs.getCard().gameObject, cs.getPosition(), cs.getCard().gameObject.transform.rotation);

        tmp.transform.SetParent(boardCanvas.gameObject.transform);
        tmp.transform.Rotate(90, 0, 0);
    }
 private void OnTriggerStay2D(Collider2D collision)
 {
     if (!currentCardDisplay.OnSlot && collision.tag == "CardSlot" && collision.GetComponent <CardSlot>().CanPutCard(currentCardDisplay))
     {
         nearestCardSlot = collision.GetComponent <CardSlot>();
         nearestCardSlot.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 100f / 255);
     }
 }
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.tag == "CardSlot" && nearestCardSlot != null && collision.GetComponent <CardSlot>() == nearestCardSlot)
     {
         nearestCardSlot.GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 15f / 255);
         nearestCardSlot = null;
     }
 }
Пример #21
0
 public void SetCard(GameManager gameManager, CardData data, CardSlot slot)
 {
     _gameManager = gameManager;
     _data        = data;
     _slot        = slot;
     UpdateCard();
     UpdateAbilityUi();
 }
Пример #22
0
    protected override void UpdateTriadPlayer()
    {
        CardSlot cardSlot = CardUnderMouse();

        HoveringOverCard(cardSlot);
        CardDropped(cardSlot);
        DraggingCard();
    }
Пример #23
0
 private void HoveringOverCard(CardSlot slot)
 {
     if (slot != null &&
         slot != currentCardSlot &&
         !draggingCard)
     {
         UpdateCardHover(slot);
     }
 }
Пример #24
0
    void FlipCardSlotDown(CardSlot mCardSlot)
    {
        float      y   = mCardSlot.GetComponent <Transform>().rotation.eulerAngles.y;
        float      z   = mCardSlot.GetComponent <Transform>().rotation.eulerAngles.z;
        Quaternion rot = transform.localRotation;

        rot.eulerAngles = new Vector3(-90f, y, z);
        mCardSlot.GetComponent <Transform> ().rotation = rot;
    }
Пример #25
0
 private void UpdateCardHover(CardSlot newCard)
 {
     if (currentCardSlot != null)
     {
         currentCardSlot.GetComponent <CardSlot>().ReturnCardToSlot();
     }
     newCard.GetComponent <CardSlot>().HoverCardInSlot();
     currentCardSlot = newCard;
 }
    public CardSlotUI CreateCardSlotUI(int libraryAmount, int deckAmount, int totalAmountPerDeck)
    {
        CardSlot   cardSlot         = new CardSlot(libraryAmount, deckAmount, totalAmountPerDeck);
        GameObject cardSlotUIPrefab = GameObject.Instantiate(cardSlotPrefab, cardLibraryTransform);
        CardSlotUI cardSlotUI       = cardSlotUIPrefab.GetComponent <CardSlotUI>();

        cardSlotUI.InitializeCardSlot(cardSlot);
        return(cardSlotUI);
    }
Пример #27
0
    //Move all cards in a slot to another slot
    private void MoveCardSlotToCardSlot(CardSlot sourceCardSlot, CardSlot targetCardSlot)
    {
        Card card;

        while ((card = sourceCardSlot.TopCard()) != null)
        {
            targetCardSlot.AddCard(card);
        }
    }
Пример #28
0
 private void CardDropped(CardSlot slot)
 {
     if (slot == null &&
         currentCardSlot != null &&
         !draggingCard)
     {
         currentCardSlot.ReturnCardToSlot();
         currentCardSlot = null;
     }
 }
Пример #29
0
    void SwapCards(CardObject cardToSwap)
    {
        if (cardToSwap._locked || _card._locked) return;

        CardSlot swapToSlot = cardToSwap._slot;
        CardSlot currentSlot = _card._slot;
        PlaceCardInSlot(cardToSwap, currentSlot);
        PlaceCardInSlot(_card, swapToSlot);
        DeselectCard(_card);
    }
Пример #30
0
 private IEnumerator StackCardRangeOnSlot(int start, int end, CardSlot cardSlot)
 {
     DealInProgress++;
     for (int i = start; i < end; ++i)
     {
         cardSlot.AddCard(_cardDeck.CardList[i]);
         yield return(new WaitForSeconds(CardStackDelay));
     }
     DealInProgress--;
 }
Пример #31
0
 public static bool cardIsType(CardSlot card, int typeID)
 {
      int counter = 0;
      while (counter < card.template.typeFlags.Count)
      {
           if (card.template.typeFlags[counter] == typeID)
           {
                return true;
           }
           ++counter;
      }
      return false;
 }
Пример #32
0
 //TO DO more types
 public static int getLocation(CardSlot card)
 {
      bool row_modifier = false;
      foreach (int type in card.template.typeFlags)
      {
           if (type == CardType_Row_Modifier)
           {
                row_modifier = true;
                continue;
           }
      }
      foreach (int type in card.template.typeFlags)
      {
           if (row_modifier)
           {
                if (type == CardType_Melee)
                {
                     return CARD_LIST_LOC_MELEEMODIFIERS;
                }
                else if (type == CardType_Ranged)
                {
                     return CARD_LIST_LOC_RANGEDMODIFIERS;
                }
                else if (type == CardType_Siege)
                {
                     return CARD_LIST_LOC_SEIGEMODIFIERS;
                }
           }
           else
           {
                if (type == CardType_Melee)
                {
                     return CARD_LIST_LOC_MELEE;
                }
                else if (type == CardType_Ranged)
                {
                     return CARD_LIST_LOC_RANGED;
                }
                else if (type == CardType_Siege)
                {
                     return CARD_LIST_LOC_SEIGE;
                }
           }
      }
      return CardType_None;
 }
Пример #33
0
 public static bool cardHasEffect(CardSlot card, int effectID)
 {
      int counter = 0;
      while (counter < card.template.effectFlags.Count)
      {
           if (card.template.effectFlags[counter] == effectID)
           {
                return true;
           }
           ++counter;
      }
      return false;
 }
Пример #34
0
          public static int getPowerChange(CardSlot card)
          {
               //TO DO implement more power changes, 
               //currently Row Modifiers and Weather only

               int power = card.template.power;
               int playerID = PLAYER_INVALID;
               //check if spy
               if (cardHasEffect(card, CardEffect_Draw2))
               {
                    if (card.owningPlayer == PLAYER_1)
                    {
                         playerID = PLAYER_2;
                    }
                    else if (card.owningPlayer == PLAYER_2)
                    {
                         playerID = PLAYER_1;
                    }
               }
               else
               {
                    playerID = card.owningPlayer;
               }

               //check for modifiers for player 1
               if (playerID == PLAYER_1)
               {
                    if (cardIsType(card, CardType_Melee))
                    {
                         if (MainWindow_ViewModel.mSingleton.P1MeleeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
                    if (cardIsType(card, CardType_Ranged))
                    {
                         if (MainWindow_ViewModel.mSingleton.P1RangeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
                    if (cardIsType(card, CardType_Siege))
                    {
                         if (MainWindow_ViewModel.mSingleton.P1SiegeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
               }

               //check for modifiers for player 2
               if (playerID == PLAYER_2)
               {
                    if (cardIsType(card, CardType_Melee))
                    {
                         if (MainWindow_ViewModel.mSingleton.P2MeleeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
                    if (cardIsType(card, CardType_Ranged))
                    {
                         if (MainWindow_ViewModel.mSingleton.P2RangeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
                    if (cardIsType(card, CardType_Siege))
                    {
                         if (MainWindow_ViewModel.mSingleton.P2SiegeModifHolder.Count > 0)
                         {
                              power = power * 2;
                         }
                    }
               }

               //Check for weather modifiers
               if (MainWindow_ViewModel.mSingleton.WeatherHolder.Count > 0)
               {
                    foreach (CardSlot weather in MainWindow_ViewModel.mSingleton.WeatherHolder)
                    {
                         if ( cardIsType(weather, CardType_Melee) &&
                              cardIsType(card, CardType_Melee))
                         {
                              power = 1;
                              return power;
                         }
                         if (cardIsType(weather, CardType_Ranged) &&
                              cardIsType(card, CardType_Ranged))
                         {
                              power = 1;
                              return power;
                         }
                         if (cardIsType(weather, CardType_Siege) &&
                              cardIsType(card, CardType_Siege))
                         {
                              power = 1;
                              return power;
                         }
                    }
               }

               return power;
          }