56 lines
1.5 KiB
C#
Raw Normal View History

2024-08-17 14:27:18 +08:00
using System;
using AppGame;
using Game.Input;
using JNGame.Math;
using Plugins.JNGame.Network;
using UnityEngine;
using UnityEngine.UI;
namespace UI
{
public class DMainUI : MonoBehaviour
{
public GameObject root;
public Text SizeText;
public Text ByteSizeText;
public Camera MainCamera;
private void Update()
{
SizeText.text = $"{root.transform.childCount}";
if (App.IsClient())
{
// ByteSizeText.text = $"{JNTCPClient.Size}";
}
if (App.IsServer())
{
ByteSizeText.text = $"{App.Server.GetByteSize()}";
}
if (!(App.IsClient())) return;
float moveHorizontal = Input.GetAxis("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
var transform1 = MainCamera.transform;
movement = transform1.forward * movement.z + transform1.right * movement.x;
movement = movement.normalized;
IDPlayerMoveVector vector = new IDPlayerMoveVector
{
X = movement.x.ToLFloat(),
Y = movement.z.ToLFloat(),
};
if (App.Game.IsStartGame)
{
Debug.Log($"{vector.X} {vector.Y}");
App.Game.GetInput<IDPlayer>().MoveVector = vector;
}
}
}
}