Example #1
0
 private void SetButtonImages()
 {
     ButtonBase[] btns =
     {
         btnLeft,
         btnXMiddle,
         btnRight,
         btnTop,
         btnYMiddle,
         btnBottom,
         btnNudgeUp,
         btnNudgeLeft,
         btnCenter,
         btnNudgeRight,
         btnNudgeDown
     };
     Image[] imgs =
     {
         Resources.AlignLeft,
         Resources.AlignXMiddle,
         Resources.AlignRight,
         Resources.AlignTop,
         Resources.AlignYMiddle,
         Resources.AlignBottom,
         Resources.NudgeUp,
         Resources.NudgeLeft,
         Resources.AlignCenter,
         Resources.NudgeRight,
         Resources.NudgeDown
     };
     ButtonUtils.SetScaledImage(btns, imgs, new Size(_buttonIconLogicalSize, _buttonIconLogicalSize));
 }
Example #2
0
        private IEnumerator Initialize()
        {
            Debug.Log($"[QuickConstruct]({name}): Initialize Launch Screen");

            // Search of the buttons to move / use them
            Button editBtn   = null;
            Button deleteBtn = null;

            launchBtn       = null;
            vesselListItems = null;

            while (editBtn == null || deleteBtn == null || launchBtn == null)
            {
                editBtn   = editBtn ? editBtn : ButtonUtils.FindButtons("Button_edit");
                deleteBtn = deleteBtn ? deleteBtn : ButtonUtils.FindButtons("Button_delete");
                launchBtn = launchBtn ? launchBtn : ButtonUtils.FindButtons("Button_launch");
                yield return(new WaitForFixedUpdate());
            }

            constructBtn = ButtonUtils.CreateConstructionButton(editBtn, OnClickOnConstruct);

            // Move other buttons
            deleteBtn.transform.Translate(-(editBtn.transform.position - deleteBtn.transform.position));
            editBtn.transform.Translate(-(launchBtn.transform.position - editBtn.transform.position));

            while (vesselListItems == null)
            {
                vesselListItems = VesselUtils.InitializeVessels();
                yield return(new WaitForFixedUpdate());
            }

            Debug.Log($"[QuickConstruct]({name}): Launch Screen initialized");
        }
Example #3
0
        protected override void OnPaint(PaintEventArgs pevent)
        {
            basePainting = true;
            base.OnPaint(pevent);
            basePainting = false;

            //We paint the disabled text on top of the base class drawing using
            //the ForeColorDisabled color that we have implemented ourselves.
            //Incomplete implementation: We don't consider the TextImageRelation property (yet).

            if (!Enabled)
            {
                TextFormatFlags flags;
                Rectangle       textRect;

                //Create flags
                flags = ButtonUtils.CreateTextFormatFlags(this, RtlTranslateContent(TextAlign), ShowKeyboardCues);

                //Create rectangle
                if (Appearance == Appearance.Button)
                {
                    textRect = ButtonUtils.GetPushButtonTextRectangle(this);
                }
                else
                {
                    textRect = ButtonUtils.GetRadioButtonTextRectangle(this, pevent.Graphics);
                }

                //Draw
                TextRenderer.DrawText(pevent.Graphics, Text, Font, textRect, DisabledForeColor, flags);
            }
        }
Example #4
0
 private void SetButtonImages()
 {
     Button[] btns =
     {
         btnLeft,
         btnXMiddle,
         btnRight,
         btnTop,
         btnYMiddle,
         btnBottom,
         btnNudgeUp,
         btnNudgeLeft,
         btnCenter,
         btnNudgeRight,
         btnNudgeDown
     };
     Image[] imgs =
     {
         Resources.AlignLeft,
         Resources.AlignXMiddle,
         Resources.AlignRight,
         Resources.AlignTop,
         Resources.AlignYMiddle,
         Resources.AlignBottom,
         Resources.NudgeUp,
         Resources.NudgeLeft,
         Resources.AlignCenter,
         Resources.NudgeRight,
         Resources.NudgeDown
     };
     ButtonUtils.SetScaledImage(btns, imgs, new Size(BUTTON_ICON_LOGICAL_SIZE, BUTTON_ICON_LOGICAL_SIZE));
 }
