Exemplo n.º 1
0
    /// <summary>
    /// 保存并退出
    /// </summary>
    public void saveAndExitOnClick()
    {
        if (CommonData.GameStatus == 1)
        {
            CommonData.GameStatus = 4;
            PuzzlesProgressBean progressBean = new PuzzlesProgressBean();


            GameMainUIControl gameMainUI = mUIMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI);
            if (gameMainUI != null)
            {
                //设置游戏时间
                progressBean.gameTime = gameMainUI.getGameTimer();
            }
            //设置ID
            progressBean.puzzleId     = CommonData.SelectPuzzlesInfo.puzzlesInfo.id;
            progressBean.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name;
            progressBean.progress     = GameUtil.getGameProgress();

            DataStorageManage.getPuzzlesProgressDSHandle().saveData(progressBean);
            SceneUtil.jumpMainScene();
        }
        else
        {
            DialogManager.createToastDialog().setToastText("不能进行此操作");
        }
    }
Exemplo n.º 2
0
    //---------------------------------------------------------------------------------------------
    /// <summary>
    /// 开始游戏
    /// </summary>
    public void gameStart()
    {
        //判断是否有存档
        PuzzlesProgressBean paramsData = new PuzzlesProgressBean();

        paramsData.puzzleId     = CommonData.SelectPuzzlesInfo.puzzlesInfo.id;
        paramsData.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name;
        PuzzlesProgressBean progressData = DataStorageManage.getPuzzlesProgressDSHandle().getData(paramsData);

        TimeBean gameTime = null;

        if (progressData != null)
        {
            gameTime = progressData.gameTime;
            GameUtil.setGameProgress(this, progressData);
        }
        else
        {
        }
        CommonData.IsCheating = false;
        CommonData.GameStatus = 1;
        CommonData.IsDargMove = true;
        Camera.main.gameObject.AddComponent <SecretCodeCpt>();
        GameMainUIControl gameMainUI = uiMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI);

        if (gameMainUI != null)
        {
            gameMainUI.startTimer(gameTime);
        }
    }
Exemplo n.º 3
0
    private void deleteData()
    {
        PuzzlesProgressBean paramsData = new PuzzlesProgressBean();

        paramsData.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name;
        paramsData.puzzleId     = CommonData.SelectPuzzlesInfo.puzzlesInfo.id;
        ((PuzzlesProgressDSHandle)DataStorageManage
         .getPuzzlesProgressDSHandle())
        .deleteData(paramsData);
    }
Exemplo n.º 4
0
    public void CreateInstallItemList(List <SteamWorkshopQueryInstallInfoBean> listData)
    {
        //删除原数据
        for (int i = 0; i < transform.childCount; i++)
        {
            if (transform.GetChild(i).gameObject.activeSelf)
            {
                Destroy(transform.GetChild(i).gameObject);
            }
        }

        List <PuzzlesInfoBean>          listPuzzlesInfo  = CreateGameInfoListByInstallInfo(listData);
        List <PuzzlesCompleteStateBean> listCompleteData = DataStorageManage.getPuzzlesCompleteDSHandle().getAllData();
        List <PuzzlesProgressBean>      listProgressData = DataStorageManage.getPuzzlesProgressDSHandle().getAllData();
        List <PuzzlesGameInfoBean>      listGameInfoData = PuzzlesDataUtil.MergePuzzlesInfo(listPuzzlesInfo, listCompleteData, listProgressData);

        for (int itemPosition = 0; itemPosition < listData.Count; itemPosition++)
        {
            PuzzlesGameInfoBean itemInfo = listGameInfoData[itemPosition];
            CreateInstallItem(itemInfo);
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// 读取拼图信息
    /// </summary>
    /// <param name="resourcesEnum"></param>
    public void loadJigsaw(JigsawResourcesEnum resourcesEnum)
    {
        StopAllCoroutines();
        resourcesType = resourcesEnum;
        //删除原数据
        for (int i = 0; i < transform.childCount; i++)
        {
            Destroy(transform.GetChild(i).gameObject);
        }

        //加载该类型下所有拼图数据
        List <PuzzlesInfoBean> listInfoData = null;

        if (resourcesEnum.Equals(JigsawResourcesEnum.Custom))
        {
            listInfoData = DataStorageManage.getCustomPuzzlesInfoDSHandle().getAllData();
            createAddItem();
        }
        else
        {
            listInfoData = PuzzlesInfoManager.LoadAllPuzzlesDataByType(resourcesEnum);
        }

        if (listInfoData == null || listInfoData.Count == 0)
        {
            return;
        }
        listInfoData.Sort((x, y) => x.Level.CompareTo(y.Level));

        List <PuzzlesCompleteStateBean> listCompleteData = DataStorageManage.getPuzzlesCompleteDSHandle().getAllData();
        List <PuzzlesProgressBean>      listProgressData = DataStorageManage.getPuzzlesProgressDSHandle().getAllData();
        List <PuzzlesGameInfoBean>      listData         = PuzzlesDataUtil.MergePuzzlesInfo(listInfoData, listCompleteData, listProgressData);

        for (int itemPosition = 0; itemPosition < listData.Count; itemPosition++)
        {
            PuzzlesGameInfoBean itemInfo = listData[itemPosition];
            createSelectItem(itemPosition, itemInfo);
        }
    }
Exemplo n.º 6
0
    /// <summary>
    /// 游戏完成
    /// </summary>
    public void gameFinsh()
    {
        CommonData.GameStatus   = 2;
        CommonData.IsDargMove   = false;
        CommonData.IsMoveCamera = false;
        //删除游戏进度
        PuzzlesProgressBean progressTemp = new PuzzlesProgressBean();

        progressTemp.puzzleId     = CommonData.SelectPuzzlesInfo.puzzlesInfo.id;
        progressTemp.markFileName = CommonData.SelectPuzzlesInfo.puzzlesInfo.mark_file_name;
        ((PuzzlesProgressDSHandle)DataStorageManage.getPuzzlesProgressDSHandle()).deleteData(progressTemp);

        float startCameraOrthographicSize = cameraControl.startCameraOrthographicSize;
        //结束游戏时间
        GameMainUIControl gameMainUI   = uiMasterControl.getUIByType <GameMainUIControl>(UIEnum.GameMainUI);
        TimeBean          completeTime = null;

        if (gameMainUI != null)
        {
            gameMainUI.endTimer();
            completeTime = gameMainUI.getGameTimer();
        }

        if (!CommonData.IsCheating)
        {
            if (CommonData.SelectPuzzlesInfo.puzzlesInfo.data_type.Equals((int)JigsawResourcesEnum.Custom))
            {
            }
            else
            {
                //增加PP
                int addPuzzlesPoint = CommonData.SelectPuzzlesInfo.puzzlesInfo.level * 2;
                DialogManager.createPuzzlesPointAddDialog(addPuzzlesPoint);
            }
            //保存数据
            GameUtil.FinshSaveCompleteData(CommonData.SelectPuzzlesInfo, completeTime);
        }

        //动画结束后显示排行榜
        transform.DOScale(new Vector3(1, 1), gameFinshAnimTime).OnComplete(delegate()
        {
            if (CommonData.SelectPuzzlesInfo.puzzlesInfo.data_type.Equals((int)JigsawResourcesEnum.Custom))
            {
                SceneUtil.jumpMainScene();
            }
            else
            {
                int leaderType = 0;
                if (CommonData.IsCheating)
                {
                    leaderType = 1;
                }
                else
                {
                    //没有作弊 放烟花
                    //GameObject dialogObj = Instantiate(ResourcesManager.LoadData<GameObject>("Prefab/Particle/Background/GameFinshParticle"));
                    //Canvas gameFinshCanvas = dialogObj.GetComponent<Canvas>();
                    //gameFinshCanvas.renderMode = RenderMode.ScreenSpaceCamera;
                    //gameFinshCanvas.worldCamera = Camera.main;
                }
                DialogManager
                .createLeaderBoradDialog(leaderType, CommonData.SelectPuzzlesInfo)
                .setUserScore(completeTime.totalSeconds)
                .setCallBack(this)
                .setCancelButtonStr(CommonData.getText(21))
                .setSubmitButtonStr(CommonData.getText(23));
            }
            CommonData.IsCheating = false;
        });

        //镜头移动
        cameraControl.transform.DOMove(cameraControl.startCameraPosition, gameFinshAnimTime);
        Tween cameraTW = DOTween
                         .To(() => Camera.main.orthographicSize, x => Camera.main.orthographicSize = x, startCameraOrthographicSize, gameFinshAnimTime);
        //图像归位
        int containerListSize = containerList.Count;

        for (int i = 0; i < containerListSize; i++)
        {
            GameObject container = containerList[i];
            if (container != null)
            {
                JigsawContainerCpt containerCpt = container.GetComponent <JigsawContainerCpt>();
                Rigidbody2D        containerRB  = container.GetComponent <Rigidbody2D>();
                containerRB.Sleep();

                container.transform.DORotate(new Vector3(containerCpt.startRotation.x, containerCpt.startRotation.y), gameFinshAnimTime);
                container.transform.DOMove(containerCpt.startPosition, gameFinshAnimTime);
                break;
            }
        }

        //设置成就
        List <PuzzlesCompleteStateBean> listCompleteState = ((PuzzlesCompleteDSHandle)DataStorageManage.getPuzzlesCompleteDSHandle()).getDefAllData();

        if (listCompleteState != null && listCompleteState.Count != 0)
        {
            int completeNumber = 0;
            foreach (PuzzlesCompleteStateBean itemState in listCompleteState)
            {
                if (itemState.completeTime != null && itemState.completeTime.totalSeconds != 0)
                {
                    completeNumber++;
                }
            }
            IUserAchievementHandle userAchievement = new UserStatsHandleImpl();
            userAchievement.userCompleteNumberChange(completeNumber);
        }
    }