Mini Game Improved

This commit is contained in:
brausjonas
2023-04-15 16:05:42 +02:00
parent 605fe5a8df
commit 54c40d7cf4
18 changed files with 89 additions and 72 deletions
Binary file not shown.
@@ -137,7 +137,9 @@ PlayerSettings:
16:9: 1
Others: 1
bundleVersion: 0.16
preloadedAssets: []
preloadedAssets:
- {fileID: -6230802382160794249, guid: 90cd1b71078984c4980fcd1aa03eaaa3, type: 2}
- {fileID: 11400000, guid: 48bf7376b3770c44cbfe3f40e77359ab, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1
@@ -21,10 +21,10 @@ EditorUserSettings:
value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b
flags: 0
RecentlyUsedSceneGuid-5:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
value: 0254505450065d02585f5573157b0744424f1b282e2971342f2b1c37b2e6663e
flags: 0
RecentlyUsedSceneGuid-6:
value: 0254505450065d02585f5573157b0744424f1b282e2971342f2b1c37b2e6663e
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
flags: 0
UnityRemoteDevice:
value: 225f4d46245b0d4902070862342649191512
+1 -1
View File
@@ -103,7 +103,7 @@
<workItem from="1681217780586" duration="94000" />
<workItem from="1681218296017" duration="162000" />
<workItem from="1681481242206" duration="13939000" />
<workItem from="1681566184866" duration="68000" />
<workItem from="1681566184866" duration="682000" />
</task>
<servers />
</component>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+4 -67
View File
@@ -6,16 +6,16 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
public class Minigame
public abstract class Minigame
{
//referenz auf den ursprünglichen raum
protected Room room;
//liste aller threads zum korrekten beenden dieser
private List<Thread> threads = new ArrayList<>();
protected List<Thread> threads = new ArrayList<>();
//liste aller temporären minigame verbindungen
private Client[] players;
protected Client[] players;
public Minigame(Room room)
{
@@ -24,70 +24,7 @@ public class Minigame
}
//fügt dem minigame "Raum" einen spieler hinzu (ähnlich wie im Room selbst)
public void addClient(Client client, int index)
{
Thread t = new Thread(new Runnable()
{
@Override
public void run()
{
players[index] = client;
DataInputStream input = client.input;
DataOutputStream output = client.output;
//Buffer für eingehende narichten
byte[] readData = new byte[10];
//TEST
try
{
output.write(new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
} catch (IOException e)
{
}
//eingehende narichten verarbeiten:
while (true)
{
try
{
input.read(readData);
switch (readData[0])
{
//TEST
case 1:
System.out.println("testtttttttttttttt");
Timer t = new Timer();
TimerTask tt = new TimerTask()
{
@Override
public void run()
{
room.closeMinigame();
}
};
t.schedule(tt, 1000);
break;
//TEST END
}
} catch (Exception e)
{
}
}
}
});
threads.add(t);
t.start();
}
public abstract void addClient(Client client, int index);
//das minigame wird beendet
public void end()
+1 -1
View File
@@ -67,7 +67,7 @@ public class Room
int randomGame = (int) (Math.random() * 1);
//minigame instanz erstellen
currentMiniGame = new Minigame(this);
currentMiniGame = new TestMiniGame(this);
try
{
+78
View File
@@ -0,0 +1,78 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
public class TestMiniGame extends Minigame
{
public TestMiniGame(Room room) {
super(room);
}
@Override
public void addClient(Client client, int index)
{
Thread t = new Thread(new Runnable()
{
@Override
public void run()
{
players[index] = client;
DataInputStream input = client.input;
DataOutputStream output = client.output;
//Buffer für eingehende narichten
byte[] readData = new byte[10];
//TEST
try
{
output.write(new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
} catch (IOException e)
{
}
//eingehende narichten verarbeiten:
while (true)
{
try
{
input.read(readData);
switch (readData[0])
{
//TEST
case 1:
System.out.println("testtttttttttttttt");
Timer t = new Timer();
TimerTask tt = new TimerTask()
{
@Override
public void run()
{
room.closeMinigame();
}
};
t.schedule(tt, 1000);
break;
//TEST END
}
} catch (Exception e)
{
}
}
}
});
threads.add(t);
t.start();
}
}