Example #5
0
        public static void Main()
        {
            LcdWriter.Instance.Write("ready!");
            Thread.Sleep(500);
            // write your code here
            motorControl = new ServoControl(Pins.GPIO_PIN_D9);
            ButtonUtils.OnBoardButtonPushed(SpinMotor);

            NetDuinoUtils.KeepRunning();
        }
Example #6
0
        private void OnGUILaunchScreenVesselSelected(ShipTemplate data)
        {
            selectedShip = data;

            ButtonUtils.RefreshButton(data, launchBtn, constructBtn);

            ConstructScenario.Instance.spaceCenterSelectedShipName = VesselUtils.ShipName(data);

            Debug.Log($"[QuickConstruct]({name}): Vessel selected");
        }
Example #7
0
        private void OnClickOnConstruct()
        {
            if (selectedShip != null)
            {
                ConstructScenario.Instance.AddToConstruction(selectedShip);
                var vesselListItem = vesselListItems.TryGet(selectedShip);
                if (vesselListItem.isSome)
                {
                    vesselListItem.value.vesselWarnings.text = MessageUtils.PrepareMessage(selectedShip);
                }
            }

            ButtonUtils.RefreshButton(selectedShip, launchBtn, constructBtn);

            Debug.Log($"[QuickConstruct]({name}): Construct");
        }
Example #8
0
    public void ToggleEffectsAudio()
    {
        ButtonUtils.PlayClickSound();

        if (GameManager.Instance.EffectAudioVolume < 0.1f)
        {
            GameManager.Instance.EffectAudioVolume = Constants.DefaultAudioVolume;
        }
        else
        {
            GameManager.Instance.EffectAudioVolume = 0f;

            if (!Debug.isDebugBuild)
            {
                Flurry.Flurry.Instance.LogEvent("Sound_SFXOff");
                Fabric.Answers.Answers.LogCustom("Sound_MusicOff");
            }
        }

        GameManager.Instance.SaveState();
    }
        private void SetButtonImages()
        {
            Button[] btns =
            {
                btnEnlarge,
                btnShrink,
                btnReset,
                btnAlign,
                btnOpenImage
            };

            Image[] imgs =
            {
                Resources.ZoomIn_128x,
                Resources.ZoomOut_128x,
                Resources.ZoomToFit_128x,
                Resources.MoveGlyph_128x,
                Resources.ExportPerformance_128x
            };

            ButtonUtils.SetScaledImage(btns, imgs, new Size(_buttonIconLogicalSize, _buttonIconLogicalSize));
        }
Example #10
0
        private void SetButtonImages()
        {
            Button[] btns =
            {
                btnEnlarge,
                btnShrink,
                btnReset,
                btnAlign,
                btnOpenImage
            };

            Image[] imgs =
            {
                Resources.ZoomIn_128x,
                Resources.ZoomOut_128x,
                Resources.ZoomToFit_128x,
                Resources.MoveGlyph_128x,
                Resources.ExportPerformance_128x
            };

            ButtonUtils.SetScaledImage(btns, imgs, new Size(BUTTON_ICON_LOGICAL_SIZE, BUTTON_ICON_LOGICAL_SIZE));
        }
Example #11
0
    public void ToggleNotifications()
    {
        ButtonUtils.PlayClickSound();

        if (PreferencesFactory.GetInt(Constants.KeyNotificationsAllowed, 1) == 1)
        {
            PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, 0);

            if (!Debug.isDebugBuild)
            {
                Flurry.Flurry.Instance.LogEvent("Notifications_Off");
                Fabric.Answers.Answers.LogCustom("Notifications_Off");
            }

            GameManager.SafeQueueMessage(new UserNotificationsChangedMessage(false));
        }
        else
        {
            PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, 1);

            if (!LocalNotifications.Allowed())
            {
                LocalNotifications.AllowDialog(() => {
                    PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, 0);

                    GameObject _n  = GameObjectHelper.GetChildNamedGameObject(gameObject, "Notifications", true);
                    Switch _switch = GameObjectHelper.GetChildComponentOnNamedGameObject <Switch> (_n, "Switch", true);

                    _switch.SetOn(false);
                });
            }
            else
            {
                GameManager.SafeQueueMessage(new UserNotificationsChangedMessage(true));
            }
        }
    }
Example #12
0
 public void Initialize()
 {
     // set our pin listeners on the button
     ThreadUtil.Start(() => ButtonUtils.OnBoardButtonPushed(WriteToLed));
 }
