Going by standard Rock-Paper-Scissors rules, what would make all of my “if” statements fire but not my else statement? Code on attached txt file.[144413-code.txt|144413]
edit (copied and reformatted from attachment):
//When the player collides with the target, determine if it is rock, paper, or scissors, and react accordingly
private void OnTriggerEnter2D(Collider2D target)
{
//If the other game object is the enemy
if (target.CompareTag("Enemy"))
{
EnemySprite = target.GetComponent<Enemy>().GetEnemySprite();
Sprite eRock = target.GetComponent<Enemy>().GeteRock();
Sprite ePaper = target.GetComponent<Enemy>().GetePaper();
Sprite eScissors = target.GetComponent<Enemy>().GeteScissors();
//If the player is rock, but the enemy is rock or paper
if ((PlayerSprite == pRock) && (EnemySprite == eRock || ePaper))
{
Debug.Log("PLAYER IS ROCK");
GameOver();
}
//If the player is paper, but the enemy is paper or scissors
else if ((PlayerSprite == pPaper) && (EnemySprite == ePaper || eScissors))
{
Debug.Log("PLAYER IS PAPER");
GameOver();
}
//If the player is scissors, but the enemy is scissors or rock
else if ((PlayerSprite == pScissors) && (EnemySprite == eScissors || eRock))
{
Debug.Log("PLAYER IS SCISSORS");
GameOver();
}
else
{
Debug.Log("PLAYER WINS");
AudioSource.PlayClipAtPoint(VictorySound, Camera.main.transform.position);
//Destroy target enemy
Destroy(target);
}