Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class Destroy : MonoBehaviour
- {
- public string reagente1, reagente2;
- public string produto1, produto2;
- public Sprite sprite1, sprite2, sprite3, sprite4, sprite5, sprite6, sprite7, sprite8, sprite9, sprite10;
- public SpriteRenderer spriteRenderer;
- public Text textoReacao;
- void Start()
- {
- reagente1 = null;
- reagente2 = null;
- }
- void OnCollisionEnter2D(Collision2D collision)
- {
- //NAOH
- if (collision.gameObject.tag == "NaOH" && (reagente1 == null || reagente2 == null))
- {
- if (reagente1 == null)
- {
- reagente1 = "NaOH";
- spriteRenderer.sprite = sprite1;
- }
- else
- {
- reagente2 = "NaOH";
- spriteRenderer.sprite = sprite3;
- }
- Destroy(collision.gameObject);
- }
- //KOH
- if (collision.gameObject.tag == "KOH" && (reagente1 == null || reagente2 == null))
- {
- if (reagente1 == null)
- {
- reagente1 = "KOH";
- spriteRenderer.sprite = sprite1;
- }
- else
- {
- reagente2 = "KOH";
- spriteRenderer.sprite = sprite3;
- }
- Destroy(collision.gameObject);
- }
- //HCl
- if (collision.gameObject.tag == "HCl" && (reagente1 == null || reagente2 == null))
- {
- if (reagente1 == null)
- {
- reagente1 = "HCl";
- spriteRenderer.sprite = sprite1;
- }
- else
- {
- reagente2 = "HCl";
- spriteRenderer.sprite = sprite3;
- }
- Destroy(collision.gameObject);
- }
- //H2SO4
- if (collision.gameObject.tag == "H2SO4" && (reagente1 == null || reagente2 == null))
- {
- if (reagente1 == null)
- {
- reagente1 = "H2SO4";
- spriteRenderer.sprite = sprite1;
- }
- else
- {
- reagente2 = "H2SO4";
- spriteRenderer.sprite = sprite3;
- }
- Destroy(collision.gameObject);
- }
- if ((reagente1 == "NaOH" && reagente2 == "HCl") || (reagente1 == "HCl" && reagente2 == "NaOH"))
- {
- produto1 = "NaCl";
- produto2 = "H2O";
- //Exibir reação na tela
- /* textoReacao.text = reagente1.ToString() + reagente2.ToString()
- +produto1.ToString() + produto2.ToString();*/
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement