|
@@ -8,6 +8,8 @@ import EventMng from "../../manager/EventMng";
|
|
|
import { HcInfoGeziInfo, ResHcInfo } from "../../shared/hc/PtlHcInfo";
|
|
|
import { ResHcMerge } from "../../shared/hc/PtlHcMerge";
|
|
|
import AssetMgr from "../../utils/AssetMgr";
|
|
|
+import { uiCommon } from "../../utils/UICommon";
|
|
|
+import HomeMergeSellCom from "../fgui/Home/Home/HomeMergeSellCom";
|
|
|
import { GridConstant } from "./GridConstant";
|
|
|
import { GridEvent } from "./GridEvent";
|
|
|
import UECell, { I_CellData } from "./UECell";
|
|
@@ -149,7 +151,7 @@ export default class UEGridMap extends UEBase {
|
|
|
mergeCube.Init({
|
|
|
type: data.cube.type,
|
|
|
id: data.cube.correlationId,
|
|
|
- idx: data.cell.GetZIndex(),
|
|
|
+ idx: data.cell.GetIdx(),
|
|
|
});
|
|
|
//播放经验爆炸飞行动画
|
|
|
|
|
@@ -186,7 +188,7 @@ export default class UEGridMap extends UEBase {
|
|
|
}
|
|
|
this.selectedCell = cell;
|
|
|
// cell.SetSelect(true);
|
|
|
- EventMng.emit(GridEvent.HC_CELL_SELECT, cell.GetZIndex());
|
|
|
+ EventMng.emit(GridEvent.HC_CELL_SELECT, cell.GetIdx());
|
|
|
EventMng.emit(GridEvent.HC_MERGE_SELL, { isShow: true, item: cell.GetCube().GetCubeData() });
|
|
|
} else {
|
|
|
this.selectedCell = null;
|
|
@@ -225,16 +227,16 @@ export default class UEGridMap extends UEBase {
|
|
|
this.lastMoveCell = targetCell;
|
|
|
if (targetCell && !targetCell.IsLock()) {
|
|
|
// targetCell.SetSelect(true);
|
|
|
- EventMng.emit(GridEvent.HC_CELL_SELECT, targetCell.GetZIndex());
|
|
|
+ EventMng.emit(GridEvent.HC_CELL_SELECT, targetCell.GetIdx());
|
|
|
}
|
|
|
if (targetCell && targetCell != this.selectedCell) {
|
|
|
if (!targetCell.IsEmpty() && GameDataCenter.gridMap.CellCanPut(this.selectedCell, targetCell)) {
|
|
|
this.ueMergeTip.node.setPosition(targetCell.node.getPosition());
|
|
|
this.ueMergeTip.Init({
|
|
|
- idx: targetCell.GetZIndex(),
|
|
|
+ idx: targetCell.GetIdx(),
|
|
|
ueCube1: this.selectedCell.GetCube(),
|
|
|
ueCube2: targetCell.GetCube(),
|
|
|
- dir: targetCell.GetZIndex() % 10 > 4 ? 2 : 1
|
|
|
+ dir: targetCell.GetIdx() % 10 > 4 ? 2 : 1
|
|
|
});
|
|
|
} else {
|
|
|
this.ueMergeTip.Hide();
|
|
@@ -268,10 +270,9 @@ export default class UEGridMap extends UEBase {
|
|
|
GameDataCenter.gridMap.TryMergeItems(this.selectedCell, targetCell);
|
|
|
// this.selectedCell.SetSelect(false);
|
|
|
// targetCell.SetSelect(true);
|
|
|
- EventMng.emit(GridEvent.HC_CELL_SELECT, targetCell.GetZIndex());
|
|
|
+ EventMng.emit(GridEvent.HC_CELL_SELECT, targetCell.GetIdx());
|
|
|
} else {
|
|
|
this.CheckSell();
|
|
|
- this.selectedCell.GetCube().BackToOriginalPos(true);
|
|
|
}
|
|
|
this.isDragging = false;
|
|
|
this.selectedCell = targetCell;
|
|
@@ -281,13 +282,22 @@ export default class UEGridMap extends UEBase {
|
|
|
|
|
|
/** 检测物品是否拖动到售卖区域售卖 */
|
|
|
private CheckSell() {
|
|
|
- let sellPos = cc.v2(0, 0);
|
|
|
- let sellSize = cc.size(GridConstant.CELL_WIDTH, GridConstant.CELL_WIDTH);
|
|
|
- let sellRect = cc.rect(sellPos.x, sellPos.y, sellSize.width, sellSize.height);
|
|
|
+ let sellSize = cc.size(200, 200);
|
|
|
+ let sellBtn = HomeMergeSellCom.instance.GetSellBtn();
|
|
|
+ let sellPos = uiCommon.transPos(sellBtn, this.cubeLayer);
|
|
|
+ // 创建以sellPos为中心点的矩形
|
|
|
+ let sellRect = cc.rect(
|
|
|
+ sellPos.x - sellSize.width / 2, // 左边界 = 中心点x - 宽度/2
|
|
|
+ sellPos.y - sellSize.height / 2, // 下边界 = 中心点y - 高度/2
|
|
|
+ sellSize.width,
|
|
|
+ sellSize.height
|
|
|
+ );
|
|
|
let cubePos = this.selectedCell.GetCube().node.getPosition();
|
|
|
- // if (cc.rectContainsPoint(sellRect, cubePos)) {
|
|
|
- // this.selectedCell.GetCube().PlayJellyAnim();
|
|
|
- // }
|
|
|
+ if (sellRect.contains(cubePos)) {
|
|
|
+ GameDataCenter.gridMap.sendHcSell(this.selectedCell.GetIdx());
|
|
|
+ } else {
|
|
|
+ this.selectedCell.GetCube().BackToOriginalPos(true);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/** 根据像素坐标获取格子 */
|
|
@@ -333,8 +343,9 @@ export default class UEGridMap extends UEBase {
|
|
|
const distanceFactor = totalDistance / 300; // 假设300是标准距离
|
|
|
const duration = Math.min(baseDuration + distanceFactor * 0.3, 1.2); // 限制最大时间为1.2秒
|
|
|
|
|
|
- // 设置最大高度(向上弹跳的高度)
|
|
|
- const maxHeight = 400;
|
|
|
+ // 根据距离动态计算最大高度
|
|
|
+ const baseHeight = 200; // 基础高度
|
|
|
+ const maxHeight = Math.min(baseHeight + totalDistance * 0.5, 600); // 根据距离增加高度,但限制最大值
|
|
|
|
|
|
// 计算最后弹跳的起点(在终点前20%距离处)
|
|
|
const bounceStartPos = cc.v3(
|
|
@@ -346,7 +357,7 @@ export default class UEGridMap extends UEBase {
|
|
|
// 创建第一段抛物线(抛向空中然后落到弹跳起点)
|
|
|
const bezier1 = [];
|
|
|
const midPoint1 = cc.v3(
|
|
|
- startWorldPos.x + moveVec.x * 0.3,
|
|
|
+ startWorldPos.x + moveVec.x * 0.35, // 调整为0.35,让第一段抛物线更自然
|
|
|
Math.max(startWorldPos.y, bounceStartPos.y) + maxHeight,
|
|
|
0
|
|
|
);
|
|
@@ -356,40 +367,40 @@ export default class UEGridMap extends UEBase {
|
|
|
|
|
|
// 创建第二段弹跳(第一次弹跳)
|
|
|
const bezier2 = [];
|
|
|
- const bounceHeight = totalDistance * 0.15; // 弹跳高度设为总距离的15%
|
|
|
+ const bounceHeight = totalDistance * 0.2; // 增加弹跳高度为总距离的20%,让弹跳更明显
|
|
|
|
|
|
// 计算第一次弹跳的最高点和落点
|
|
|
const firstBounceTop = cc.v2(
|
|
|
- (bounceStartPos.x + endWorldPos.x) / 2, // 水平位置在中间
|
|
|
- endWorldPos.y + bounceHeight // 垂直高度为弹跳高度
|
|
|
+ bounceStartPos.x + (endWorldPos.x - bounceStartPos.x) * 0.3, // 调整水平位置,让弹跳更自然
|
|
|
+ endWorldPos.y + bounceHeight
|
|
|
);
|
|
|
|
|
|
// 计算第二段距离(从bounceStartPos到终点的距离)
|
|
|
- const secondDistance = totalDistance * 0.2; // 最后20%的距离
|
|
|
+ const secondDistance = totalDistance * 0.2;
|
|
|
const firstBounceEnd = cc.v2(
|
|
|
- bounceStartPos.x + normalizedDir.x * (secondDistance * 0.5), // 前进一半
|
|
|
- bounceStartPos.y + normalizedDir.y * (secondDistance * 0.5)
|
|
|
+ bounceStartPos.x + normalizedDir.x * (secondDistance * 0.6), // 增加到0.6,让第二次弹跳的起点更靠近终点
|
|
|
+ bounceStartPos.y + normalizedDir.y * (secondDistance * 0.6)
|
|
|
);
|
|
|
|
|
|
- bezier2.push(cc.v2(bounceStartPos.x, bounceStartPos.y)); // 起跳点
|
|
|
- bezier2.push(firstBounceTop); // 最高点
|
|
|
- bezier2.push(firstBounceEnd); // 第一次落点
|
|
|
+ bezier2.push(cc.v2(bounceStartPos.x, bounceStartPos.y));
|
|
|
+ bezier2.push(firstBounceTop);
|
|
|
+ bezier2.push(firstBounceEnd);
|
|
|
|
|
|
// 创建第三段弹跳(最后一次弹跳到终点)
|
|
|
const bezier3 = [];
|
|
|
const secondBounceTop = cc.v2(
|
|
|
- (firstBounceEnd.x + endWorldPos.x) / 2,
|
|
|
- endWorldPos.y + bounceHeight * 0.6 // 第二次弹跳高度为第一次的60%
|
|
|
+ firstBounceEnd.x + (endWorldPos.x - firstBounceEnd.x) * 0.5,
|
|
|
+ endWorldPos.y + bounceHeight * 0.4 // 降低为40%,让最后的弹跳更轻盈
|
|
|
);
|
|
|
|
|
|
- bezier3.push(firstBounceEnd); // 起跳点
|
|
|
- bezier3.push(secondBounceTop); // 最高点
|
|
|
- bezier3.push(cc.v2(endWorldPos.x, endWorldPos.y)); // 终点
|
|
|
+ bezier3.push(firstBounceEnd);
|
|
|
+ bezier3.push(secondBounceTop);
|
|
|
+ bezier3.push(cc.v2(endWorldPos.x, endWorldPos.y));
|
|
|
|
|
|
// 创建动作序列
|
|
|
- const bezierAction1 = cc.bezierTo(duration * 0.7, bezier1);
|
|
|
- const bezierAction2 = cc.bezierTo(duration * 0.18, bezier2);
|
|
|
- const bezierAction3 = cc.bezierTo(duration * 0.12, bezier3);
|
|
|
+ const bezierAction1 = cc.bezierTo(duration * 0.65, bezier1); // 缩短第一段时间
|
|
|
+ const bezierAction2 = cc.bezierTo(0.2, bezier2);
|
|
|
+ const bezierAction3 = cc.bezierTo(0.15, bezier3);
|
|
|
|
|
|
const seq = cc.sequence(
|
|
|
bezierAction1,
|