Пример #1
0
    public IEnumerator AnimateAttack()
    {
        print("Animating Attack");
        MenuController.instance.DoMenuStateChange("animateAttack");
        yield return(new WaitForSeconds(swapDuration / 2 + 0.1f));

        // === MOVE PHASE ===
        WeaponController weaponL = GameController.instance.playerControllerL.GetCurrentWeaponController();
        Transform        tL      = weaponL.weaponVisualObj.transform;

        LeanTween.move(tL.gameObject, new Vector3(-5, tL.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);

        WeaponController weaponR = GameController.instance.playerControllerR.GetCurrentWeaponController();
        Transform        tR      = weaponR.weaponVisualObj.transform;

        LeanTween.move(tR.gameObject, new Vector3(5, tR.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
        yield return(new WaitForSeconds(weaponFlyTime + 0.1f));

        // === APPLY CARDS PHASE ===
        CardIterator cardIt   = new CardIterator();
        BaseCard     nextCard = cardIt.GetNextCard();

        while (nextCard != null)
        {
            //DO CARDS
            nextCard.DoPreAttackAction();
            nextCard = cardIt.GetNextCard();
        }

        // === WIN PHASE ===
        WinnerData winnerData = GameController.instance.DetermineWinner();
        float      coins      = GameController.CalculateCoins(winnerData.winnerAttDefDiff);

        yield return(new WaitForSeconds(weaponPreAttack));

        Vector3 tlScale = tL.localScale;
        Vector3 tRScale = tR.localScale;

        if (winnerData.winner == Player.L)
        {
            LeanTween.move(tL.gameObject, new Vector3(0.2f, tL.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            LeanTween.move(tR.gameObject, new Vector3(0.1f, tR.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            yield return(new WaitForSeconds(weaponFlyTime - 0.3f));

            LeanTween.scale(tL.gameObject, tL.localScale * winnerScale, weaponSizeChangeTime);
            LeanTween.scale(tR.gameObject, tR.localScale * loserScale, weaponSizeChangeTime);
            LeanTween.move(tR.gameObject, new Vector3(4f, tR.position.y, 0), weaponFlyBounceBackTime).setEase(LeanTweenType.easeOutExpo);
            currMenuObj.GetComponent <AnimateAttackWindowController>().EnableWinnerText(Player.L, coins);
        }
        else if (winnerData.winner == Player.R)
        {
            LeanTween.move(tR.gameObject, new Vector3(-0.2f, tR.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            LeanTween.move(tL.gameObject, new Vector3(0.1f, tL.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            yield return(new WaitForSeconds(weaponFlyTime - 0.3f));

            LeanTween.scale(tR.gameObject, tR.localScale * winnerScale, weaponSizeChangeTime);
            LeanTween.scale(tL.gameObject, tL.localScale * loserScale, weaponSizeChangeTime);
            LeanTween.move(tL.gameObject, new Vector3(-4f, tL.position.y, 0), weaponFlyBounceBackTime).setEase(LeanTweenType.easeOutExpo);
            currMenuObj.GetComponent <AnimateAttackWindowController>().EnableWinnerText(Player.R, coins);
        }
        else
        {
            LeanTween.move(tR.gameObject, new Vector3(-0.5f, tR.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            LeanTween.move(tL.gameObject, new Vector3(0.5f, tL.position.y, 0), weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            currMenuObj.GetComponent <AnimateAttackWindowController>().EnableWinnerText(Player.NaN, coins);
        }

        Player isGameWinner = GameController.instance.RegisterWinner(winnerData);

        if (isGameWinner != Player.NaN)
        {
            // === ENG GAME PHASE ===
            winText.text    = GlobalVars.GAME_WIN_DISPLAY_TEXT[0] + isGameWinner.ToString() + GlobalVars.GAME_WIN_DISPLAY_TEXT[1];
            winText.enabled = true;
            yield return(new WaitForSeconds(winningTextDisplayTime));

            _EventBus.Publish <GameOver>(new GameOver(isGameWinner));
        }
        else
        {
            // === RESET PHASE ===
            yield return(new WaitForSeconds(winningTextDisplayTime));

            LeanTween.scale(tR.gameObject, tRScale, weaponFlyTime);
            LeanTween.scale(tL.gameObject, tlScale, weaponFlyTime);
            LeanTween.move(tL.gameObject, weaponL.weaponVisualInitPos, weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            LeanTween.move(tR.gameObject, weaponR.weaponVisualInitPos, weaponFlyTime).setEase(LeanTweenType.easeInOutExpo);
            _EventBus.Publish <GameStateOver>(new GameStateOver(GameController.instance.currState));
        }
    }
Пример #2
0
    public void GameStateOver()
    {
        currState = GetNextState();
        if (currState == GameState.IssuingAttack)
        {
            playerControllerL.ResetAllCurrentWeaponStats();
            playerControllerR.ResetAllCurrentWeaponStats();

            //Issue this round's cards
            foreach (KeyValuePair <Player, List <BaseCard> > kv in currentRoundCards)
            {
                foreach (BaseCard c in kv.Value.ToList <BaseCard>())
                {
                    activeCards[kv.Key].Add(c);
                }
            }
            currentRoundCards[Player.L].Clear();
            currentRoundCards[Player.R].Clear();

            //Issue Attack
            if (GlobalVars.instance.animateAttack)
            {
                StartCoroutine(MenuController.instance.AnimateAttack());
            }
            else
            {
                CardIterator cardIt   = new CardIterator();
                BaseCard     nextCard = cardIt.GetNextCard();
                while (nextCard != null)
                {
                    //DO CARDS
                    nextCard.DoPreAttackAction();
                    nextCard = cardIt.GetNextCard();
                }
                Player isGameWinner = RegisterWinner(DetermineWinner());
                if (isGameWinner != Player.NaN)
                {
                    _EventBus.Publish <GameOver>(new GameOver(isGameWinner));
                }
                else
                {
                    _EventBus.Publish <GameStateOver>(new GameStateOver(GameController.instance.currState));
                }
            }
        }
        else
        {
            _EventBus.Publish <TurnPhaseChanged>(new TurnPhaseChanged(null, TurnPhase.BuyPhase));

            _EventBus.Publish <CurrentPlayerChanged>(new CurrentPlayerChanged(GetOpponentPlayerType()));

            if (currPlayerMode == PlayerMode.UI)
            {
                _EventBus.Publish <MenuStateChanged>(new MenuStateChanged(MenuState.BuyPhaseMenu));
            }
            else //API player, does nothing if both players are API players
            {
                _EventBus.Publish <MenuStateChanged>(new MenuStateChanged(MenuState.NonUIPlayerPlaying));
            }
        }
    }