Beispiel #1
0
    public void Update()
    {
        foreach (var lhs in particles)
        {
            foreach (var rhs in particles)
            {
                if (lhs != rhs && (lhs != null && rhs != null))
                {
                    if (CollisionDetector2D.DetectCollision(lhs, rhs))
                    {
                        if (!toBeDeleted.Contains(lhs))
                        {
                            toBeDeleted.Add(lhs);
                        }
                        if (!toBeDeleted.Contains(rhs))
                        {
                            toBeDeleted.Add(rhs);
                        }
                    }
                }
            }
        }

        foreach (var particle in toBeDeleted)
        {
            particles.Remove(particle);
            Destroy(particle.gameObject);
        }
        toBeDeleted.Clear();
    }
Beispiel #2
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }