Ejemplo n.º 1
0
    private void AddItemInventory(string name)
    {
        var gameClass = _player;
        var addCard   = _objectStorage.GetCardByName(name);
        var typeCard  = addCard.GetDataCard().TypeCard;

        if (typeCard == CardType.Spell && gameClass != addCard.GetDataCard().GameClass)
        {
            gameClass = addCard.GetDataCard().GameClass;
        }
        var list          = _inventoryPlayers[gameClass];
        var equpment      = _equpmentCardsPlayers[gameClass];
        var indexEqupment = equpment.IndexOf("");

        if (_autoequpment && indexEqupment != -1)
        {
            Debug.Log("аутоеквип!");
            if (typeCard == CardType.Spell)
            {
                equpment[indexEqupment] = name;
                if (gameClass == _player)
                {
                    SpawnItemEqupmentCard(indexEqupment);
                }
            }
            else
            {
                SerchAndEqupmentCard(name);
            }
        }
        else
        {
            var indexInventory = list.IndexOf("");
            if (indexInventory != -1)
            {
                list[indexInventory] = name;
                if (gameClass == _player)
                {
                    SpawnItemInventory(indexInventory);
                }
            }
            else
            {
                Debug.Log("инвентарь полон");
            }
        }
    }
Ejemplo n.º 2
0
    private IEnumerator GetCardsInHand()
    {
        _currentDeck = _inventoryManager.GetCardInDeck();
        _currentDeck = RandomExtensions.Shuffle(_currentDeck);
        yield return(new WaitForSeconds(2f));

        _currentCardsInHand = 0;
        var list = _currentDeck.GetRange(0, _currentDeck.Count);

        foreach (var card in list)
        {
            foreach (var cardPlayer in _poolCardsPlayer)
            {
                if (cardPlayer.activeSelf)
                {
                    continue;
                }
                foreach (Transform child in cardPlayer.transform)
                {
                    child.gameObject.SetActive(true);
                }
                var cardDisplay = cardPlayer.GetComponent <ActionsWithCards>();
                var cardByName  = _objectStorage.GetCardByName(card);
                cardDisplay.СhangeCardType(cardByName);
                cardDisplay.SetIdCard(_currentCardsInHand);
                cardDisplay.CardGame.DisplayCardInGame(cardPlayer);
                cardDisplay.SetDependecies(_publisher, _animaManager);
                cardDisplay.enabled = false;
                var component = cardPlayer.GetComponent <DraggableCard>();
                component.SetDependecies(_pointStopDrag, _pointReturnCard, _targetManager);
                cardPlayer.SetActive(true);
                _configurateManager.ConfigurateCardByBattle(cardPlayer);
                _animaManager.SetStateAnimation(cardPlayer, "go_hand", true);
                _currentCardsInHand++;
                _coroutiner.StartCoroutine(SwithParentCard(cardPlayer));
                _currentDeck.Remove(card);
                yield return(new WaitForSeconds(0.2f));

                break;
            }
            if (_currentCardsInHand == _maxCardsInHand)
            {
                break;
            }
        }
    }
Ejemplo n.º 3
0
    private IEnumerator PreparationStageBattle()
    {
        ReturnCardEvent();
        yield return(new WaitForSeconds(0.4f));

        foreach (var element in _poolCardArea)
        {
            if (!element.activeSelf)
            {
                continue;
            }
            _animaManager.SetStateAnimation(element, "stage_battle", true);
        }
        _publisher.Publish(null, new CustomEventArgs(GameEventName.GoSetNextStage));
        yield return(new WaitForSeconds(0.4f));

        var spawnUnits = _selectedCardUnit.GetDataCard().SpawnUnits;
        var count      = 1;

        foreach (var nameSpawnUnit in spawnUnits)
        {
            foreach (var card in _poolCardBattleUnit)
            {
                if (card.activeSelf)
                {
                    continue;
                }
                var cardDisplay = card.GetComponent <ActionsWithCards>();
                var cardByName  = _objectStorage.GetCardByName(nameSpawnUnit);
                cardDisplay.СhangeCardType(cardByName);
                cardDisplay.SetIdCard(count);
                cardDisplay.CardGame.DisplayCardInGame(card);
                cardDisplay.SetDependecies(_publisher, _animaManager);
                cardDisplay.enabled = false;
                card.SetActive(true);
                _publisher.Publish(null, new CustomEventArgs(GameEventName.SpawnEnemy, card));
                _animaManager.SetStateAnimation(card, "stage_battle", true);
                break;
            }
            count++;
        }
    }
Ejemplo n.º 4
0
 public override void Activate()
 {
     SetDependecies(LoadManager.LogicManager);
     if (_saveManager.CheckLoad())
     {
         //TODO Continue game
         Debug.Log("Continue");
     }
     else
     {   //-------------стадия начало игры
         CreateDependecies();
         // TODO пофиксить
         var gameclass = _objectStorage.GetCardByName("Purple") as CardsGameClass;
         _publisher.Publish(this, new CustomEventArgs(GameEventName.GoSaveGameClass, gameclass));
     }
 }