Ejemplo n.º 1
0
 public void OnRestartAfterInterstitialClosed(EventData e)
 {
     EventManager.OnInterstitialClosedEvent -= OnRestartAfterInterstitialClosed;
     Hide();
     GameManager.Instance.Game.RestartGame();
     ZAnalitycs.RestartLevelEvent();
 }
Ejemplo n.º 2
0
    public void Initialize()
    {
        Input.multiTouchEnabled = false;
        Localer.Init();
        CreatePauseListener();
        GameData         = new GameData();
        Settings         = new ZPlayerSettings();
        AtlasFramesCache = new AtlasFramesCache();
        GameFlow         = new GameFlow();
        EventManager     = new EventManager();
        CurrentMenu      = UISetType.Global;
        // Feeding
        BoardData  = new GameBoardData();
        IAPManager = new ZIAPManager();

        ZAnalitycs.Initialize();
    }
Ejemplo n.º 3
0
    public void ButtonRestartOnClick()
    {
        if (_isHiding)
        {
            return;
        }
        GameManager.Instance.Player.RestartCounter++;

        if (GameManager.Instance.Player.RestartCounter == 3)
        {
            GameManager.Instance.Player.RestartCounter = 0;
            EventManager.OnInterstitialClosedEvent    += OnRestartAfterInterstitialClosed;
            GameManager.Instance.Ads.ShowInterstitial();
        }
        else
        {
            Hide();
            GameManager.Instance.Game.RestartGame();
            ZAnalitycs.RestartLevelEvent();
        }
    }
Ejemplo n.º 4
0
    /////////////// MAIN_MENU
    //#if UNITY_STANDALONE
    //IEnumerator LoadLogo()
    //{
    //	string path = Application.streamingAssetsPath + "/logo.png";
    //	string url = "file://" + path;
    //	WWW www = new WWW(url);
    //	yield return www;
    //	Sprite aSprite = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0)); // new Vector2(www.texture.width / 2, www.texture.height / 2));
    //	Image im = transform.Find("MGLogo").GetComponent<Image>();
    //	im.sprite = aSprite;
    //	im.SetNativeSize();
    //}
    //#else
    //void LoadLogo()
    //{
    //Sprite aSprite = Resources.Load<Sprite>("art/Splash/logo");
    //Image im = transform.Find("MGLogo").GetComponent<Image>();
    //im.sprite = aSprite;
    ////im.SetNativeSize();
    //}
    //#endif

    public void ButtonPlayEndlessOnClick()
    {
        //MusicManager.PlayGameTracks();

        //GameManager.Instance.BoardData.AGameBoard.RestartGame(); no need for restart course this clears saved game!
        GameManager.Instance.CurrentMenu = UISetType.ClassicGame;
        EventData eventData = new EventData("OnUISwitchNeededEvent");

        eventData.Data["setid"] = UISetType.ClassicGame;
        GameManager.Instance.EventManager.CallOnUISwitchNeededEvent(eventData);

        GameBoard.AddingType = EAddingType.OnNoMatch;
        if (GameBoard.GameType != EGameType.Classic)
        {
            GameManager.Instance.Game.ClearBoardForce();
            GameManager.Instance.Game.PlayGame();
        }
        else
        {
            GameManager.Instance.Settings.User.SavedGame = null;
        }

        ZAnalitycs.StartEndlessLevelEvent();
    }
Ejemplo n.º 5
0
    public override bool OpenForm(EventData e)
    {
        //TryRescale();
        HideButtons();
        float canvasTime = 0.5f;

        ACanvasGroup.alpha = 0;
        LeanTween.value(ACanvasGroup.gameObject, 0.0f, 1.0f, canvasTime)
        .setOnUpdate((float val) => {
            ACanvasGroup.alpha = val;
        });

        float atime = 0.3f;

        LevelText.text = Localer.GetText("Level") + " " + (GameManager.Instance.Player.CurrentLevel + 1).ToString();
        int starsAmount = (int)GameManager.Instance.BoardData.StarsGained;
        int moves       = GameManager.Instance.BoardData._allTurns;

        for (int i = 0; i < Stars.Count; ++i)
        {
            if (i < starsAmount)
            {
                Stars[i].SetActive(true);
                Image img = Stars[i].GetComponent <Image>();
                img.color = new Color(1, 1, 1, 0);
                int starNumber = i;
                LeanTween.delayedCall(canvasTime + i * atime, () => { PlayStarSound(starNumber); });
                LeanTween.value(img.gameObject, img.color, Color.white, atime)
                .setOnUpdate((Color val) => {
                    img.color = val;
                })
                .setDelay(canvasTime + i * atime);
            }
            else
            {
                Stars[i].SetActive(false);
            }
        }

        LeanTween.delayedCall(canvasTime + starsAmount * atime, ShowButtons);

        //Invoke("ShowButtons", canvasTime + starsAmount * atime);

        int        currentLevel      = GameManager.Instance.Player.CurrentLevel;
        LevelState levelState        = GameManager.Instance.Player.LevelsStates[currentLevel];
        int        prevBest          = levelState.BestMoves;
        bool       firstTimeComplete = prevBest < 0;

        if (firstTimeComplete)
        {
            levelState.BestMoves = moves;
        }
        else
        {
            levelState.BestMoves = Mathf.Min(moves, levelState.BestMoves);
        }
        levelState.Stars = starsAmount;
        //
        GameManager.Instance.Player.LevelsStates[currentLevel] = levelState;

        if (currentLevel == Consts.LEVELS_COUNT - 1)
        {
            // it was last level
            if (firstTimeComplete)
            {
                //TODO Message that you completed all levels!!!!
            }
        }
        else
        {
            // unlock next level
            int        nextLevel      = currentLevel + 1;
            LevelState nextLevelState = GameManager.Instance.Player.LevelsStates[nextLevel];
            nextLevelState.Unlocked = true;
            GameManager.Instance.Player.LevelsStates[nextLevel] = nextLevelState;
            GameManager.Instance.Settings.Save();
        }
        ZAnalitycs.FinishLevelEvent(currentLevel);
        return(true);
    }