Пример #1
0
    private void OnDicePlacement(DiceHolder holder, AbilityCard card)
    {
        int diceAmount = 0;

        foreach (DiceHolder dh in _diceHolders)
        {
            if (dh.ContainedDice != null)
            {
                diceAmount++;
            }
        }
        if (diceAmount == _diceHolders.Length)
        {
            UseAbility(Fight);
            var dices = Fight.GetPlayerDice();
            foreach (DiceHolder dh in _diceHolders)
            {
                if (_hideDiceOnUse)
                {
                    dices.Remove(dh.ContainedDice);
                }
                dh.DeselectDice(_hideDiceOnUse);
            }
            CheckAvailable();
        }
    }
Пример #2
0
 public static void SetPlayerSlot(AbilityCard abilityCard, PlayerAbilitySlot.SlotType slotType = PlayerAbilitySlot.SlotType.Cycling)
 {
     if (mainHud != null)
     {
         mainHud.quickBar.SetQuickBarSlot(abilityCard, slotType);
     }
 }
Пример #3
0
    public bool UseCard(AbilityCard card)
    {
        SpawnPlayEffect spawnEffect = card.PlayEffect as SpawnPlayEffect;

        if (spawnEffect != null)
        {
            if (Creature)
            {
                return(false);
            }

            // this is hard to debug because card.Play()'s use of the play effect depends on CurrentTarget
            TargetController.CurrentTarget = GetComponent <ITargetable>();
            card.Play();
            return(true);
        }
        else
        {
            if (!Creature)
            {
                return(false);
            }
            TargetController.CurrentTarget = Creature.gameObject.GetComponent <ITargetable>();
            card.Play();
            return(true);
        }
    }
    void PlayTopCard()
    {
        LeanTween.scale(playCard, new Vector3(2, 2, 2), .5f).setLoopPingPong(1);
        playSound.Play();

        decidingnum = Random.Range(1, 10);
        AbilityCard targetCard = _playerHand.TopItem;

        targetCard.Play();
        //TODO consider expanding Remove to accept a deck position
        _playerHand.Remove(_playerHand.LastIndex);
        _abilityDiscard.Add(targetCard);
        Debug.Log("Card added to discard: " + targetCard.Name);

        if (decidingnum <= 7)
        {
            StartCoroutine(turnChange());
            myPlayer.TakeDamage(enemyDamage);
        }
        else
        {
            StartCoroutine(turnChange());
            _creature.EnemyHeal(healAMount);
        }
    }
Пример #5
0
 public void ClearQuickBarSlot(AbilityCard abilityCard, SlotType slotType = SlotType.Cycling)
 {
     //if (slotIndex > quickbarSlots.Count) {
     //    Debug.LogError("[PlayerQuickBar] index out of range. " + slotIndex + " is more than 4");
     //}
     GetSlotByCard(abilityCard, slotType).RemoveSlotAbility();
 }
    public void RemoveSlotAbility()
    {
        CurrentCard = null;
        recovery    = null;
        icon.sprite = parent.emptySlotImage;

        IsEmpty = true;
    }
Пример #7
0
    public void DiscardTopCard()
    {
        AbilityCard targetCard = _playerHand.TopItem;

        _playerHand.Remove(_playerHand.LastIndex);
        _abilityDiscard.Add(targetCard);
        Debug.Log("Card added to discard: " + targetCard.Name);
    }
Пример #8
0
    public static AbilityCard CreateCard(List <SpecialAbilityData> abilities, Entity owner, SlotType cardSlotType = SlotType.None, int itemID = -1)
    {
        //Debug.Log("Create Card is recieving " + abilities.Count + " abilities in the card factory");

        AbilityCard newCard = new AbilityCard(abilities, owner, cardSlotType, itemID);

        return(newCard);
    }
