Exemplo 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);
        }
    }
Exemplo n.º 2
0
        //get default element data
        public static List <StagePart> GetDefaultElementsData()
        {
            List <StagePart> stageElements = new List <StagePart> ();
            StagePart        part;

            for (int i = 0; i < maxCount; i++)
            {
                part = new StagePart();
                if (i != 0)
                {
                    part.isLocked = true;
                }

                part.id = (i + 1);
                stageElements.Add(part);
            }
            return(stageElements);
        }
Exemplo n.º 3
0
        //get stage current element data
        public static List <StagePart> GetStageCurrentElementsData()
        {
            GameObject [] stagesObjects = GameObject.FindGameObjectsWithTag("StageElement");

            if (stagesObjects == null)
            {
                return(GetDefaultElementsData());
            }
            else if (stagesObjects.Length == 0)
            {
                return(GetDefaultElementsData());
            }

            List <StagePart> stageElements = new List <StagePart> ();

            int          count = stagesObjects.Length;
            StageElement sp;
            StagePart    part;

            for (int i = 0; i < count; i++)
            {
                sp = stagesObjects [i].GetComponent <StageElement> ();

                if (sp == null)
                {
                    Debug.LogError("Null StageElement Component");
                    continue;
                }

                part           = new StagePart();
                part.id        = sp.id;
                part.starLevel = sp.starLevel;
                part.isLocked  = sp.isLocked;
                stageElements.Add(part);
            }
            return(stageElements);
        }
Exemplo n.º 4
0
        //get stage current element data
        public static List<StagePart> GetStageCurrentElementsData()
        {
            GameObject [] stagesObjects = GameObject.FindGameObjectsWithTag ("StageElement");

                        if (stagesObjects == null) {
                                return GetDefaultElementsData ();
                        } else if (stagesObjects.Length == 0) {
                                return GetDefaultElementsData ();
                        }

                        List<StagePart> stageElements = new List<StagePart> ();

                        int count = stagesObjects.Length;
                        StageElement sp;
                        StagePart part;
                        for (int i = 0; i < count; i++) {

                                sp = stagesObjects [i].GetComponent<StageElement> ();

                                if (sp == null) {
                                        Debug.LogError ("Null StageElement Component");
                                        continue;
                                }

                                part = new StagePart ();
                                part.id = sp.id;
                                part.starLevel = sp.starLevel;
                                part.isLocked = sp.isLocked;
                                stageElements.Add (part);
                        }
                        return stageElements;
        }
Exemplo n.º 5
0
        //get default element data
        public static List<StagePart> GetDefaultElementsData()
        {
            List<StagePart> stageElements = new List<StagePart> ();
                        StagePart part;
                        for (int i = 0; i  <maxCount; i++) {
                                part = new StagePart ();
                                if (i != 0) {
                                        part.isLocked = true;
                                }

                                part.id = (i + 1);
                                stageElements.Add (part);

                        }
                        return stageElements;
        }