Esempio n. 1
0
    public virtual bool React(Atom atom, Vector3 pos)
    {
        if (this.ignoreAtom && (this.ignoreAtom == atom))
        {
            return(false);
        }
        bool myreacted = false;

        if (this.type == 1)
        {
            return(false);
        }
        if ((((((Random.value > 0.7f) && atom) && (this.type == 2)) && (this.energy > (float)(atom.ionizedForces[atom.charge]))) && (this.energy < 2000)) && (atom.electrons > 1))
        {
            atom.electrons--;
            atom.RedoOrbitals();
            atom.dirty = true;
            this.StartCoroutine(this.Done());
            GameObject hydrogen = (GameObject)UnityEngine.Object.Instantiate(atom.prefab, pos, Quaternion.identity);
            ((Atom)hydrogen.GetComponent(typeof(Atom))).electrons = 1;
            ((Atom)hydrogen.GetComponent(typeof(Atom))).protons   = 1;
            ((Atom)hydrogen.GetComponent(typeof(Atom))).neutrons  = 0;
            Vector3 dir = (((pos - atom.transform.position).normalized * 1.6f) + Random.onUnitSphere) + (this.velocity * 0.005f);
            ((Mover)hydrogen.GetComponent(typeof(Mover))).SetFactors(dir.x, 0, dir.z);
            return(true);
        }
        float gammaProbability = this.energy < 200 ? 0.3f : (this.energy < 2000 ? 0.1f : (this.energy < 20000 ? 0.03f : 0.01f));
        int   angle            = (atom.protons - atom.electrons) < -2 ? (this.energy < 200 ? 180 : 40) : (this.energy < 200 ? 30 : 22);

        if (((atom.protons - atom.electrons) > -1) && (this.energy > 2000))
        {
            angle = (int)(angle * 1.6f);
        }
        if ((this.type == 0) && (Vector3.Angle(this.transform.position - atom.transform.position, Shooter.instance.transform.position - atom.transform.position) > 22))
        {
            return(false);
        }
        if (!atom.CheckForIonization(this.energy, this.type) && (atom.smacked < 0))
        {
            if ((atom.charge > 0) && (this.type == 0))
            {
                atom.electrons++;
                atom.RedoOrbitals();
                atom.smacked = 5;
                this.StartCoroutine(this.Done());
                myreacted = false;
            }
            else
            {
                if (this.type == 0)
                {
                    this.StartCoroutine(this.Bend(atom, 3));
                }
                this.reacted = false;
            }
        }
        else
        {
            if ((atom.electrons > 0) && ((Random.value < gammaProbability) || (this.type != 3)))
            {
                if (((this.type != 0) || (this.energy < 20000)) || (Random.value < 0.3f))
                {
                    atom.ESmack(this.energy, this.type, this.transform);
                    this.energy = this.energy * 0.2f;
                    myreacted   = false;
                }
            }
        }
        return(myreacted);
    }