Пример #9
0
 void SetupPlayerCards(CardPlayer player)
 {
     for (int i = 0; i < player.Hand.Count; i++)
     {
         AbilityCard newCard = player.Hand.GetCard(i);
         _playerView.AddNewCard(newCard);
     }
 }
    // TODO I don't think it's best that this goes here, but I don't know a better way to organize it yet
    // TODO these if checks are kinda disgusting
    IEnumerator AbilityCardSelection(AbilityCard card, int index)
    {
        SelectedAbilityCard?.Invoke(card);
        if (_selectedAudio)
        {
            AudioHelper.PlayClip2D(_selectedAudio, 0.5f);
        }
        yield return(new WaitForEndOfFrame());

        while (true)
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit   = GetPointerRaycast();
                BoardSpace space = hit.collider?.GetComponent <BoardSpace>();
                if (space != null) // && hit.collider.gameObject.layer == LayerMask.NameToLayer("PlayerSpace"))
                {
                    if (!space.UseCard(card))
                    {
                        EndedSelection?.Invoke();
                        _abilityRoutine = null;
                        yield break;
                    }
                    Actions -= card.Cost;
                    Hand.Remove(index);
                    AbilityDiscard.Add(card);

                    RaiseActions(Actions);
                    RaiseDiscard(AbilityDiscard);
                    RaiseHand(Hand);
                    EndedSelection?.Invoke();

                    _abilityRoutine = null;
                    yield break;
                }
                else
                {
                    if (_clickFailAudio)
                    {
                        AudioHelper.PlayClip2D(_clickFailAudio, 0.5f);
                    }
                }
            }
            else if (Input.GetMouseButtonDown(1))
            {
                EndedSelection?.Invoke();
                if (_droppedAudio)
                {
                    AudioHelper.PlayClip2D(_droppedAudio, 0.5f);
                }
                _abilityRoutine = null;
                yield break;
            }

            yield return(null);
        }
    }
Пример #11
0
 public void Display(AbilityCard abilityCard)
 {
     _nameText.text = abilityCard.Name;
     //_costText.text = abilityCard.Cost.ToString();
     _graphicUI.sprite     = abilityCard.Graphic;
     _descriptionText.text = abilityCard.Description;
     _bgColor       = abilityCard.Color;
     _bgImage.color = _bgColor;
 }
Пример #12
0
    private void Draw()
    {
        AbilityCard newCard = _abilityDeck.Draw(DeckPosition.Top);

        Debug.Log("Drew card: " + newCard.Name);
        _playerHand.Add(newCard, DeckPosition.Top);

        _abilityCardView.Display(newCard);
    }
 private void SetupAbilityDeck()
 {
     foreach (AbilityCardData abilityData in _abilityDeckConfig)
     {
         AbilityCard newAbilityCard = new AbilityCard(abilityData);
         _abilityDeck.Add(newAbilityCard);
     }
     _abilityDeck.Shuffle();
 }
Пример #14
0
    public void AddNewCard(AbilityCard card)
    {
        AbilityCardView cardView = Instantiate(_cardViewPrefab, this.transform, false);

        _cardViews.Add(cardView);

        cardView.Setup(this, _deckStyleData);
        cardView.LoadNewCard(card);
    }
Пример #15
0
 public void Draw()
 {
     if (_playerHand.LastIndex < handMax)
     {
         AbilityCard newCard = _abilityDeck.Draw(DeckPosition.Top);
         Debug.Log("Drew card: " + newCard.Name);
         _playerHand.Add(newCard, DeckPosition.Top);
         // _abilityCardView.Display(newCard);
     }
 }
Пример #16
0
    public void PlayTopCard()
    {
        AbilityCard targetCard = _enemyHand.TopItem;

        targetCard.Play();
        //TODO consider expanding Remove to accept a deck position
        _enemyHand.Remove(_enemyHand.LastIndex);
        _enemyAbilityDiscard.Add(targetCard);
        Debug.Log("Card added to discard: " + targetCard.Name);
    }
Пример #17
0
 public void PlayCard(AbilityCard card, Controller2D.CollisionInfo colInfo, PlayerAbilitySlot.SlotType slotType = PlayerAbilitySlot.SlotType.Cycling)
 {
     if (card.Activate(colInfo))
     {
         if (slotType == PlayerAbilitySlot.SlotType.Cycling)
         {
             TransferCard(card, DeckType.Library);
         }
     }
 }
Пример #18
0
    public void Display(AbilityCard abilityCard)
    {
        //_button.onClick.AddListener(SelectCard);


        _nameTextUI.text  = abilityCard.Name;
        _costTextUI.text  = abilityCard.Cost.ToString();
        _graphicUI.sprite = abilityCard.Graphic;

        //_cardPosition.position = abilityCard.UIPosition;
    }
    public virtual void SetupAbilityDeck(List <AbilityCardData> abilityDeckConfig)
    {
        foreach (AbilityCardData abilityData in abilityDeckConfig)
        {
            AbilityCard newAbilityCard = new AbilityCard(abilityData);
            AbilityDeck.Add(newAbilityCard);
        }

        AbilityDeck.Shuffle();
        RaiseMain(AbilityDeck);
    }
