// other entities can call this method to hurt the player public void HurtPlayer(MapEntity mapEntity) { if (!isInvincible) { // if map entity is an enemy, kill player on touch if (mapEntity is Enemy) { LevelState = LevelState.PLAYER_DEAD; } } }
/* * determines if map entity (enemy, enhanced map tile, or npc) is active by the camera's standards * 1. if entity's status is REMOVED, it is not active, no questions asked * 2. if entity's status is not REMOVED, then there's additional checks that take place: * 1. if entity's isUpdateOffScreen attribute is true, it is active * 2. OR if the camera determines that it is in its boundary range, it is active */ private bool IsMapEntityActive(MapEntity mapEntity) { return(mapEntity.MapEntityStatus != MapEntityStatus.REMOVED && (mapEntity.IsUpdateOffScreen || ContainsUpdate(mapEntity))); }