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:
+3
-2
@@ -11,6 +11,7 @@
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="HighlightingSettingsPerFile">
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scenes/EventScenes/Testt.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/AutoSetAndroidPassword.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Client.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Assets/Scripts/Fields/EventField.cs" root0="FORCE_HIGHLIGHTING" />
|
||||
@@ -60,7 +61,7 @@
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Attach to Unity Editor.Attach to Unity Editor">
|
||||
<configuration name="Standalone Player" type="RunUnityExe" factoryName="Unity Executable">
|
||||
<option name="EXE_PATH" value="$USER_HOME$/Desktop/Build\FlufflParty.exe" />
|
||||
<option name="EXE_PATH" value="$USER_HOME$/Desktop/Build/FlufflParty.exe" />
|
||||
<option name="PROGRAM_PARAMETERS" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="C:\Users\braus\OneDrive\Desktop\FlufflPartyTestBuild" />
|
||||
<option name="PASS_PARENT_ENVS" value="1" />
|
||||
@@ -167,7 +168,7 @@
|
||||
<workItem from="1680813239896" duration="4155000" />
|
||||
<workItem from="1681056387914" duration="882000" />
|
||||
<workItem from="1681415672515" duration="5000" />
|
||||
<workItem from="1681479671396" duration="15225000" />
|
||||
<workItem from="1681479671396" duration="20754000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95a4c2802d12dd240bbab3e7760c0ff6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using UnityEngine;
|
||||
|
||||
public class Testt : MonoBehaviour
|
||||
{
|
||||
private TcpClient client;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
client = new TcpClient("185.245.96.48", 8051);
|
||||
|
||||
Stream stream = client.GetStream();
|
||||
|
||||
stream.Write(new byte[]{5, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6bcb140aa3415a146b7b0c224ec46b05
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 949d5f18d4d6f3b4095e61728c284b6d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,316 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 512
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 256
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 1
|
||||
m_PVRDenoiserTypeDirect: 1
|
||||
m_PVRDenoiserTypeIndirect: 1
|
||||
m_PVRDenoiserTypeAO: 1
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 1
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_LightingSettings: {fileID: 0}
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &363352570
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 363352572}
|
||||
- component: {fileID: 363352571}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &363352571
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 363352570}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_UseViewFrustumForShadowCasterCull: 1
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &363352572
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 363352570}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &1017695554
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1017695557}
|
||||
- component: {fileID: 1017695556}
|
||||
- component: {fileID: 1017695555}
|
||||
- component: {fileID: 1017695558}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &1017695555
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1017695554}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &1017695556
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1017695554}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &1017695557
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1017695554}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1017695558
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1017695554}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ddf3c4ab225c68d4d8849a8a6a231bc0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aed253495191e88448cbba7dbbad0f2f
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,12 +4,12 @@ using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
||||
[InitializeOnLoad]
|
||||
//[InitializeOnLoad]
|
||||
public class AutoSetAndroidPassword
|
||||
{
|
||||
static AutoSetAndroidPassword()
|
||||
{
|
||||
PlayerSettings.keystorePass = "ACD1576BbBACD";
|
||||
PlayerSettings.keyaliasPass = "ACD1576BbBACD";
|
||||
}
|
||||
// static AutoSetAndroidPassword()
|
||||
// {
|
||||
// PlayerSettings.keystorePass = "ACD1576BbBACD";
|
||||
// PlayerSettings.keyaliasPass = "ACD1576BbBACD";
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -41,21 +41,57 @@ public class Client : MonoBehaviour
|
||||
[SerializeField] private Image[] playerItemInfoImages;
|
||||
|
||||
private Dice diceScript;
|
||||
|
||||
public static int playerID = -1;
|
||||
|
||||
//Icon
|
||||
[SerializeField] private Image[] playerIconInfoImages;
|
||||
[SerializeField] private Sprite[] playerIconInfoImagesPrefabs;
|
||||
|
||||
private static Client thisClient;
|
||||
|
||||
|
||||
//players in game text blub
|
||||
[SerializeField] private TMP_Text playersInGameText;
|
||||
|
||||
//Scene System
|
||||
public static Scene sceneMap;
|
||||
|
||||
//Minigames
|
||||
private string[] miniGamesMapping = new string[] { "TestGame" };
|
||||
private int currentMiniGameId = -1;
|
||||
|
||||
public static Client GetCurrentInstance()
|
||||
{
|
||||
return thisClient;
|
||||
}
|
||||
|
||||
public void LoadMinigame(int id)
|
||||
{
|
||||
currentMiniGameId = id;
|
||||
|
||||
//Hide the current Scene (not the client!)
|
||||
GameObject[] objectsToUnload = sceneMap.GetRootGameObjects();
|
||||
foreach (GameObject g in objectsToUnload)
|
||||
{
|
||||
if (!g.name.Equals("EventSystem"))
|
||||
{
|
||||
g.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
SceneManager.LoadScene(miniGamesMapping[id], LoadSceneMode.Additive);
|
||||
}
|
||||
|
||||
public void UnloadMinigame()
|
||||
{
|
||||
GameObject[] objectsToUnload = sceneMap.GetRootGameObjects();
|
||||
foreach (GameObject g in objectsToUnload)
|
||||
{
|
||||
g.SetActive(true);
|
||||
}
|
||||
|
||||
SceneManager.UnloadSceneAsync(miniGamesMapping[currentMiniGameId]);
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Time.fixedDeltaTime = 0.01f;
|
||||
@@ -63,10 +99,12 @@ public class Client : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
sceneMap = SceneManager.GetActiveScene();
|
||||
|
||||
diceScript = dice.GetComponent<Dice>();
|
||||
|
||||
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
|
||||
thisClient = this;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
@@ -85,7 +123,7 @@ public class Client : MonoBehaviour
|
||||
string name = PlayerPrefs.GetString("name");
|
||||
stream.Write(Encoding.ASCII.GetBytes(name), 0, 10);
|
||||
int characterID = PlayerPrefs.GetInt("characterID");
|
||||
stream.Write(new byte[] { (byte)characterID, 0, 0, 0, 0, 0, 0, 0, 0, 0 },0, 10);
|
||||
stream.Write(new byte[] { (byte)characterID, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 10);
|
||||
|
||||
for (int i = 0; i < playerInfo.Length; i++)
|
||||
{
|
||||
@@ -95,6 +133,46 @@ public class Client : MonoBehaviour
|
||||
new Thread(Read).Start();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Logic to load another Scene with Seperate Connection, while the current connection is holding
|
||||
*/
|
||||
|
||||
// private bool bub = false;
|
||||
// private void Update()
|
||||
// {
|
||||
// if (Input.GetKeyDown(KeyCode.Space) && !bub)
|
||||
// {
|
||||
//
|
||||
// bub = true;
|
||||
// GameObject[] gameObjectsToHide = sceneMap.GetRootGameObjects();
|
||||
// foreach (GameObject g in gameObjectsToHide)
|
||||
// {
|
||||
// if (!g.name.Equals("EventSystem"))
|
||||
// {
|
||||
// g.SetActive(true);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// SceneManager.LoadScene("Test", LoadSceneMode.Additive);
|
||||
// }
|
||||
//
|
||||
// else if (Input.GetKeyDown(KeyCode.Space) && bub)
|
||||
// {
|
||||
//
|
||||
// bub = false;
|
||||
// GameObject[] gameObjectsToHide = sceneMap.GetRootGameObjects();
|
||||
// foreach (GameObject g in gameObjectsToHide)
|
||||
// {
|
||||
// g.SetActive(true);
|
||||
// }
|
||||
//
|
||||
// SceneManager.UnloadSceneAsync("Test");
|
||||
// }
|
||||
// }
|
||||
|
||||
public void CalculatePlacement()
|
||||
{
|
||||
Player[] temp = new Player[playerAmount];
|
||||
@@ -105,7 +183,7 @@ public class Client : MonoBehaviour
|
||||
temp[j] = players[j];
|
||||
samePlacement[j] = false;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < temp.Length - 1; i++)
|
||||
{
|
||||
for (int f = 0; f < temp.Length - 1; f++)
|
||||
@@ -116,9 +194,9 @@ public class Client : MonoBehaviour
|
||||
}
|
||||
else if (temp[f].stars == temp[f + 1].stars && temp[f].coins < temp[f + 1].coins)
|
||||
{
|
||||
(temp[f], temp[f + 1]) = (temp[f + 1], temp[f]);
|
||||
(temp[f], temp[f + 1]) = (temp[f + 1], temp[f]);
|
||||
}
|
||||
else if(temp[f].stars == temp[f + 1].stars && temp[f].coins == temp[f + 1].coins)
|
||||
else if (temp[f].stars == temp[f + 1].stars && temp[f].coins == temp[f + 1].coins)
|
||||
{
|
||||
samePlacement[f] = true;
|
||||
}
|
||||
@@ -147,7 +225,7 @@ public class Client : MonoBehaviour
|
||||
private void FixedUpdate()
|
||||
{
|
||||
fpsText.text = "" + Time.frameCount / Time.time + "";
|
||||
|
||||
|
||||
if (jobs.Count > 0)
|
||||
{
|
||||
Job job = jobs.Dequeue();
|
||||
@@ -157,14 +235,15 @@ public class Client : MonoBehaviour
|
||||
//-----Create A new player-----
|
||||
case 1:
|
||||
playerAmount++;
|
||||
|
||||
|
||||
//player is playable
|
||||
if (job.data[1] == 1)
|
||||
{
|
||||
GameObject player = Instantiate(playerPrefab[job.data[9]]);
|
||||
playerIconInfoImages[job.data[5]].sprite = playerIconInfoImagesPrefabs[job.data[9]];
|
||||
|
||||
player.transform.position = new Vector3(job.data[2], job.data[3] + playerPrefabsHeightInfo[job.data[9]].heightOffset, job.data[4]);
|
||||
player.transform.position = new Vector3(job.data[2],
|
||||
job.data[3] + playerPrefabsHeightInfo[job.data[9]].heightOffset, job.data[4]);
|
||||
|
||||
PlayablePlayer script = player.AddComponent<PlayablePlayer>();
|
||||
players[job.data[5]] = script;
|
||||
@@ -176,7 +255,7 @@ public class Client : MonoBehaviour
|
||||
|
||||
//ITEM INFO IMAGES
|
||||
Image[] temp = new Image[3];
|
||||
|
||||
|
||||
int itemInfoImagesStartIndex = job.data[5] * 3;
|
||||
int idx = 0;
|
||||
for (int i = itemInfoImagesStartIndex; i < itemInfoImagesStartIndex + 3; i++)
|
||||
@@ -197,7 +276,8 @@ public class Client : MonoBehaviour
|
||||
GameObject player = Instantiate(playerPrefab[job.data[9]]);
|
||||
playerIconInfoImages[job.data[5]].sprite = playerIconInfoImagesPrefabs[job.data[9]];
|
||||
|
||||
player.transform.position = new Vector3(job.data[2], job.data[3] + playerPrefabsHeightInfo[job.data[9]].heightOffset, job.data[4]);
|
||||
player.transform.position = new Vector3(job.data[2],
|
||||
job.data[3] + playerPrefabsHeightInfo[job.data[9]].heightOffset, job.data[4]);
|
||||
|
||||
NoPlayablePlayer script = player.AddComponent<NoPlayablePlayer>();
|
||||
players[job.data[5]] = script;
|
||||
@@ -209,7 +289,7 @@ public class Client : MonoBehaviour
|
||||
|
||||
//ITEM INFO IMAGES
|
||||
Image[] temp = new Image[3];
|
||||
|
||||
|
||||
int itemInfoImagesStartIndex = job.data[5] * 3;
|
||||
int idx = 0;
|
||||
for (int i = itemInfoImagesStartIndex; i < itemInfoImagesStartIndex + 3; i++)
|
||||
@@ -221,7 +301,7 @@ public class Client : MonoBehaviour
|
||||
|
||||
script.itemInfoImages = temp;
|
||||
//END
|
||||
|
||||
|
||||
itemButtons[job.data[5]].interactable = false;
|
||||
}
|
||||
|
||||
@@ -295,6 +375,7 @@ public class Client : MonoBehaviour
|
||||
{
|
||||
amount *= -1;
|
||||
}
|
||||
|
||||
players[job.data[3]].AddCoins(amount);
|
||||
break;
|
||||
case 14:
|
||||
@@ -322,10 +403,10 @@ public class Client : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uiHandler.ActivateRotator();
|
||||
rotator.StartRandom();
|
||||
break;
|
||||
@@ -334,9 +415,19 @@ public class Client : MonoBehaviour
|
||||
rotator2.Stop(job.data[1]);
|
||||
Invoke("ActivateLayout1", 3.5f);
|
||||
break;
|
||||
|
||||
case 100:
|
||||
|
||||
playerID = job.data[1];
|
||||
LoadMinigame(job.data[2]);
|
||||
|
||||
break;
|
||||
|
||||
case 101:
|
||||
Debug.Log("test");
|
||||
UnloadMinigame();
|
||||
break;
|
||||
case 126:
|
||||
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
|
||||
stream.Write(new byte[] { 126, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, 0, 10);
|
||||
break;
|
||||
case 127:
|
||||
client.Close();
|
||||
@@ -350,7 +441,7 @@ public class Client : MonoBehaviour
|
||||
{
|
||||
uiHandler.ActivateLayout1();
|
||||
}
|
||||
|
||||
|
||||
private void Activate(int player)
|
||||
{
|
||||
for (int i = 0; i < players.Length; i++)
|
||||
@@ -389,36 +480,36 @@ public class Client : MonoBehaviour
|
||||
//1 x, x = zahl
|
||||
public void SendWurfeln(int zahl)
|
||||
{
|
||||
|
||||
stream.Write(new byte[]{3, (byte)zahl, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 3, (byte)zahl, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
//0 4 arrow selected
|
||||
//1 x, x = arrow idx
|
||||
public void SendArrowSelected(int idx)
|
||||
{
|
||||
stream.Write(new byte[]{4, (byte)idx, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 4, (byte)idx, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
//0 5
|
||||
|
||||
public void SendFinished()
|
||||
{
|
||||
stream.Write(new byte[]{5, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 5, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendCoinFieldAction(int action)
|
||||
{
|
||||
stream.Write(new byte[]{6, (byte)action, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 6, (byte)action, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendEventStopFinished()
|
||||
{
|
||||
stream.Write(new byte[]{7, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 7, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendBuyStar()
|
||||
{
|
||||
stream.Write(new byte[]{8, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 8, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendBuyItem(Item item)
|
||||
@@ -428,22 +519,22 @@ public class Client : MonoBehaviour
|
||||
|
||||
public void SendActiveItem(byte index)
|
||||
{
|
||||
stream.Write(new byte[]{10, index, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 10, index, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 126, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
private void OnApplicationPause(bool pauseStatus)
|
||||
{
|
||||
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 126, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendLostItem(byte index)
|
||||
{
|
||||
stream.Write(new byte[]{12, index, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 12, index, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
public void SendCoins(int amount)
|
||||
@@ -454,9 +545,9 @@ public class Client : MonoBehaviour
|
||||
isPositive = 0;
|
||||
amount *= -1;
|
||||
}
|
||||
|
||||
|
||||
stream.Write(new byte[]{13, isPositive, (byte)amount, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
|
||||
stream.Write(new byte[] { 13, isPositive, (byte)amount, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -472,13 +563,18 @@ public class Client : MonoBehaviour
|
||||
* TYPE:
|
||||
* 0 = Pink Field
|
||||
*/
|
||||
public void SendStartRotator(int opt1, int opt2, int opt3, int opt4, int val1, int val2, int val3, int val4, int type)
|
||||
public void SendStartRotator(int opt1, int opt2, int opt3, int opt4, int val1, int val2, int val3, int val4,
|
||||
int type)
|
||||
{
|
||||
stream.Write(new byte[]{14, (byte)opt1, (byte)opt2, (byte)opt3, (byte)opt4, (byte)val1, (byte)val2, (byte)val3, (byte)val4, (byte)type});
|
||||
stream.Write(new byte[]
|
||||
{
|
||||
14, (byte)opt1, (byte)opt2, (byte)opt3, (byte)opt4, (byte)val1, (byte)val2, (byte)val3, (byte)val4,
|
||||
(byte)type
|
||||
});
|
||||
}
|
||||
|
||||
public void SendStopRotator(int stopIndex)
|
||||
{
|
||||
stream.Write(new byte[]{15, (byte)stopIndex, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
stream.Write(new byte[] { 15, (byte)stopIndex, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 85174208f996d96459f4f8b2dc24eec7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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:
|
||||
@@ -11,6 +11,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/WesternMap.unity
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Minigames/TestGame.unity
|
||||
guid: aed253495191e88448cbba7dbbad0f2f
|
||||
m_configObjects:
|
||||
com.unity.adaptiveperformance.loader_settings: {fileID: 11400000, guid: 90cd1b71078984c4980fcd1aa03eaaa3, type: 2}
|
||||
com.unity.adaptiveperformance.samsung.android.provider_settings: {fileID: 11400000, guid: 48bf7376b3770c44cbfe3f40e77359ab, type: 2}
|
||||
|
||||
@@ -138,7 +138,7 @@ PlayerSettings:
|
||||
Others: 1
|
||||
bundleVersion: 0.16
|
||||
preloadedAssets:
|
||||
- {fileID: -6390619424234631034, guid: 90cd1b71078984c4980fcd1aa03eaaa3, type: 2}
|
||||
- {fileID: -6230802382160794249, guid: 90cd1b71078984c4980fcd1aa03eaaa3, type: 2}
|
||||
- {fileID: 11400000, guid: 48bf7376b3770c44cbfe3f40e77359ab, type: 2}
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
|
||||
@@ -12,9 +12,18 @@ EditorUserSettings:
|
||||
value: 55010d0300055a5a595a592641730d44104e4c287b2e71662c7b186bb3b86069
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-2:
|
||||
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
||||
value: 05000d54575659030f57542011760844414e40282a2c2565797f4565b4e23060
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-3:
|
||||
value: 000757055c0d5e580e5f5920492209441415497e2f7972607c704e62b5b66d3a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-4:
|
||||
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-5:
|
||||
value: 0254505450065d02585f5573157b0744424f1b282e2971342f2b1c37b2e6663e
|
||||
flags: 0
|
||||
RecentlyUsedSceneGuid-6:
|
||||
value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b
|
||||
flags: 0
|
||||
UnityRemoteDevice:
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+2
-1
@@ -46,6 +46,7 @@
|
||||
"project.structure.last.edited": "Artifacts",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "preferences.sourceCode.Java",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
@@ -101,7 +102,7 @@
|
||||
<workItem from="1681130452664" duration="6192000" />
|
||||
<workItem from="1681217780586" duration="94000" />
|
||||
<workItem from="1681218296017" duration="162000" />
|
||||
<workItem from="1681481242206" duration="5995000" />
|
||||
<workItem from="1681481242206" duration="12651000" />
|
||||
</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.
@@ -26,6 +26,12 @@ public class Client
|
||||
this.characterID = characterID;
|
||||
}
|
||||
|
||||
public Client(DataOutputStream output, DataInputStream input, Socket socket) {
|
||||
this.output = output;
|
||||
this.input = input;
|
||||
this.socket = socket;
|
||||
}
|
||||
|
||||
public void close()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
public class Minigame
|
||||
{
|
||||
protected Room room;
|
||||
private List<Thread> threads = new ArrayList<>();
|
||||
private Client[] players;
|
||||
|
||||
public Minigame(Room room)
|
||||
{
|
||||
this.room = room;
|
||||
players = new Client[room.players.length];
|
||||
}
|
||||
|
||||
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;
|
||||
byte[] readData = new byte[10];
|
||||
|
||||
|
||||
//TEST
|
||||
try
|
||||
{
|
||||
output.write(new byte[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
} catch (IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
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 void end()
|
||||
{
|
||||
for (int i = 0; i < threads.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
threads.get(i).interrupt();
|
||||
} catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < players.length; i++)
|
||||
{
|
||||
players[i].close();
|
||||
}
|
||||
|
||||
threads.clear();
|
||||
}
|
||||
}
|
||||
+324
-181
@@ -11,7 +11,8 @@ import java.util.TimerTask;
|
||||
/**
|
||||
* this class handels all operations / syncs performed in a single room
|
||||
*/
|
||||
public class Room {
|
||||
public class Room
|
||||
{
|
||||
//tells how many clients can connect to a room
|
||||
public Client[] players = new Client[2];
|
||||
//the array of players start positions
|
||||
@@ -29,9 +30,12 @@ public class Room {
|
||||
|
||||
//tells players turn (array index)
|
||||
private int currentPlayer = 0;
|
||||
private int playersPlayedCount = 0;
|
||||
private Minigame currentMiniGame;
|
||||
private boolean inMiniGame = false;
|
||||
|
||||
|
||||
public Room(String roomCode, Server server) {
|
||||
public Room(String roomCode, Server server)
|
||||
{
|
||||
|
||||
this.roomCode = roomCode;
|
||||
startPositions = new Vector3[4];
|
||||
@@ -43,6 +47,69 @@ public class Room {
|
||||
startPositions[3] = new Vector3(92, 0, 128);
|
||||
|
||||
this.server = server;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void addPlayerToCurrentMiniGame(int index, Client tempClient)
|
||||
{
|
||||
currentMiniGame.addClient(tempClient, index);
|
||||
}
|
||||
|
||||
|
||||
private void activateMinigame()
|
||||
{
|
||||
inMiniGame = true;
|
||||
int randomGame = (int) (Math.random() * 1);
|
||||
|
||||
currentMiniGame = new Minigame(this);
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
players[i].output.write(new byte[]{100, (byte) i, (byte) randomGame, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void closeMinigame()
|
||||
{
|
||||
if(currentMiniGame != null)
|
||||
{
|
||||
System.out.println("close minigame");
|
||||
currentMiniGame.end();
|
||||
currentMiniGame = null;
|
||||
inMiniGame = false;
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
players[i].output.write(new byte[]{101, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} catch (Exception e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//sync the activation of the current player to ALL clients
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//!!data processing!!
|
||||
//----------------------------action--------the next player-----------free space------
|
||||
try
|
||||
{
|
||||
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
} catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,12 +117,15 @@ public class Room {
|
||||
*
|
||||
* @param client
|
||||
*/
|
||||
public void addClient(Client client) {
|
||||
public void addClient(Client client)
|
||||
{
|
||||
|
||||
//loops through all players existing and sends the needed information
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//places the new joined player in the next free slot
|
||||
if (players[i] == null) {
|
||||
if (players[i] == null)
|
||||
{
|
||||
players[i] = client;
|
||||
playerCount++;
|
||||
|
||||
@@ -63,37 +133,48 @@ public class Room {
|
||||
System.out.println(client.name.replace(" ", "") + " joined room " + roomCode + " successfully as player " + i);
|
||||
|
||||
//creates a thread for the connection with the joined player
|
||||
Thread t = new Thread(new Runnable() {
|
||||
Thread t = new Thread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
public void run()
|
||||
{
|
||||
//assignes a player id
|
||||
int player = playerCount - 1;
|
||||
|
||||
DataInputStream input = null;
|
||||
try {
|
||||
try
|
||||
{
|
||||
//tries to get the input stream (TCP)
|
||||
input = new DataInputStream(players[player].socket.getInputStream());
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
server.deleteRoom(roomCode);
|
||||
}
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
if (players[i] != null) {
|
||||
try {
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
if (players[i] != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
players[i].output.write(new byte[]{11, (byte) playerCount, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
//this is a buffer for all data being received by the player
|
||||
byte[] readData = new byte[10];
|
||||
while (true)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
//read the data to the buffer
|
||||
input.read(readData);
|
||||
//this is a buffer for all data being received by the player
|
||||
byte[] readData = new byte[10];
|
||||
|
||||
//read the data to the buffer
|
||||
input.read(readData);
|
||||
|
||||
|
||||
/*
|
||||
@@ -105,152 +186,184 @@ public class Room {
|
||||
----------------------------------------
|
||||
----------------------------------------
|
||||
*/
|
||||
//Checks which action (array[0]) is received
|
||||
switch (readData[0]) {
|
||||
//Checks which action (array[0]) is received
|
||||
switch (readData[0])
|
||||
{
|
||||
|
||||
/**
|
||||
* //spieler hat gewürfelt
|
||||
*/
|
||||
case 3:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//sync to all OTHER players
|
||||
if (i != player) {
|
||||
/**
|
||||
* //spieler hat gewürfelt
|
||||
*/
|
||||
case 3:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//sync to all OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//!!data processing!!
|
||||
//----------------------------action---player-------rolled number----free space--------
|
||||
players[i].output.write(new byte[]{3, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
/**
|
||||
* //pfeil wurde ausgewählt
|
||||
*/
|
||||
case 4:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//!!data processing!!
|
||||
//----------------------------action---player-------rolled number----free space--------
|
||||
players[i].output.write(new byte[]{3, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
//sync to all OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//-------------------------------action----player-----arrow index--------free space-----
|
||||
players[i].output.write(new byte[]{4, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
/**
|
||||
* //pfeil wurde ausgewählt
|
||||
*/
|
||||
case 4:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//!!data processing!!
|
||||
//sync to all OTHER players
|
||||
if (i != player) {
|
||||
//-------------------------------action----player-----arrow index--------free space-----
|
||||
players[i].output.write(new byte[]{4, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
/**
|
||||
* //Spieler ist fertig mit seinem Zug
|
||||
*/
|
||||
case 5:
|
||||
//calculate the next player
|
||||
currentPlayer++;
|
||||
if (currentPlayer >= players.length) {
|
||||
currentPlayer = 0;
|
||||
}
|
||||
//sync the activation of the current player to ALL clients
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//!!data processing!!
|
||||
//----------------------------action--------the next player-----------free space------
|
||||
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
break;
|
||||
|
||||
/**
|
||||
* //Es wurde auf ein CoinField getreten (Rot oder Blau)
|
||||
*/
|
||||
case 6:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//sync to OTHER players
|
||||
if (i != player) {
|
||||
//!!data processing!!
|
||||
//-----------------------------action--player-------losse or get------------free space--
|
||||
players[i].output.write(new byte[]{6, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
/**
|
||||
* //Spieler ist fertig mit seinem Zug
|
||||
*/
|
||||
case 5:
|
||||
//calculate the next player
|
||||
currentPlayer++;
|
||||
if (currentPlayer >= players.length)
|
||||
{
|
||||
currentPlayer = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/**
|
||||
* //Eventstop (ItemShop, BuyStar, ...) ist fertig
|
||||
*/
|
||||
case 7:
|
||||
//sync to ALL players
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//!!simple sync!!
|
||||
//------------------------------action---player---------free space--------
|
||||
players[i].output.write(new byte[]{7, (byte) player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
break;
|
||||
/**
|
||||
* //Spieler hat einen Stern gekauft
|
||||
*/
|
||||
case 8:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//!!simple sync!!
|
||||
//sync to OTHER players
|
||||
if (i != player) {
|
||||
//-----------------------------action----player----------free space------
|
||||
players[i].output.write(new byte[]{8, (byte) player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
if (currentPlayer != 0)
|
||||
{
|
||||
//sync the activation of the current player to ALL clients
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//!!data processing!!
|
||||
//----------------------------action--------the next player-----------free space------
|
||||
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} else
|
||||
{
|
||||
activateMinigame();
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
/**
|
||||
* //Spieler hat ein Item Gekauft
|
||||
*/
|
||||
case 9:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//Sync to OTHER players
|
||||
if (i != player) {
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item ID--------free space--------
|
||||
players[i].output.write(new byte[]{9, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
/**
|
||||
* //Es wurde auf ein CoinField getreten (Rot oder Blau)
|
||||
*/
|
||||
case 6:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//!!data processing!!
|
||||
//-----------------------------action--player-------losse or get------------free space--
|
||||
players[i].output.write(new byte[]{6, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//Sync to OTHER players
|
||||
if (i != player) {
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item index--------free space--------
|
||||
players[i].output.write(new byte[]{10, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
/**
|
||||
* //Eventstop (ItemShop, BuyStar, ...) ist fertig
|
||||
*/
|
||||
case 7:
|
||||
//sync to ALL players
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//!!simple sync!!
|
||||
//------------------------------action---player---------free space--------
|
||||
players[i].output.write(new byte[]{7, (byte) player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//Sync to OTHER players
|
||||
if (i != player) {
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item index--------free space--------
|
||||
players[i].output.write(new byte[]{12, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
break;
|
||||
/**
|
||||
* //Spieler hat einen Stern gekauft
|
||||
*/
|
||||
case 8:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//!!simple sync!!
|
||||
//sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//-----------------------------action----player----------free space------
|
||||
players[i].output.write(new byte[]{8, (byte) player, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
//Coins Sync
|
||||
case 13:
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//Sync to OTHER players
|
||||
if (i != player) {
|
||||
players[i].output.write(new byte[]{13, readData[1], readData[2], (byte) player, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
//Start Rotator AND stop Rotator
|
||||
case 14: case 15:
|
||||
|
||||
for (int i = 0; i < players.length; i++) {
|
||||
//Sync to OTHER players
|
||||
if (i != player) {
|
||||
players[i].output.write(readData);
|
||||
/**
|
||||
* //Spieler hat ein Item Gekauft
|
||||
*/
|
||||
case 9:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//Sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item ID--------free space--------
|
||||
players[i].output.write(new byte[]{9, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 126:
|
||||
server.deleteRoom(roomCode);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
} catch (IOException e) {
|
||||
case 10:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//Sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item index--------free space--------
|
||||
players[i].output.write(new byte[]{10, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//Sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
//!!data processing!!
|
||||
//------------------------------action---player-------item index--------free space--------
|
||||
players[i].output.write(new byte[]{12, (byte) player, readData[1], 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
//Coins Sync
|
||||
case 13:
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//Sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
players[i].output.write(new byte[]{13, readData[1], readData[2], (byte) player, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
//Start Rotator AND stop Rotator
|
||||
case 14:
|
||||
case 15:
|
||||
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
//Sync to OTHER players
|
||||
if (i != player)
|
||||
{
|
||||
players[i].output.write(readData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 126:
|
||||
server.deleteRoom(roomCode);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
//if something is crashing, the room is being deleted
|
||||
server.deleteRoom(roomCode);
|
||||
}
|
||||
@@ -268,9 +381,12 @@ public class Room {
|
||||
}
|
||||
|
||||
//Make clients add all players to the world
|
||||
if (playerCount == players.length) {
|
||||
for (int j = 0; j < players.length; j++) {
|
||||
for (int k = 0; k < players.length; k++) {
|
||||
if (playerCount == players.length)
|
||||
{
|
||||
for (int j = 0; j < players.length; j++)
|
||||
{
|
||||
for (int k = 0; k < players.length; k++)
|
||||
{
|
||||
//0 1 create new player
|
||||
//1 0 no playable player
|
||||
//1 1 playable character
|
||||
@@ -278,8 +394,10 @@ public class Room {
|
||||
//5 player index
|
||||
|
||||
//if the player should be playable
|
||||
if (j == k) {
|
||||
try {
|
||||
if (j == k)
|
||||
{
|
||||
try
|
||||
{
|
||||
//sends the inital message to the player
|
||||
players[j].output.write(new byte[]{1, 1, (byte) startPositions[k].x, (byte) startPositions[k].y, (byte) startPositions[k].z, (byte) k, 0, 0, 0, (byte) players[k].characterID});
|
||||
|
||||
@@ -289,31 +407,37 @@ public class Room {
|
||||
send[0] = 5;
|
||||
send[1] = (byte) k;
|
||||
|
||||
for (int i = 2; i < send.length; i++) {
|
||||
for (int i = 2; i < send.length; i++)
|
||||
{
|
||||
send[i] = name[i - 2];
|
||||
}
|
||||
|
||||
players[j].output.write(send);
|
||||
//stop sending the name................................................................................
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
server.deleteRoom(roomCode);
|
||||
}
|
||||
}
|
||||
//if the player should be a bot
|
||||
else {
|
||||
try {
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
players[j].output.write(new byte[]{1, 0, (byte) startPositions[k].x, (byte) startPositions[k].y, (byte) startPositions[k].z, (byte) k, 0, 0, 0, (byte) players[k].characterID});
|
||||
byte[] name = players[k].name.substring(0, 8).getBytes(StandardCharsets.US_ASCII);
|
||||
byte[] send = new byte[10];
|
||||
send[0] = 5;
|
||||
send[1] = (byte) k;
|
||||
|
||||
for (int i = 2; i < send.length; i++) {
|
||||
for (int i = 2; i < send.length; i++)
|
||||
{
|
||||
send[i] = name[i - 2];
|
||||
}
|
||||
|
||||
players[j].output.write(send);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
server.deleteRoom(roomCode);
|
||||
}
|
||||
}
|
||||
@@ -324,11 +448,14 @@ public class Room {
|
||||
//1 x, x = idx
|
||||
|
||||
//send the inital activation message
|
||||
try {
|
||||
for (Client c : players) {
|
||||
try
|
||||
{
|
||||
for (Client c : players)
|
||||
{
|
||||
c.output.write(new byte[]{2, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (IOException e)
|
||||
{
|
||||
server.deleteRoom(roomCode);
|
||||
}
|
||||
}
|
||||
@@ -337,53 +464,69 @@ public class Room {
|
||||
/**
|
||||
* Closes the room
|
||||
*/
|
||||
public void closeRoom() {
|
||||
public void closeRoom()
|
||||
{
|
||||
//try to cick all the players (still connected) of the room
|
||||
try {
|
||||
try
|
||||
{
|
||||
|
||||
if (players[0] != null) {
|
||||
if (players[0] != null)
|
||||
{
|
||||
//127 is the action for room cick
|
||||
players[0].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
players[0].close();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
try {
|
||||
if (players[1] != null) {
|
||||
try
|
||||
{
|
||||
if (players[1] != null)
|
||||
{
|
||||
players[1].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
players[1].close();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
try {
|
||||
if (players[2] != null) {
|
||||
try
|
||||
{
|
||||
if (players[2] != null)
|
||||
{
|
||||
players[2].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
players[2].close();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
try {
|
||||
if (players[3] != null) {
|
||||
try
|
||||
{
|
||||
if (players[3] != null)
|
||||
{
|
||||
players[3].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
players[3].close();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
} catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//try to close all open threads (not crashed yet)
|
||||
for (int i = 0; i < threads.size(); i++) {
|
||||
try {
|
||||
for (int i = 0; i < threads.size(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
threads.get(i).interrupt();
|
||||
System.out.println("thread " + threads.get(i).getName() + " stopped!");
|
||||
} catch (Exception e) {
|
||||
} catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -189,6 +189,19 @@ public class Server
|
||||
client = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
//Player wats to join a minigame
|
||||
case 5:
|
||||
int playerIDInRoom = readData[1];
|
||||
|
||||
input.read(readData);
|
||||
|
||||
String roomCodeOriginal = new String(readData, StandardCharsets.US_ASCII);
|
||||
Client miniGameConnectorClient = new Client(output, input, client);
|
||||
rooms.get(roomCodeOriginal).addPlayerToCurrentMiniGame(playerIDInRoom, miniGameConnectorClient);
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
System.out.println("Init Thread finished");
|
||||
|
||||
Reference in New Issue
Block a user