/// <summary> /// Advances user to next area /// </summary> /// <param name="sender">Object command sent from</param> /// <param name="e">EventArgs that contain position and areaID</param> private void OnNewAreaEnter(Entity sender, BoxArgs e) { //if everything is either dead or in its original position if (entities.Count(entity => entity.State == SpriteState.Die) + entities.Count(entity => (entity.InitialPosition - entity.Position).Length() <= 1) == entities.Count) { foreach (EventBox box in EventBoxes) { box.UnloadBox(true); } User.Position = (e as NewAreaEventArgs).Position; User.CurrentArea = LoadArea((e as NewAreaEventArgs).AreaID); } }
/// <summary> /// Spawns an entity /// </summary> /// <param name="sender">Object command is sent from</param> /// <param name="e">EventArgs that contain position, name, entityID and max number</param> private void Spawn(Entity sender, BoxArgs e) { EntitySpawnEventArgs args = e as EntitySpawnEventArgs; //get current count of entities of this type int currentNum = entities.Count(entity => entity.EntityName.Contains(args.Name) && entity.EntityID == args.EntityID); Entity potential = new Enemy(this, args.Position, args.Name + currentNum, args.EntityID, args.Direction, args.Bounds); if (args.Type == EntityType.Enemy && CheckForCollisions(potential)) { entities.Add(potential); } //else //entities.Add(new NPC(this, args.Position, args.Name + currentNum, args.EntityID)); }