mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交Unity 联机Pro
This commit is contained in:
56
JNFrame2/Assets/Scripts/UI/DMainUI.cs
Normal file
56
JNFrame2/Assets/Scripts/UI/DMainUI.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
3
JNFrame2/Assets/Scripts/UI/DMainUI.cs.meta
Normal file
3
JNFrame2/Assets/Scripts/UI/DMainUI.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92f14f0fc9194cc3993c79ccce2bc7ee
|
||||
timeCreated: 1722219215
|
Reference in New Issue
Block a user