Пример #20
0
    public void PlayAbilityCard(List <ITargetable> possibleTargets, int targetIndex)
    {
        AbilityCard targetCard = Hand.GetCard(targetIndex);

        //TODO figure out how to get possible targets
        //List<ITargetable> possibleTargets = ??
        //targetCard.Play(possibleTargets, CurrentTarget);
        // card should no longer exist in 'hand'
        Hand.Remove(targetIndex);
        // allow the next thing to grab it, if desired
        PlayedCard.Invoke(targetCard);
    }
    public override void PlayAbilityCard(int index)
    {
        AbilityCard targetCard = Hand.GetCard(index);

        if (targetCard != null && Actions > 0 && Actions >= targetCard.Cost)
        {
            if (_abilityRoutine == null)
            {
                _abilityRoutine = StartCoroutine(AbilityCardSelection(targetCard, index));
            }
        }
    }
Пример #22
0
    private void SetupAbilityDeck()
    {
        Debug.Log("Creating Ability Cards...");

        foreach (AbilityCardData abilityData in _abilityDeckConfig)
        {
            AbilityCard newAbilityCard = new AbilityCard(abilityData);
            _abilityDeck.Add(newAbilityCard);
        }

        _abilityDeck.Shuffle();
    }
Пример #23
0
    public void TransferCard(AbilityCard card, DeckType destination)
    {
        AbilityDeck targetDeck = deckManager.GetDeck(destination);

        if (targetDeck.IsDeckFull())
        {
            Debug.Log("Target Deck is Full");
            return;
        }

        TransferCard(card, targetDeck);
    }
Пример #24
0
    public void ReshuffleDiscarded()
    {
        for (int i = 0; i <= _abilityDiscard.LastIndex; i++)
        {
            AbilityCard targetCard = _abilityDiscard.TopItem;
            //TODO consider expanding REmove to accept a deck position
            _abilityDiscard.Remove(_abilityDiscard.LastIndex);
            _abilityDeck.Add(targetCard);
        }

        _abilityDeck.Shuffle();
        Debug.Log("Discard pile shuffled back into ability deck.");
    }
Пример #25
0
    public void SetSlotAbility(AbilityCard abilityCard)
    {
        this.CurrentCard = abilityCard;
        recovery         = abilityCard.abilities[0].Recovery;
        SetIcon();

        //Debug.Log("Adding a card to a slot");

        if (abilityCard != null)
        {
            IsEmpty = false;
        }
    }
    private void Draw()
    {
        AbilityCard newCard = _abilityDeck.Draw(DeckPosition.Top);

        //Instantiate(newCard, new Vector3(i * 2.0F, 0, 0), Quaternion.identity);
        Debug.Log("Drew card: " + newCard.Name);
        _playerHand.Add(newCard, DeckPosition.Top);

        //newCard._cardPosition = new Vector3();

        //_abilityCardView.Display(newCard);
        PrintPlayerHand();
    }
    void PlayTopCard()
    {
        AbilityCard targetCard = _playerHand.TopItem;

        targetCard.Play();
        //TODO consider expanding Remove to accept a deck position
        Destroy(_displayedHand[_playerHand.LastIndex]);
        _displayedHand.RemoveAt(_playerHand.LastIndex);
        _playerHand.Remove(_playerHand.LastIndex);

        _abilityDiscard.Add(targetCard);
        Debug.Log("Card added to discard: " + targetCard.Name);
    }
Пример #28
0
    private void CreateAblityCards()
    {
        int count = ItemData.itemCards.Count;

        for (int i = 0; i < count; i++)
        {
            AbilityCard card = CardFactory.CreateCard(ItemData.itemCards[i].abiliites, GameManager.GetPlayer(), ItemData.itemCards[i].cardSlotType, ItemID);

            //Debug.Log(ItemData.itemCards[i].abiliites.Count + " abilities found");

            abilityCards.Add(card);
        }
    }
Пример #29
0
        public void ApplyAbilityCardToUnit(AbilityCard card, Unit unit)
        {
            var ability        = (UnitAbility)card.Data;
            var removedAbility = unit.EquipAbility(ability);

            if (removedAbility != null)
            {
                GameState.PlayerCards.Add(new AbilityCard(removedAbility));
            }

            var gameUnit = Level.GameUnits.Single(x => x.Agent.OwnerContext.Id == unit.Id);

            AgentService.RefreshAgent(gameUnit.Agent);
        }
Пример #30
0
    void InitializeCards(RectTransform panel, List <Ability> abilities)
    {
        foreach (Ability _ability in abilities)
        {
            if (!AllAbilities.Contains(_ability))
            {
                AllAbilities.Add(_ability);
            }

            AbilityCard newCard = Instantiate(abilityCard, panel);
            newCard.InitializeCard(_ability);
            newCard.cardButton.onClick.AddListener(delegate { AddToSelectedAbilities(_ability); });
            newCard.cardButton.onClick.AddListener(delegate { OnLoadoutEdited(); });
        }
    }