Example #13
0
    public virtual void Show(bool isWon, float time, int points = 0, ChallengeManager.GameStates gameState = ChallengeManager.GameStates.Leaved, ChallengeManager.GameStateMessage message = null)
    {
        _multiplayer = GameSparksManager.Instance.GetGameMode() == GameMode.Multi;

        _buttonPurchaseObject = GameObject.Find("PurchaseButton");

        if (_buttonPurchaseObject != null && !_multiplayer)
        {
            _inviteOriginalParent   = _buttonPurchaseObject.transform.parent.gameObject;
            _inviteOriginalPosition = _buttonPurchaseObject.transform.position;

            _inviteButtonObject = gameObject;
            DialogInstance _inviteDialogInstance = gameObject.GetComponent <DialogInstance>();

            GameObjectUtils.MoveObjectToAtIndex(_buttonPurchaseObject, _inviteDialogInstance.Target, 1);
        }

        pointsView      = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "PointsView", true);
        shareView       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "SharingView", true);
        multiplayerView = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "MultiplayerPointsView", true);

        if (_multiplayer)
        {
            pointsView.SetActive(false);
            multiplayerView.SetActive(true);

            if (gameState == ChallengeManager.GameStates.Won || gameState == ChallengeManager.GameStates.Draw)
            {
                ButtonUtils.PlayWinSound();
            }
            else
            {
                ButtonUtils.PlayLoseSound();
            }
        }
        else
        {
            pointsView.SetActive(true);
            multiplayerView.SetActive(false);

            ButtonUtils.PlayWinSound();
        }

        var currentLevel = GameManager.Instance.Levels.Selected;

        int  coins           = 0;
        bool firstTimePlayed = _multiplayer ? true : currentLevel.ProgressBest < 0.9f;

        LevelManager.Instance.EndLevel();

        this.Coins = coins;

        if (firstTimePlayed && !_multiplayer)
        {
            currentLevel.AddPoints(points);
            currentLevel.ProgressBest = 1.0f;
        }

        if (_multiplayer && gameState == ChallengeManager.GameStates.Lost)
        {
            points *= -1;
        }

        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Dialog", true), false);

        Assert.IsTrue(LevelManager.IsActive, "Ensure that you have a LevelManager component attached to your scene.");

        if (coins > 0 && !_multiplayer)
        { // add coins for this level
            currentLevel.AddCoins(coins);
            GameManager.Instance.Player.AddCoins(coins);
        }

        GameManager.Instance.Player.AddPoints(points);

        // update the player coins if necessary
        if (((UpdatePlayerCoins == CopyType.Always) || (UpdatePlayerCoins == CopyType.OnWin && isWon)) && !_multiplayer)
        {
            GameManager.Instance.Player.AddCoins(currentLevel.Coins);
        }

        // show won / lost game objects as appropriate
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Lost", true), !isWon);

        // see if the world or game is won and also if we should unlock the next world / level
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "GameWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "WorldWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelWon", true), false);
        GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), false);

        GameObject levelName = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "LevelName", true);

        if (_multiplayer)
        {
            levelName.GetComponent <Text>().text = LocaliseText.Get("LevelCompleted.Match");
        }
        else
        {
            levelName.GetComponent <Text>().text = LocaliseText.Format("LevelCompleted.LevelName", currentLevel.Number);
        }

        GameObjectHelper.SafeSetActive(levelName, true);

        if (!_multiplayer && isWon)
        {
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Won", true), true);

            // process and update game state - do this last so we can check some bits above.
            GameHelper.ProcessCurrentLevelComplete();
        }

        // set some text based upon the result
        UIHelper.SetTextOnChildGameObject(DialogInstance.gameObject, "AchievementText", LocaliseText.Format(LocalisationBase + ".Achievement", currentLevel.Score, currentLevel.Name));

        // setup stars
        var starsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Stars", true);

        GameObjectHelper.SafeSetActive(starsGameObject, ShowStars);
        if (ShowStars && !_multiplayer)
        {
            Assert.IsNotNull(starsGameObject, "GameOver->ShowStars is enabled, but could not find a 'Stars' gameobject. Disable the option or fix the structure.");
            starsGameObject.SetActive(ShowStars);
            var newStarsWon = GetNewStarsWon();
            currentLevel.StarsWon |= newStarsWon;
            var star1WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star1", true);
            var star2WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star2", true);
            var star3WonGameObject = GameObjectHelper.GetChildNamedGameObject(starsGameObject, "Star3", true);
            StarWon(currentLevel.StarsWon, newStarsWon, star1WonGameObject, 1, coins);
            StarWon(currentLevel.StarsWon, newStarsWon, star2WonGameObject, 2, coins);
            StarWon(currentLevel.StarsWon, newStarsWon, star3WonGameObject, 4, coins);
            GameObjectHelper.SafeSetActive(GameObjectHelper.GetChildNamedGameObject(starsGameObject, "StarWon", true), newStarsWon != 0);
        }

        // set time

        var timeGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Time", true);

        GameObjectHelper.SafeSetActive(timeGameObject, ShowTime);
        if (!_multiplayer && ShowTime)
        {
            TimeSpan timeSpan = TimeSpan.FromSeconds(time);

            string timeText = LocaliseText.Format("LevelCompleted.Time", timeSpan.Minutes, timeSpan.Seconds);

            Assert.IsNotNull(timeGameObject, "GameOver->ShowTime is enabled, but could not find a 'Time' gameobject. Disable the option or fix the structure.");

            UIHelper.SetTextOnChildGameObject(timeGameObject, "TimeResult", timeText, true);
        }

        if (!_multiplayer && currentLevel.TimeBest < 0.05)
        { // save only first time played
            currentLevel.TimeBest = time;
        }

        // set coins
        if (ShowCoins && coins > 0)
        {
            var coinsGameObject = GameObjectHelper.GetChildNamedGameObject(DialogInstance.gameObject, "Coins", true);
            GameObjectHelper.SafeSetActive(coinsGameObject, ShowCoins);

            Assert.IsNotNull(coinsGameObject, "GameOver->ShowCoins is enabled, but could not find a 'Coins' gameobject. Disable the option or fix the structure.");
            UIHelper.SetTextOnChildGameObject(coinsGameObject, "CoinsResult", coins.ToString(), true);
        }

        if (!_multiplayer)
        {
            if (firstTimePlayed)
            {
                GameObject DoubleButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "DoubleButton", true);
                DoubleButton.SetActive(Reachability.Instance.IsReachable());
            }
            else
            {
                GameObject ShareButton = GameObjectHelper.GetChildNamedGameObject(pointsView, "ShareButton", true);
                ShareButton.SetActive(true);
            }
        }

        // set score
        var scoreGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "Score", true);

        GameObjectHelper.SafeSetActive(scoreGameObject, ShowScore);

        if (!firstTimePlayed)
        {
            GameObjectHelper.SafeSetActive(scoreGameObject, false);
        }

        if (!_multiplayer && firstTimePlayed)
        {
            GameObject adsObject  = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true);
            Text       unlockText = GameObjectHelper.GetChildComponentOnNamedGameObject <Text>(pointsView, "UnlockText", true);

            if (LevelController.Instance.LastLevelInPack(currentLevel))
            {
                Pack pack     = LevelController.Instance.PackForLevel(currentLevel);
                Pack nextPack = LevelController.Packs().GetItem(pack.Number + 1);

                if (nextPack)
                {
                    nextPack.LoadData();

                    adsObject.SetActive(false);
                    unlockText.gameObject.SetActive(true);

                    unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInPack", LocaliseText.Get(nextPack.JsonData.GetString("name")));
                }
            }

            if (LevelController.Instance.LastLevelInRank(currentLevel))
            {
                Rank rank     = LevelController.Instance.RankForLevel(currentLevel);
                Rank nextRank = LevelController.Ranks().GetItem(rank.Number + 1);

                if (nextRank)
                {
                    nextRank.LoadData();

                    adsObject.SetActive(false);
                    unlockText.gameObject.SetActive(true);

                    unlockText.text = LocaliseText.Format("LevelCompleted.LastLevelInRank", LocaliseText.Get(nextRank.JsonData.GetString("name")));
                }
            }
        }

        if (ShowScore)
        {
            Assert.IsNotNull(scoreGameObject, "GameOver->ShowScore is enabled, but could not find a 'Score' gameobject. Disable the option or fix the structure.");

            UIHelper.SetTextOnChildGameObject(scoreGameObject, "ScoreResult", LocaliseText.Format("LevelCompleted.Score", "0"), true);

            AnimateScoreText(points);
        }

        if (_multiplayer)
        {
            var resultStateObject = GameObjectHelper.GetChildNamedGameObject(multiplayerView, "ResultState", true);
            GameObjectHelper.SafeSetActive(resultStateObject, true);

            string text = "";

            switch (gameState)
            {
            case ChallengeManager.GameStates.Won:
                text = LocaliseText.Get("Game.YouWon");
                break;

            case ChallengeManager.GameStates.Lost:
                text = LocaliseText.Get("Game.YouLost");
                break;

            case ChallengeManager.GameStates.Draw:
                text = LocaliseText.Get("Game.ItsDrawn");
                break;
            }

            resultStateObject.GetComponent <Text>().text = text;
        }

        if (!_multiplayer)
        {
            UpdateNeededCoins();

            LevelController.Instance.PackProgressCompleted(currentLevel);
            UnlockNextLevel();

            //

            int StartupLevels = ((CustomGameManager)CustomGameManager.Instance).StartupLevels;

            if (StartupLevels == currentLevel.Number)
            {
                GameObject adsObject = GameObjectHelper.GetChildNamedGameObject(pointsView, "Ads", true);

                Text adsText = adsObject.GetComponent <Text>();

                adsText.text                 = LocaliseText.Get("Text.PlayedAllLevels");
                adsText.fontSize             = 39;
                adsText.resizeTextForBestFit = false;

                if (!Debug.isDebugBuild)
                {
                    Flurry.Flurry.Instance.LogEvent("Game_LastLevel", new Dictionary <string, string>()
                    {
                        { "Level", currentLevel.Number.ToString() }
                    });
                    Fabric.Answers.Answers.LogCustom("Game_LastLevel", new Dictionary <string, object>()
                    {
                        { "Level", currentLevel.Number.ToString() }
                    });
                }
            }
        }

        if (!_multiplayer && firstTimePlayed)
        {
            JSONObject pointsData = new JSONObject();
            pointsData.Add("Level", currentLevel.Number.ToString());
            pointsData.Add("Language", LocaliseText.Language);
            pointsData.Add("RealLanguage", LanguageUtils.RealLanguage(LocaliseText.Language));
            pointsData.Add("Time", time.ToString());
            pointsData.Add("UsedHints", GameController.Instance.usedHintsCount);
            pointsData.Add("UserCoins", GameManager.Instance.Player.Coins);
            pointsData.Add("Words", JsonUtils.ListToArray(GameController.Instance.GetFoundWords()));
            pointsData.Add("Date", DateTimeUtils.DateTimeToISO8601(UnbiasedTime.Instance.UTCNow()));

            GameSparksManager.Instance.SendPoints(points, "LevelComplete", pointsData);
        }

        //

        GameObject completeTextGameObject = GameObjectHelper.GetChildNamedGameObject(_multiplayer ? multiplayerView : pointsView, "CompleteText", true);

        // save game state.
        GameManager.Instance.Player.UpdatePlayerPrefs();

        if (!_multiplayer)
        {
            currentLevel.UpdatePlayerPrefs();
        }

        PreferencesFactory.Save();

        GameObject NameContainer = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "NameContainer", true);
        GameObject LevelName     = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "LevelName", true);
        GameObject Results       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Results", true);
        GameObject Buttons       = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Buttons", true);
        GameObject CloseButton   = GameObjectHelper.GetChildNamedGameObject(DialogInstance.Content, "Close", true);

        GameObject parent = DialogInstance.Content.transform.parent.gameObject;

        Vector3 currentScale = parent.transform.localScale;

        parent.transform.DOScale(new Vector3(0, 0, 0), 0.0f);
        NameContainer.transform.localScale          = new Vector3(0, 0, 0);
        LevelName.transform.localScale              = new Vector3(0, 0, 0);
        Results.transform.localScale                = new Vector3(0, 0, 0);
        Buttons.transform.localScale                = new Vector3(0, 0, 0);
        completeTextGameObject.transform.localScale = new Vector3(0, 0, 0);

        CloseButton.GetComponent <Image>().color = new Color(1, 1, 1, 0);

        //show dialog
        DialogInstance.Show();

        parent.transform.DOScale(currentScale, 1.0f).SetEase(Ease.OutElastic);
        NameContainer.transform.DOScale(new Vector3(1, 1, 1), 1.5f).SetDelay(0.1f).SetEase(Ease.OutElastic);
        LevelName.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        Results.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        Buttons.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.2f).SetEase(Ease.OutElastic);
        completeTextGameObject.transform.DOScale(new Vector3(1, 1, 1), 0.8f).SetDelay(0.35f).SetEase(Ease.OutElastic);

        CloseButton.GetComponent <Image>().DOFade(1, 0.5f).SetDelay(0.7f);

        GameObject Light = GameObjectHelper.GetChildNamedGameObject(completeTextGameObject, "Light", true);

        Light.transform.DOLocalRotate(new Vector3(0, 0, -360), 10, RotateMode.LocalAxisAdd).SetLoops(-1).SetEase(Ease.Linear);

        //TODO bug - as we increase TimesPlayedForRatingPrompt on both game start (GameManager) and level finish we can miss this comparison.
        if (GameManager.Instance.TimesPlayedForRatingPrompt == TimesPlayedBeforeRatingPrompt)
        {
            GameFeedback gameFeedback = new GameFeedback();
            gameFeedback.GameFeedbackAssumeTheyLikeOptional();
        }

