MiniGame System Test (TCP only)

Nach jeder Runde (jeder spieler hat einmal gewürfelt) wird ein zufälliges minigame geladen. Ist das minigame beendet (stand jz nach 1 sekunde fix) wird die Map in Ihrem vorherigen zustand neu geladen. Die Kommunikation zwischen Client und Server im Minigame erfolgt unabhängig der Kommunikation in der Map
This commit is contained in:
brausjonas
2023-04-15 03:52:15 +02:00
parent 7c0d3ac7ae
commit 412490ea85
30 changed files with 1055 additions and 229 deletions
@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
public class MinigamesClient : MonoBehaviour
{
private TcpClient client;
private Stream stream;
private Queue<Job> jobs = new Queue<Job>();
private void Start()
{
client = new TcpClient("185.245.96.48", 8051);
stream = client.GetStream();
stream.Write(new byte[]{5, (byte)Client.playerID, 0, 0, 0, 0, 0, 0, 0, 0});
byte[] originalRoomCode = Encoding.ASCII.GetBytes(PlayerPrefs.GetString("roomcode"));
stream.Write(originalRoomCode);
new Thread(Read).Start();
}
private void Update()
{
if (jobs.Count > 0)
{
Job job = jobs.Dequeue();
switch (job.data[0])
{
//TEST
case 1:
stream.Write(new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
break;
}
}
}
private void Read()
{
while (true)
{
byte[] read = new byte[10];
stream.Read(read, 0, 10);
jobs.Enqueue(new Job(read));
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddf3c4ab225c68d4d8849a8a6a231bc0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: