Exemplo n.º 1
0
        private static void CorrectDeck2_AddItemToHand()
        {
            string cardname = "apollobow";

            CardManager.Card chosenCard = null;

            foreach (CardManager.Card card in Game.instance.currentDeck)
            {
                if (card.name.Equals(cardname))
                {
                    chosenCard = card;
                    break;
                }
            }

            foreach (CardManager.Card card in Game.instance.reserveDeck)
            {
                if (card.name.Equals(cardname))
                {
                    chosenCard = card;
                    break;
                }
            }



            if (chosenCard != null)
            {
                Game.instance.currentDeck.Remove(chosenCard);
                SameDistanceChildren distance = Visual.instance.TreasureHand.GetComponent <SameDistanceChildren>();
                int        emptySlotIndex     = distance.GetOccupiedSlotsNumber();
                GameObject treasureslot       = distance.slots[emptySlotIndex];
                OneCardManager.CreateOneCardManager(chosenCard, treasureslot);
            }
        }
        private IEnumerator Draw3CardsCoroutine()
        {
            List <OneCardManager> drawlist = new List <OneCardManager>();

            OneCardManager[]     deckcards = Visual.instance.CardDeckFrame.GetComponentsInChildren <OneCardManager>();
            SameDistanceChildren distance  = Visual.instance.CurrentEncounter.GetComponent <SameDistanceChildren>();
            int drawCardNumber             = 3;

            distance.CurrentEncounterSize = drawCardNumber;


            for (int i = 1; i <= drawCardNumber; i++)
            {
                if (deckcards.Length < i)
                {
                    break;
                }

                OneCardManager card = deckcards[deckcards.Length - (i)];
                drawlist.Add(card);
            }


            float TimeMovement1     = .6f;
            float TimeMovement2     = .4f;
            float SmallAmountOfTime = .05f;
            float DelayTime         = .3f;


            foreach (OneCardManager card in drawlist)
            {
                card.transform.SetParent(null);

                Sequence sequence = DOTween.Sequence();
                sequence.Append(card.transform.DOMove(Visual.instance.CardPoint.transform.position, TimeMovement1));
                sequence.Insert(0f, card.transform.DORotate(Vector3.zero, TimeMovement1));
                sequence.AppendInterval(DelayTime);
                int        index = drawlist.IndexOf(card);
                GameObject slot  = distance.slots[index];

                sequence.Append(card.transform.DOLocalMove(slot.transform.position, TimeMovement2));
                sequence.OnComplete(() => MoveCardToCurrentEncounterGroup(card, slot.transform));

                sequence.Play();
                yield return(new WaitForSeconds(DelayTime));
            }

            yield return(new WaitForSeconds(TimeMovement1 + TimeMovement2 + DelayTime));

            Command.CommandExecutionComplete();
        }
        private IEnumerator MoveTreasureToHandCoroutine()
        {
            List <OneCardManager> trList = new List <OneCardManager>();


            List <OneCardManager> curEnc = Visual.instance.GetCurrentEncounter();

            foreach (OneCardManager cardManager in curEnc)
            {
                if ((cardManager.cardAsset.type == CardType.treasure) && (cardManager.cardAsset.resolved == ResolvedType.resolved_win))
                {
                    trList.Add(cardManager);
                }
            }

            if (trList.Count == 0)
            {
                yield return(new WaitForSeconds(.05f));
            }
            else
            {
                SameDistanceChildren distance = Visual.instance.TreasureHand.GetComponent <SameDistanceChildren>();
                int emptySlotIndex            = distance.GetOccupiedSlotsNumber();

                foreach (OneCardManager cardManager in trList)
                {
                    cardManager.transform.SetParent(null);
                    Sequence   sequence = DOTween.Sequence();
                    GameObject slot     = distance.slots[emptySlotIndex];
                    emptySlotIndex++;
                    sequence.Append(cardManager.transform.DOMove(slot.transform.position, TimeMovement1));
                    sequence.OnComplete(() =>
                    {
                        MoveCardToCurrentEncounterGroup(cardManager, slot.transform);

                        if (cardManager.cardAsset.useType == UseType.continuous)
                        {
                            GameLogicEvents.eventNewEffect.Invoke(cardManager.cardAsset.effecttype);
                        }

                        //GameLogicEvents.eventNewEffect.Invoke(cardManager.cardAsset.effecttype);
                    });
                }
                yield return(new WaitForSeconds(TimeMovement1));
            }



            Command.CommandExecutionComplete();
        }
    private void ResetSlotRectTransform(SameDistanceChildren slots)
    {
        float backX;

        if (_resourceSprites.Count > 0)
        {
            backX = slots.children[0].GetComponent <RectTransform>().anchoredPosition.x - slots.children[_resourceSprites.Count - 1].GetComponent <RectTransform>().anchoredPosition.x;
        }
        else
        {
            backX = 0f;
        }

        RectTransform slotsRectTransform = slots.gameObject.GetComponent <RectTransform>();

        slotsRectTransform.anchoredPosition -= new Vector2(backX / 2, 0);
    }
    private void PlaceResourcesOnSlots()
    {
        SameDistanceChildren slots = resources.GetComponentInChildren <SameDistanceChildren>();
        int currentSlot            = 0;

        foreach (Sprite s in _resourceSprites)
        {
            Image currentSlotImage = slots.children[currentSlot].GetComponent <Image>();
            currentSlotImage.sprite = s;
            Color tempColor = currentSlotImage.color;
            tempColor.a            = 1;
            currentSlotImage.color = tempColor;
            currentSlot++;
        }

        UpdatePlacementOfSlots(slots);
    }
    private void ResetResourceSlots()
    {
        SameDistanceChildren slots = resources.GetComponentInChildren <SameDistanceChildren>();

        // move the Slots GameObject back to its origin.
        ResetSlotRectTransform(slots);
        // Clear the sprite list
        _resourceSprites.Clear();
        // reset the art
        foreach (Transform imageTransform in slots.children)
        {
            Image currentSlotImage = imageTransform.GetComponent <Image>();
            currentSlotImage.sprite = null;
            Color tempColor = currentSlotImage.color;
            tempColor.a            = 0;
            currentSlotImage.color = tempColor;
        }
    }
    // move Slots GameObject according to the number of resources
    private void UpdatePlacementOfSlots(SameDistanceChildren slots)
    {
        slots.setDistances();

        float posX;

        if (_resourceSprites.Count > 0)
        {
            posX = slots.children[0].GetComponent <RectTransform>().anchoredPosition.x - slots.children[_resourceSprites.Count - 1].GetComponent <RectTransform>().anchoredPosition.x;
        }
        else
        {
            posX = 0f;
        }

        RectTransform slotsRectTransform = slots.gameObject.GetComponent <RectTransform>();

        slotsRectTransform.anchoredPosition += new Vector2(posX / 2, 0);
    }
