Beispiel #1
0
        public void Show()
        {
            _selfPage = Object.Instantiate(
                _loadObjectsManager.GetObjectByPath <GameObject>("Prefabs/UI/Pages/MainMenuPage"));
            _selfPage.transform.SetParent(_uiManager.Canvas.transform, false);

            _buttonPlay    = _selfPage.transform.Find("Button_Play").GetComponent <Button>();
            _buttonDeck    = _selfPage.transform.Find("Button_Deck").GetComponent <Button>();
            _buttonArmy    = _selfPage.transform.Find("Button_Army").GetComponent <MenuButtonNoGlow>();
            _buttonCredits = _selfPage.transform.Find("BackMetalLeft2/Button_Credits")
                             .GetComponent <ButtonShiftingContent>();
            _buttonQuit     = _selfPage.transform.Find("BackMetalLeft/Button_Quit").GetComponent <ButtonShiftingContent>();
            _buttonTutorial = _selfPage.transform.Find("Button_Tutorial").GetComponent <ButtonShiftingContent>();
            _buttonBuy      = _selfPage.transform.Find("Button_Shop").GetComponent <ButtonShiftingContent>();
            _buttonOpen     = _selfPage.transform.Find("Button_OpenPacks").GetComponent <ButtonShiftingContent>();
            _packsCount     = _selfPage.transform.Find("Button_OpenPacks/Count").GetComponent <TextMeshProUGUI>();
            _buttonMusic    = _selfPage.transform.Find("Button_Music").GetComponent <MenuButtonToggle>();
            _buttonSfx      = _selfPage.transform.Find("Button_SFX").GetComponent <MenuButtonToggle>();

            _logoAnimator = _selfPage.transform.Find("Logo").GetComponent <Animator>();

            _connectionStatusText = _selfPage.transform.Find("ConnectionPanel/ConnectionStatusText")
                                    .GetComponent <TextMeshProUGUI>();
            _buttonReconnect = _selfPage.transform.Find("ConnectionPanel/Button_Reconnect").GetComponent <Button>();
            _buttonLogout    = _selfPage.transform.Find("ConnectionPanel/Button_Logout").GetComponent <Button>();
            _markerOffline   = _selfPage.transform.Find("ConnectionPanel/Marker_Status_Offline").gameObject;
            _markerOnline    = _selfPage.transform.Find("ConnectionPanel/Marker_Status_Online").gameObject;

            _buttonPlay.onClick.AddListener(OnClickPlay);
            _buttonDeck.onClick.AddListener(OnClickPlay);
            _buttonArmy.Clicked.AddListener(OnClickCollection);
            _buttonBuy.onClick.AddListener(BuyButtonHandler);
            _buttonOpen.onClick.AddListener(OpenButtonHandler);
            _buttonCredits.onClick.AddListener(CreditsButtonOnClickHandler);
            _buttonQuit.onClick.AddListener(QuitButtonOnClickHandler);
            _buttonTutorial.onClick.AddListener(TutorialButtonOnClickHandler);
            _buttonReconnect.onClick.AddListener(ReconnectButtonOnClickHandler);
            _buttonLogout.onClick.AddListener(LogoutButtonOnClickHandler);
            _buttonMusic.ValueChanged.AddListener(OnValueChangedEventMusic);
            _buttonSfx.ValueChanged.AddListener(OnValueChangedEventSfx);

            _buttonArmy.Interactable = true;

            _packsCount.text = _playerManager.LocalUser.PacksCount <= 99 ?
                               _playerManager.LocalUser.PacksCount.ToString() :
                               "99";

            _logoAnimator.SetBool("LogoShow", true);

            _buttonMusic.SetStatus(!_soundManager.MusicMuted);
            _buttonSfx.SetStatus(!_soundManager.SfxMuted);

            if (!_dataManager.CachedUserLocalData.AgreedTerms)
            {
                _uiManager.DrawPopup <TermsPopup>();
            }

            UpdateConnectionStateUI();
        }
Beispiel #2
0
        public void StartTutorial()
        {
            _battlegroundController.SetupBattlegroundAsSpecific(CurrentTutorial.SpecificBattlegroundInfo);

            IsBubbleShow = true;
            _uiManager.DrawPopup <TutorialPopup>();
            _popup = _uiManager.GetPopup <TutorialPopup>();
            UpdateTutorialVisual();
            _soundManager.PlaySound(Enumerators.SoundType.TUTORIAL, CurrentTutorialDataStep.SoundName, Constants.TutorialSoundVolume, false);

            IsTutorial = true;
        }
        private void ContinueButtonOnClickHandler()
        {
            _soundManager.PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true);

            _uiManager.GetPopup <OverlordAbilitySelectionPopup>().PopupHiding += AbilityPopupClosedEvent;
            _uiManager.DrawPopup <OverlordAbilitySelectionPopup>(_currentOverlordObject.SelfHero);
        }
