private void InitEntity(DungeonTile tile, TiledMapProperties properties) { if (!properties.ContainsKey("entity")) { Log.Error("Invalid entity at " + tile + ": 'entity' not found."); return; } if (!Enum.TryParse(properties.GetString("direction", "Down"), out Direction direction)) { Log.Error("Unknown entity direction '" + properties.GetString("direction") + "' at " + tile); } var entityName = properties.GetString("entity"); if (entityName == "player") { PlayerStartTile = tile; PlayerStartDirection = direction; } else { var entity = EntityData.Get(entityName); if (entity == null) { Log.Error("Unknown entity '" + entityName + "' at " + tile); } else { entities.Add(new EntityArguments(entity, tile.X, tile.Y, direction)); } } }
private void InitGroup(TiledMapObject obj, Rectangle bounds) { var loot = EntityData.Get(obj.Properties.GetString("loot")); if (loot == null) { Log.Error("Group at " + bounds + " has an invalid loot '" + obj.Properties.GetString("loot") + "'."); return; } var id = groupRewards.Count; groupRewards.Add(loot); IterateEntities((entity) => { if (entity.Data.Groupable && Mathf.IntersectPoint(bounds, entity.TileX * Global.TileSize, entity.TileY * Global.TileSize)) { entity.GroupId = id; Log.Debug("Assigned " + entity + " to group " + id + "."); } }); }
public Ghost(Vector2 position) : base(new EntityArguments(EntityData.Get("ghost"), position)) { Sprite.Alpha = 0.3f; }