コード例 #1
0
    GameObject CreateNewSubstance(substanceType type, Transform t, Mesh mesh, Material mat, float[] color)
    {
        //Debug.Log((int)type);
        GameObject new_obj = Instantiate(objPrefabs[(int)type]);

        if (t != null)
        {
            new_obj.transform.position = new Vector3(t.position.x, t.position.y, t.position.z);
            if (type == substanceType.Liquid)
            {
                new_obj.transform.rotation   = t.rotation;
                new_obj.transform.localScale = t.lossyScale;
            }
        }
        if (mesh != null)
        {
            new_obj.GetComponent <MeshFilter>().mesh = mesh;
        }
        if (mat != null)
        {
            new_obj.GetComponent <MeshRenderer>().material = mat;
        }
        if (type == substanceType.Liquid)
        {
            if (sysType == systemType.Solution)
            {
                new_obj.GetComponent <LiquidSimulator>().fluid = solutionFliud;
            }
            else
            {
                new_obj.GetComponent <LiquidSimulator>().fluid = null;
            }
        }
        return(new_obj);
    }
コード例 #2
0
 public substanceInfoOfReaction(XmlElement xe)
 {
     //Debug.Log("im here");
     name = xe.InnerText;
     rate = int.Parse(xe.GetAttribute("rate").ToString());
     type = (substanceType)System.Enum.Parse(typeof(substanceType), xe.GetAttribute("type"), true);
 }
コード例 #3
0
    void DrawSubstance(substanceInfo substance, float reactionAmount, substanceType stype)
    {
        switch (stype)
        {
        case substanceType.Solid:
        {
            float newAmount = substance.amount[(int)stype];
            float oldAmount = newAmount - reactionAmount;
            DrawSolid(substance, newAmount / oldAmount);
            break;
        }

        case substanceType.Liquid:
        {
            //DrawLiquid(substance, (float)substance.concentration);
            break;
        }

        case substanceType.Gas:
        {
            //Debug.Log("bubbles" + reactionAmount);
            DrawGas(substance, reactionAmount);
            break;
        }

        default:
            break;
        }
    }