Beispiel #4
0
        public void SelectCard(BoardCard card)
        {
            _uiManager.GetPopup <CardInfoPopup>().Hide();
            ClearPreviewCard();

            Opening?.Invoke();

            _blockedClosing = true;

            SetIsStateChanging(true);
            _selectedCollectionCard = card;

            if (_previewCard != null && _previewCard.GameObject != null)
            {
                Object.DestroyImmediate(_previewCard.GameObject);
            }

            _previewCard = new BoardCard(Object.Instantiate(card.GameObject));
            _previewCard.GameObject.name = "CardPreview";
            _previewCard.GameObject.transform.position   = card.GameObject.transform.position;
            _previewCard.GameObject.transform.localScale = card.GameObject.transform.lossyScale;

            _previewCard.GameObject.GetComponent <SortingGroup>().sortingLayerID = SRSortingLayers.GameUI2;

            PreviewCardInstantiated?.Invoke(_previewCard);

            Sequence mySequence = DOTween.Sequence();

            mySequence.Append(_previewCard.Transform.DORotate(new Vector3(-20, 30, -20), .2f));
            mySequence.Append(_previewCard.Transform.DORotate(new Vector3(0, 0, 0), .4f));

            Sequence mySequence2 = DOTween.Sequence();

            mySequence2.Append(_previewCard.Transform.DOMove(new Vector3(-4.3f, 1.2f, 5), .4f));
            mySequence2.Append(_previewCard.Transform.DOMove(new Vector3(-4.3f, .8f, 5), .2f));

            Sequence mySequence3 = DOTween.Sequence();

            mySequence3.Append(_previewCard.Transform.DOScale(new Vector3(.9f, .9f, .9f), .4f));
            mySequence3.Append(_previewCard.Transform.DOScale(new Vector3(.72f, .72f, .72f), .2f));
            mySequence3.OnComplete(
                () =>
            {
                SetIsStateChanging(false);
            });

            _uiManager.GetPopup <CardInfoPopup>().BlockedClosing = true;
            _uiManager.GetPopup <CardInfoPopup>().CardTransform  = _previewCard.Transform;
            _uiManager.DrawPopup <CardInfoPopup>(card.LibraryCard);

            GameClient.Get <ITimerManager>().AddTimer(
                x =>
            {
                _blockedClosing = false;
                _uiManager.GetPopup <CardInfoPopup>().BlockedClosing = false;
            });
        }
 private void SelectTowerSlot(TowerSlot towerSlot)
 {
     if (towerSlot.IsEmpty)
     {
         _uiManager.DrawPopup <BuildTowerPopup>(new BuildTowerPopupInfo()
         {
             selectedTowerSlot       = towerSlot,
             towerSlotScreenPosition = _gameManager.MainCamera.WorldToScreenPoint(towerSlot.TowerSlotPosition),
         });
     }
     else
     {
         _uiManager.DrawPopup <TowerPopup>(new TowerPopupInfo()
         {
             selectedTowerSlot       = towerSlot,
             towerSlotScreenPosition = _gameManager.MainCamera.WorldToScreenPoint(towerSlot.TowerSlotPosition),
         });
     }
 }
        private void CloseDesintegratePopup()
        {
            GameClient.Get <ISoundManager>()
            .PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true);
            Card libraryCard = GameClient.Get <IDataManager>().CachedCardsLibraryData.Cards
                               .Find(card => card.Name == _cardData.CardName);

            _uiManager.DrawPopup <CardInfoPopup>(libraryCard);

            Hide();
        }
        public void FinishMatch(Enumerators.AppState appStateAfterMatch)
        {
            _tutorialManager.StopTutorial();

            if (_gameplayManager.IsTutorial &&
                !_tutorialManager.IsTutorial &&
                appStateAfterMatch != Enumerators.AppState.MAIN_MENU)
            {
                _sceneManager.ChangeScene(Enumerators.AppState.GAMEPLAY, true);
                return;
            }

            _finishMatchAppState = appStateAfterMatch;

            _uiManager.HideAllPages();
            _uiManager.DrawPopup <LoadingGameplayPopup>();

            _gameplayManager.ResetWholeGameplayScene();

            _sceneManager.ChangeScene(Enumerators.AppState.APP_INIT);
        }
