using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public enum NPCState
{ Person, Puppy, Kitten};


public class Transmission : MonoBehaviour
{

    public NPCState state;
    private GameTimer gameTimer;
    public bool touchedByP1, touchedByP2;

    public AudioSource nuuSound, barkSound, mewSound;

    private void Start()
    {
        state = NPCState.Person;

        gameTimer = GameObject.Find("GameTimer").GetComponent<GameTimer>();
    }



    private void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "P1" && state != NPCState.Puppy)
        {
            state = NPCState.Puppy;
            touchedByP1 = true;
            touchedByP2 = false;
            Score score = coll.gameObject.GetComponent<Score>();
            if (score != null)
                score.points++;

            GetComponent<Animator>().SetBool("touchedByP1", true);
            GetComponent<Animator>().SetBool("touchedByP2", false);

            GetComponentInChildren<SpriteRenderer>().color = Random.ColorHSV();

            barkSound.Play();
        }

        else if (coll.gameObject.tag == "P2" && state != NPCState.Kitten)
        {
            state = NPCState.Kitten;
            touchedByP2 = true;
            touchedByP1 = false;

            Score score = coll.gameObject.GetComponent<Score>();
            if (score != null)
				score.points++;

			GetComponent<Animator>().SetBool("touchedByP1", false);
			GetComponent<Animator>().SetBool("touchedByP2", true);

            GetComponentInChildren<SpriteRenderer>().color = Random.ColorHSV();

            mewSound.Play();
        }
    }


}
