public void UnPlaced(TrashBehaviour dataTransfer)
 {
     if (type == dataTransfer.GetTrashType())
     {
         GameData.instance.AddScore(-dataTransfer.GetData().TrashScore);
         // give vfx here
     }
 }
 public void Placed(TrashBehaviour dataTransfer)
 {
     if (type == dataTransfer.GetTrashType())
     {
         GameData.instance.AddScore(dataTransfer.GetData().TrashScore);
         dataTransfer.transform.position = transform.position;
         // give vfx here
     }
 }
Exemple #3
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "Trash")
     {
         if (!interactingWithTrash)
         {
             interactTrash = collision.GetComponent <TrashBehaviour>();
         }
     }
 }
    //o grab é pra ser chamado por algo, tipo um trigger, e deve ser passado o trash que ele deve pegar.
    //Eu coloquei um limite de lixo que o jogador pode segurar e um int de ID do lixo que ele tá segurando
    // a ideia desse ID do lixo é ser 0 para não estar segurando lixo e ser 1,2,3... para os tipos de lixo
    //para ele não poder pegar outro tipo
    //ao pegar um lixo um saco de lixo aparece (ainda não modelei e coloquei esse saco no jogo) e ao pegar mais lixo o saco cresce

    public void Grab(TrashBehaviour trash)
    {
        if (trash.trashID == holdingTrashID || holdingTrashID == 0)
        {
            anim.SetTrigger("grab");
            anim.SetBool("hold", true);
            Destroy(trash.gameObject);
            holdingTrashCount++;
            trashBag.SetActive(true);
            trashBag.transform.localScale = Vector3.one * holdingTrashCount * 0.5f;
            holdingTrashID        = trash.trashID;
            hudHoldingTrash.color = trashColors[trash.trashID];
            GUITrashCounter.text  = "" + holdingTrashCount;
            throwAudio.Play();
        }
        else
        {
            wrongCanAudio.Play();
        }
    }