Skip to content

Commit

Permalink
Merge pull request #14 from necg/feature/second-player-color
Browse files Browse the repository at this point in the history
Added second player color
  • Loading branch information
RicardoCQB authored Nov 21, 2020
2 parents 0413359 + f967360 commit 22ee0cd
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
12 changes: 12 additions & 0 deletions FEUP Mayhem/Assets/Scenes/GameSection.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 13 additions & 1 deletion FEUP Mayhem/Assets/Scripts/GameManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -52,15 +54,25 @@ void Start()
player2.AddComponent(Type.GetType(charactersPerks[index2]));

spritesP2 = idleSpritesFolder[index2];

if(index1 == index2)
{
SpriteRenderer sp2 = player2.GetComponent<SpriteRenderer>();
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;
}
Expand All @@ -75,6 +87,6 @@ public void SetWinningCharacterAnimation(string winningCharacter)
sprites.Add((Sprite)obj);
}

winnerImageAnimation.SetIdleSprites(sprites, rotateImage);
winnerImageAnimation.SetIdleSprites(sprites, rotateImage, color);
}
}
4 changes: 2 additions & 2 deletions FEUP Mayhem/Assets/Scripts/Player/outOfBounds.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
9 changes: 7 additions & 2 deletions FEUP Mayhem/Assets/Scripts/WinnerImageAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ public class WinnerImageAnimation : MonoBehaviour
private float animationTime = .5f;

[SerializeField]
private Image image;
private Image image = null;

public void SetIdleSprites(List<Sprite> sprites, bool rotateImage = false)
public void SetIdleSprites(List<Sprite> 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);
Expand Down

0 comments on commit 22ee0cd

Please sign in to comment.