From 481f0d1577a631a9b9a44a43ba310e74069a70b6 Mon Sep 17 00:00:00 2001 From: brausjonas Date: Fri, 14 Apr 2023 23:01:04 +0200 Subject: [PATCH] Color Dice based on Item --- .../.idea.FlufflParty/.idea/workspace.xml | 2 +- FlufflParty/Assets/Materials/Dice/Dice3.mat | 80 +++++++++++++++++++ .../Assets/Materials/Dice/Dice3.mat.meta | 8 ++ FlufflParty/Assets/Materials/Dice/Dice4.mat | 80 +++++++++++++++++++ .../Assets/Materials/Dice/Dice4.mat.meta | 8 ++ FlufflParty/Assets/Scenes/WesternMap.unity | 16 ++++ FlufflParty/Assets/Scripts/Actions/Dice.cs | 12 ++- FlufflParty/Assets/Scripts/Client.cs | 5 ++ .../Scripts/Players/NoPlayablePlayer.cs | 69 +++++++++------- .../Assets/Scripts/Players/PlayablePlayer.cs | 5 ++ FlufflParty/Assets/Scripts/Players/Player.cs | 2 - Server/.idea/workspace.xml | 2 +- 12 files changed, 255 insertions(+), 34 deletions(-) create mode 100644 FlufflParty/Assets/Materials/Dice/Dice3.mat create mode 100644 FlufflParty/Assets/Materials/Dice/Dice3.mat.meta create mode 100644 FlufflParty/Assets/Materials/Dice/Dice4.mat create mode 100644 FlufflParty/Assets/Materials/Dice/Dice4.mat.meta diff --git a/FlufflParty/.idea/.idea.FlufflParty/.idea/workspace.xml b/FlufflParty/.idea/.idea.FlufflParty/.idea/workspace.xml index c3d5224..b786fd7 100644 --- a/FlufflParty/.idea/.idea.FlufflParty/.idea/workspace.xml +++ b/FlufflParty/.idea/.idea.FlufflParty/.idea/workspace.xml @@ -165,7 +165,7 @@ - + diff --git a/FlufflParty/Assets/Materials/Dice/Dice3.mat b/FlufflParty/Assets/Materials/Dice/Dice3.mat new file mode 100644 index 0000000..30414c2 --- /dev/null +++ b/FlufflParty/Assets/Materials/Dice/Dice3.mat @@ -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: [] diff --git a/FlufflParty/Assets/Materials/Dice/Dice3.mat.meta b/FlufflParty/Assets/Materials/Dice/Dice3.mat.meta new file mode 100644 index 0000000..07186a7 --- /dev/null +++ b/FlufflParty/Assets/Materials/Dice/Dice3.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 65c98776af70e114e805be306f2f8350 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FlufflParty/Assets/Materials/Dice/Dice4.mat b/FlufflParty/Assets/Materials/Dice/Dice4.mat new file mode 100644 index 0000000..6ba349b --- /dev/null +++ b/FlufflParty/Assets/Materials/Dice/Dice4.mat @@ -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: [] diff --git a/FlufflParty/Assets/Materials/Dice/Dice4.mat.meta b/FlufflParty/Assets/Materials/Dice/Dice4.mat.meta new file mode 100644 index 0000000..2a30ff7 --- /dev/null +++ b/FlufflParty/Assets/Materials/Dice/Dice4.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 21c33fce8dc2d6445a68ef6d6bce8ea0 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/FlufflParty/Assets/Scenes/WesternMap.unity b/FlufflParty/Assets/Scenes/WesternMap.unity index 47220ac..f94c436 100644 --- a/FlufflParty/Assets/Scenes/WesternMap.unity +++ b/FlufflParty/Assets/Scenes/WesternMap.unity @@ -37835,6 +37835,22 @@ PrefabInstance: propertyPath: m_Materials.Array.data[0] value: 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} propertyPath: m_fontAsset value: diff --git a/FlufflParty/Assets/Scripts/Actions/Dice.cs b/FlufflParty/Assets/Scripts/Actions/Dice.cs index 21b836a..f065520 100644 --- a/FlufflParty/Assets/Scripts/Actions/Dice.cs +++ b/FlufflParty/Assets/Scripts/Actions/Dice.cs @@ -12,12 +12,20 @@ public class Dice : MonoBehaviour [SerializeField] private Rigidbody rb; private bool started; 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() { rb.useGravity = false; gameObject.SetActive(false); + renderer = GetComponent(); } private void Update() @@ -66,4 +74,6 @@ public class Dice : MonoBehaviour t.text = random.ToString(); } } + + } \ No newline at end of file diff --git a/FlufflParty/Assets/Scripts/Client.cs b/FlufflParty/Assets/Scripts/Client.cs index 7236f29..70d96f3 100644 --- a/FlufflParty/Assets/Scripts/Client.cs +++ b/FlufflParty/Assets/Scripts/Client.cs @@ -39,6 +39,8 @@ public class Client : MonoBehaviour [SerializeField] private Image imageCurrentItem; [SerializeField] private Image[] playerItemInfoImages; + + private Dice diceScript; //Icon [SerializeField] private Image[] playerIconInfoImages; @@ -61,6 +63,8 @@ public class Client : MonoBehaviour private void Start() { + diceScript = dice.GetComponent(); + Application.targetFrameRate = 60; thisClient = this; @@ -225,6 +229,7 @@ public class Client : MonoBehaviour //--------------------------------------------------------- //-----Activate a Player case 2: + diceScript.SetMaterial(0); Activate(job.data[1]); break; //Jemand hat gewürfelt diff --git a/FlufflParty/Assets/Scripts/Players/NoPlayablePlayer.cs b/FlufflParty/Assets/Scripts/Players/NoPlayablePlayer.cs index a59410c..5530aba 100644 --- a/FlufflParty/Assets/Scripts/Players/NoPlayablePlayer.cs +++ b/FlufflParty/Assets/Scripts/Players/NoPlayablePlayer.cs @@ -15,7 +15,7 @@ public class NoPlayablePlayer : Player private float interPol = 0; private int wurfelZahl = 0; public Client client; - + private bool wait = false; private bool lastActivated = false; @@ -24,7 +24,7 @@ public class NoPlayablePlayer : Player private Vector3 useLess = new Vector3(); private bool checkDoubleDice = false; - + //Animation: private Vector3 lastPosAnim = Vector3.zero; private bool jumpRequest = false; @@ -35,7 +35,7 @@ public class NoPlayablePlayer : Player { TMP_Text[] playerTexts = GetComponentsInChildren(); playerTexts[0].text = playerTexts[1].text = name; - + activated = false; diceScript = dice.GetComponent(); } @@ -54,13 +54,13 @@ public class NoPlayablePlayer : Player { animator.SetInteger("value", 1); } - else if(jumpRequest) + else if (jumpRequest) { jumpRequest = false; animator.SetInteger("value", 2); lastTimeDoneIdleAction = Time.time; } - else if(Time.time - lastTimeDoneIdleAction > idleActionDelay) + else if (Time.time - lastTimeDoneIdleAction > idleActionDelay) { lastTimeDoneIdleAction = Time.time; idleActionDelay = Random.Range(2f, 5f); @@ -72,7 +72,7 @@ public class NoPlayablePlayer : Player animator.SetInteger("value", 0); } //END - + lastPosAnim = transform.position; } @@ -82,7 +82,7 @@ public class NoPlayablePlayer : Player AddCoins(-20); AddStars(1); } - + public void CoinFieldAction(int action) { if (action == 0) @@ -97,17 +97,27 @@ public class NoPlayablePlayer : Player public void Wurfeln(int wurfelZahl) { - jumpRequest = true; + diceScript.SetMaterial(0); + jumpRequest = true; + wurfelt = true; this.wurfelZahl = wurfelZahl; switch (activeItem) { - case Item.Type.Mushroom: wurfelZahl += 3; activeItem = Item.Type.None; break; - case Item.Type.DoubleDice: checkDoubleDice = true; activeItem = Item.Type.None; break; + case Item.Type.Mushroom: + 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 TargetNextField(); @@ -125,19 +135,19 @@ public class NoPlayablePlayer : Player { a.Deactivate(); } - - nextField = nextField.Target[idx]; + + nextField = nextField.Target[idx]; moveTo = nextField.transform.position; wait = false; } - - + + private void FixedUpdate() { - 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 @@ -156,12 +166,12 @@ public class NoPlayablePlayer : Player InterPolerate(); wurfelZahl--; textLeftMoves.text = wurfelZahl + ""; - + //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) + if (wurfelZahl > 0) { TargetNextField(); } @@ -174,8 +184,8 @@ public class NoPlayablePlayer : Player if (currentField.placedItem != null) { Trap t = currentField.placedItem.GetComponent(); - - if(t.target.index != index) + + if (t.target.index != index) { int coinsAmount = (int)(coins * 0.1f); AddCoins(-coinsAmount); @@ -189,18 +199,18 @@ public class NoPlayablePlayer : Player Vector3 currentRotation = Quaternion.ToEulerAngles(transform.rotation); currentRotation.y = -34; transform.rotation = Quaternion.Euler(currentRotation); - - + + if (!wurfelt) { - StartDice(); + StartDice(); } else { if (checkDoubleDice) { checkDoubleDice = false; - wurfelt = false; + wurfelt = false; } } } @@ -243,12 +253,13 @@ public class NoPlayablePlayer : Player //Rotation in move direction Vector3 lookPos = nextPoint - transform.position; lookPos.y = 0; - if(lookPos != Vector3.zero) + if (lookPos != Vector3.zero) { Quaternion rotation = Quaternion.LookRotation(lookPos); transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * rotationDamping); } + //END transform.position = new Vector3(nextPoint.x, transform.position.y, nextPoint.z); interPol += (Time.deltaTime * speed) / Mathf.Abs(Vector3.Distance(moveTo, lastPos)); @@ -256,7 +267,7 @@ public class NoPlayablePlayer : Player } private Star currentStar; - + private void OnTriggerEnter(Collider collider) { if (collider.name.Equals("ItemShopTrigger")) @@ -267,7 +278,7 @@ public class NoPlayablePlayer : Player { currentStar = collider.GetComponent(); - if(currentStar.IsActive) + if (currentStar.IsActive) { base.OnTriggerEnter(collider); } @@ -286,4 +297,4 @@ public class NoPlayablePlayer : Player { itemInfoImages[index].color = new Color(0, 0, 0, 0); } -} +} \ No newline at end of file diff --git a/FlufflParty/Assets/Scripts/Players/PlayablePlayer.cs b/FlufflParty/Assets/Scripts/Players/PlayablePlayer.cs index 1e7a74a..a76b756 100644 --- a/FlufflParty/Assets/Scripts/Players/PlayablePlayer.cs +++ b/FlufflParty/Assets/Scripts/Players/PlayablePlayer.cs @@ -107,6 +107,8 @@ public class PlayablePlayer : Player private void DiceRollRoutine() { + diceScript.SetMaterial(0); + jumpRequest = true; wurfelt = true; @@ -117,10 +119,12 @@ public class PlayablePlayer : Player case Item.Type.Mushroom: wurfelZahl += 3; activeItem = Item.Type.None; + diceScript.SetMaterial(2); break; case Item.Type.DoubleDice: checkDoubleDice = true; activeItem = Item.Type.None; + diceScript.SetMaterial(1); break; } @@ -399,6 +403,7 @@ public class PlayablePlayer : Player private void Finish() { imageCurrentItem.color = new Color(0, 0, 0, 0); + diceScript.SetMaterial(0); client.SendFinished(); } diff --git a/FlufflParty/Assets/Scripts/Players/Player.cs b/FlufflParty/Assets/Scripts/Players/Player.cs index d098572..bf8c81e 100644 --- a/FlufflParty/Assets/Scripts/Players/Player.cs +++ b/FlufflParty/Assets/Scripts/Players/Player.cs @@ -97,8 +97,6 @@ public abstract class Player : MonoBehaviour break; } } - - Debug.Log(item.type); } public void ActivateItem(int index) diff --git a/Server/.idea/workspace.xml b/Server/.idea/workspace.xml index a83d479..58da162 100644 --- a/Server/.idea/workspace.xml +++ b/Server/.idea/workspace.xml @@ -101,7 +101,7 @@ - +