/// <summary> /// A method to call the level directly with an id /// </summary> /// <param name="id">id of the level that should be spawned </param> public void SpawnLevel(int id) { var level = GameObject.Find("Level"); Destroy(level); foreach (var ballsandpaddles in Instantiated) { Destroy(ballsandpaddles); } var powerUps = GameObject.FindGameObjectsWithTag("PowerUp"); foreach (var powerUp in powerUps) { Destroy(powerUp); } Instantiated.Clear(); SpawnPaddleAndBall(); if (id == 8) { GetComponent <LevelSpawner>().LoadLevel(GetComponent <LevelSpawner>().GenerateRandomLevel(5, 2, 5)); } else { GetComponent <LevelSpawner>().LoadLevel(id); } }
private void Update() { if (NumberOfDestructibleTiles > 0) { return; } foreach (var ballsandpaddles in Instantiated) { Destroy(ballsandpaddles); } var powerUps = GameObject.FindGameObjectsWithTag("PowerUp"); foreach (var powerUp in powerUps) { Destroy(powerUp); } Instantiated.Clear(); SpawnPaddleAndBall(); GetComponent <LevelSpawner>().SpawnNextLevel(); }
internal void ClearCacheValue(object obj) { lock (Instantiated) { foreach (var instance in Instantiated) { if (instance.Target is string) { ((string)instance.Target).DestroyString(); } else { // todo: Destroy reference //var gcAlloc = GCHandle.Alloc(instance.Target, GCHandleType.Weak); //var size = Marshal.SizeOf(instance.Target); //unsafe //{ // var gcPtr = (int*) ((IntPtr) gcAlloc).ToPointer(); // for (int i = 0; i < size; i++) // { // gcPtr[i] = 0; // } //} } } Instantiated.Clear(); if (!HasCache) { return; } var cacheProperty = GetCacheProperty(obj); cacheProperty.NullField(obj); } }