Exemplo n.º 1
0
    public void SwitchAmmo(AmmoDisplay ammoDisplay)
    {
        if (_movingAmmo)
        {
            //Debug.Log("switch ammoDisplay = " + ammoDisplay.Type + " with movingAmmoDisplay = " + _movingAmmoDisplay.Type);
            //_lastAmmoDisplayEntered.ShowImage();
            DeactivateMovingAmmo();
            AmmoType ammoType = ammoDisplay.Type;
            ammoDisplay.Initialize(_movingAmmoDisplay.Type);
            _movingAmmoDisplay.Initialize(ammoType);
            _movingAmmo        = false;
            _movingAmmoDisplay = null;

            for (int i = 0; i < AmmoDisplayArray.Length; i++)
            {
                if (AmmoDisplayArray[i].Set)
                {
                    Avatar.Instance.Ammo.AmmoList[i] = AmmoDisplayArray[i].Type;
                }
            }

            LoadingAlert.Present();
            StartCoroutine(SendAmmoArrangeToServer());
        }
    }
Exemplo n.º 2
0
    void BuyBalloon()
    {
        SoundManager.Instance.PlaySoundEffect(SoundType.BALLOON_PURCHASE);

        LoadingAlert.Present();
        StartCoroutine(SendAmmoBuyToServer(AmmoType.BALLOON, BALLOON_COST));
    }
Exemplo n.º 3
0
    void BuyBomb()
    {
        SoundManager.Instance.PlaySoundEffect(SoundType.BOMB_PURCHASE);

        LoadingAlert.Present();
        StartCoroutine(SendAmmoBuyToServer(AmmoType.BOMB, BOMB_COST));
    }
Exemplo n.º 4
0
    void BuyArrow()
    {
        SoundManager.Instance.PlaySoundEffect(SoundType.ARROW_PURCHASE);

        LoadingAlert.Present();
        StartCoroutine(SendAmmoBuyToServer(AmmoType.ARROW, ARROW_COST));
    }
Exemplo n.º 5
0
    protected override void OnActivate()
    {
        base.OnActivate();

        if (!_loggedIn && !GameManager.Client)
        {
            _loggedIn = true;
            //Debug.Log("presenting login alert");
            //LoadingAlert.Present();

            /*
             * if (OnlineManager.Token == null || OnlineManager.Token == "")
             *  FullLoginAlert.Present();
             * else
             *  LoginAlert.Present();
             */

            // Application.ExternalCall("trySetToken");
            Application.ExternalEval("window.sendMeTheToken = true");
            FullLoginAlert.Present();
        }
        else if (GameManager.Client)
        {
            // after game replay
            LoadingAlert.Present();
            OnlineManager.Instance.SetServer();
            StartCoroutine(LogBackIn());
        }
        else
        {
            //DefaultAlert.Present(
        }

        BattleButton.Reset();
        StoreButton.Reset();
        StatsButton.Reset();
        SettingsButton.Reset();

        if (!_music)
        {
            _music = true;
            SoundManager.Instance.StartMenuMusic();
        }

        StoreRefreshButtonObj.SetActive(false);

        VersionText.Text = "Version " + VERSION;
    }
Exemplo n.º 6
0
    void SetUpButtons()
    {
        if (SceneManager.GetActiveScene().name == "Moderator")
        {
            PlayButton.Disable();

            if (Client)
            {
                LoadingAlert.Present();
                PlayButton.Deactivate();
                LockButton.Deactivate();
                _countdown      = true;
                _countdownTimer = COUNTDOWN_TIME;
                StartCoroutine(ReplayGame());
            }
            else
            {
                UIViewController.ActivateUIView("MainView");
                //OnlineManager.Instance.SetServer(false, true, false);
                StartCoroutine(GetGameData());
            }
        }
    }
Exemplo n.º 7
0
 public void ClickSignIn()
 {
     SoundManager.Instance.PlaySoundEffect(SoundType.BUTTON_CLICK);
     LoadingAlert.Present();
     StartCoroutine(SignIn());
 }
Exemplo n.º 8
0
    void Refresh()
    {
        LoadingAlert.Present();

        StartCoroutine(StartRefresh());
    }
Exemplo n.º 9
0
    IEnumerator LoadingFinishedJSON()
    {
        // show loader and get the season
        LoadingAlert.Present();
        yield return(StartCoroutine(OnlineManager.Instance.StartGetSeason()));

        yield return(StartCoroutine(OnlineManager.Instance.StartGetPreviousGame()));

        // remove loader
        LoadingAlert.FinishLoading();

        // set team data
        int blueWins = 0;
        int redWins  = 0;

        for (int i = 0; i < OnlineManager.Instance.SeasonSyncData.team_summaries.Count; i++)
        {
            TeamSummaryData teamData = OnlineManager.Instance.SeasonSyncData.team_summaries[i];
            if (teamData.team_name == "blue")
            {
                blueWins = teamData.captures;
            }
            else
            {
                redWins = teamData.captures;
            }
        }
        RedWins.Text  = redWins.ToString();
        BlueWins.Text = blueWins.ToString();

        // red in the lead
        if (redWins > blueWins)
        {
            BannerImage.Image.color = Colors.RedBannerColor;
        }
        // blue in the lead
        else if (blueWins > redWins)
        {
            LeadTitleImage.Image.sprite = BlueLeadTitle;
            BannerImage.Image.color     = Colors.BlueBannerColor;
        }
        // tie
        else if (blueWins == redWins)
        {
            LeadTitleImage.Image.sprite = TieTitle;
            BannerImage.Image.color     = Colors.PurpleBannerColor;
        }
        BannerImage.Activate();
        LeadTitleImage.Activate();
        //LeaderboardTitleImage.Activate();

        // set player data
        for (int i = 0; i < OnlineManager.Instance.SeasonSyncData.player_summaries.Count; i++)
        {
            PlayerSummaryData playerData = OnlineManager.Instance.SeasonSyncData.player_summaries[i];
            if (OnlineManager.Instance.PlayerID == playerData.player_id.ToString())
            {
                AMVP.Text = playerData.attack_mvp.ToString();
                DMVP.Text = playerData.defend_mvp.ToString();
            }
        }
        if (AMVP.Text == "")
        {
            AMVP.Text = "0";
        }
        if (DMVP.Text == "")
        {
            DMVP.Text = "0";
        }

        GemCountText.Text = "x " + Avatar.Instance.GemsAvailable;
        if (Avatar.Instance.GemsAvailable > 0)
        {
            if (Avatar.Instance.GemsAvailable > 1)
            {
                ActivityClaimButton.ButtonIconImage.sprite = AssetLookUp.Instance.ClaimGemsButton;
            }

            ActivityClaimButton.Enable();
        }

        // play fill sound effect
        if (_stepsShown < Avatar.Instance.Steps || _activityMinShown < Avatar.Instance.ActiveMins)
        {
            SoundManager.Instance.PlaySoundEffect(SoundType.COINS_TALLY);
        }

        // activate battle button if there is a battle to watch
        if (OnlineManager.Instance.PreviousGameData != null && OnlineManager.Instance.PreviousGameData.id != "")
        {
            BattleButton.Activate();
        }
    }
Exemplo n.º 10
0
    public void ClickRefresh()
    {
        LoadingAlert.Present();

        StartCoroutine(LoadingFinishedJSON());
    }
Exemplo n.º 11
0
    public void ClickRefresh()
    {
        LoadingAlert.Present();

        StartCoroutine(RefreshBattleStatus());
    }
Exemplo n.º 12
0
    void FixedUpdate()
    {
        if (_mouseOverInfo != null && _mouseOverPiece != null)
        {
            _mouseOverInfo.SetPosition(_mouseOverPiece.transform.position);
        }

        if (_replay)
        {
            if (_gameOver)
            {
                _gameOverTimer += Time.deltaTime;
                if (_gameOverTimer >= GAME_OVER_TIME)
                {
                    enabled = false;
                    LoadingAlert.Present();
                    PlayerPrefs.SetString("LAST_GAME_VIEWED", OnlineManager.Instance.GameData.id);
                    //Debug.Log("saved game id " + OnlineManager.Instance.GameData.id);
                    PlayerPrefs.Save();
                    ActivateResultsView();
                }
            }
            else
            {
                if (_countdown)
                {
                    _countdownTimer -= Time.deltaTime;
                    if (_countdownTimer < 0.0f)
                    {
                        UIViewController.DeactivateUIView("CountdownView");
                        _countdown = false;
                        //Debug.Log("here!");
                    }
                    else
                    {
                        int count = (int)Mathf.Ceil(_countdownTimer);
                        CountdownText.Text = count.ToString();
                    }
                }
                else
                {
                    if (_replayWatcherInfo != null)
                    {
                        _replayWatcherInfo.SetPosition(_replayWatcherPiece.transform.position);
                        //SetWatcherInfoPosition();
                    }

                    TurnData turnData = DataRecorder.Instance.TurnDataList[_replayIndex];
                    ReplayTurn(turnData);
                    _replayIndex++;

                    // game over
                    if (_gameOver)
                    {
                        _gameOverTimer += Time.deltaTime;
                        if (_gameOverTimer >= GAME_OVER_TIME)
                        {
                            if (_mouseOverInfo != null)
                            {
                                Destroy(_mouseOverInfo.gameObject);
                            }
                            enabled = false;
                            LoadingAlert.Present();
                            PlayerPrefs.SetString("LAST_GAME_VIEWED", OnlineManager.Instance.GameData.id);
                            //Debug.Log("saved game id " + OnlineManager.Instance.GameData.id);
                            PlayerPrefs.Save();
                            ActivateResultsView();
                        }
                    }
                    else if (_replayIndex >= DataRecorder.Instance.TurnDataList.Count)
                    {
                        if (_replayWatcherInfo != null)
                        {
                            Destroy(_replayWatcherInfo.gameObject);
                        }
                        if (_mouseOverInfo != null)
                        {
                            Destroy(_mouseOverInfo.gameObject);
                        }
                        _redTeam.StopPieceAnimations();
                        _blueTeam.StopPieceAnimations();
                        _gameOver      = true;
                        _gameOverTimer = 0.0f;
                    }
                }
            }
        }
        else
        {
            if (_gameOver)
            {
                _gameOverTimer += Time.deltaTime;
                if (_gameOverTimer >= GAME_OVER_TIME)
                {
                    enabled = false;
                    LoadingAlert.Present();
                    _gameTime = DateTime.UtcNow - _startTime;
                    _redTeam.CalulateMVPs();
                    _blueTeam.CalulateMVPs();
                    DisplayGameResults();
                }
            }
            else
            {
#if SLOW_MOTION
                if (Input.GetKey(KeyCode.A))
#endif
                {
                    StartTurn(Time.deltaTime);
                    Attack(Time.deltaTime);
                    RecordMoves();
                    RemoveDoneBalloons();
                    if (CheckGameOver())
                    {
                        _redTeam.StopPieceAnimations();
                        _blueTeam.StopPieceAnimations();
                        SoundManager.Instance.PlaySoundEffect(SoundType.CHEER);
                        _gameOver      = true;
                        _gameOverTimer = 0.0f;
                    }
                }
            }
        }
    }