void OnTriggerEnter2D(Collider2D other) { if (other.tag == "P1" || other.tag == "P2") { playAudio(); } if (other.CompareTag("P1")) { if (GetComponent <SpriteRenderer> ().sprite == spriteP1) { GetComponent <SpriteRenderer> ().sprite = spriteOff; currentState = 0; } else if (GetComponent <SpriteRenderer> ().sprite == spriteP2) { GetComponent <SpriteRenderer> ().sprite = spriteP1; currentState = 2; } else { GetComponent <SpriteRenderer> ().sprite = spriteP1; currentState = 1; } if (currentState == 0) { playerPoints.decreaseHackerPoints(); } else if (currentState == 1) { playerPoints.increaseHackerPoints(); } else if (currentState == 2) { playerPoints.increaseHackerPoints(); playerPoints.decreaseAntiHackerPoints(); } } if (other.CompareTag("P2")) { if (GetComponent <SpriteRenderer>().sprite == spriteP2) { GetComponent <SpriteRenderer> ().sprite = spriteOff; currentState = 0; } else if (GetComponent <SpriteRenderer> ().sprite == spriteP1) { GetComponent <SpriteRenderer> ().sprite = spriteP2; currentState = 1; } else { GetComponent <SpriteRenderer> ().sprite = spriteP2; currentState = 2; } if (currentState == 0) { playerPoints.decreaseAntiHackerPoints(); } else if (currentState == 1) { playerPoints.increaseAntiHackerPoints(); playerPoints.decreaseHackerPoints(); } else if (currentState == 2) { playerPoints.increaseAntiHackerPoints(); } } }