Exemplo n.º 8
0
    public void RemoveCardsFromTable()
    {
        // remove all cards in played area
        for (int i = 0; i < playerArea.monsterVisual.slots.Children.Length; i++)
        {
            SameDistanceChildren skillSlots = playerArea.monsterVisual.slots.Children[i].GetComponent <SameDistanceChildren>();
            for (int j = 0; j < skillSlots.Children.Length; j++)
            {
                new RemoveACardCommand(playerArea, i, j).AddToQueue();
            }
        }

        for (int i = 0; i < opponentArea.monsterVisual.slots.Children.Length; i++)
        {
            SameDistanceChildren skillSlots = playerArea.monsterVisual.slots.Children[i].GetComponent <SameDistanceChildren>();
            for (int j = 0; j < skillSlots.Children.Length; j++)
            {
                new RemoveACardCommand(opponentArea, i, j).AddToQueue();
            }
        }
    }
    private IEnumerator PrepareCardForNewGameCoroutine()
    {
        foreach (CardManager.Card card in Game.instance.currentDeck)
        {
            GameObject cardObject = OneCardManager.CreateOneCardManager(card, Visual.instance.CardDeckFrame);
            cardObject.transform.DORotate(new Vector3(0f, 179f, 0f), 0);
        }



        SameDistanceChildren distance = Visual.instance.CurrentEncounter.GetComponent <SameDistanceChildren>();

        foreach (CardManager.Card card in Game.instance.currentEncounter)
        {
            int        index      = Game.instance.currentEncounter.IndexOf(card);
            GameObject slot       = distance.slots[index];
            GameObject cardObject = OneCardManager.CreateOneCardManager(card, slot);
        }

        SameDistanceChildren treasureHand = Visual.instance.TreasureHand.GetComponent <SameDistanceChildren>();

        foreach (CardManager.Card card in Game.instance.TreasureHand)
        {
            int        index      = Game.instance.TreasureHand.IndexOf(card);
            GameObject slot       = treasureHand.slots[index];
            GameObject cardObject = OneCardManager.CreateOneCardManager(card, slot);
        }

        foreach (Effect effect in Game.instance.CardEffects)
        {
            GameObject effectActorObject = EffectActor.CreateNewEffectActor(effect);
        }

        yield return(new WaitForSeconds(.01f));

        GameLogicEvents.eventUpdateCurrentEncounter.Invoke();
        Command.CommandExecutionComplete();
    }