public void Clear() { if (level == MAX_LEVEL) { entities.Clear(); return; } else //if(this.level + 1 <= numLevels) { pNW.Clear(); pNE.Clear(); pSW.Clear(); pSE.Clear(); } if (entities.Count > 0) { entities.Clear(); } }
public void Update(float step_time) { spatialGrid.ClearAll(); // checkPickupsCollisionEachOther(step_time); this.checkBulletVsEntityCollisions(step_time); treeMonsters.Clear(); //treeBullets.Clear(); //update bullets int bulletCount = bullets.Count; for (int i = 0; i < bulletCount; i++) { if (bullets[i].isActive()) { bullets[i].Update(step_time); //treeBullets.AddEntity(bullets[i]); } else { bullets.RemoveAt(i); i--; bulletCount = bullets.Count; } } //update monsters int monsterCount = monsters.Count; for (int i = 0; i < monsterCount; i++) { if (monsters[i].isActive()) { monsters[i].Update(step_time); treeMonsters.AddEntity(monsters[i]); } else { monsters.RemoveAt(i); i--; monsterCount = monsters.Count; } } // update pickups List <int> keysToRemove = new List <int>(); foreach (var item in pickups) { cPickupAble pickup = item.Value; if (pickup.isActive()) { pickup.Update(step_time); } else { //pickups.Remove(item.Key); keysToRemove.Add(item.Key); } } foreach (int key in keysToRemove) { pickups.Remove(key); } this.checkPlayerCanUseOrPickupOrInteract(); /* * int pickupCount = pickups.Count; * for (int i = 0; i < pickupCount; i++) * { * if (pickups[i].isActive()) * { * pickups[i].Update(step_time); * } * else * { * pickups.RemoveAt(i); * i--; * pickupCount = pickups.Count; * } * } */ }