Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
fix: aimTargetの統合
Browse files Browse the repository at this point in the history
  • Loading branch information
K-Kizuku committed Aug 18, 2024
1 parent e02752a commit d99275b
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/components/Yatai/TargetOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ export const TargetOverlay = () => {

useEffect(() => {
onMessage((data) => {
if (data.message_type === MessageType.Action) {
shotTarget(data);
}
if (data.message_type === MessageType.Pointer) {
if (
data.message_type === MessageType.Action ||
data.message_type === MessageType.Pointer
) {
aimTarget(data);
}
});
}, [onMessage]);

// TODO: これらは一人用,いつかマルチプレイヤー対応する
const [aim, setAim] = useState<Target | undefined>(undefined);
const aimTarget = (data: PointerSchema) => {
const x = window.innerWidth / 2 + data.target.x * 1200;
const y = window.innerHeight / 2 + data.target.y * 1200;
setAim({ x, y });
};

const shotTarget = (data: ActionSchema) => {
const aimTarget = (data: PointerSchema | ActionSchema) => {
const x = window.innerWidth / 2 + data.target.x * 1200;
const y = window.innerHeight / 2 + data.target.y * 1200;
setAim({ x, y });
Expand Down

0 comments on commit d99275b

Please sign in to comment.