From aa5d8943bde5f6e5c831fc8656cd1fc14edf967c Mon Sep 17 00:00:00 2001 From: Pedro Esteves Date: Sat, 21 Nov 2020 22:23:43 +0000 Subject: [PATCH 1/2] Added second player color --- FEUP Mayhem/Assets/Scenes/GameSection.unity | 12 ++++++++++++ FEUP Mayhem/Assets/Scripts/GameManager.cs | 14 +++++++++++++- FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs | 9 +++++++-- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/FEUP Mayhem/Assets/Scenes/GameSection.unity b/FEUP Mayhem/Assets/Scenes/GameSection.unity index 9fa278e..ed54e50 100644 --- a/FEUP Mayhem/Assets/Scenes/GameSection.unity +++ b/FEUP Mayhem/Assets/Scenes/GameSection.unity @@ -9425,6 +9425,18 @@ PrefabInstance: propertyPath: m_Sprite value: objectReference: {fileID: 21300000, guid: ad378bbc5a2612fc8bd829f74fdf5c5f, type: 3} + - target: {fileID: 7637583668806234002, guid: a2d18529be5bb644987385f32b40ea06, type: 3} + propertyPath: m_Color.r + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7637583668806234002, guid: a2d18529be5bb644987385f32b40ea06, type: 3} + propertyPath: m_Color.g + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7637583668806234002, guid: a2d18529be5bb644987385f32b40ea06, type: 3} + propertyPath: m_Color.b + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7637583668806234003, guid: a2d18529be5bb644987385f32b40ea06, type: 3} propertyPath: m_AngularDrag value: 0 diff --git a/FEUP Mayhem/Assets/Scripts/GameManager.cs b/FEUP Mayhem/Assets/Scripts/GameManager.cs index ca5a94b..242b240 100644 --- a/FEUP Mayhem/Assets/Scripts/GameManager.cs +++ b/FEUP Mayhem/Assets/Scripts/GameManager.cs @@ -24,6 +24,8 @@ public class GameManager : MonoBehaviour [SerializeField] private WinnerImageAnimation winnerImageAnimation = null; + private bool changeColor = false; + // Start is called before the first frame update void Start() { @@ -52,15 +54,25 @@ void Start() player2.AddComponent(Type.GetType(charactersPerks[index2])); spritesP2 = idleSpritesFolder[index2]; + + if(index1 == index2) + { + SpriteRenderer sp2 = player2.GetComponent(); + sp2.color = new Color(.5f, .5f, .5f); + + changeColor = true; + } } public void SetWinningCharacterAnimation(string winningCharacter) { string folder; bool rotateImage; + bool color = changeColor; if(winningCharacter == "Player 1") { + color = false; rotateImage = false; folder = "IdleSprites/" + spritesP1; } @@ -75,6 +87,6 @@ public void SetWinningCharacterAnimation(string winningCharacter) sprites.Add((Sprite)obj); } - winnerImageAnimation.SetIdleSprites(sprites, rotateImage); + winnerImageAnimation.SetIdleSprites(sprites, rotateImage, color); } } diff --git a/FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs b/FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs index dbcc037..2807427 100644 --- a/FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs +++ b/FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs @@ -11,13 +11,18 @@ public class WinnerImageAnimation : MonoBehaviour private float animationTime = .5f; [SerializeField] - private Image image; + private Image image = null; - public void SetIdleSprites(List sprites, bool rotateImage = false) + public void SetIdleSprites(List sprites, bool rotateImage = false, bool changeColor = false) { idleSprites = sprites; StopAllCoroutines(); + if (changeColor) + { + image.color = new Color(.5f, .5f, .5f); + } + if (rotateImage) { Vector3 eulerAngles = transform.eulerAngles + new Vector3(0, 180, 0); From f967360450c279fca217e6aa72255c8ba1084429 Mon Sep 17 00:00:00 2001 From: Pedro Esteves Date: Sat, 21 Nov 2020 22:41:26 +0000 Subject: [PATCH 2/2] Minor changes --- FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs b/FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs index 73381e1..a13dd6e 100644 --- a/FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs +++ b/FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs @@ -39,13 +39,13 @@ void Update() private void OnDisable() { - pointer.SetActive(false); + pointer?.SetActive(false); isVisible = false; } private void OnBecameInvisible() //when object leaves the camera bounds { - pointer.SetActive(true); //pointer becomes active + pointer?.SetActive(true); //pointer becomes active isVisible = false; //player is not visible anymore }