//-------------- очищаем слоты инвентаря private void ClearInventory() { foreach (Transform child in _holderCards.transform) { if (child.transform.childCount <= 0) { continue; } _coroutiner.StartCoroutine(_objectStorage.ReturnInPool(ObjectTypeEnum.PrefabCardInInventory, child.transform.GetChild(0).gameObject, 0.1f)); var component = child.GetComponent <ActionsWithSlotInventory>(); component.SetVarsSlot(true, false); } foreach (Transform child in _holderInventory.transform) { if (child.transform.childCount <= 0) { continue; } _coroutiner.StartCoroutine(_objectStorage.ReturnInPool(ObjectTypeEnum.PrefabCardInInventory, child.transform.GetChild(0).gameObject, 0.1f)); var component = child.GetComponent <ActionsWithSlotInventory>(); component.SetVarsSlot(true, false); } }
public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.SpawnEnemy: { var enemy = messageData.Value as GameObject; _listEnemys.Add(enemy); _coroutiner.StartCoroutine(SwitchParent(enemy, 0.6f)); break; } case GameEventName.GoEndTurnPlayer: { _coroutiner.StartCoroutine(EnemyTurn()); break; } case GameEventName.GoDeadEnemy: { var gameObject = messageData.Value as GameObject; _listEnemys.Remove(gameObject); _animaManager.SetStateAnimation(gameObject, "dead", true); if (_listEnemys.Count == 0) { _publisher.Publish(null, new CustomEventArgs(GameEventName.GoFinishBattle)); } break; } } }
public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoOpenPopupWithDescriptionCard: { var card = messageData.Value as ICard; _fullDescription.text = card.GetDataCard().FullDescription; _popupDescription.transform.SetAsLastSibling(); _popupDescription.SetActive(true); _coroutiner.StartCoroutine(ViewDescriptionCard(0.6f)); break; } case GameEventName.GoOpenPopupNoDescription: _popupDescription.transform.SetAsLastSibling(); _popupDescription.SetActive(true); break; case GameEventName.GoClosePopupDescriptionCard: _animaManager.SetStateAnimation(_popupDescription, "popupCard", false); _coroutiner.StartCoroutine(ClosePopup(0.5f)); break; //case GameEventName.GoStartEvent: // _popupDescription.SetActive(false); // break; } }
private void DisplayEvent() { _firstPause = 0.04f; _secondPause = 0.4f; var data = _adventure.GetDataEvent(); _title.text = data.NameEvent; _text = data.Description; _coroutiner.StartCoroutine(DisplayDescription(data.Description, 0.5f)); _firstArt.sprite = data.Art; var events = data.Events; var count = 1; foreach (var @event in events) { foreach (var btn in _poolButtons) { if (btn.activeSelf) { continue; } var child = btn.GetComponentsInChildren <Transform>().SearchChild("Text"); var btnText = child.GetComponent <TMP_Text>(); btnText.text = @event.label; var button = btn.GetComponent <Button>(); button.onClick.AddListener(delegate { OnClickButtonEvent(@event); }); _configurateManager.ConfigurateByParent(btn, count <= 2 ? _panelButtons1 : _panelButtons2, true); count++; break; } } var component = _btnSkip.GetComponent <Button>(); component.onClick.AddListener(OnClickButtonSkip); }
public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoStageBattle: _coroutiner.StartCoroutine(GoStageBattle()); break; case GameEventName.GoFinishBattle: _membership = Membership.Undefined; _animaManager.SetStateAnimation(_hud, "battle", false); _btnEscapeBattle.SetActive(false); _btnEndTurn.SetActive(false); _iconСounterCardPlay.SetActive(false); break; case GameEventName.GoSaveGameClass: _saveManager.SaveClass(messageData.Value as CardsGameClass); break; case GameEventName.GoNextTurn: { if (_membership == Membership.Undefined) { _membership = Membership.Player; } else { _membership = _membership == Membership.Player ? Membership.Enemy : Membership.Player; _messageText.text = _membership == Membership.Player ? "Your turn" : "Enemy turn"; _popupText.transform.SetAsLastSibling(); _animaManager.SetStateAnimation(_popupText, "startturn", true); _coroutiner.StartCoroutine(GoClosePopupText()); } return; } case GameEventName.GoStageRandomEvent: Debug.Log("GoStageRandomEvent"); _popupFade.transform.SetAsLastSibling(); _popupFade.SetActive(true); _animaManager.SetStateAnimation(_hud, "faiding", true); break; case GameEventName.GoRewardEvent: _popupFade.transform.SetAsLastSibling(); _popupFade.SetActive(true); _animaManager.SetStateAnimation(_hud, "faiding", false); _coroutiner.StartCoroutine(GoClosePopupFade(1f)); break; } }
private void SpawnAlly(GameObject ally) { _listAllies.Add(ally); var componentEnemy = ally.GetComponent <ActionsWithCards>(); var child = ally.GetComponentsInChildren <Transform>().SearchChild("Hp"); var componentText = child.GetComponent <TextMeshProUGUI>(); _hpAlliesText[ally] = componentText; child = ally.GetComponentsInChildren <Transform>().SearchChild("Damage"); componentText = child.GetComponent <TextMeshProUGUI>(); _damageAlliesText[ally] = componentText; var attribute = componentEnemy.CardGame.GetDataCard().AttributeUnit; var hp = attribute[0]; var damage = attribute[1]; _curAndMaxHpAllies[ally] = new List <int>() { hp.value, hp.value }; _curAndMaxDamageAllies[ally] = new List <int>() { damage.value, damage.value }; InitBarsAlly(ally); _coroutiner.StartCoroutine(SwitchParent(ally, 0.6f)); }
//----------------- events public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoSelectCardEnemy: { _coroutiner.StartCoroutine(GetCardsInHand()); break; } case GameEventName.GoEndTurnPlayer: foreach (var card in _poolCardsPlayer) { var component = card.GetComponent <DraggableCard>(); component.enabled = false; if (_currentDeck.Count != 0) { continue; } _currentDeck = _discardCards.GetRange(0, _discardCards.Count); _discardCards.Clear(); } break; case GameEventName.GoEndTurnEnemy: _coroutiner.StartCoroutine(ActivateDraggableCard(1.2f)); if (_currentCardsInHand <= 4) { _coroutiner.StartCoroutine(GetCardsInHand(2, 0.5f)); } else if ((6 - _currentCardsInHand) > 0) { _coroutiner.StartCoroutine(GetCardsInHand(1, 0.5f)); } break; case GameEventName.GoPlayerTurn: _coroutiner.StartCoroutine(ActivateDraggableCard(0.6f)); break; case GameEventName.ActivateCardPlayer: var activateCard = messageData.Value as ICard; _discardCards.Add(activateCard.GetDataCard().NameCard); _currentCardsInHand--; break; case GameEventName.GoFinishBattle: FinishBattle(); break; } }
private void PlayMusic(string nameAudio) { var clip = _objectStorage.GetAudioByName(nameAudio); // _musicSource1.Play (); if (_crossFading) { return; } _coroutiner.StartCoroutine(CrossFadeMusic(clip)); // При изменении музыкальной композиции вызываем сопрограмму. }
//------------------- события public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoStageStartNewGame: _stageList = new List <GameEventName> { GameEventName.GoStageAddCardSpell, GameEventName.GoSelectCardSpell, GameEventName.GoStageAddCardConsumables, GameEventName.GoSelectCardConsumables, //GameEventName.GoStageAddCardArea, //GameEventName.GoSelectCardArea, GameEventName.GoStageAddCardEvent, GameEventName.GoSelectCardEvent }; break; case GameEventName.GoSetNextStage: { var value = messageData.Value as ICard; if (value != null && value.GetDataCard().TypeCard == CardType.GameEvent) { AddEventInStageList(value); } _publisher.Publish(null, new CustomEventArgs(_stageList[0])); _stageList.RemoveAt(0); break; } case GameEventName.GoFinishBattle: { _coroutiner.StartCoroutine(GoNewEvent()); break; } case GameEventName.GoFinishStageEvent: { Debug.Log("finish event"); _stageList.Add(GameEventName.GoStageAddCardEvent); _stageList.Add(GameEventName.GoSelectCardEvent); _publisher.Publish(null, new CustomEventArgs(GameEventName.GoSetNextStage)); break; } } }
public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoRewardEvent: _buttonContinue.interactable = false; _popupReward.transform.SetAsLastSibling(); _popupReward.SetActive(true); var reward = messageData.Value as List <TokenRewardEnum>; _coroutiner.StartCoroutine(DisplayTokensReward(1f, reward)); break; case GameEventName.GoClosePopupReward: _popupReward.SetActive(false); _publisher.Publish(null, new CustomEventArgs(GameEventName.GoUseAutoReward, _tokensReward)); _publisher.Publish(null, new CustomEventArgs(GameEventName.GoFinishStageEvent)); break; case GameEventName.GoSelectTokenReward: { _popupReward.GetComponent <Image>().raycastTarget = false; _closePanel.SetActive(false); break; } case GameEventName.GoDeActivateTargetsPlayer: { _popupReward.GetComponent <Image>().raycastTarget = true; _closePanel.SetActive(true); break; } case GameEventName.GoEndSelectTokenReward: var token = messageData.Value as IToken; var index = _tokensReward.IndexOf(token.GetDataToken().Token); _tokensReward.RemoveAt(index); var obj = _poolTokensReward[index].GetComponent <ClickHandlerTokenReward>(); obj.DestoyIt(); _closePanel.SetActive(true); checkСanСontinue(); break; } }
public void OnEvent(CustomEventArgs messageData) { var message = messageData.Message; switch (message) { case GameEventName.GoStageAddCardSpell: _coroutiner.StartCoroutine(SpawnCardsByType(CardType.Spell, DropChance.ChanceSpell, DropChance.StartСhanceRarity, 3)); break; case GameEventName.GoStageAddCardConsumables: _coroutiner.StartCoroutine(SpawnCardsByType(CardType.Consumables, DropChance.ChanceConsumables, DropChance.StartСhanceRarity, 3)); break; case GameEventName.GoStageAddCardArea: _coroutiner.StartCoroutine(SpawnCardArea()); break; case GameEventName.GoStageAddCardEvent: _coroutiner.StartCoroutine(SpawnCardEvent()); break; case GameEventName.GoStageAddCardEnemy: _coroutiner.StartCoroutine(SpawnCardEnemy()); break; case GameEventName.GoStageRandomEvent: _coroutiner.StartCoroutine(StartRandomEvent()); break; case GameEventName.GoSelectCardEnemy: { foreach (var card in _poolCardEnemy) { if (!card.activeSelf) { continue; } var cardDisplay = card.GetComponent <ActionsWithCards>(); _selectedCardUnit = cardDisplay.CardGame; break; } _coroutiner.StartCoroutine(PreparationStageBattle()); //_coroutiner.StartCoroutine(SpawnCardsInHand()); break; } case GameEventName.GoSummonAllies: _selectedCardUnit = messageData.Value as ICard; SpawnAllies(); break; case GameEventName.GoStageBattle: _publisher.Publish(null, new CustomEventArgs(GameEventName.GoNextTurn)); break; case GameEventName.GoFinishBattle: FinishBattle(); break; case GameEventName.GoRewardEvent: _coroutiner.StartCoroutine(EndRandomEvent(0.7f)); break; case GameEventName.GoOpenPopupWithDescriptionCard: { ReturnNoSelectedCard(_poolGameCard); var cardGame = messageData.Value; _publisher.Publish(_hud, new CustomEventArgs(GameEventName.GoSetNextStage, cardGame)); break; } case GameEventName.GoOpenPopupNoDescription: { ReturnNoSelectedCard(_poolCardArea); ReturnNoSelectedCard(_poolCardEvent); ReturnNoSelectedCard(_poolCardEnemy); var cardGame = messageData.Value; _publisher.Publish(_hud, new CustomEventArgs(GameEventName.GoSetNextStage, cardGame)); break; } case GameEventName.GoDeadEnemy: var objCard = messageData.Value as GameObject; _configurateManager.ConfigurateByParent(objCard, _hud, false); break; /*case GameEventName.GoEndTurnPlayer: * foreach (var card in _poolCardsPlayer) * { * var component = card.GetComponent<DraggableCard>(); * component.enabled = false; * } * break; * case GameEventName.GoEndTurnEnemy: * foreach (var card in _poolCardsPlayer) * { * var component = card.GetComponent<DraggableCard>(); * component.enabled = true; * } * break;*/ } }