Beispiel #8
0
        public void EndGame(Enumerators.EndGameType endGameType, float timer = 4f)
        {
            if (IsGameEnded)
            {
                return;
            }

            IsGameEnded = true;

            _soundManager.PlaySound(Enumerators.SoundType.BACKGROUND, 128, Constants.BackgroundSoundVolume, null, true);

            if (endGameType != Enumerators.EndGameType.CANCEL)
            {
                _timerManager.AddTimer(
                    x =>
                {
                    if (endGameType == Enumerators.EndGameType.WIN)
                    {
                        _uiManager.DrawPopup <YouWonPopup>();
                    }
                    else if (endGameType == Enumerators.EndGameType.LOSE)
                    {
                        _uiManager.DrawPopup <YouLosePopup>();
                    }
                },
                    null,
                    timer);
            }

            _soundManager.CrossfaidSound(Enumerators.SoundType.BACKGROUND, null, true);

            StopGameplay();

            CurrentTurnPlayer = null;
            CurrentPlayer     = null;
            OpponentPlayer    = null;

            GameEnded?.Invoke(endGameType);
        }
        private void DesintegrateButtonHandler()
        {
            GameClient.Get <ISoundManager>()
            .PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true);
            int amount = CardData.Amount;

            if (!_disableMelt)
            {
                if (amount == 0)
                {
                    _buttonMelt.GetComponent <MenuButtonNoGlow>().Interactable = false;
                }
                else
                {
                    Hide();
                    _uiManager.DrawPopup <DesintigrateCardPopup>(CardData);
                }
            }
            else
            {
                _uiManager.DrawPopup <WarningPopup>(
                    $"Melting is Disabled\nfor version {BuildMetaInfo.Instance.DisplayVersionName}.\n Thanks for helping us make this game Awesome\n-Loom Team");
            }
        }
Beispiel #10
0
        public void StopTurn()
        {
            EndTurn();

            if (_gameplayManager.IsLocalPlayerTurn())
            {
                _uiManager.DrawPopup <YourTurnPopup>();

                _timerManager.AddTimer((x) =>
                {
                    StartTurn();
                }, null, 4f);
            }
            else
            {
                StartTurn();
            }
        }
Beispiel #11
0
        public void BackButtonOnClickHandler()
        {
            Action[] actions = new Action[2];
            actions[0] = () =>
            {
                _uiManager.HidePopup <YourTurnPopup>();

                _gameplayManager.EndGame(Enumerators.EndGameType.CANCEL);
                GameClient.Get <IMatchManager>().FinishMatch(Enumerators.AppState.MAIN_MENU);

                _soundManager.StopPlaying(Enumerators.SoundType.TUTORIAL);
                _soundManager.CrossfaidSound(Enumerators.SoundType.BACKGROUND, null, true);
            };
            actions[1] = () => { };

            _uiManager.DrawPopup <ConfirmationPopup>(actions);
            _soundManager.PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true);
        }
        public void ChangeAppState(Enumerators.AppState stateTo, bool force = false)
        {
            if (!force)
            {
                if (AppState == stateTo)
                {
                    return;
                }
            }

            switch (stateTo)
            {
            case Enumerators.AppState.APP_INIT:
                _uiManager.SetPage <LoadingPage>();
                GameClient.Get <ISoundManager>().PlaySound(
                    Enumerators.SoundType.BACKGROUND,
                    128,
                    Constants.BackgroundSoundVolume,
                    null,
                    true);

                break;

            case Enumerators.AppState.LOGIN:
                break;

            case Enumerators.AppState.MAIN_MENU:
                _uiManager.SetPage <MainMenuPage>();
                break;

            case Enumerators.AppState.HERO_SELECTION:
                _uiManager.SetPage <HeroSelectionPage>();
                break;

            case Enumerators.AppState.DECK_SELECTION:
                _uiManager.SetPage <HordeSelectionPage>();
                break;

            case Enumerators.AppState.COLLECTION:
                _uiManager.SetPage <CollectionPage>();
                break;

            case Enumerators.AppState.DECK_EDITING:
                _uiManager.SetPage <DeckEditingPage>();
                break;

            case Enumerators.AppState.SHOP:

                //_uiManager.SetPage<ShopPage>();
                //break;
                _uiManager.DrawPopup <WarningPopup>(
                    $"The Shop is Disabled\nfor version {BuildMetaInfo.Instance.DisplayVersionName}\n\n Thanks for helping us make this game Awesome\n\n-Loom Team");
                return;

            case Enumerators.AppState.PACK_OPENER:
            {
                //_uiManager.SetPage<PackOpenerPage>();
                //break;
                _uiManager.DrawPopup <WarningPopup>(
                    $"The Pack Opener is Disabled\nfor version {BuildMetaInfo.Instance.DisplayVersionName}\n\n Thanks for helping us make this game Awesome\n\n-Loom Team");
                return;
            }

            case Enumerators.AppState.GAMEPLAY:
                _uiManager.SetPage <GameplayPage>();
                break;

            case Enumerators.AppState.CREDITS:
                _uiManager.SetPage <CreditsPage>();
                break;

            default:
                throw new NotImplementedException("Not Implemented " + stateTo + " state!");
            }

            _previousState = AppState != Enumerators.AppState.SHOP ? AppState : Enumerators.AppState.MAIN_MENU;

            AppState = stateTo;
        }
 private void OpenAlertDialog(string msg)
 {
     _uiManager.DrawPopup <WarningPopup>(msg);
 }
