-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGasBehaviour.cs
103 lines (90 loc) · 2.63 KB
/
GasBehaviour.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GasBehaviour : MonoBehaviour {
private const float CONSTANTE_GASES = 0.082f;
public float presion;
public float volumen;
public float temperatura;
public float moles;
public bool presionFija = false;
public bool volumenFijo = false;
public bool temperaturaFija = false;
public bool molesFijo = false;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void CambiarPresion(float presion)
{
this.presion = presion;
ActualizarVolumen();
ActualizarTemperatura();
ActualizarMoles();
}
public void CambiarVolumen(float volumen)
{
this.volumen = volumen;
ActualizarPresion();
ActualizarTemperatura();
ActualizarMoles();
}
public void CambiarMoles(float moles)
{
this.moles = moles;
ActualizarPresion();
ActualizarVolumen();
ActualizarTemperatura();
ActualizarParticleSystem();
}
public void CambiarTemperatura(float temperatura)
{
this.temperatura = temperatura;
ActualizarPresion();
ActualizarVolumen();
ActualizarMoles();
}
private void ActualizarPresion()
{
if (!presionFija)
{
presion = moles * CONSTANTE_GASES * temperatura / volumen;
}
}
private void ActualizarMoles()
{
if (!molesFijo)
{
moles = Convert.ToSingle(presion * volumen / (CONSTANTE_GASES * temperatura));
ActualizarParticleSystem();
}
}
private void ActualizarTemperatura()
{
if (!temperaturaFija)
{
temperatura = presion * volumen / (moles * CONSTANTE_GASES);
}
}
private void ActualizarVolumen()
{
if (!volumenFijo)
{
volumen = moles * CONSTANTE_GASES * temperatura / presion;
GameObject.Find("VolumenInput").GetComponent<VolumenInputBehaviour>().ActualizarContenedor(volumen);
}
}
private void ActualizarParticleSystem()
{
ParticleSystem particleSystem = gameObject.GetComponent<ParticleSystem>();
ParticleSystem.Burst[] nuevoBurst = new ParticleSystem.Burst[particleSystem.emission.burstCount];
particleSystem.emission.GetBursts(nuevoBurst);
nuevoBurst[0].count = 30 * moles;
particleSystem.emission.SetBursts(nuevoBurst);
particleSystem.Stop(false, ParticleSystemStopBehavior.StopEmittingAndClear);
particleSystem.Play();
}
}