static World() { if (ViewModelBase.IsInDesignModeStatic) { return; } var settingspath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.xml"); LoadObjectDbXml(settingspath); Sprites.Add(new Sprite()); if (SettingsTileFrameImportant == null || SettingsTileFrameImportant.Length <= 0) { SettingsTileFrameImportant = new bool[TileCount]; for (int i = 0; i < TileCount; i++) { if (TileProperties.Count > i) { SettingsTileFrameImportant[i] = TileProperties[i].IsFramed; } } } var saveVersionPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TerrariaVersionTileData.json"); LoadSaveVersions(saveVersionPath); }
public Player(PlayerIndex playerIndex, Vector2 position) : base(position) { PlayerIndex = playerIndex; Sprites.Add("run", new SpriteSheet("Sprites\\Player\\Run", 0.08f, new Rectangle(500, 250, 64, 64))); Sprites.Add("jump", new SpriteSheet("Sprites\\Player\\Jump", 0.08f, new Rectangle(500, 250, 64, 64))); Sprites.Add("idle", new SpriteSheet("Sprites\\Player\\Idle", 0.08f, new Rectangle(500, 250, 64, 64))); }
public void Add(string name, Sprite sprite) { if (!Sprites.ContainsKey(name)) { Sprites.Add(name, sprite); } }
static World() { var settingspath = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase), "settings.xml"); LoadObjectDbXml(settingspath); Sprites.Add(new Sprite()); }
private void ModelShotMovedEventHandler(object sender, ShotMovedEventArgs e) { if (!e.Disappeared) { if (!_shots.ContainsKey(e.Shot)) { var shotControl = _gameEngineHelper.ShotControlFactory(e.Shot, Scale); _shots.Add(e.Shot, shotControl); Sprites.Add(shotControl); } else { var shotControl = _shots[e.Shot]; _gameEngineHelper.MoveElementOnCanvas(shotControl, e.Shot.Location.X, e.Shot.Location.Y, Scale); } } else { if (_shots.ContainsKey(e.Shot)) { var shotControl = _shots[e.Shot]; Sprites.Remove(shotControl); _shots.Remove(e.Shot); } } }
/// <summary> /// Creates and initializes the video player sample screen. /// </summary> /// <param name="spriteBatch">The <see cref="SpriteBatch"/> to render to.</param> public VideoPlayerScreen(SpriteBatch spriteBatch) : base(spriteBatch, Color.DarkGray) { Name = "VideoPlayer"; //Reduces the ARGB values, then resets alpha to 255 ClearColor *= 1f / 6f; ClearColor.A = 255; //See MainMenu for TextSprite sample comments title = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Title"), "VideoPlayer Sample", Color.PaleGoldenrod); title.Position = new Vector2(title.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport).X, 15); AdditionalSprites.Add(title); escapeReturnDesc = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Details"), "Press escape\nto return to\nthe main menu", Color.PaleGoldenrod); escapeReturnDesc.Position = new Vector2(3); AdditionalSprites.Add(escapeReturnDesc); //This event is fired when a key is pressed KeyboardManager.KeyDown += new SingleKeyEventHandler(KeyboardManager_KeyDown); creditTextSprite = new TextSprite(spriteBatch, GLibXNASampleGame.Instance.Content.Load <SpriteFont>("Details"), "Video obtained from nps.gov/cany/planyourvisit/rivervideos.htm", Color.Goldenrod); creditTextSprite.Color.A = 32; creditTextSprite.Position = new Vector2(creditTextSprite.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport).X, spriteBatch.GraphicsDevice.Viewport.Height - creditTextSprite.Height - 5); AdditionalSprites.Add(creditTextSprite); //VideoSprite: Like a sprite, but displays a video video = new VideoSprite(GLibXNASampleGame.Instance.Content.Load <Video>("VideoSample"), Vector2.Zero, spriteBatch); video.Video.Stop(); video.Position = video.GetCenterPosition(spriteBatch.GraphicsDevice.Viewport); Sprites.Add(video); }
private void InitializeAvatar() { Vector2 startPosition = currentPosition; Vector2 offset = new Vector2(23, 23); float depth = spriteBackground != null ? spriteBackground.Depth + 0.000001f : 0; if (spriteAvatar != null) { spriteAvatar.InitialPosition = startPosition + offset; if (spriteAvatar.Texture == null) { spriteAvatar.OnTextureLoaded += delegate { spriteAvatar.Scale = 74F / Math.Max(spriteAvatar.Width, spriteAvatar.Height); } } ; spriteAvatar.Scale = 74F / Math.Max(spriteAvatar.Width, spriteAvatar.Height); } else { spriteAvatar = GetFreshAvatarSprite(startPosition + offset, depth, 74f); if (Sprites != null) { Sprites.Add(spriteAvatar); } } spriteAvatar.Position = currentPosition + offset; spriteAvatar.Origin = Origins.Centre; }
/// <summary> /// Create a new sprite /// </summary> /// <param name="image">Picture to be used for the sprite</param> /// <param name="load">Not used</param> /// <returns>A new sprite object</returns> public Sprite LoadNewSprite(Bitmap image, bool load) { Sprite sprite = new Sprite(); sprite.Rectangle = new Rectangle(0, 0, image.Width, image.Height); int spriteWidth = sprite.Rectangle.Width; int spriteHeight = sprite.Rectangle.Height; /*if (!load) * { * spriteWidth *= 2; * spriteHeight *= 2; * }*/ sprite.Image = image; sprite.Name = "Anim " + GetNameInt(0); sprite.Parent = Sprites; if (SelectedAnim.MaxSize.Width < spriteWidth) { SelectedAnim.MaxSize = new System.Drawing.Size(spriteWidth, SelectedAnim.MaxSize.Height); } if (SelectedAnim.MaxSize.Height < spriteHeight) { SelectedAnim.MaxSize = new System.Drawing.Size(SelectedAnim.MaxSize.Width, spriteHeight); } Sprites.Add(sprite); return(sprite); }
public AnimationScreen(SpriteBatch b) : base(b, Color.DarkRed) { Name = "AnimatedScreen"; //SpriteSheet: Allows for animation with a single sprite sheet //FrameCollection: A collection of frames animated = new SpriteSheet(Vector2.Zero, b, FrameCollection.FromSpriteSheet(GLibXNASampleGame.Instance.Content.Load <Texture2D>("TestSpritesheet"), new Rectangle(99, 11, 45, 44), new Rectangle(150, 9, 45, 46), new Rectangle(198, 9, 45, 45), new Rectangle(252, 8, 45, 44), new Rectangle(303, 9, 45, 46), new Rectangle(351, 7, 45, 46), new Rectangle(396, 8, 45, 46), new Rectangle(444, 9, 45, 46), new Rectangle(495, 8, 45, 45), new Rectangle(552, 7, 45, 45))); animated.UseCenterAsOrigin = true; animated.Position = animated.GetCenterPosition(b.GraphicsDevice.Viewport); //FrameTime: The amount of time to spend on each frame animated.Frames.SetTimeAll(TimeSpan.FromMilliseconds(50)); //FrameChanged: An event fired upon frame change animated.FrameChanged += new EventHandler(animated_FrameChanged); AdditionalSprites.Add(new HitboxVisualizer(animated, b)); Sprites.Add(animated); }
public Frame(string name, int height, int width, ConsoleColor background = ConsoleColor.Black) : base(height, width, background) { _borders = CreateBorders(); Sprites.Add(_borders); Name = name; }
public Sprite AddSprite(string file, RectangleI?source = null) { Platform.LoadImage(file, out int width, out int height, out byte[] imageData); Bitmap spriteData = new Bitmap(imageData, width, height); RectangleI s = source ?? new RectangleI(width, height); #if DEBUG Point2 offset = GetValidPlacementNaive(s.W, s.H); #else Point2 offset = GetValidPlacement(s.W, s.H); #endif for (int y = 0; y < s.H; y++) { for (int x = 0; x < s.W; x++) { Bitmap[offset.X + x, offset.Y + y] = spriteData[s.X + x, s.Y + y]; } } if (texture == null) { throw new CKGLException("SpriteSheet.Texture is null."); } texture.UpdateData(spriteData.Bytes(), new RectangleI(offset.X, offset.Y, spriteData.Width, spriteData.Height)); Sprite sprite = new Sprite(this, offset.X, offset.Y, s.W, s.H); Sprites.Add(sprite); aabbs.Add(new AABBi(sprite.SpriteSheetX, sprite.SpriteSheetY, sprite.Width + padding, sprite.Height + padding)); return(sprite); }
public void LoadSprites() { try { List <string> pipes = new List <string> { "IronPipe", "GoldPipe", "IridiumPipe", "ExtractorPipe", "GoldExtractorPipe", "IridiumExtractorPipe", "InserterPipe", "PolymorphicPipe", "FilterPipe" }; foreach (string name in pipes) { if (!name.Contains("Iridium")) { Sprites.Add($"{name}_Item", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/{name}_Item.png")); Sprites.Add($"{name}_default_Sprite", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/{name}_default_Sprite.png")); Sprites.Add($"{name}_connecting_Sprite", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/{name}_connecting_Sprite.png")); Sprites.Add($"{name}_item_Sprite", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/{name}_item_Sprite.png")); } else { Sprites.Add($"{name}_Item", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/1/{name}_Item.png")); Sprites.Add($"{name}_Item1", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/1/{name}_Item.png")); Sprites.Add($"{name}_default_Sprite1", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/1/{name}_default_Sprite.png")); Sprites.Add($"{name}_connecting_Sprite1", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/1/{name}_connecting_Sprite.png")); Sprites.Add($"{name}_item_Sprite1", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/1/{name}_item_Sprite.png")); Sprites.Add($"{name}_Item2", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/2/{name}_Item.png")); Sprites.Add($"{name}_default_Sprite2", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/2/{name}_default_Sprite.png")); Sprites.Add($"{name}_connecting_Sprite2", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/2/{name}_connecting_Sprite.png")); Sprites.Add($"{name}_item_Sprite2", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/2/{name}_item_Sprite.png")); Sprites.Add($"{name}_Item3", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/3/{name}_Item.png")); Sprites.Add($"{name}_default_Sprite3", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/3/{name}_default_Sprite.png")); Sprites.Add($"{name}_connecting_Sprite3", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/3/{name}_connecting_Sprite.png")); Sprites.Add($"{name}_item_Sprite3", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/{name}/3/{name}_item_Sprite.png")); } } Sprites.Add("signal_on", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/on.png")); Sprites.Add("signal_off", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/off.png")); Sprites.Add("signal_unconnected", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/unconnected.png")); Sprites.Add("signal_nochest", ModEntry.helper.Content.Load <Texture2D>($"assets/Pipes/nochest.png")); Sprites.Add("PPM_Item", ModEntry.helper.Content.Load <Texture2D>($"assets/Objects/PPM/PPM_off.png")); Sprites.Add("PPM_on", ModEntry.helper.Content.Load <Texture2D>($"assets/Objects/PPM/PPM_on.png")); Sprites.Add("PPM_off", ModEntry.helper.Content.Load <Texture2D>($"assets/Objects/PPM/PPM_off.png")); Sprites.Add("Wrench_Item", ModEntry.helper.Content.Load <Texture2D>($"assets/Objects/Wrench/Wrench_Item.png")); Sprites.Add("nochest_state", ModEntry.helper.Content.Load <Texture2D>($"assets/Misc/nochest_state.png")); Sprites.Add("nochest1_state", ModEntry.helper.Content.Load <Texture2D>($"assets/Misc/nochest1_state.png")); //Sprites.Add("unconnected_state", ModEntry.helper.Content.Load<Texture2D>($"assets/Misc/unconnected_state.png")); Sprites.Add("unconnected1_state", ModEntry.helper.Content.Load <Texture2D>($"assets/Misc/unconnected1_state.png")); } catch (Exception e) { Printer.Info("Can't load Item Pipes mod sprites!"); Printer.Info(e.Message); Printer.Info(e.StackTrace); } }
private void ReadSprites() { string[] newSprites = config.ReadSection("Sprites", true); foreach (string nSprite in newSprites) { var s = GetKeyValue(nSprite, "="); IRenderSprite sprite = renderer.CreateSprite(s.Key); IseSprite iseSprite; if (usePlaceHolders) { iseSprite = new IseText(sprite, globalFontCorrection); } else { switch (s.Value.ToLower()) { case "text": iseSprite = new IseText(sprite, globalFontCorrection); break; default: iseSprite = new IseSprite(sprite); break; } } Sprites.Add(s.Key, iseSprite); } }
private void _AddSprite(HTMLImageElement image, Sprite sprite, RectangleI?source = null) { RectangleI s = source ?? new RectangleI((int)image.width, (int)image.height); #if DEBUG Point2 offset = GetValidPlacementNaive(s.W, s.H); #else Point2 offset = GetValidPlacement(s.W, s.H); #endif //for (int y = 0; y < s.H; y++) // for (int x = 0; x < s.W; x++) // Bitmap[offset.X + x, offset.Y + y] = spriteData[s.X + x, s.Y + y]; if (Platform.GraphicsBackend == GraphicsBackend.WebGL2) { (Texture as WebGL2.WebGL2Texture).UpdateData(image, offset.X, offset.Y); } else if (Platform.GraphicsBackend == GraphicsBackend.WebGL) { (Texture as WebGL.WebGLTexture).UpdateData(image, offset.X, offset.Y); } sprite.Update(this, offset.X, offset.Y, s.W, s.H); Sprites.Add(sprite); aabbs.Add(new AABBi(sprite.SpriteSheetX, sprite.SpriteSheetY, sprite.Width + padding, sprite.Height + padding)); }
protected override void AllocateSprites(Game i_Game) { for (int i = 0; i < k_NumberOfBarriers; i++) { Sprites.Add(new Barrier(i_Game, m_Screen)); } }
/// <summary> /// Transfers sprites either from or to the listbox /// </summary> /// <param name="fromListBox">Specifies whether to transfer the sprites from the listbox or to the listbox.</param> protected virtual void TransferSprites(bool fromListBox = true) { if (fromListBox) { Sprites.Clear(); foreach (Sprite o in edittingBuff) { Sprites.Add((Sprite)o); } } else { listBoxSprites.Items.Clear(); foreach (Sprite s in Sprites) { listBoxSprites.Items.Add(s.ToString()); edittingBuff.Add(s.Clone()); } if (Sprites.Count > 0) { listBoxSprites.SelectedIndex = 0; spriteControl1.Value = edittingBuff[0]; } } }
/// <summary> /// loads the elevator sprites /// </summary> /// <param name="Content"></param> override public void LoadContent(ContentManager Content) { Sprites.Add(1, Content.Load <Texture2D>("Elevator")); Sprites.Add(4, Content.Load <Texture2D>("Elevator")); Sprites.Add(7, Content.Load <Texture2D>("Elevator")); Sprites.Add(10, Content.Load <Texture2D>("ElevatorLocation")); }
protected override void LoadContent() { Cameras.Main.DrawSize = new Vector2(Resolution.X / 2f, Resolution.Y); Camera cam2 = Cameras.Create(0, 0, Graphics.WorldScale.X, Graphics.WorldScale.Y); cam2.DrawPosition = new Vector2(Resolution.X / 2f, 0); cam2.DrawSize = new Vector2(Resolution.X / 2f, Resolution.Y); Content.AddImage("../../Content/GameOver.png", "GameOver"); Content.AddImage("../../Content/Asteroid.png", "Asteroid"); Content.AddImage("../../Content/Cursor.png", "Cursor"); Sprites.Add("cursor", new SImage(this, 0, 0, 50, 50, "Cursor")); Sprites.Scale("cursor", 0.5); Sprites.Display("cursor", true); cursorSize = Sprites.GetSize("cursor"); Content.AddSound("../../Content/pew.mp3", "Pew"); Content.AddFont("../../Content/heav.ttf", "Heavy Data"); test = new SharpSlugsEngine.Physics.PolygonCollider(new Vector2(0, -34.375f), new Vector2(25, 15.625f), new Vector2(0, 3.125f), new Vector2(-25, 15.625f)); }
public Mouton(bool EstAdulte, int Enclos, params int[] Position) : base(EstAdulte, Enclos, Position) { Prix = 20; Type = "Mouton"; // temp Sprites.Add(AnimalTileSetImageGenerator.GetTile(0)); }
private void AddCoins(Vector2 position) { int coinNumber = rand.Next(1, 3); if (position.X >= 0 && position.Y >= 0 && position.X < Camera.SCREEN_WIDTH && position.Y < Camera.SCREEN_HEIGHT) { Sprites.Add(new Coin(TextureManager.Instance.GetTexture("coin" + coinNumber), position, 1, coinNumber * 100)); } }
public Concierge() { for (int i = 16; i < 20; i++) { Sprites.Add(HumainTileSetImageGenerator.GetTile(i)); } Position = new int[] { 38, 5 }; Frais = 2; }
internal pButton(string text, Vector2 position, Vector2 size, Color4 colour, EventHandler action) { this.action = action; Colour = colour; s_BackingPlate = new pSprite(TextureManager.Load(OsuTexture.notification_button_ok), position) { Origin = OriginTypes.Centre, DrawDepth = base_depth, HandleClickOnUp = true }; Sprites.Add(s_BackingPlate); s_BackingPlate.OnHover += delegate { if (!Enabled) { return; } additiveButton = s_BackingPlate.AdditiveFlash(10000, 0.4f); pendingUnhover = true; }; s_BackingPlate.OnHoverLost += delegate { if (!Enabled || !pendingUnhover) { return; } if (additiveButton != null) { additiveButton.FadeOut(100); } }; s_BackingPlate.OnClick += s_BackingPlate_OnClick; s_BackingPlate.HandleClickOnUp = true; s_Text = new pText(text, 25, position, base_depth + 0.01f, true, Color4.White); s_Text.Origin = OriginTypes.Centre; Sprites.Add(s_Text); s_Status = new pSprite(TextureManager.Load(OsuTexture.notification_button_toggle), position + new Vector2(-185, 0)) { Origin = OriginTypes.Centre, DrawDepth = base_depth + 0.005f, Bypass = true }; s_Status.OnClick += s_BackingPlate_OnClick; Sprites.Add(s_Status); }
public Fillette() { for (int i = 8; i < 12; i++) { Sprites.Add(HumainTileSetImageGenerator.GetTile(i)); } Type = "Fillette"; Sexe = 1; Nom = AssignerNom(Sexe); }
public void DrawTexture(CCSpriteFrame spriteFrame, CCPoint position, CCSize size, CCColor3B color, float opacity) { CCSprite sprite = new CCSprite(spriteFrame) { Position = position, Color = color, ContentSize = size, Opacity = (byte)(opacity * 255) }; Sprites.Add(sprite); AddChild(sprite); }
public void DrawTexture(string texturePath, CCPoint position, CCSize size, CCColor3B color, float opacity) { CCSprite sprite = new CCSprite(texturePath) { Position = position, Color = color, ContentSize = size }; Sprites.Add(sprite); AddChild(sprite); }
public Monsieur() { for (int i = 12; i < 16; i++) { Sprites.Add(HumainTileSetImageGenerator.GetTile(i)); } Type = "Monsieur"; Sexe = 0; Nom = AssignerNom(Sexe); }
public Pepe() { for (int i = 0; i < 4; i++) { Sprites.Add(HumainTileSetImageGenerator.GetTile(i)); } Type = "Pépé"; Sexe = 0; Nom = AssignerNom(Sexe); }
public Dame() { for (int i = 4; i < 8; i++) { Sprites.Add(HumainTileSetImageGenerator.GetTile(i)); } Type = "Dame"; Sexe = 1; Nom = AssignerNom(Sexe); }
private void LoadElements(XElement element, int parentTriggerIndex) { foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "sprite": Sprites.Add(new Sprite(subElement, lazyLoad: true)); break; case "specularsprite": SpecularSprites.Add(new Sprite(subElement, lazyLoad: true)); break; case "deformablesprite": DeformableSprite = new DeformableSprite(subElement, lazyLoad: true); break; case "overridecommonness": string levelType = subElement.GetAttributeString("leveltype", ""); if (!OverrideCommonness.ContainsKey(levelType)) { OverrideCommonness.Add(levelType, subElement.GetAttributeFloat("commonness", 1.0f)); } break; case "leveltrigger": case "trigger": OverrideProperties.Add(null); LevelTriggerElements.Add(subElement); LoadElements(subElement, LevelTriggerElements.Count - 1); break; case "childobject": ChildObjects.Add(new ChildObject(subElement)); break; case "overrideproperties": var propertyOverride = new LevelObjectPrefab(subElement); OverrideProperties[OverrideProperties.Count - 1] = propertyOverride; if (!propertyOverride.Sprites.Any() && propertyOverride.DeformableSprite == null) { propertyOverride.Sprites = Sprites; propertyOverride.DeformableSprite = DeformableSprite; } break; case "body": case "physicsbody": PhysicsBodyElement = subElement; PhysicsBodyTriggerIndex = parentTriggerIndex; break; } } }
public override void Read(EndianBinaryReader reader, ISection section = null) { int signature = reader.ReadInt32(); uint texturesOffset = reader.ReadUInt32(); int textureCount = reader.ReadInt32(); int spriteCount = reader.ReadInt32(); long spritesOffset = reader.ReadOffset(); long textureNamesOffset = reader.ReadOffset(); long spriteNamesOffset = reader.ReadOffset(); long spriteUnknownsOffset = reader.ReadOffset(); reader.ReadAtOffsetIf(section == null, texturesOffset, () => { TextureSet.Load(reader.BaseStream, true); }); Sprites.Capacity = spriteCount; reader.ReadAtOffset(spritesOffset, () => { for (int i = 0; i < spriteCount; i++) { var sprite = new Sprite() { ParentTextureSet = TextureSet, }; sprite.ReadFirst(reader); Sprites.Add(sprite); } }); reader.ReadAtOffset(textureNamesOffset, () => { foreach (var texture in TextureSet.Textures) { texture.Name = reader.ReadStringOffset(StringBinaryFormat.NullTerminated); } }); reader.ReadAtOffset(spriteNamesOffset, () => { foreach (var sprite in Sprites) { sprite.Name = reader.ReadStringOffset(StringBinaryFormat.NullTerminated); } }); reader.ReadAtOffset(spriteUnknownsOffset, () => { foreach (var sprite in Sprites) { sprite.ReadSecond(reader); } }); }