Fixed Item Field Rotator

This commit is contained in:
brausjonas
2023-04-16 18:13:18 +02:00
parent db5f7a5081
commit 6e642b511a
4 changed files with 81 additions and 89 deletions
+5 -7
View File
@@ -4,10 +4,7 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="f0abe486-ee58-49bd-ad63-04a8b3fc78ec" name="Changes" comment=""> <list default="true" id="f0abe486-ee58-49bd-ad63-04a8b3fc78ec" name="Changes" comment="" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.FlufflParty/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.FlufflParty/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Assets/Scripts/Players/PlayablePlayer.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Assets/Scripts/Players/PlayablePlayer.cs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
@@ -56,9 +53,9 @@
}, },
"keyToStringList": { "keyToStringList": {
"rider.external.source.directories": [ "rider.external.source.directories": [
"C:\\Users\\afist\\AppData\\Roaming\\JetBrains\\Rider2022.3\\resharper-host\\DecompilerCache", "C:\\Users\\braus\\AppData\\Roaming\\JetBrains\\Rider2023.1\\resharper-host\\DecompilerCache",
"C:\\Users\\afist\\AppData\\Roaming\\JetBrains\\Rider2022.3\\resharper-host\\SourcesCache", "C:\\Users\\braus\\AppData\\Roaming\\JetBrains\\Rider2023.1\\resharper-host\\SourcesCache",
"C:\\Users\\afist\\AppData\\Local\\Symbols\\src" "C:\\Users\\braus\\AppData\\Local\\Symbols\\src"
] ]
} }
}]]></component> }]]></component>
@@ -174,6 +171,7 @@
<workItem from="1681479671396" duration="22217000" /> <workItem from="1681479671396" duration="22217000" />
<workItem from="1681565663292" duration="642000" /> <workItem from="1681565663292" duration="642000" />
<workItem from="1681648997302" duration="1618000" /> <workItem from="1681648997302" duration="1618000" />
<workItem from="1681659517327" duration="1971000" />
</task> </task>
<servers /> <servers />
</component> </component>
+36 -1
View File
@@ -405,6 +405,28 @@ public class Client : MonoBehaviour
} }
} }
break;
case 1:
for (int i = 0; i < 4; i++)
{
int option = job.data[i + 1];
int value = job.data[i + 5];
switch (option)
{
case 0:
rotator.SetOptionsText(i, "Mushroom");
break;
case 1:
rotator.SetOptionsText(i, "Doubledice");
break;
case 2:
rotator.SetOptionsText(i, "Trap");
break;
}
}
break; break;
} }
@@ -551,6 +573,9 @@ public class Client : MonoBehaviour
} }
/* /*
* TYPE:
* 0 = Pink Field!!!!
*
* OPT: * OPT:
* 0 = Get Coins * 0 = Get Coins
* 1 = Loose Coins * 1 = Loose Coins
@@ -560,8 +585,18 @@ public class Client : MonoBehaviour
* VAL: * VAL:
* value of each option (not needed = 0) * value of each option (not needed = 0)
* *
*
* TYPE: * TYPE:
* 0 = Pink Field * 1 = Item Field!!!!
*
* OPT:
* 0 = Mushroom
* 1 = Double Dice
* 2 = Trap
* 3 = Trap
*
* VAL:
* value of each option (not needed = 0)
*/ */
public void SendStartRotator(int opt1, int opt2, int opt3, int opt4, int val1, int val2, int val3, int val4, public void SendStartRotator(int opt1, int opt2, int opt3, int opt4, int val1, int val2, int val3, int val4,
int type) int type)
@@ -1,13 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Net.Mail;
using TMPro; using TMPro;
using Unity.VisualScripting;
using UnityEditor;
using UnityEditor.Timeline.Actions;
using UnityEngine; using UnityEngine;
using UnityEngine.UI;
using Random = UnityEngine.Random; using Random = UnityEngine.Random;
public class PlayablePlayer : Player public class PlayablePlayer : Player
@@ -36,7 +28,7 @@ public class PlayablePlayer : Player
private static PlayablePlayer instance; private static PlayablePlayer instance;
//Animation: //Animation:
private Vector3 lastPosAnim = Vector3.zero; private Vector3 lastPosAnim = Vector3.zero;
private Quaternion rotation = Quaternion.identity; private Quaternion rotation = Quaternion.identity;
@@ -54,7 +46,7 @@ public class PlayablePlayer : Player
diceScript = dice.GetComponent<Dice>(); diceScript = dice.GetComponent<Dice>();
instance = this; instance = this;
nameSign = playerTexts[1].gameObject; nameSign = playerTexts[1].gameObject;
} }
@@ -76,13 +68,13 @@ public class PlayablePlayer : Player
{ {
animator.SetInteger("value", 1); animator.SetInteger("value", 1);
} }
else if(jumpRequest) else if (jumpRequest)
{ {
jumpRequest = false; jumpRequest = false;
animator.SetInteger("value", 2); animator.SetInteger("value", 2);
lastTimeDoneIdleAction = Time.time; lastTimeDoneIdleAction = Time.time;
} }
else if(Time.time - lastTimeDoneIdleAction > idleActionDelay) else if (Time.time - lastTimeDoneIdleAction > idleActionDelay)
{ {
lastTimeDoneIdleAction = Time.time; lastTimeDoneIdleAction = Time.time;
idleActionDelay = Random.Range(2f, 5f); idleActionDelay = Random.Range(2f, 5f);
@@ -94,7 +86,7 @@ public class PlayablePlayer : Player
animator.SetInteger("value", 0); animator.SetInteger("value", 0);
} }
//END //END
if (activated && !name.Equals("")) if (activated && !name.Equals(""))
{ {
//Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf //Generiere Würfelzahl von 1-6 wenn gerade gewürfelt werden darf
@@ -102,7 +94,7 @@ public class PlayablePlayer : Player
{ {
if (!Physics.Raycast(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -200), Vector3.forward)) if (!Physics.Raycast(new Vector3(Input.mousePosition.x, Input.mousePosition.y, -200), Vector3.forward))
{ {
DiceRollRoutine(); DiceRollRoutine();
} }
} }
} }
@@ -113,11 +105,11 @@ public class PlayablePlayer : Player
private void DiceRollRoutine() private void DiceRollRoutine()
{ {
diceScript.SetMaterial(0); diceScript.SetMaterial(0);
jumpRequest = true; jumpRequest = true;
wurfelt = true; wurfelt = true;
wurfelZahl = Random.Range(1, 7); wurfelZahl = Random.Range(2, 3);
switch (activeItem) switch (activeItem)
{ {
@@ -191,8 +183,8 @@ public class PlayablePlayer : Player
if (currentField.placedItem != null) if (currentField.placedItem != null)
{ {
Trap t = currentField.placedItem.GetComponent<Trap>(); Trap t = currentField.placedItem.GetComponent<Trap>();
if(t.target.index != index) if (t.target.index != index)
{ {
int coinsAmount = (int)(coins * 0.1f); int coinsAmount = (int)(coins * 0.1f);
AddCoins(-coinsAmount); AddCoins(-coinsAmount);
@@ -202,20 +194,20 @@ public class PlayablePlayer : Player
} }
} }
} }
Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation); Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation);
currentRotation.y = -34; currentRotation.y = -34;
transform.rotation = Quaternion.Euler(currentRotation); transform.rotation = Quaternion.Euler(currentRotation);
int fieldReturnStatus = -1; int fieldReturnStatus = -1;
if (currentField != null) if (currentField != null)
{ {
fieldReturnStatus = currentField.Action(index); fieldReturnStatus = currentField.Action(index);
} }
//TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde //TODO: temp spieler finsihed erst, wenn field action ausgeführt wurde
if (wurfelt) if (wurfelt)
{ {
switch (fieldReturnStatus) switch (fieldReturnStatus)
{ {
case 0: //Blaues Feld case 0: //Blaues Feld
@@ -226,44 +218,6 @@ public class PlayablePlayer : Player
client.SendCoinFieldAction(1); client.SendCoinFieldAction(1);
AddCoins(-3); AddCoins(-3);
break; break;
// case 2: //pinkes Feld
// int randyPinkField = Random.Range(4, 4);
// int tempCurrentItems = -1;
// switch (randyPinkField)
// {
// case 1:
// client.SendCoinFieldAction(0);
// int tempAddCoins = Random.Range(3, 6);
// AddCoins(tempAddCoins);
// break;
// case 2:
// client.SendCoinFieldAction(1);
// int tempLoseCoins = Random.Range(-3, -6);
// AddCoins(tempLoseCoins);
// break;
// case 3:
// int tempAddItem = Random.Range(0, 3);
// AddItem(client.items[tempAddItem]);
// break;
// case 4:
// for (int i = 0; i < items.Length; i++)
// {
// if (items[i] != null)
// {
// tempCurrentItems++;
// }
// }
//
// if (tempCurrentItems >= 0)
// {
// int pickRandomItem = Random.Range(0, tempCurrentItems);
// client.items[pickRandomItem] = null;
// itemInfoImages[pickRandomItem].color = new Color(0, 0, 0, 0);
// client.SendLostItem((byte)pickRandomItem);
// }
// break;
// }
// break;
case 2: case 2:
int randCoins1 = Random.Range(2, 6); int randCoins1 = Random.Range(2, 6);
int randCoins2 = Random.Range(1, 4); int randCoins2 = Random.Range(1, 4);
@@ -305,7 +259,7 @@ public class PlayablePlayer : Player
Invoke("StopRotator", 2); Invoke("StopRotator", 2);
Invoke("ActivateLayout1", 5.5f); Invoke("ActivateLayout1", 5.5f);
break; break;
case 3: //Item Field keine Ahnung ob das funktioniert XD muss man mal testen; Keine Ahnung was SendStartRotator an den Server weitersendet MUSS überarbeitet werden case 3: //Item Field keine Ahnung ob das funktioniert XD muss man mal testen; Keine Ahnung was SendStartRotator an den Server weitersendet MUSS überarbeitet werden
RandomRotator rotatorItemField = uiHandler.rotator.GetComponent<RandomRotator>(); RandomRotator rotatorItemField = uiHandler.rotator.GetComponent<RandomRotator>();
this.rotator = rotatorItemField; this.rotator = rotatorItemField;
@@ -313,13 +267,18 @@ public class PlayablePlayer : Player
rotatorItemField.SetOptionsText(0, "Mushroom"); rotatorItemField.SetOptionsText(0, "Mushroom");
rotatorItemField.SetOptionsText(1, "Double Dice"); rotatorItemField.SetOptionsText(1, "Double Dice");
rotatorItemField.SetOptionsText(2, "Trap"); rotatorItemField.SetOptionsText(2, "Trap");
rotatorItemField.SetOptionsText(3, "Trap");
rotatorItemField.StartRandom(); rotatorItemField.StartRandom();
//???client.SendStartRotator(0, 1, 2, randCoins1, randCoins2, -randCoins3, 0, 0); client.SendStartRotator(0, 1, 2, 2, 0, 0, 0, 0, 1);
int randomItemField = Random.Range(0, 4);
int randomItemField = Random.Range(0, 3);
AddItem(client.items[randomItemField]);
rotatorStopIndex = randomItemField; rotatorStopIndex = randomItemField;
randomItemField = randomItemField == 3 ? randomItemField - 1 : randomItemField;
AddItem(client.items[randomItemField]);
Invoke("StopRotator", 2); Invoke("StopRotator", 2);
Invoke("ActivateLayout1", 5.5f); Invoke("ActivateLayout1", 5.5f);
break; break;
@@ -327,11 +286,11 @@ public class PlayablePlayer : Player
if (!checkDoubleDice) if (!checkDoubleDice)
{ {
if(fieldReturnStatus != 2) if (fieldReturnStatus != 2 && fieldReturnStatus != 3)
{ {
Invoke("Finish", 2); Invoke("Finish", 2);
} }
activated = false; activated = false;
} }
else else
@@ -396,7 +355,6 @@ public class PlayablePlayer : Player
{ {
wait = true; wait = true;
} }
} }
//Bewegt den Player von einem Punkt(lastPos) zu einem anderen Punkt(moveTo) mit konstanter Geschwindigkeit //Bewegt den Player von einem Punkt(lastPos) zu einem anderen Punkt(moveTo) mit konstanter Geschwindigkeit
@@ -408,17 +366,17 @@ public class PlayablePlayer : Player
if (!eventstop) if (!eventstop)
{ {
nextPoint = Vector3.Lerp(lastPos, moveTo, interPol); nextPoint = Vector3.Lerp(lastPos, moveTo, interPol);
//Rotation in move direction //Rotation in move direction
Vector3 lookPos = nextPoint - transform.position; Vector3 lookPos = nextPoint - transform.position;
lookPos.y = 0; lookPos.y = 0;
if(lookPos != Vector3.zero) if (lookPos != Vector3.zero)
{ {
Quaternion rotation = Quaternion.LookRotation(lookPos); Quaternion rotation = Quaternion.LookRotation(lookPos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping);
} }
//END //END
transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z); transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z);
interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos)); interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos));
} }
@@ -505,6 +463,7 @@ public class PlayablePlayer : Player
temp.transform.position = currentField.transform.position + (Vector3.up / 2); temp.transform.position = currentField.transform.position + (Vector3.up / 2);
activeItem = Item.Type.None; activeItem = Item.Type.None;
} }
items[index] = null; items[index] = null;
} }
@@ -513,7 +472,7 @@ public class PlayablePlayer : Player
uiHandler.ActivateLayout1(); uiHandler.ActivateLayout1();
Finish(); Finish();
} }
private void StopRotator() private void StopRotator()
{ {
client.SendStopRotator(rotatorStopIndex); client.SendStopRotator(rotatorStopIndex);
@@ -19,7 +19,7 @@ MonoBehaviour:
width: 1920 width: 1920
height: 1117 height: 1117
m_ShowMode: 4 m_ShowMode: 4
m_Title: Project m_Title: Scene
m_RootView: {fileID: 6} m_RootView: {fileID: 6}
m_MinSize: {x: 875, y: 300} m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
@@ -68,8 +68,8 @@ MonoBehaviour:
y: 0 y: 0
width: 377 width: 377
height: 1067 height: 1067
m_MinSize: {x: 275, y: 50} m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4000, y: 4000} m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 16} m_ActualView: {fileID: 16}
m_Panes: m_Panes:
- {fileID: 16} - {fileID: 16}
@@ -453,9 +453,9 @@ MonoBehaviour:
m_IsLocked: 0 m_IsLocked: 0
m_FolderTreeState: m_FolderTreeState:
scrollPos: {x: 0, y: 77} scrollPos: {x: 0, y: 77}
m_SelectedIDs: ae610000 m_SelectedIDs: 1c6c0000
m_LastClickedID: 25006 m_LastClickedID: 27676
m_ExpandedIDs: 000000008461000086610000886100008a6100008c61000000ca9a3b m_ExpandedIDs: 00000000e86b0000ea6b0000ec6b0000ee6b0000f06b000000ca9a3b
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -483,7 +483,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 000000008461000086610000886100008a6100008c610000 m_ExpandedIDs: 00000000e86b0000ea6b0000ec6b0000ee6b0000f06b0000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@@ -510,7 +510,7 @@ MonoBehaviour:
m_ListAreaState: m_ListAreaState:
m_SelectedInstanceIDs: m_SelectedInstanceIDs:
m_LastClickedInstanceID: 0 m_LastClickedInstanceID: 0
m_HadKeyboardFocusLastEvent: 1 m_HadKeyboardFocusLastEvent: 0
m_ExpandedInstanceIDs: c6230000f8650000a03e0500 m_ExpandedInstanceIDs: c6230000f8650000a03e0500
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
@@ -611,9 +611,9 @@ MonoBehaviour:
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: 56170000 m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: 04fbffff m_ExpandedIDs: 00e8ffff50e8ffffbae9ffff4aecffff7aecffff0ef2ffff60f2ffffcaf3ffff5af6ffff8af6ffff06fbffff
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name: