Commit 5eff3f54 authored by Chunchi Che's avatar Chunchi Che

update setupHandInteractivity

parent 49e2424b
...@@ -64,7 +64,7 @@ export const HandHoverOutScaling = () => { ...@@ -64,7 +64,7 @@ export const HandHoverOutScaling = () => {
export const HandInteractShape = () => { export const HandInteractShape = () => {
return { width: 0.8, height: 0.2 }; return { width: 0.8, height: 0.2 };
}; };
export const HandInteractFontSize = 300; export const HandInteractFontSize = 200;
// 怪兽区 // 怪兽区
export const MonsterColor = () => { export const MonsterColor = () => {
......
import * as BABYLON from "@babylonjs/core"; import * as BABYLON from "@babylonjs/core";
import * as BABYLON_GUI from "@babylonjs/gui"; import * as BABYLON_GUI from "@babylonjs/gui";
import * as CONFIG from "../../../config/ui"; import * as CONFIG from "../../../config/ui";
import { Card } from "../../../reducers/duel/util"; import { Card, InteractType } from "../../../reducers/duel/util";
export default (hands: Card[], scene: BABYLON.Scene) => { export default (hands: Card[], scene: BABYLON.Scene) => {
const handShape = CONFIG.HandShape(); const handShape = CONFIG.HandShape();
...@@ -59,8 +59,11 @@ function setupHandInteractivity( ...@@ -59,8 +59,11 @@ function setupHandInteractivity(
scene: BABYLON.Scene scene: BABYLON.Scene
) { ) {
const interactShape = CONFIG.HandInteractShape(); const interactShape = CONFIG.HandInteractShape();
const interactivities = state.interactivities;
for (let i = 0; i < interactivities.length; i++) {
const interact = BABYLON.MeshBuilder.CreatePlane( const interact = BABYLON.MeshBuilder.CreatePlane(
`handInteract${handIdx}`, `handInteract_${handIdx}_${i}`,
interactShape, interactShape,
scene scene
); );
...@@ -68,14 +71,16 @@ function setupHandInteractivity( ...@@ -68,14 +71,16 @@ function setupHandInteractivity(
// 调整位置 // 调整位置
interact.translate( interact.translate(
new BABYLON.Vector3(0, 1, 0), new BABYLON.Vector3(0, 1, 0),
CONFIG.HandShape().height / 2 + interactShape.height / 2 CONFIG.HandShape().height / 2 +
interactShape.height / 2 +
interactShape.height * i
); );
const advancedTexture = const advancedTexture =
BABYLON_GUI.AdvancedDynamicTexture.CreateForMesh(interact); BABYLON_GUI.AdvancedDynamicTexture.CreateForMesh(interact);
const button = BABYLON_GUI.Button.CreateImageWithCenterTextButton( const button = BABYLON_GUI.Button.CreateImageWithCenterTextButton(
`handInteractButtion${handIdx}`, `handInteractButtion_${handIdx}_${i}`,
"test", interactTypeToString(interactivities[i].interactType),
"http://localhost:3030/images/interact_button.png" "http://localhost:3030/images/interact_button.png"
); );
button.fontSize = CONFIG.HandInteractFontSize; button.fontSize = CONFIG.HandInteractFontSize;
...@@ -84,6 +89,7 @@ function setupHandInteractivity( ...@@ -84,6 +89,7 @@ function setupHandInteractivity(
console.log(`<Interact>hand ${handIdx}`); console.log(`<Interact>hand ${handIdx}`);
}); });
advancedTexture.addControl(button); advancedTexture.addControl(button);
}
} }
function setupHandAction( function setupHandAction(
...@@ -149,3 +155,7 @@ function setupHandAction( ...@@ -149,3 +155,7 @@ function setupHandAction(
) )
); );
} }
function interactTypeToString(t: InteractType): string {
return InteractType[t];
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment