Exemple #1
0
    private void Awake()
    {
        // Singleton instantiation
        transform.parent = null;
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }

        // Initialization of the experiment
        CreateMetaballs();
        CreateGrid();
        CreateMesh();
        EvaluateRectangle();
    }
Exemple #2
0
    void OnCollisionStay2D(Collision2D collision)
    {
        int layer = collision.collider.gameObject.layer;

        if (layer != 9 && layer != 8)
        {
            return;
        }
        if (layer == 8)
        {
            Metaball2D metaball = collision.gameObject.GetComponent <Metaball2D>();
            if (metaball == null)
            {
                return;
            }
            if (!metaball.onGround)
            {
                return;
            }
        }
        onGround = true;
        MetaballManager.OnGround();
    }
 public static void Remove(Metaball2D metaball)
 {
     MetaballManager.RemoveMetaball(metaball);
 }
 public static List <Metaball2D> Get()
 {
     return(MetaballManager.GetMetaballs());
 }
 public static void Add(Metaball2D metaball)
 {
     MetaballManager.AddMetaball(metaball);
 }
 // Update is called once per frame
 void Update()
 {
     AmountOfWater.SetGlobalValue(MetaballManager.GetMetaballs().Count);
 }