Smooth Camera and Room Exist check

This commit is contained in:
brausjonas
2023-01-28 11:32:12 +01:00
parent cf9a17a8ff
commit fc84f233ec
18 changed files with 172 additions and 83 deletions
+2 -1
View File
@@ -105,7 +105,8 @@
<workItem from="1674673452934" duration="3050000" />
<workItem from="1674687637475" duration="660000" />
<workItem from="1674838735946" duration="520000" />
<workItem from="1674839572534" duration="22597000" />
<workItem from="1674839572534" duration="23192000" />
<workItem from="1674896945068" duration="4294000" />
</task>
<servers />
</component>
+18 -5
View File
@@ -650,7 +650,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &505032542
GameObject:
@@ -1230,7 +1230,7 @@ RectTransform:
- {fileID: 293557777}
- {fileID: 1780335805}
m_Father: {fileID: 0}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
@@ -1485,7 +1485,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 30.973, y: 49.515, z: 103.288}
--- !u!1 &1337600622
GameObject:
@@ -2176,7 +2176,19 @@ MonoBehaviour:
m_Calls: []
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
m_Calls:
- m_Target: {fileID: 2045552894}
m_TargetAssemblyTypeName: StartHandler, Assembly-CSharp
m_MethodName: OnTextHasChanged
m_Mode: 0
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_OnTouchScreenKeyboardStatusChanged:
m_PersistentCalls:
m_Calls: []
@@ -2300,7 +2312,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2045552894
MonoBehaviour:
@@ -2317,6 +2329,7 @@ MonoBehaviour:
layout1: {fileID: 293557776}
layout2: {fileID: 1780335804}
roomCodeEnter: {fileID: 505032544}
buttonJoin: {fileID: 1640298562}
--- !u!1 &2072539372
GameObject:
m_ObjectHideFlags: 0
+9 -2
View File
@@ -6,6 +6,7 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Client : MonoBehaviour
{
@@ -55,6 +56,7 @@ public class Client : MonoBehaviour
script.client = this;
script.nextField = nextField;
script.dice = dice;
script.camera = cam;
script.Init();
}
//player is not playable
@@ -68,6 +70,7 @@ public class Client : MonoBehaviour
players[job.data[5]] = script;
script.nextField = nextField;
script.dice = dice;
script.camera = cam;
script.Init();
}
break;
@@ -84,6 +87,10 @@ public class Client : MonoBehaviour
case 4:
((NoPlayablePlayer)players[job.data[1]]).ArrowSelect(job.data[2]);
break;
case 127:
client.Close();
SceneManager.LoadScene(0, LoadSceneMode.Single);
break;
}
}
}
@@ -105,8 +112,8 @@ public class Client : MonoBehaviour
}
}
cam.transform.parent = players[player].transform;
cam.transform.localPosition = new Vector3(-3, 8, 7);
// cam.transform.parent = players[player].transform;
// cam.transform.localPosition = new Vector3(-3, 8, 7);
}
@@ -29,6 +29,7 @@ public class NoPlayablePlayer : Player
public void Wurfeln(int wurfelZahl)
{
wurfelt = true;
this.wurfelZahl = wurfelZahl;
//nächstes Feld anvisieren
TargetNextField();
@@ -52,18 +53,21 @@ public class NoPlayablePlayer : Player
wait = false;
}
private void FixedUpdate()
{
if (activated)
{
camera.transform.position = Vector3.SmoothDamp(camera.transform.position, transform.position + cameraOffset, ref velocity, 0.2f);
if (!wait)
{
//Laufe zum nöchsten Feld, falls noch Züge übrig sind
if (interPol < 1 && wurfelZahl > 0)
{
//delay
if (Time.time - timeSinceWurfeln > 1)
if (Time.time - timeSinceWurfeln > 2)
{
InterPolerate();
}
@@ -82,10 +86,13 @@ public class NoPlayablePlayer : Player
//Der Spieler steht gerade
else
{
//start the dice
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
if (!wurfelt)
{
//start the dice
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
}
}
}
else
@@ -18,6 +18,7 @@ public class PlayablePlayer : Player
private float timeSinceWurfeln = 0;
private float timeSinceStop = 0;
private Vector3 useLess = new Vector3();
@@ -59,13 +60,15 @@ public class PlayablePlayer : Player
{
if (activated)
{
camera.transform.position = Vector3.SmoothDamp(camera.transform.position, transform.position + cameraOffset, ref velocity, 0.2f);
if (!wait)
{
//Laufe zum nöchsten Feld, falls noch Züge übrig sind
if (interPol < 1 && wurfelZahl > 0)
{
//delay
if (Time.time - timeSinceWurfeln > 1)
if (Time.time - timeSinceWurfeln > 2)
{
InterPolerate();
}
@@ -84,17 +87,19 @@ public class PlayablePlayer : Player
//Der Spieler steht gerade
else
{
//start the dice
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
//TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde
if (wurfelt)
{
client.SendFinished();
Invoke("Finish", 2);
activated = false;
}
else
{
//start the dice
dice.transform.position = Vector3.SmoothDamp(dice.transform.position,
transform.position + Vector3.up * 2, ref useLess, 0.2f);
diceScript.StartRandom();
}
}
}
else
@@ -157,5 +162,9 @@ public class PlayablePlayer : Player
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
}
private void Finish()
{
client.SendFinished();
}
}
@@ -7,6 +7,11 @@ public class Player : MonoBehaviour
public bool activated = false;
protected bool wurfelt = false;
public GameObject camera;
protected Vector3 velocity = Vector3.zero;
protected Vector3 cameraOffset = new Vector3(-5.81f, 8.13f, 7.6f);
//Aktiviert den Player
public void Activate()
{
@@ -13,6 +13,9 @@ public class StartHandler : MonoBehaviour
[SerializeField] private GameObject layout1;
[SerializeField] private GameObject layout2;
[SerializeField] private TMP_Text roomCodeEnter;
[SerializeField] private GameObject buttonJoin;
private string roomcode;
private void Start()
{
@@ -20,6 +23,8 @@ public class StartHandler : MonoBehaviour
layout1.SetActive(true);
layout2.SetActive(false);
buttonJoin.SetActive(false);
}
public void ButtonNewRoom()
@@ -41,6 +46,7 @@ public class StartHandler : MonoBehaviour
string code = Encoding.ASCII.GetString(readMessage);
PlayerPrefs.SetString("roomcode", code);
roomcode = code;
PlayerPrefs.Save();
layout2.GetComponentInChildren<TMP_Text>().text = "Your room code is: \n" + code;
@@ -49,6 +55,7 @@ public class StartHandler : MonoBehaviour
public void ButtonJoin()
{
string code = roomCodeEnter.text;
roomcode = code;
PlayerPrefs.SetString("roomcode", code);
PlayerPrefs.Save();
@@ -58,6 +65,9 @@ public class StartHandler : MonoBehaviour
public void ButtonJoin2()
{
PlayerPrefs.SetString("roomcode", roomcode);
PlayerPrefs.Save();
SceneManager.LoadScene(1, LoadSceneMode.Single);
client.Close();
}
@@ -72,4 +82,16 @@ public class StartHandler : MonoBehaviour
{
GUIUtility.systemCopyBuffer = PlayerPrefs.GetString("roomcode");
}
public void OnTextHasChanged(string s)
{
if (s.Length >= 10)
{
buttonJoin.SetActive(true);
}
else
{
buttonJoin.SetActive(false);
}
}
}
@@ -831,7 +831,7 @@ PlayerSettings:
allowUnsafeCode: 0
useDeterministicCompilation: 1
enableRoslynAnalyzers: 1
selectedPlatform: 2
selectedPlatform: 0
additionalIl2CppArgs:
scriptingRuntimeVersion: 1
gcIncremental: 1
@@ -4,7 +4,7 @@
QualitySettings:
m_ObjectHideFlags: 0
serializedVersion: 5
m_CurrentQuality: 2
m_CurrentQuality: 3
m_QualitySettings:
- serializedVersion: 2
name: Very Low
@@ -117,15 +117,15 @@ QualitySettings:
- serializedVersion: 2
name: High
pixelLightCount: 2
shadows: 2
shadowResolution: 1
shadows: 1
shadowResolution: 0
shadowProjection: 1
shadowCascades: 2
shadowDistance: 40
shadowDistance: 30
shadowNearPlaneOffset: 3
shadowCascade2Split: 0.33333334
shadowCascade2Split: 0.7905023
shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667}
shadowmaskMode: 1
shadowmaskMode: 0
skinWeights: 2
textureQuality: 0
anisotropicTextures: 1
@@ -231,7 +231,7 @@ QualitySettings:
PSP2: 2
Server: 0
Stadia: 5
Standalone: 5
Standalone: 3
WebGL: 3
Windows Store Apps: 5
XboxOne: 5
@@ -19,7 +19,7 @@ MonoBehaviour:
width: 1920
height: 1117
m_ShowMode: 4
m_Title: Hierarchy
m_Title: Game
m_RootView: {fileID: 6}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
@@ -48,7 +48,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 40
controlID: 78
--- !u!114 &3
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -111,7 +111,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ConsoleWindow
m_Name: ProjectBrowser
m_EditorClassIdentifier:
m_Children: []
m_Position:
@@ -120,14 +120,14 @@ MonoBehaviour:
y: 686
width: 1447
height: 381
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 18}
m_MinSize: {x: 231, y: 271}
m_MaxSize: {x: 10001, y: 10021}
m_ActualView: {fileID: 15}
m_Panes:
- {fileID: 15}
- {fileID: 18}
m_Selected: 1
m_LastSelected: 0
m_Selected: 0
m_LastSelected: 1
--- !u!114 &6
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -223,7 +223,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 47
controlID: 557
--- !u!114 &10
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -248,7 +248,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
controlID: 48
controlID: 55
--- !u!114 &11
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -259,7 +259,7 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 1
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: GameView
m_Name: SceneView
m_EditorClassIdentifier:
m_Children: []
m_Position:
@@ -270,13 +270,13 @@ MonoBehaviour:
height: 686
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 12}
m_ActualView: {fileID: 14}
m_Panes:
- {fileID: 14}
- {fileID: 13}
- {fileID: 12}
m_Selected: 2
m_LastSelected: 0
m_Selected: 0
m_LastSelected: 2
--- !u!114 &12
MonoBehaviour:
m_ObjectHideFlags: 52
@@ -305,10 +305,8 @@ MonoBehaviour:
m_OverlayCanvas:
m_LastAppliedPresetName: Default
m_SaveData: []
m_SerializedViewNames:
- UnityEditor.DeviceSimulation.SimulatorWindow
m_SerializedViewValues:
- F:\Projects\Unity\flufflparty\FlufflParty\Library\PlayModeViewStates\46d6f1c4f31f58e4cacd8a58295190c9
m_SerializedViewNames: []
m_SerializedViewValues: []
m_PlayModeViewName: GameView
m_ShowGizmos: 0
m_TargetDisplay: 0
@@ -317,7 +315,7 @@ MonoBehaviour:
m_TextureFilterMode: 0
m_TextureHideFlags: 61
m_RenderIMGUI: 1
m_EnterPlayModeBehavior: 2
m_EnterPlayModeBehavior: 0
m_UseMipMap: 0
m_VSyncEnabled: 0
m_Gizmos: 0
@@ -340,7 +338,7 @@ MonoBehaviour:
m_HSlider: 0
m_VSlider: 0
m_IgnoreScrollWheelUntilClicked: 0
m_EnableMouseInput: 1
m_EnableMouseInput: 0
m_EnableSliderZoomHorizontal: 0
m_EnableSliderZoomVertical: 0
m_UniformScale: 1
@@ -391,9 +389,9 @@ MonoBehaviour:
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 329
x: 343
y: 73
width: 1060
width: 1102
height: 665
m_ViewDataDictionary: {fileID: 0}
m_OverlayCanvas:
@@ -672,14 +670,14 @@ MonoBehaviour:
m_OverrideSceneCullingMask: 6917529027641081856
m_SceneIsLit: 1
m_SceneLighting: 1
m_2DMode: 0
m_2DMode: 1
m_isRotationLocked: 0
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 98.8307, y: 8.411106, z: 123.58132}
m_Target: {x: 977.5928, y: 457.28116, z: 33874.965}
speed: 2
m_Value: {x: 98.8307, y: 8.411106, z: 123.58132}
m_Value: {x: 977.5928, y: 457.28116, z: 33874.965}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
@@ -726,17 +724,17 @@ MonoBehaviour:
m_GridAxis: 1
m_gridOpacity: 0.5
m_Rotation:
m_Target: {x: -0.44589415, y: 0.51905, z: -0.27737507, w: -0.6744397}
m_Target: {x: 0, y: 0, z: 0, w: 1}
speed: 2
m_Value: {x: -0.44588518, y: 0.5190396, z: -0.27736947, w: -0.67442614}
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 2.1001658
m_Target: 709.59906
speed: 2
m_Value: 2.1001658
m_Value: 709.59906
m_Ortho:
m_Target: 0
m_Target: 1
speed: 2
m_Value: 0
m_Value: 1
m_CameraSettings:
m_Speed: 1.005
m_SpeedNormalized: 0.5
@@ -750,7 +748,7 @@ MonoBehaviour:
m_FarClip: 10000
m_DynamicClip: 1
m_OcclusionCulling: 0
m_LastSceneViewRotation: {x: -0.08717229, y: 0.89959055, z: -0.21045254, w: -0.3726226}
m_LastSceneViewRotation: {x: -0.44589415, y: 0.51905, z: -0.27737507, w: -0.6744397}
m_LastSceneViewOrtho: 0
m_ReplacementShader: {fileID: 0}
m_ReplacementString:
@@ -811,9 +809,9 @@ MonoBehaviour:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 766a0000
m_LastClickedID: 27254
m_ExpandedIDs: 00000000285d00002a5d00002c5d0000
m_SelectedIDs: ae5d0000
m_LastClickedID: 23982
m_ExpandedIDs: 00000000285d00002a5d00002c5d00009e5d000000ca9a3b
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -971,7 +969,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 30e1ffff72e1ffff54e8ffff64e8ffff4aebffff8aebffff26f1ffff36f1ffffb2f2fffff2f2ffffd4f9ffffe4f9ffff04fbffff
m_ExpandedIDs: 1831ffff6831ffff4a38ffff5a38ffff843affffd23affffb441ffffc441ffff4850ffff9650ffff7857ffff8857ffffa859fffff859ffffda60ffffea60ffff4e63ffff2868ffff8268ffff4a6fffff666fffff8080ffff2c83ffff8283ffff648affff748affff928cffffe88cffffca93ffffda93ffffe095ffff3696ffff189dffff289dfffff89effff4e9fffff30a6ffff40a6ffffe4d5ffff04fbffff345c0000605c0000965c00009c5c000058a6000036bc000048bc000064bc00007ebc0000aabc0000b4bc0000c4bc0000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@@ -987,7 +985,7 @@ MonoBehaviour:
m_IsRenaming: 0
m_OriginalEventType: 11
m_IsRenamingFilename: 0
m_ClientGUIView: {fileID: 3}
m_ClientGUIView: {fileID: 4}
m_SearchString:
m_ExpandedScenes: []
m_CurrenRootInstanceID: 0
+15 -14
View File
@@ -33,21 +33,21 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"project.structure.last.edited": "Artifacts",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;project.structure.last.edited&quot;: &quot;Artifacts&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RunManager">
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="Main" />
@@ -72,6 +72,7 @@
<updated>1674839030210</updated>
<workItem from="1674839031467" duration="221000" />
<workItem from="1674839402490" duration="20380000" />
<workItem from="1674897525328" duration="2102000" />
</task>
<servers />
</component>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18
View File
@@ -111,6 +111,15 @@ public class Room
}
break;
case 0:
try
{
for (int i = 0; i < players.length; i++)
{
players[player].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}
} catch (IOException ex)
{
}
server.deleteRoom(roomCode);
for(int i = 0; i < threads.size(); i++)
{
@@ -121,6 +130,15 @@ public class Room
} catch (IOException e)
{
try
{
for (int i = 0; i < players.length; i++)
{
players[player].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}
} catch (IOException ex)
{
}
for(int i = 0; i < threads.size(); i++)
{
threads.get(i).stop();
+10 -2
View File
@@ -64,9 +64,17 @@ public class Server
input.read(readData);
String roomCode = new String(readData, StandardCharsets.US_ASCII);
Client client1 = new Client(output, input, client);
rooms.get(roomCode).addClient(client1);
if(rooms.containsKey(roomCode))
{
Client client1 = new Client(output, input, client);
rooms.get(roomCode).addClient(client1);
}
else
{
output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}
break;
}