/// <summary> /// Initializes a new organism state by computed and /// attaching a TerrariumSprite class that can be used /// to control on screen movement, animation skins, and /// selection. /// </summary> /// <param name="orgState">The organism state to attach the sprite animation information to.</param> private void InitOrganism(OrganismState orgState) { var tsSprite = new TerrariumSprite(); tsSprite.CurFrame = 0; tsSprite.CurFrameDelta = 1; var species = orgState.Species; if (species is AnimalSpecies) { tsSprite.SpriteKey = ((AnimalSpecies) species).Skin; tsSprite.SkinFamily = ((AnimalSpecies) species).SkinFamily.ToString(); tsSprite.IsPlant = false; if (tsSprite.SpriteKey == null && tsSprite.SkinFamily == null) { tsSprite.SpriteKey = AnimalSkinFamily.Spider.ToString(); // This will be our default } } else { tsSprite.SpriteKey = ((PlantSpecies) species).Skin; tsSprite.SkinFamily = ((PlantSpecies) species).SkinFamily.ToString(); tsSprite.IsPlant = true; if (tsSprite.SpriteKey == null && tsSprite.SkinFamily == null) { tsSprite.SpriteKey = PlantSkinFamily.Plant.ToString(); // This will be our default } } tsSprite.XPosition = orgState.Position.X; tsSprite.YPosition = orgState.Position.Y; tsSprite.PreviousAction = orgState.PreviousDisplayAction; orgState.RenderInfo = tsSprite; }
/// <summary> /// Sets up the hack table with teleporter information. /// The hack table is used to quickly implement new types /// of sprites or implement sprites linked to immutable /// objects (like the teleporter). /// </summary> /// <param name="zone">The teleporter zone to initialize.</param> private void InitTeleporter(TeleportZone zone) { var tsZone = new TerrariumSprite(); tsZone.CurFrame = 0; tsZone.CurFrameDelta = 1; tsZone.SpriteKey = "teleporter"; tsZone.XPosition = zone.Rectangle.X; tsZone.YPosition = zone.Rectangle.Y; hackTable.Add(zone.ID, tsZone); }