Beispiel #14
0
        public async void Update()
        {
            if (_selfPage == null)
            {
                return;
            }

            if (!_selfPage.activeInHierarchy ||
                GameClient.Get <IAppStateManager>().AppState != Enumerators.AppState.APP_INIT)
            {
                return;
            }

            if (!_isLoaded)
            {
                _percentage          += 1f;
                _loaderBar.fillAmount = Mathf.Clamp(_percentage / 100f, 0.03f, 1f);
                if (_percentage >= 100)
                {
                    _isLoaded = true;
                    _progressBar.gameObject.SetActive(false);
                    _pressAnyText.gameObject.SetActive(true);
                }
            }
            else
            {
                if (!Input.anyKey)
                {
                    return;
                }

                if (!_pressAnyText.gameObject.activeSelf)
                {
                    return;
                }

                _pressAnyText.gameObject.SetActive(false);

                if (_backendDataControlMediator.LoadUserDataModel() &&
                    _backendDataControlMediator.UserDataModel.IsValid)
                {
                    ConnectionPopup connectionPopup = _uiManager.GetPopup <ConnectionPopup>();

                    Func <Task> connectFunc = async() =>
                    {
                        bool success = true;
                        try
                        {
                            await _backendDataControlMediator.LoginAndLoadData();
                        }
                        catch (GameVersionMismatchException e)
                        {
                            success = false;
                            _uiManager.DrawPopup <LoginPopup>();
                            _uiManager.GetPopup <LoginPopup>().Show(e);
                        }
                        catch (Exception e)
                        {
                            // HACK: ignore to allow offline mode
                            Debug.LogWarning(e);
                        }

                        connectionPopup.Hide();

                        if (success)
                        {
                            GameClient.Get <IAppStateManager>().ChangeAppState(Enumerators.AppState.MAIN_MENU);
                        }
                    };
                    _uiManager.DrawPopup <ConnectionPopup>();
                    connectionPopup.ConnectFunc = connectFunc;
                    await connectionPopup.ExecuteConnection();
                }
                else
                {
                    _uiManager.DrawPopup <LoginPopup>();
                }
            }
        }
Beispiel #15
0
 public void CompleteLevel()
 {
     StopGame();
     _uIManager.DrawPopup <LevelCompletedPopup>();
 }
Beispiel #16
0
        private async void PressedBetaHandler()
        {
            GameClient.Get <ISoundManager>()
            .PlaySound(Enumerators.SoundType.CLICK, Constants.SfxSoundVolume, false, false, true);

            string betaKey        = _betaKeyInputField.text.Trim();
            bool   isBetaKeyValid = betaKey.Length == 12;

            try
            {
                isBetaKeyValid &= CryptoUtils.HexStringToBytes(betaKey).Length == 6;
            }
            catch (Exception)
            {
                isBetaKeyValid = false;
            }

            if (isBetaKeyValid)
            {
                // check if field is empty. Can replace with exact value once we know if there's a set length for beta keys
                SetUIState(LoginState.BetaKeyValidateAndLogin);

                GenerateKeysAndUserFromBetaKey(betaKey, out byte[] privateKey, out byte[] _, out string userId);

                try
                {
                    isBetaKeyValid = await _backendFacade.CheckIfBetaKeyValid(betaKey);

                    if (!isBetaKeyValid)
                    {
                        throw new Exception("Tester key not registered");
                    }

                    UserDataModel userDataModel = new UserDataModel(userId, betaKey, privateKey)
                    {
                        // HACK
                        IsValid = true

                                  // IsValid = false
                    };
                    _backendDataControlMediator.SetUserDataModel(userDataModel);
                    await _backendDataControlMediator.LoginAndLoadData();

                    // HACK
                    // userDataModel.IsValid = true;
                    _backendDataControlMediator.SetUserDataModel(userDataModel);

                    SuccessfulLogin();
                }
                catch (GameVersionMismatchException e)
                {
                    SetUIState(LoginState.RemoteVersionMismatch);
                    UpdateVersionMismatchText(e);
                }
                catch (Exception e)
                {
                    Debug.LogWarning(e);
                    SetUIState(LoginState.BetaKeyValidationFailed);
                }
            }
            else
            {
                _uiManager.DrawPopup <WarningPopup>("Input a valid Tester Key");
            }
        }