Ejemplo n.º 1
0
    /// <summary>
    /// 点击退出设置按钮
    /// </summary>
    public void ExitSetting_Click()
    {
        if (nowUIFocus)
        {
            nowUIFocus.LostForcus();
        }
        bigMapOperateState = EnumBigMapOperateState.OperateMap;
        //根据当前的设置更新状态
        UIFocusDropdown thisFocus = uiFocusPath.NewUIFocusArray.Where(temp => string.Equals(temp.Tag, "SceneDropDown")).FirstOrDefault() as UIFocusDropdown;

        if (thisFocus != null)
        {
            int index = thisFocus.dropdown.value;
            if (index >= 0)
            {
                SceneData       sceneData       = DataCenter.Instance.GetMetaData <SceneData>();
                SceneDataInfo[] sceneDataInfos  = sceneData.GetAllSceneData();
                List <string>   sceneNameList   = sceneDataInfos.Where(temp => temp.SceneAction == EnumSceneAction.Game).Select(temp => temp.SceneName).ToList();
                string          selectSceneName = sceneNameList[index];
                if (!string.Equals(nowSceneName, selectSceneName))//当前地图显示的和选择的场景不一致则重新载入
                {
                    MapData     mapData     = DataCenter.Instance.GetMetaData <MapData>();
                    MapDataInfo mapDataInfo = mapData[selectSceneName];
                    if (mapDataInfo != null)
                    {
                        mapDataInfo.Load();
                        PlayerState playerState   = DataCenter.Instance.GetEntity <PlayerState>();
                        Sprite      mapMaskSprite = playerState.GetSceneMapMaskSprite(selectSceneName, mapDataInfo.MapSprite);
                        ResetMap(mapDataInfo.MapSprite, mapMaskSprite, mapDataInfo.SceneRect, selectSceneName);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 重设场景下拉列表
    /// </summary>
    private void ResetSceneDropDown()
    {
        UIFocusDropdown thisFocus = uiFocusPath.NewUIFocusArray.Where(temp => string.Equals(temp.Tag, "SceneDropDown")).FirstOrDefault() as UIFocusDropdown;

        if (thisFocus != null)
        {
            if (thisFocus.dropdown.options == null)
            {
                thisFocus.dropdown.options = new List <UnityEngine.UI.Dropdown.OptionData>();
            }
            thisFocus.dropdown.options.Clear();
            SceneData       sceneData      = DataCenter.Instance.GetMetaData <SceneData>();
            SceneDataInfo[] sceneDataInfos = sceneData.GetAllSceneData();
            List <string>   sceneNameList  = sceneDataInfos.Where(temp => temp.SceneAction == EnumSceneAction.Game).Select(temp => temp.SceneName).ToList();
            sceneNameList.ForEach(temp =>
                                  thisFocus.dropdown.options.Add(new UnityEngine.UI.Dropdown.OptionData(temp))//后期需要添加多语言
                                  );
            int index = sceneNameList.IndexOf(iGameState.SceneName);
            if (index >= 0)
            {
                thisFocus.dropdown.captionText.text = sceneNameList[index];
                thisFocus.dropdown.value            = index;
            }
        }
    }