Item Shop Stop

This commit is contained in:
AlexE030
2023-02-07 20:55:29 +01:00
parent c6589f2d56
commit f36dd36d21
9 changed files with 163 additions and 36 deletions
+17
View File
@@ -12,6 +12,7 @@ GameObject:
- component: {fileID: 711685448941949431}
- component: {fileID: 711685448941949430}
- component: {fileID: 711685448941949429}
- component: {fileID: 4002111064334437516}
m_Layer: 0
m_Name: Player
m_TagString: Untagged
@@ -99,6 +100,22 @@ BoxCollider:
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!54 &4002111064334437516
Rigidbody:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 711685448941949428}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0.05
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 0
m_Constraints: 126
m_CollisionDetection: 0
--- !u!1 &3284309164958886127
GameObject:
m_ObjectHideFlags: 0
@@ -5020,6 +5020,51 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3283c2131aad7954fac11b8f7a76af0e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1202275722
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1202275724}
- component: {fileID: 1202275723}
m_Layer: 0
m_Name: ItemShopTrigger
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!65 &1202275723
BoxCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1202275722}
m_Material: {fileID: 0}
m_IsTrigger: 1
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1, y: 1, z: 1}
m_Center: {x: 0, y: 0, z: 0}
--- !u!4 &1202275724
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1202275722}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 84.85, y: 1.08, z: 103.37}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 14
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1257267486
GameObject:
m_ObjectHideFlags: 0
+8
View File
@@ -128,6 +128,9 @@ public class Client : MonoBehaviour
case 6:
((NoPlayablePlayer)players[job.data[1]]).CoinFieldAction(job.data[2]);
break;
case 7:
((NoPlayablePlayer)players[job.data[1]]).EventStopFinished();
break;
case 126:
stream.Write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 10);
break;
@@ -198,4 +201,9 @@ public class Client : MonoBehaviour
{
stream.Write(new byte[]{6, (byte)action, 0, 0, 0, 0, 0, 0, 0, 0});
}
public void EventStopFinshed()
{
stream.Write(new byte[]{7, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}
}
@@ -21,6 +21,8 @@ public class NoPlayablePlayer : Player
private float timeSinceWurfeln = 0;
private Vector3 useLess = new Vector3();
public override void Init()
{
@@ -142,9 +144,17 @@ public class NoPlayablePlayer : Player
//Bewegt den Player von einem Punkt(lastPos) zu einem anderen Punkt(moveTo) mit konstanter Geschwindigkeit
private void InterPolerate()
{
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
if (!eventstop)
{
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
}
}
public void EventStopFinshed()
{
eventstop = false;
}
}
@@ -14,9 +14,9 @@ public class PlayablePlayer : Player
private float speed = 5;
private float interPol = 0;
private int wurfelZahl = 0;
private bool wait = false;
private float timeSinceWurfeln = 0;
private float timeSinceStop = 0;
@@ -28,7 +28,7 @@ public class PlayablePlayer : Player
public override void Init()
{
GetComponentInChildren<TMP_Text>().text = name;
activated = false;
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = 61;
@@ -37,16 +37,21 @@ public class PlayablePlayer : Player
private void Update()
{
if (Input.GetMouseButtonDown(0))
{
eventstop = false;
}
if (activated && !name.Equals(""))
{
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
if ((Input.GetMouseButtonDown(0)) && wurfelZahl == 0 && !wurfelt)
{
wurfelt = true;
wurfelZahl = Random.Range(1, 7);
wurfelZahl = Random.Range(6, 7);
client.SendWurfeln(wurfelZahl);
//nächstes Feld anvisieren
TargetNextField();
@@ -63,8 +68,9 @@ public class PlayablePlayer : Player
{
if (activated && !name.Equals(""))
{
camera.transform.position = Vector3.SmoothDamp(camera.transform.position, transform.position + cameraOffset, ref velocity, 0.2f);
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
@@ -83,7 +89,7 @@ public class PlayablePlayer : Player
//the next field is the current field XD
currentField = nextField;
//Visiere das nächste Feld an falls noch ein Zug übrig ist (Player steht gerade auf einem Feld oder läuft darüber)
if (wurfelZahl > 0)
{
@@ -109,7 +115,7 @@ public class PlayablePlayer : Player
AddCoins(-3);
break;
}
Invoke("Finish", 2);
activated = false;
}
@@ -132,7 +138,7 @@ public class PlayablePlayer : Player
if (nextField.DirectionalArrow[0].IsClicked())
{
client.SendArrowSelected(0);
foreach (Arrow a in nextField.DirectionalArrow)
{
a.Deactivate();
@@ -177,15 +183,20 @@ public class PlayablePlayer : Player
//Bewegt den Player von einem Punkt(lastPos) zu einem anderen Punkt(moveTo) mit konstanter Geschwindigkeit
private Vector3 nextPoint;
private void InterPolerate()
{
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
if (!eventstop)
{
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
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();
}
}
@@ -17,6 +17,7 @@ public abstract class Player : MonoBehaviour
public int index;
public int coins = 0;
public TMP_Text textCoinsInfo;
protected bool eventstop = false;
//for coin animation
private AnimationHandler animationHandler;
@@ -61,4 +62,9 @@ public abstract class Player : MonoBehaviour
textCoinsInfo.text = coins + "";
PlayAnimation(AnimationType.Coin);
}
private void OnTriggerEnter(Collider c)
{
eventstop = true;
}
}