fix:1、删除sdk相关。2、添加tips界面,修复bug

This commit is contained in:
2026-06-17 14:45:28 +08:00
parent 19efcb09fa
commit acf888d9be
1099 changed files with 127081 additions and 74087 deletions
+204 -41
View File
@@ -74,6 +74,21 @@ namespace ChillConnect
// 所有网格圆点实例列表,用于批量改色/清理
private List<ArrorPoint> _gridDotList = new List<ArrorPoint>();
#region
// 8种预设彩色,可按需调整色值
private readonly Color[] _colorfulPalette = new Color[]
{
new Color(1f, 0.3f, 0.3f), // 红
new Color(1f, 0.6f, 0.2f), // 橙
new Color(1f, 0.9f, 0.2f), // 黄
new Color(0.3f, 0.8f, 0.4f), // 绿
new Color(0.2f, 0.8f, 0.9f), // 青
new Color(0.3f, 0.5f, 1f), // 蓝
new Color(0.7f, 0.4f, 1f), // 紫
new Color(1f, 0.5f, 0.8f) // 粉
};
#endregion
#region
// 缩放阈值(滑动条左右边界对应这两个值)
private readonly float _minScale = 0.6f;
@@ -257,7 +272,8 @@ namespace ChillConnect
else if (InputHelper.Instance.TouchCount == 1)
{
Touch touch = InputHelper.Instance.GetTouch(0);
Vector2 curTouchPos = touch.position;
// 触摸坐标和鼠标同属Unity屏幕坐标系,统一转成FGUI坐标系
Vector2 curTouchPos = UnityMouseToFGUIPos(touch.position);
if (touch.phase == TouchPhase.Began)
{
@@ -327,6 +343,10 @@ namespace ChillConnect
GameDispatcher.Instance.AddListener(GameMsg.reset_game, OnRestartGame);
GameDispatcher.Instance.AddListener(GameMsg.Update102, SetTopCurr);
GameDispatcher.Instance.AddListener(GameMsg.Update101, SetTopCurr);
GameDispatcher.Instance.AddListener(GameMsg.ThemeChange, SetModel);
GameDispatcher.Instance.AddListener(GameMsg.UpdateSpeed, SetSpeed);
GameDispatcher.Instance.AddListener(GameMsg.SetDelete, SetDeleteMode);
}
protected override void RemoveListener()
@@ -334,6 +354,12 @@ namespace ChillConnect
GameDispatcher.Instance.RemoveListener(GameMsg.reset_game, OnRestartGame);
GameDispatcher.Instance.RemoveListener(GameMsg.Update102, SetTopCurr);
GameDispatcher.Instance.RemoveListener(GameMsg.Update101, SetTopCurr);
GameDispatcher.Instance.RemoveListener(GameMsg.ThemeChange, SetModel);
GameDispatcher.Instance.RemoveListener(GameMsg.UpdateSpeed, SetSpeed);
GameDispatcher.Instance.RemoveListener(GameMsg.SetDelete, SetDeleteMode);
}
#endregion
@@ -345,13 +371,18 @@ namespace ChillConnect
_isTwoFingerTouch = false;
_isDraging = false;
SetModel();
ui.text_level.SetVar("lv", GameHelper.GetLevel().ToString()).FlushVars();
// 按钮点击事件绑定
OnBtnClickBindEvent();
//爱心重新更新显示
for (int i = _heartCount; i > 0; i--)
{
ui.HeartsPanel.GetChild($"xin_{i}").visible = true;
}
_fingerTipObj = com_finger.CreateInstance();
_viewContainer.AddChild(_fingerTipObj);
@@ -401,6 +432,7 @@ namespace ChillConnect
_initComplete = true;
SetModel();
SetTopCurr();
@@ -437,6 +469,11 @@ namespace ChillConnect
ui.com_bottom.btn_clear.SetClick(OnClickDeleteItem);
ui.com_bottom.btn_hint.SetClick(OnClickHint);
ui.com_bottom.btn_setting.SetClick(() =>
{
uiCtrlDispatcher.Dispatch(UICtrlMsg.PersonViewUI_Open, _moveSpeed);
});
ui.com_bottom.btn_skin.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.ArrowThemeUI_Open); });
ui.btn_petty.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.PettyAwardUI_Open); });
@@ -448,35 +485,51 @@ namespace ChillConnect
ui.btn_saveingpot.SetClick(() => { uiCtrlDispatcher.Dispatch(UICtrlMsg.SaveingPotUI_Open); });
}
/// <summary>
/// 切换模式 默认黑夜模式
/// </summary>
/// <param name="mod">true:白天 false:黑夜</param>
private void SetModel(object mod = null)
{
int idx = 0;
if (mod != null)
{
idx = (bool)mod? 1 : 0;
}
ui.mode.selectedIndex = idx;
// 同步更新网格圆点颜色
bool isDayMode = idx == 1;
UpdateGridDotColor(isDayMode);
// 缓存上一次箭头主题,用于判断是否需要重新随机彩色
private int _lastArrowTheme = -1;
/// <summary>
/// 主题变更统一回调(昼夜/箭头主题切换都会触发)
/// </summary>
private void SetModel(object a = null)
{
int darkThemeIdx = DataMgr.ArrowDarkTheme.Value;
int currentArrowTheme = DataMgr.ArrowTheme.Value;
ui.mode.selectedIndex = darkThemeIdx;
// 1. 更新网格圆点昼夜配色
bool isDarkMode = darkThemeIdx == 0; // 0=黑夜
Debug.Log($"ArrowDarkTheme==={darkThemeIdx}");
UpdateGridDotColor(isDarkMode);
// 2. 判断是否需要重新随机彩色:只有从非彩色切到彩色时才刷新
bool forceRandomColorful = currentArrowTheme == 2 && _lastArrowTheme != currentArrowTheme;
// 3. 更新所有箭头颜色
UpdateAllArrowsColor(forceRandomColorful);
// 4. 更新缓存,用于下次对比
_lastArrowTheme = currentArrowTheme;
Debug.Log($"主题刷新完成:昼夜={darkThemeIdx},箭头主题={currentArrowTheme}");
}
/// <summary>
/// 批量设置网格圆点颜色(随昼夜模式切换)
/// // 色值映射:白天#2c3a62,黑夜#d4e3f2
/// </summary>
/// <param name="isDay">true=白天模式,false=黑夜模式</param>
/// <param name="isDay">true=黑夜模式,false=白天模式</param>
private string DarkColor = "#d4e3f2";
private string LightColor = "#2c3a62";
private void UpdateGridDotColor(bool isDay)
{
if (_gridDotList == null || _gridDotList.Count == 0)
return;
// 色值映射:白天#2c3a62,黑夜#d4e3f2
string colorHex = isDay ? "#2c3a62" : "#d4e3f2";
Debug.Log($"isDay=========={isDay}");
string colorHex = isDay ? DarkColor : LightColor;
ColorUtility.TryParseHtmlString(colorHex, out Color targetColor);
foreach (var dot in _gridDotList)
@@ -486,6 +539,77 @@ namespace ChillConnect
dot.point.color = targetColor;
}
}
/// <summary>
/// 根据当前主题,为单个箭头生成对应颜色
/// </summary>
/// <param name="arrow">箭头配置对象</param>
/// <param name="isRandomNew">彩色模式下是否重新随机颜色</param>
private Color GetArrowRuntimeColor(ArrowConfig arrow, bool isRandomNew = false)
{
int themeType = DataMgr.ArrowTheme.Value;
// 0 = 纯色模式(黑色按钮):白天黑、黑夜白
if (themeType == 0)
{
bool isDark = DataMgr.ArrowDarkTheme.Value == 0; // 0=黑夜
return isDark ? Color.white : Color.black;
}
// 2 = 彩色随机模式
else if (themeType == 2)
{
if (isRandomNew || arrow.runtimeColor == default)
{
int randomIndex = Random.Range(0, _colorfulPalette.Length);
arrow.runtimeColor = _colorfulPalette[randomIndex];
}
return arrow.runtimeColor;
}
// 兜底默认黑色
return Color.black;
}
/// 批量更新场上所有箭头的颜色(线条+单箭头)
/// </summary>
/// <param name="forceRandomColorful">彩色模式下是否强制重新随机</param>
private void UpdateAllArrowsColor(bool forceRandomColorful = false)
{
if (_levelConfig == null || _levelConfig.arrows == null)
return;
int themeType = DataMgr.ArrowTheme.Value;
bool isColorfulMode = themeType == 2;
foreach (var arrow in _levelConfig.arrows)
{
// 只有强制刷新时,彩色模式才重新随机颜色
bool isRandomNew = isColorfulMode && forceRandomColorful;
Color targetColor = GetArrowRuntimeColor(arrow, isRandomNew);
// 更新线条颜色
if (arrow.lineUnits != null)
{
foreach (var line in arrow.lineUnits)
{
if (line != null)
{
line.GetChild("line").asGraph.color = targetColor;
}
}
}
// 更新单箭头颜色
if (arrow.arrowObj != null)
{
GImage icon = arrow.arrowObj.GetChild("icon").asImage;
if (icon != null)
{
icon.color = targetColor;
}
}
}
}
#endregion
@@ -583,8 +707,29 @@ namespace ChillConnect
public static void InitAllLevelData()
{
string path = Path.Combine(Application.streamingAssetsPath, "all_levels.json");
#if UNITY_ANDROID && !UNITY_EDITOR
// Android 平台需要使用 UnityWebRequest 读取 StreamingAssets
using (UnityEngine.Networking.UnityWebRequest www = UnityEngine.Networking.UnityWebRequest.Get(path))
{
www.SendWebRequest();
while (!www.isDone) { }
if (www.result == UnityEngine.Networking.UnityWebRequest.Result.Success)
{
string json = www.downloadHandler.text;
_allLevelData = JsonUtility.FromJson<AllLevelRoot>(json);
}
else
{
Debug.LogError($"Failed to load all_levels.json: {www.error}");
}
}
#else
// Editor 和其他平台直接读取
string json = File.ReadAllText(path);
_allLevelData = JsonUtility.FromJson<AllLevelRoot>(json);
#endif
}
public static LevelConfig LoadLevelById(int targetLevelId)
@@ -835,12 +980,13 @@ namespace ChillConnect
if (tilePositions.Count > 0)
tilePositions.RemoveAt(tilePositions.Count - 1);
ColorUtility.TryParseHtmlString(arrow.color, out Color lineColor);
for (int i = 0; i < tilePositions.Count; i++)
{
Vector2 pos = tilePositions[i];
LineTile unit = LineTile.CreateInstance();
unit.SetPosition(pos.x, pos.y, 0);
// 运行时主题取色
Color lineColor = GetArrowRuntimeColor(arrow);
unit.GetChild("line").asGraph.color = lineColor;
unit.visible = true;
unit.touchable = true;
@@ -859,8 +1005,7 @@ namespace ChillConnect
// 在 CreateArrowAndLines 方法最后,补充这段初始化代码
// ========== 新增:初始化距离偏移 ==========
// ========== 初始化距离偏移 ==========
arrow.movedDistance = 0f;
// 轨迹总长度 = (点数-1) * 点间距
arrow.trackTotalLength = (arrow.totalTrack.Count - 1) * 10f;
@@ -878,21 +1023,27 @@ namespace ChillConnect
#region
private void SetDeleteMode(object a)
{
_isDeleteMode = !_isDeleteMode;
}
/// <summary>点击删除道具,开启/关闭删除模式</summary>
private void OnClickDeleteItem()
{
_isDeleteMode = !_isDeleteMode;
// _isDeleteMode = !_isDeleteMode;
// 可选:加提示,区分状态
if (_isDeleteMode)
{
Debug.Log("已开启删除模式,点击箭头即可删除");
// 可加UI提示:如图标高亮、文字提示
}
else
{
Debug.Log("已关闭删除模式");
}
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.ArrowTipsUI_Open);
// // 可选:加提示,区分状态
// if (_isDeleteMode)
// {
// Debug.Log("已开启删除模式,点击箭头即可删除");
// // 可加UI提示:如图标高亮、文字提示
// }
// else
// {
// Debug.Log("已关闭删除模式");
// }
}
private void OnClickHint()
@@ -1219,7 +1370,8 @@ namespace ChillConnect
arrowIns.rotation = DirToRotation(arrow.defaultDir);
}
ColorUtility.TryParseHtmlString(arrow.color, out Color arrowColor);
// 运行时主题取色
Color arrowColor = GetArrowRuntimeColor(arrow);
GImage icon = arrowIns.GetChild("icon").asImage;
if (icon != null) icon.color = arrowColor;
@@ -1302,8 +1454,17 @@ namespace ChillConnect
RunCoroutine(MoveAndDisappearCoroutine(arrow));
}
private void SetSpeed(object a = null)
{
if (a != null)
{
_moveSpeed = (float)a;
}
}
// 新增:统一移动速度(像素/秒),数值越大移动越快,可自由修改
[SerializeField] private float _moveSpeed = 800f;
[SerializeField] private float _moveSpeed = 1500f;
private IEnumerator MoveAndDisappearCoroutine(ArrowConfig arrow)
{
@@ -1467,7 +1628,7 @@ namespace ChillConnect
temp.IsLevelSuccess = false;
temp.IsH5Reward = false;
temp.boost_array = GameHelper.GetRewardBoost(1);
DOVirtual.DelayedCall(0.55f, () =>
DOVirtual.DelayedCall(0.25f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp);
});
@@ -1575,7 +1736,7 @@ namespace ChillConnect
temp.IsLevelSuccess = true;
temp.IsH5Reward = false;
temp.boost_array = GameHelper.GetRewardBoost(2);
DOVirtual.DelayedCall(0.5f, () =>
DOVirtual.DelayedCall(0.2f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp);
});
@@ -1591,7 +1752,7 @@ namespace ChillConnect
temp.IsLevelSuccess = true;
temp.IsH5Reward = false;
temp.boost_array = GameHelper.GetRewardBoost(2);
DOVirtual.DelayedCall(0.5f, () =>
DOVirtual.DelayedCall(0.2f, () =>
{
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp);
});
@@ -1677,11 +1838,13 @@ namespace ChillConnect
public int arrowTrackIndex;
public string finalMoveDir;
// ========== 新增:距离驱动移动所需字段 ==========
// ========== 距离驱动移动所需字段 ==========
public float movedDistance; // 当前整体累计移动距离
public float trackTotalLength; // 整条轨迹的总像素长度
public List<float> lineInitOffsets; // 每个线条单元的初始距离偏移
public float arrowInitOffset; // 箭头的初始距离偏移
// ========== 运行时颜色缓存 ==========
public Color runtimeColor;
}
[System.Serializable]