Color Dice based on Item

This commit is contained in:
brausjonas
2023-04-14 23:01:04 +02:00
parent d63c43deb5
commit 481f0d1577
12 changed files with 255 additions and 34 deletions
+1 -1
View File
@@ -165,7 +165,7 @@
<workItem from="1680813239896" duration="4155000" /> <workItem from="1680813239896" duration="4155000" />
<workItem from="1681056387914" duration="882000" /> <workItem from="1681056387914" duration="882000" />
<workItem from="1681415672515" duration="5000" /> <workItem from="1681415672515" duration="5000" />
<workItem from="1681479671396" duration="8956000" /> <workItem from="1681479671396" duration="10055000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dice3
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.25943398, g: 0.8374978, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 65c98776af70e114e805be306f2f8350
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,80 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 8
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: Dice4
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 1, g: 0.28311464, b: 0.2588235, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
m_BuildTextureStacks: []
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 21c33fce8dc2d6445a68ef6d6bce8ea0
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
@@ -37835,6 +37835,22 @@ PrefabInstance:
propertyPath: m_Materials.Array.data[0] propertyPath: m_Materials.Array.data[0]
value: value:
objectReference: {fileID: 2180264, guid: d06671affd8526948a76e0ac9aae126e, type: 2} objectReference: {fileID: 2180264, guid: d06671affd8526948a76e0ac9aae126e, type: 2}
- target: {fileID: 6391402203742902167, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3}
propertyPath: materials.Array.size
value: 3
objectReference: {fileID: 0}
- target: {fileID: 6391402203742902167, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3}
propertyPath: materials.Array.data[0]
value:
objectReference: {fileID: 2100000, guid: 45b47f99d1549dd409d0132b7f4e23ab, type: 2}
- target: {fileID: 6391402203742902167, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3}
propertyPath: materials.Array.data[1]
value:
objectReference: {fileID: 2100000, guid: 65c98776af70e114e805be306f2f8350, type: 2}
- target: {fileID: 6391402203742902167, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3}
propertyPath: materials.Array.data[2]
value:
objectReference: {fileID: 2100000, guid: 21c33fce8dc2d6445a68ef6d6bce8ea0, type: 2}
- target: {fileID: 6528083627130749425, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3} - target: {fileID: 6528083627130749425, guid: 06e960ba226dd6e4c972ec724166cc0d, type: 3}
propertyPath: m_fontAsset propertyPath: m_fontAsset
value: value:
+11 -1
View File
@@ -12,12 +12,20 @@ public class Dice : MonoBehaviour
[SerializeField] private Rigidbody rb; [SerializeField] private Rigidbody rb;
private bool started; private bool started;
private float timeLastNumberChanged = 0; private float timeLastNumberChanged = 0;
//0 = default, 1 = double dice, 2 = red
[SerializeField] private Material[] materials;
private Renderer renderer;
public void SetMaterial(int mat)
{
renderer.material = materials[mat];
}
private void Start() private void Start()
{ {
rb.useGravity = false; rb.useGravity = false;
gameObject.SetActive(false); gameObject.SetActive(false);
renderer = GetComponent<Renderer>();
} }
private void Update() private void Update()
@@ -66,4 +74,6 @@ public class Dice : MonoBehaviour
t.text = random.ToString(); t.text = random.ToString();
} }
} }
} }
+5
View File
@@ -39,6 +39,8 @@ public class Client : MonoBehaviour
[SerializeField] private Image imageCurrentItem; [SerializeField] private Image imageCurrentItem;
[SerializeField] private Image[] playerItemInfoImages; [SerializeField] private Image[] playerItemInfoImages;
private Dice diceScript;
//Icon //Icon
[SerializeField] private Image[] playerIconInfoImages; [SerializeField] private Image[] playerIconInfoImages;
@@ -61,6 +63,8 @@ public class Client : MonoBehaviour
private void Start() private void Start()
{ {
diceScript = dice.GetComponent<Dice>();
Application.targetFrameRate = 60; Application.targetFrameRate = 60;
thisClient = this; thisClient = this;
@@ -225,6 +229,7 @@ public class Client : MonoBehaviour
//--------------------------------------------------------- //---------------------------------------------------------
//-----Activate a Player //-----Activate a Player
case 2: case 2:
diceScript.SetMaterial(0);
Activate(job.data[1]); Activate(job.data[1]);
break; break;
//Jemand hat gewürfelt //Jemand hat gewürfelt
@@ -15,7 +15,7 @@ public class NoPlayablePlayer : Player
private float interPol = 0; private float interPol = 0;
private int wurfelZahl = 0; private int wurfelZahl = 0;
public Client client; public Client client;
private bool wait = false; private bool wait = false;
private bool lastActivated = false; private bool lastActivated = false;
@@ -24,7 +24,7 @@ public class NoPlayablePlayer : Player
private Vector3 useLess = new Vector3(); private Vector3 useLess = new Vector3();
private bool checkDoubleDice = false; private bool checkDoubleDice = false;
//Animation: //Animation:
private Vector3 lastPosAnim = Vector3.zero; private Vector3 lastPosAnim = Vector3.zero;
private bool jumpRequest = false; private bool jumpRequest = false;
@@ -35,7 +35,7 @@ public class NoPlayablePlayer : Player
{ {
TMP_Text[] playerTexts = GetComponentsInChildren<TMP_Text>(); TMP_Text[] playerTexts = GetComponentsInChildren<TMP_Text>();
playerTexts[0].text = playerTexts[1].text = name; playerTexts[0].text = playerTexts[1].text = name;
activated = false; activated = false;
diceScript = dice.GetComponent<Dice>(); diceScript = dice.GetComponent<Dice>();
} }
@@ -54,13 +54,13 @@ public class NoPlayablePlayer : 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);
@@ -72,7 +72,7 @@ public class NoPlayablePlayer : Player
animator.SetInteger("value", 0); animator.SetInteger("value", 0);
} }
//END //END
lastPosAnim = transform.position; lastPosAnim = transform.position;
} }
@@ -82,7 +82,7 @@ public class NoPlayablePlayer : Player
AddCoins(-20); AddCoins(-20);
AddStars(1); AddStars(1);
} }
public void CoinFieldAction(int action) public void CoinFieldAction(int action)
{ {
if (action == 0) if (action == 0)
@@ -97,17 +97,27 @@ public class NoPlayablePlayer : Player
public void Wurfeln(int wurfelZahl) public void Wurfeln(int wurfelZahl)
{ {
jumpRequest = true; diceScript.SetMaterial(0);
jumpRequest = true;
wurfelt = true; wurfelt = true;
this.wurfelZahl = wurfelZahl; this.wurfelZahl = wurfelZahl;
switch (activeItem) switch (activeItem)
{ {
case Item.Type.Mushroom: wurfelZahl += 3; activeItem = Item.Type.None; break; case Item.Type.Mushroom:
case Item.Type.DoubleDice: checkDoubleDice = true; activeItem = Item.Type.None; break; wurfelZahl += 3;
activeItem = Item.Type.None;
diceScript.SetMaterial(2);
break;
case Item.Type.DoubleDice:
checkDoubleDice = true;
activeItem = Item.Type.None;
diceScript.SetMaterial(1);
break;
} }
//nächstes Feld anvisieren //nächstes Feld anvisieren
TargetNextField(); TargetNextField();
@@ -125,19 +135,19 @@ public class NoPlayablePlayer : Player
{ {
a.Deactivate(); a.Deactivate();
} }
nextField = nextField.Target[idx]; nextField = nextField.Target[idx];
moveTo = nextField.transform.position; moveTo = nextField.transform.position;
wait = false; wait = false;
} }
private void FixedUpdate() private void FixedUpdate()
{ {
if (activated && !name.Equals("")) 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) if (!wait)
{ {
//Laufe zum nöchsten Feld, falls noch Züge übrig sind //Laufe zum nöchsten Feld, falls noch Züge übrig sind
@@ -156,12 +166,12 @@ public class NoPlayablePlayer : Player
InterPolerate(); InterPolerate();
wurfelZahl--; wurfelZahl--;
textLeftMoves.text = wurfelZahl + ""; textLeftMoves.text = wurfelZahl + "";
//the next field is the current field XD //the next field is the current field XD
currentField = nextField; 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) //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) if (wurfelZahl > 0)
{ {
TargetNextField(); TargetNextField();
} }
@@ -174,8 +184,8 @@ public class NoPlayablePlayer : 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);
@@ -189,18 +199,18 @@ public class NoPlayablePlayer : 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);
if (!wurfelt) if (!wurfelt)
{ {
StartDice(); StartDice();
} }
else else
{ {
if (checkDoubleDice) if (checkDoubleDice)
{ {
checkDoubleDice = false; checkDoubleDice = false;
wurfelt = false; wurfelt = false;
} }
} }
} }
@@ -243,12 +253,13 @@ public class NoPlayablePlayer : Player
//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));
@@ -256,7 +267,7 @@ public class NoPlayablePlayer : Player
} }
private Star currentStar; private Star currentStar;
private void OnTriggerEnter(Collider collider) private void OnTriggerEnter(Collider collider)
{ {
if (collider.name.Equals("ItemShopTrigger")) if (collider.name.Equals("ItemShopTrigger"))
@@ -267,7 +278,7 @@ public class NoPlayablePlayer : Player
{ {
currentStar = collider.GetComponent<Star>(); currentStar = collider.GetComponent<Star>();
if(currentStar.IsActive) if (currentStar.IsActive)
{ {
base.OnTriggerEnter(collider); base.OnTriggerEnter(collider);
} }
@@ -286,4 +297,4 @@ public class NoPlayablePlayer : Player
{ {
itemInfoImages[index].color = new Color(0, 0, 0, 0); itemInfoImages[index].color = new Color(0, 0, 0, 0);
} }
} }
@@ -107,6 +107,8 @@ public class PlayablePlayer : Player
private void DiceRollRoutine() private void DiceRollRoutine()
{ {
diceScript.SetMaterial(0);
jumpRequest = true; jumpRequest = true;
wurfelt = true; wurfelt = true;
@@ -117,10 +119,12 @@ public class PlayablePlayer : Player
case Item.Type.Mushroom: case Item.Type.Mushroom:
wurfelZahl += 3; wurfelZahl += 3;
activeItem = Item.Type.None; activeItem = Item.Type.None;
diceScript.SetMaterial(2);
break; break;
case Item.Type.DoubleDice: case Item.Type.DoubleDice:
checkDoubleDice = true; checkDoubleDice = true;
activeItem = Item.Type.None; activeItem = Item.Type.None;
diceScript.SetMaterial(1);
break; break;
} }
@@ -399,6 +403,7 @@ public class PlayablePlayer : Player
private void Finish() private void Finish()
{ {
imageCurrentItem.color = new Color(0, 0, 0, 0); imageCurrentItem.color = new Color(0, 0, 0, 0);
diceScript.SetMaterial(0);
client.SendFinished(); client.SendFinished();
} }
@@ -97,8 +97,6 @@ public abstract class Player : MonoBehaviour
break; break;
} }
} }
Debug.Log(item.type);
} }
public void ActivateItem(int index) public void ActivateItem(int index)
+1 -1
View File
@@ -101,7 +101,7 @@
<workItem from="1681130452664" duration="6192000" /> <workItem from="1681130452664" duration="6192000" />
<workItem from="1681217780586" duration="94000" /> <workItem from="1681217780586" duration="94000" />
<workItem from="1681218296017" duration="162000" /> <workItem from="1681218296017" duration="162000" />
<workItem from="1681481242206" duration="3770000" /> <workItem from="1681481242206" duration="4364000" />
</task> </task>
<servers /> <servers />
</component> </component>