#if UNITY_ANALYTICS
        // record some analytics on the level played
        if (!_multiplayer)
        {
            var values = new Dictionary <string, object>
            {
                { "score", currentLevel.Score },
                { "Coins", coins },
                { "time", time },
                { "level", currentLevel.Number }
            };
            Analytics.CustomEvent("LevelCompleted", values);
        }
#endif

#if UNITY_EDITOR
        if (!_multiplayer)
        {
            GameSparksManager.Instance.SyncProgressCoroutine();
        }
#endif

#if !UNITY_EDITOR
        AdColonyManager.Instance.RequestAd();
        AdColonyManager.Instance.RequestAd(Constants.AdColonyDoubleCoins);

        LoadInterstitialAd();
        LoadAdmobRewarderVideo();
#endif

        // co routine to periodic updates of display (don't need to do this every frame)
        if (!Mathf.Approximately(PeriodicUpdateDelay, 0))
        {
            StartCoroutine(PeriodicUpdate());
        }
    }
    public void Searching()
    {
        var username = _searchField.text;

        if (username.Length == 0)
        {
            ChallengeManager.Instance.RefreshChallengesList();

            return;
        }

        _activityIndicator.SetActive(true);

        GameSparksManager.Instance.SearchOnlineUser(username, (List <ChallengeManager.Challenge> challenges) => {
            _mapUsersAvatar.Clear();

            foreach (Transform child in _scrollView.transform)
            {
                Destroy(child.gameObject);
            }

            foreach (var challenge in challenges)
            {
                var prefabButton = Instantiate(_usersPrefab);
                prefabButton.transform.SetParent(_scrollView.transform, false);

                var nameText  = GameObjectHelper.GetChildComponentOnNamedGameObject <Text> (prefabButton, "Name", true);
                nameText.text = challenge.UserName;

                if (challenge.AvatarUploadId != null)
                {
                    var image = GameObjectHelper.GetChildComponentOnNamedGameObject <RawImage> (prefabButton, "AvatarImage", true);

                    GameSparksManager.Instance.DownloadAvatar(challenge.AvatarUploadId, (Texture2D tex) => {
                        if (tex != null && image != null)
                        {
                            image.texture = tex;
                        }
                    });
                }
                else
                {
                    string FBUserId = challenge.ExternalIds == null ? null : challenge.ExternalIds.GetString("FB");

                    if (FBUserId != null && !_mapUsersAvatar.ContainsKey(FBUserId))
                    {
                        _mapUsersAvatar.Add(FBUserId, prefabButton);

                        FacebookRequests.Instance.LoadProfileImages(FBUserId);
                    }
                }

                var inside     = prefabButton.GetComponent <Button>();
                var challenge1 = challenge;
                inside.onClick.AddListener(delegate
                {
                    ButtonUtils.PlayClickSound();

                    if (_isUserLoggedIn)
                    {
                        if (!Reachability.Instance.IsReachable())
                        {
                            DialogManager.Instance.ShowInfo(LocaliseText.Get("GeneralMessage.NoInternet"));
                        }
                        else
                        {
                            LeaveLoby();
                            ChallengeManager.Instance.SendJoinChallengeRequest(challenge1.ChallengeId);
                        }
                    }
                    else
                    {
                        DialogManager.Instance.Show("SignInDialog");
                    }
                });
            }

            _activityIndicator.SetActive(false);
        });
    }