Esempio n. 1
0
    //on game win
    public void OnGameWin()
    {
        try {
            if (dialogsComponent.winDialog.activeSelf || dialogsComponent.loseDialog.activeSelf || shownDialogType != Game.DialogType.WIN)
            {
                return;
            }
            pauseButtonCollider.enabled = false;
            General.audioManagerComp.FadeOutClip(SFX.instance.audioSources [0], 0.5f, 0.1f);
            blackScreenAnimatorComp.SetBool("isFadingOut", false);
            blackScreenAnimatorComp.SetBool("isFadingIn", true);
            dialogsComponent.winDialog.SetActive(true);
            Animator winDialogAnimatorComp = dialogsComponent.winDialog.GetComponent <Animator> ();
            winDialogAnimatorComp.SetBool("isFadingOut", false);
            winDialogAnimatorComp.SetBool("isFadingIn", true);

            if (winStarsCount >= 1 && winStarsCount <= 3)
            {
                //Save new level data To file
                StorageManager.StagesDataRoot stagesDataRoot = StorageManager.StagesStorageHelper.stagesDataRoot;

                if (stagesDataRoot == null)
                {
                    Debug.Log("stagesDataRoot is undefined");
                    return;
                }
                if (stagesDataRoot.stagesParts == null)
                {
                    Debug.Log("stagesDataRoot.stagesParts is undefined");
                    return;
                }

                StorageManager.StagePart currentStagePart = StorageManager.StagesStorageHelper.GetStagePartById(Stage.selectedElementId, stagesDataRoot.stagesParts);

                if (currentStagePart == null)
                {
                    Debug.Log("currentStagePart is undefined");
                    return;
                }
                if (Stage.selectedElementId + 1 <= StorageManager.StagesStorageHelper.MaxElementsCount)
                {
                    StorageManager.StagePart nextStagePart = StorageManager.StagesStorageHelper.GetStagePartById(Stage.selectedElementId + 1, stagesDataRoot.stagesParts);
                    nextStagePart.isLocked = false;
                }

                if (currentStagePart != null)
                {
                    currentStagePart.isLocked  = false;
                    currentStagePart.starLevel = Game.winStarsCount;
                    StorageManager.StagesStorageHelper.WriteStagesData(stagesDataRoot);
                }
                else
                {
                    Debug.Log("currentStagePart is undefined");
                }
            }
        } catch (Exception ex) {
            Debug.LogError(ex.Message);
        }
    }
Esempio n. 2
0
        //wirte stages data
        public static void WriteStagesData(StagesDataRoot root)
        {
            string path = FileManager.getPlatformPath() + fileName;

            FileManager.WriteToBinaryFile(path, root);
            Debug.Log("Stages Data has been written at " + Time.time);
        }
Esempio n. 3
0
    //on reset yes click event
    private void OnResetYesClick(Object ob)
    {
        StorageManager.StagesDataRoot stagesDataRoot = new StorageManager.StagesDataRoot();
        stagesDataRoot.stagesParts = StorageManager.StagesStorageHelper.GetDefaultElementsData();
        StorageManager.StagesStorageHelper.WriteStagesData(stagesDataRoot);
        Animator dialogAnimator = GameObject.Find("Main").GetComponent <Animator> ();

        dialogAnimator.SetBool("isFadingIn", false);
        dialogAnimator.SetBool("isYesFadingOut", true);
    }
Esempio n. 4
0
        //Read stages data
        public static StagesDataRoot ReadStagesData()
        {
            StagesDataRoot root = null;
            string         path = FileManager.getPlatformPath() + fileName;

            if (!FileManager.IsFileExists(path))
            {
                root             = new StagesDataRoot();
                root.stagesParts = GetStageCurrentElementsData();
                WriteStagesData(root);
            }
            else
            {
                root = (StagesDataRoot)FileManager.ReadFromBinaryFile <StagesDataRoot> (path);
                if (FileManager.isException)
                {
                    WriteStagesData(root);
                }
                Debug.Log("Stages Data has been readed at " + Time.time);
            }

            return(root);
        }
Esempio n. 5
0
 //wirte stages data
 public static void WriteStagesData(StagesDataRoot root)
 {
     string path = FileManager.getPlatformPath () + fileName;
                 FileManager.WriteToBinaryFile (path, root);
                 Debug.Log ("Stages Data has been written at " + Time.time);
 }
Esempio n. 6
0
        //Read stages data
        public static StagesDataRoot ReadStagesData()
        {
            StagesDataRoot root = null;
                        string path = FileManager.getPlatformPath () + fileName;
                        if (!FileManager.IsFileExists (path)) {
                                root = new StagesDataRoot ();
                                root.stagesParts = GetStageCurrentElementsData ();
                                WriteStagesData (root);
                        } else {
                                root = (StagesDataRoot)FileManager.ReadFromBinaryFile<StagesDataRoot> (path);
                                if (FileManager.isException) {
                                        WriteStagesData (root);
                                }
                                Debug.Log ("Stages Data has been readed at " + Time.time);
                        }

                        return root;
        }
Esempio n. 7
0
 //on reset yes click event
 private void OnResetYesClick(Object ob)
 {
     StorageManager.StagesDataRoot stagesDataRoot = new StorageManager.StagesDataRoot ();
             stagesDataRoot.stagesParts = StorageManager.StagesStorageHelper.GetDefaultElementsData ();
             StorageManager.StagesStorageHelper.WriteStagesData (stagesDataRoot);
             Animator dialogAnimator = GameObject.Find ("Main").GetComponent<Animator> ();
             dialogAnimator.SetBool ("isFadingIn", false);
             dialogAnimator.SetBool ("isYesFadingOut", true);
 }