fix:1、结算优化
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using FairyGUI;
|
||||
using FGUI.Arrow_game;
|
||||
using UnityEngine;
|
||||
@@ -160,6 +161,14 @@ namespace ChillConnect
|
||||
{
|
||||
ui = baseUI as com_arrow_game;
|
||||
}
|
||||
|
||||
// 新增坐标转换方法
|
||||
private Vector2 UnityMouseToFGUIPos(Vector2 unityPos)
|
||||
{
|
||||
float x = unityPos.x;
|
||||
float y = Screen.height - unityPos.y;
|
||||
return new Vector2(x, y);
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
{
|
||||
@@ -170,46 +179,52 @@ namespace ChillConnect
|
||||
// }
|
||||
//
|
||||
// ========= 编辑器模拟触摸(仅编辑模式生效) =========
|
||||
|
||||
// ========== 编辑器鼠标拖拽 ==========
|
||||
#if UNITY_EDITOR
|
||||
//1. 鼠标左键 = 单指拖拽
|
||||
// Debug.Log($"Input.GetMouseButtonDown======={Input.GetMouseButtonDown(0)}");
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
float moveThreshold = 1f; // 移动阈值,大于这个值才算有效拖动
|
||||
|
||||
// 鼠标按下:仅初始化状态和起点
|
||||
if (InputHelper.Instance.GetMouseButtonDown(0))
|
||||
{
|
||||
_lastTouchPos = Input.mousePosition;
|
||||
Vector2 unityPos = InputHelper.Instance.MousePosition;
|
||||
_lastTouchPos = UnityMouseToFGUIPos(unityPos);
|
||||
_isDraging = true;
|
||||
}
|
||||
if (Input.GetMouseButton(0) && _isDraging)
|
||||
{
|
||||
Vector2 curMousePos = Input.mousePosition;
|
||||
Vector2 offset = curMousePos - _lastTouchPos;
|
||||
MoveContainer(offset);
|
||||
_lastTouchPos = curMousePos;
|
||||
}
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
_isDraging = false;
|
||||
Debug.Log("鼠标按下,开始拖拽");
|
||||
return; // 本帧直接返回,不执行拖动逻辑
|
||||
}
|
||||
|
||||
// 2. 鼠标滚轮 = 双指缩放
|
||||
// float scrollDelta = Input.GetMouseWheelDelta();
|
||||
// if (Mathf.Abs(scrollDelta) > 0)
|
||||
// {
|
||||
// float curScale = _viewContainer.scaleX;
|
||||
// curScale += scrollDelta * 0.1f;
|
||||
// curScale = Mathf.Clamp(curScale, _minScale, _maxScale);
|
||||
//
|
||||
// _viewContainer.scaleX = curScale;
|
||||
// _viewContainer.scaleY = curScale;
|
||||
// _zoomSlider.value = GetSliderValueByScale(curScale);
|
||||
// }
|
||||
// 拖拽中:按住左键 + 拖拽标记为true
|
||||
if (_isDraging && InputHelper.Instance.GetMouseButton(0))
|
||||
{
|
||||
Vector2 unityPos = InputHelper.Instance.MousePosition;
|
||||
Vector2 curMousePos = UnityMouseToFGUIPos(unityPos);
|
||||
Vector2 offset = curMousePos - _lastTouchPos;
|
||||
|
||||
Debug.Log($"curMousePos=={curMousePos} _lastTouchPos=={_lastTouchPos} offset=={offset}");
|
||||
|
||||
// 只有偏移超过阈值才移动 & 更新基准点
|
||||
if (offset.magnitude > moveThreshold)
|
||||
{
|
||||
MoveContainer(offset);
|
||||
_lastTouchPos = curMousePos; // 移动后再刷新起点
|
||||
}
|
||||
}
|
||||
|
||||
// 鼠标抬起,结束拖拽
|
||||
if (InputHelper.Instance.GetMouseButtonUp(0))
|
||||
{
|
||||
_isDraging = false;
|
||||
Debug.Log("鼠标抬起,结束拖拽");
|
||||
}
|
||||
#endif
|
||||
|
||||
// ========= 双指 = 缩放(优先级最高) =========
|
||||
if (Input.touchCount == 2)
|
||||
if (InputHelper.Instance.TouchCount == 2)
|
||||
{
|
||||
_isDraging = false;
|
||||
Touch t0 = Input.GetTouch(0);
|
||||
Touch t1 = Input.GetTouch(1);
|
||||
Touch t0 = InputHelper.Instance.GetTouch(0);
|
||||
Touch t1 = InputHelper.Instance.GetTouch(1);
|
||||
float currentDis = Vector2.Distance(t0.position, t1.position);
|
||||
|
||||
if (!_isTwoFingerTouch)
|
||||
@@ -236,9 +251,9 @@ namespace ChillConnect
|
||||
}
|
||||
}
|
||||
// ========= 单指 = 拖拽平移 =========
|
||||
else if (Input.touchCount == 1)
|
||||
else if (InputHelper.Instance.TouchCount == 1)
|
||||
{
|
||||
Touch touch = Input.GetTouch(0);
|
||||
Touch touch = InputHelper.Instance.GetTouch(0);
|
||||
Vector2 curTouchPos = touch.position;
|
||||
|
||||
if (touch.phase == TouchPhase.Began)
|
||||
@@ -820,6 +835,7 @@ namespace ChillConnect
|
||||
/// <summary>移动容器 + 边界限制,防止完全拖出屏幕</summary>
|
||||
private void MoveContainer(Vector2 offset)
|
||||
{
|
||||
Debug.Log($"[arrow] 移动容器:{offset}");
|
||||
float newX = _viewContainer.x + offset.x;
|
||||
float newY = _viewContainer.y + offset.y;
|
||||
|
||||
@@ -1400,7 +1416,42 @@ namespace ChillConnect
|
||||
arrow.isMoving = false;
|
||||
}
|
||||
|
||||
uiCtrlDispatcher.Dispatch(UICtrlMsg.LevelSuccessUI_Open, isSuccess);
|
||||
// uiCtrlDispatcher.Dispatch(UICtrlMsg.LevelSuccessUI_Open, isSuccess);
|
||||
|
||||
if (isSuccess)
|
||||
{
|
||||
GameHelper.SetLevel(GameHelper.GetLevel() + 1);
|
||||
//通关成功
|
||||
float[] cash_array = GameHelper.GetRewardValue(2);
|
||||
|
||||
var temp = new SuccessData();
|
||||
temp.IsWin = true;
|
||||
temp.cash_number = cash_array[0];
|
||||
temp.rate = (int)cash_array[1];
|
||||
temp.IsLevelSuccess = true;
|
||||
temp.IsH5Reward = false;
|
||||
temp.boost_array = GameHelper.GetRewardBoost(2);
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
//通关失败
|
||||
float[] cash_array = GameHelper.GetRewardValue(2);
|
||||
|
||||
var temp = new SuccessData();
|
||||
temp.IsWin = false;
|
||||
temp.cash_number = cash_array[0];
|
||||
temp.IsLevelSuccess = true;
|
||||
temp.IsH5Reward = false;
|
||||
temp.boost_array = GameHelper.GetRewardBoost(2);
|
||||
DOVirtual.DelayedCall(0.5f, () =>
|
||||
{
|
||||
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.LevelSuccessUI_Open, temp);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 重新开始本局
|
||||
|
||||
Reference in New Issue
Block a user