コード例 #1
0
    private IEnumerator SpawnCardEvent()
    {
        SelectCardInDeck(_poolGameCard);
        SelectCardInDeck(_poolCardArea);
        yield return(new WaitForSeconds(0.3f));

        var count       = 1;
        var arrayRarity = new[] { CardRarity.Common, CardRarity.Rare, CardRarity.Legendary };
        var rarity      = arrayRarity[RandomExtensions.GetRandomElementDictionary(DropChance.ChanceEvent)];

        foreach (var card in _poolCardEvent)
        {
            if (count > 3)
            {
                break;
            }
            if (card.activeSelf)
            {
                continue;
            }
            var cardDisplay = card.GetComponent <ActionsWithCards>();
            var randomCard  = _objectStorage.GetRandomCardByType(SubTypeCard.GameEvent, rarity);
            //var randomCard = _objectStorage.GetCardByName("random_event");
            cardDisplay.СhangeCardType(randomCard);
            cardDisplay.SetIdCard(count);
            cardDisplay.CardGame.DisplayCardInGame(card);
            cardDisplay.SetDependecies(_publisher, _animaManager);
            card.SetActive(true);
            _animaManager.SetStateAnimation(card, "dist_num", count);
            yield return(new WaitForSeconds(0.2f));

            ++count;
        }
    }
コード例 #2
0
    private IEnumerator GoNewEvent()
    {
        yield return(new WaitForSeconds(0.4f));

        var list = new List <GameEventName>()
        {
            GameEventName.GoStageAddCardSpell, GameEventName.GoStageAddCardConsumables
        };
        var newevent = list[RandomExtensions.GetRandomElementDictionary(DropChance.ChanceReward)];

        switch (newevent)
        {
        case GameEventName.GoStageAddCardSpell:
            _stageList.Add(GameEventName.GoStageAddCardSpell);
            _stageList.Add(GameEventName.GoSelectCardSpell);
            _stageList.Add(GameEventName.GoStageAddCardEvent);
            _stageList.Add(GameEventName.GoSelectCardEvent);
            _publisher.Publish(null, new CustomEventArgs(GameEventName.GoSetNextStage));
            Debug.Log("награда");
            break;

        case GameEventName.GoStageAddCardConsumables:
            _stageList.Add(GameEventName.GoStageAddCardConsumables);
            _stageList.Add(GameEventName.GoSelectCardConsumables);
            _stageList.Add(GameEventName.GoStageAddCardEvent);
            _stageList.Add(GameEventName.GoSelectCardEvent);
            _publisher.Publish(null, new CustomEventArgs(GameEventName.GoSetNextStage));
            Debug.Log("награда");
            break;
        }
    }
コード例 #3
0
    //---------------- раздача карт по типу
    private IEnumerator SpawnCardsByType(CardType type, DropChance typeDropChance, DropChance rarityDropChance, int count)
    {
        SelectCardInDeck(_poolGameCard);
        yield return(new WaitForSeconds(0.3f));

        SubTypeCard[] arrayType;
        var           arrayRarity = new[] { CardRarity.Common, CardRarity.Rare, CardRarity.Legendary };

        switch (type)
        {
        case CardType.Equipment:
            arrayType = new[] { SubTypeCard.Decoration };
            break;

        case CardType.Spell:
            arrayType = new[] { SubTypeCard.AttackingSpell, SubTypeCard.ImprovingSpell, SubTypeCard.CurseSpell };
            break;

        case CardType.Consumables:
            arrayType = new[] { SubTypeCard.Consumables };
            break;

        default:
            throw new UnityException("It is unknown CardType in SpawnCardsByType");
        }
        var typeCard = arrayType[RandomExtensions.GetRandomElementDictionary(typeDropChance)];
        var rarity   = arrayRarity[RandomExtensions.GetRandomElementDictionary(rarityDropChance)];
        var number   = 1;

        foreach (var card in _poolGameCard)
        {
            if (number > count)
            {
                break;
            }
            if (card.activeSelf)
            {
                continue;
            }
            var cardDisplay = card.GetComponent <ActionsWithCards>();
            var randomCard  = _objectStorage.GetRandomCardByType(typeCard, rarity);
            cardDisplay.СhangeCardType(randomCard);
            cardDisplay.SetIdCard(number);
            cardDisplay.CardGame.DisplayCardInGame(card);
            cardDisplay.SetDependecies(_publisher, _animaManager);
            card.SetActive(true);
            _animaManager.SetStateAnimation(card, "dist_num", number);
            yield return(new WaitForSeconds(0.2f));

            ++number;
        }
    }
コード例 #4
0
    private void OnClickButtonEvent(Adventure.Event @event)
    {
        var outcomes = @event.outcomes;
        var outcome  = outcomes.Count != 1 ? outcomes[RandomExtensions.GetRandomElementDictionary(DropChance.ChanceOutcome)] : outcomes[0];

        _stopDisplayDescription = true;
        _btnSkip.SetActive(false);
        _secondArt.sprite = outcome.art;
        _animaManager.SetStateAnimation(_popupEvent, "result", true);
        foreach (var btn in _poolButtons)
        {
            if (!btn.activeSelf)
            {
                continue;
            }
            var button = btn.GetComponent <Button>();
            button.onClick.RemoveAllListeners();
            btn.SetActive(false);
        }
        foreach (var btn in _poolButtons)
        {
            if (btn.activeSelf)
            {
                continue;
            }
            var child   = btn.GetComponentsInChildren <Transform>().SearchChild("Text");
            var btnText = child.GetComponent <TMP_Text>();
            btnText.text = "Продолжить";
            var button = btn.GetComponent <Button>();
            button.onClick.AddListener(OnClickButtonEndEvent);
            _configurateManager.ConfigurateByParent(btn, _panelButtons2, true);
            break;
        }
        _text             = outcome.description;
        _torenRewardEvent = outcome.reward;
        _coroutiner.StartCoroutine(DisplayDescription(outcome.description, 0.1f));
    }