feat: receive input data from python

master
tiendat3699 2024-04-16 11:37:30 +07:00
parent d395793750
commit fd9206f8d7
3 changed files with 14 additions and 5 deletions

View File

@ -1255,6 +1255,7 @@ MonoBehaviour:
width: 4.5
height: 1
_gravityScaleRange: {x: 0.1, y: 0.5}
_canvas: {fileID: 1939570966}
_time: {fileID: 1230716510}
_score: {fileID: 1901652404}
_itemPools:

View File

@ -1,4 +1,5 @@
using GadGame.Manager;
using GadGame.Network;
using GadGame.State;
using GadGame.State.GameState;
using Pools.Runtime;
@ -18,8 +19,9 @@ namespace GadGame.MiniGame
[SerializeField, Range(0,1)] private float _bombChange;
[SerializeField] private Rect _spawnArea;
[SerializeField, MinMaxSlider(0, 2, true)] private Vector2 _gravityScaleRange;
[Header("UI")]
[SerializeField] private Canvas _canvas;
[SerializeField] private TextMeshProUGUI _time;
[SerializeField] private TextMeshProUGUI _score;
@ -69,9 +71,15 @@ namespace GadGame.MiniGame
public void PlayerControl()
{
if (Input.GetMouseButton(0))
//640x480;
var inputData = DataReceiver.Instance.DataReceived.PosPoint;
var inputNormalize = new Vector2(inputData.x / 640, inputData.y / 480);
var input = new Vector2();
input.x = Mathf.Lerp(0, _canvas.pixelRect.width, inputNormalize.x);
input.y = -Mathf.Lerp(0, _canvas.pixelRect.height, inputNormalize.y);
if (input != Vector2.zero)
{
var mousePos = Input.mousePosition;
var mousePos = input;
var pos = _camera.ScreenToWorldPoint(mousePos);
var currentPosition = _basket.position;
pos.y = currentPosition.y;

View File

@ -1,5 +1,4 @@
using UnityEngine.Serialization;
using UnityEngine;
namespace GadGame.Network
{
@ -19,5 +18,6 @@ namespace GadGame.Network
public Genders Gender;
public int AgeMin;
public int AgeMax;
public Vector2 PosPoint;
}
}