コード例 #1
0
    public void InitView(Action <GameState, Dictionary <string, object> > onChangeState, SettingType settingType, GameState beforeGameState, UserData userData)
    {
        _onChangeState     = onChangeState;
        _currentUserData   = userData;
        _textViewName.text = settingType == SettingType.Save ? VIEW_NAME_SAVE : VIEW_NAME_LOAD;
        var userDatas = PlayerPrefsUtil.GetValue <UserData[]>(KEY_USER_DATA_LIST);

        if (userDatas == null || userDatas.Length <= 0)
        {
            _userDataList = new List <UserData>();
            for (int i = 0; i < 5; i++)
            {
                var index = i;
                _userDataList.Add(new UserData(index + 1));
            }
        }
        else
        {
            _userDataList = userDatas.ToList();
        }

        ScreenCapture.CaptureScreenshot($"{RESOURCES_SCREEN_SHOT_PATH} {TEST_SCREEN_SHOT_NAME}.png");
        cacheScreenShot = ResourceManager.Instance.LoadScreenShot(TEST_SCREEN_SHOT_NAME);



        gameObject.SetActive(true);
        _currentSettingType = settingType;

        if (_gameDataPanelList == null)
        {
            _gameDataPanelList = new List <GameDataPanel>();
        }


        UpdateGameDataPanel();


        _buttonOK.onClick.RemoveAllListeners();
        _buttonOK.onClick.AddListener(delegate {
            OnClickOkButton();
        });

        _buttonCancel.onClick.RemoveAllListeners();
        _buttonCancel.onClick.AddListener(delegate {
            _objConfirmation.SetActive(false);
        });
        _buttonReturn.onClick.RemoveAllListeners();
        _buttonReturn.onClick.AddListener(delegate {
            gameObject.SetActive(false);
            _onChangeState(beforeGameState, new Dictionary <string, object>());
        });
    }
コード例 #2
0
    /// <summary>
    /// 開放済みエンディングId一覧を取得する
    /// </summary>
    /// <returns></returns>
    private List <long> GetUnlockedEndingIdList()
    {
        var unlockedEndingIdList = new List <long>();
        var userDatas            = PlayerPrefsUtil.GetValue <UserData[]>(KEY_USER_DATA_LIST);


        if (userDatas != null && userDatas.Length > 0)
        {
            foreach (var data in userDatas)
            {
                foreach (var id in data.endingIds)
                {
                    if (!unlockedEndingIdList.Contains(id))
                    {
                        unlockedEndingIdList.Add(id);
                    }
                }
            }
        }
        return(unlockedEndingIdList);
    }
コード例 #3
0
    public void InitView(long endingId, Action <GameState, Dictionary <string, object> > onChangeState, Action tapCallBack = null, UserData userData = null)
    {
        var endingData = ResourceManager.Instance.LoadMasterData <EndingData, EndingDataObjectList>(endingId);

        if (endingData == null)
        {
            return;
        }
        var backGroundData = ResourceManager.Instance.LoadMasterData <BackGroundData, BackGroundDataObjectList>(endingData.BackGroundId);

        if (backGroundData != null)
        {
            _imageBackGround.sprite = backGroundData.Sprites[0];
        }


        if (endingData.BgmId != default(long))
        {
            SoundManager.Instance.PlayBgm(endingData.BgmId);
        }

        _textEndName.text = endingData.Memo;

        _tapArea.onClick.RemoveAllListeners();
        _tapArea.onClick.AddListener(() => {
            if (tapCallBack != null)
            {
                tapCallBack.Invoke();
            }
            else
            {
                //現在読み込んでいるユーザーデータのendingIdsに保存する
                var userDatas = PlayerPrefsUtil.GetValue <UserData[]>(KEY_USER_DATA_LIST);
                List <UserData> userDataList;
                if (userDatas == null || userDatas.Length <= 0)
                {
                    userDataList = new List <UserData>();
                    for (int i = 0; i < 5; i++)
                    {
                        var index = i;
                        userDataList.Add(new UserData(index + 1));
                    }
                }
                else
                {
                    userDataList = userDatas.ToList();
                }

                for (int i = 0; i < userDataList.Count; i++)
                {
                    if (userDataList[i].slotId == userData.slotId)
                    {
                        var endingIdList = userDataList[i].endingIds.ToList();
                        if (!endingIdList.Contains(endingId))
                        {
                            endingIdList.Add(endingId);
                        }
                        userDataList[i].endingIds = endingIdList.ToArray();
                    }
                }
                PlayerPrefsUtil.SetValue <UserData[]>(KEY_USER_DATA_LIST, userDataList.ToArray());
                onChangeState(GameState.InitTitle, new Dictionary <string, object>());
            }
        });
    }