-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from Superyodeler/Multiplayer
Adds Multiplayer
- Loading branch information
Showing
64 changed files
with
1,602 additions
and
596 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using Blocktest.Rendering; | ||
|
||
namespace Blocktest | ||
{ | ||
/// <summary> | ||
/// Handles sprites for blocks. | ||
/// </summary> | ||
public class BlockSprites | ||
{ | ||
/// <summary> Shared block info </summary> | ||
public BlockShared blockShared; | ||
|
||
/// <summary> The block's sprite. </summary> | ||
public Drawable blockSprite; | ||
|
||
/// <summary> The sprite sheet used for smoothing the block. </summary> | ||
public SpriteSheet spriteSheet; | ||
|
||
/* METHODS */ | ||
|
||
public BlockSprites(BlockShared newBlockShared, ContentManager content) | ||
{ | ||
blockShared = newBlockShared; | ||
LoadSprite(content); | ||
} | ||
|
||
/// <summary> | ||
/// Called when the block is created by the block sprites manager. | ||
/// </summary> | ||
/// <remarks> | ||
/// DO NOT FORGET TO CALL THE BASE METHOD IF YOU OVERRIDE THIS. | ||
/// </remarks> | ||
public virtual void LoadSprite(ContentManager content) | ||
{ | ||
string path = @"Graphics\Blocks\" + blockShared.blockName.ToLower().Replace(" ", ""); | ||
try { | ||
blockSprite = new Drawable(path, new Rectangle(1, 1, 10, 10)); //this might need to be expanded in the future in case we decide to make use of the full 12x12 tiles on our spritesheets | ||
/*if (!blockShared.blockSmoothing) { | ||
return; | ||
}*/ | ||
spriteSheet = new SpriteSheet(path, 4, 4, 1); | ||
if (spriteSheet.OrderedSprites.Length <= 1) { | ||
Console.WriteLine("Block " + this + " is marked as smoothable, but a sprite sheet could not be found at " + path + "!"); | ||
} | ||
} | ||
catch (ContentLoadException) { | ||
blockSprite = new Drawable(@"Graphics\Blocks\error"); | ||
Console.WriteLine("Block " + this + " does not have an icon at " + path + "!"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Blocktest.Rendering; | ||
|
||
namespace Blocktest | ||
{ | ||
public class BlockSpritesManager | ||
{ | ||
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary> | ||
private static BlockSprites[] allBlocksSprites; | ||
/// <summary> Array which stores all blocksprites instances for referencing as if they were globals. </summary> | ||
public static BlockSprites[] AllBlocksSprites { get => allBlocksSprites; private set => allBlocksSprites = value; } | ||
|
||
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary> | ||
private static string[] blockSpriteNames; | ||
/// <summary> List used to store the names of blocks. The indexes are the corresponding block's ID. </summary> | ||
public static string[] BlockSpriteNames { get => blockSpriteNames; private set => blockSpriteNames = value; } | ||
|
||
public static void LoadBlockSprites(ContentManager content) | ||
{ | ||
AllBlocksSprites = new BlockSprites[BlockManagerShared.AllBlocks.Length]; | ||
BlockSpriteNames = new string[BlockManagerShared.AllBlocks.Length]; | ||
|
||
for(int i = 0; i < BlockManagerShared.AllBlocks.Length; i++) | ||
{ | ||
BlockShared block = BlockManagerShared.AllBlocks[i]; | ||
BlockSprites newBlockSprites = new(block, content); | ||
BlockSpriteNames[block.blockID] = block.blockName; | ||
AllBlocksSprites[block.blockID] = newBlockSprites; | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Blocktest.Rendering; | ||
namespace Blocktest | ||
{ | ||
/// <summary> | ||
/// Handles drawing <see cref="TilemapShared"/>. | ||
/// </summary> | ||
public class TilemapSprites | ||
{ | ||
public TilemapShared tilemap; | ||
|
||
/// <summary> | ||
/// Creates a <see cref="Tilemap"/>. | ||
/// </summary> | ||
/// <param name="sizeX">The width of the tilemap in tiles.</param> | ||
/// <param name="sizeY">The height of the tilemap in tiles.</param> | ||
public TilemapSprites(TilemapShared newTilemap) | ||
{ | ||
tilemap = newTilemap; | ||
} | ||
|
||
/// <summary> | ||
/// Called from the main draw loop, draws each tile in the tilemap. | ||
/// </summary> | ||
/// <remarks> | ||
/// This can almost definitely be optimized, but I'm focused on getting a decent version out | ||
/// quickly so the codebase split causes fewer issues for others. | ||
/// </remark> | ||
/// <param name="spriteBatch">The spritebatch to draw the tilemap tiles' sprite on.</param> | ||
public void DrawAllTiles(SpriteBatch spriteBatch) | ||
{ | ||
for(int x = 0; x < tilemap.tilemapSize.X; x++) | ||
{ | ||
for(int y = 0; y < tilemap.tilemapSize.Y; y++) | ||
{ | ||
TileShared? tile = tilemap.tileGrid[x, y]; | ||
BlockSprites blockSprites = BlockSpritesManager.AllBlocksSprites[tile.SourceBlock.blockID]; | ||
Drawable sprite = blockSprites.spriteSheet.OrderedSprites[tile.bitmask]; | ||
spriteBatch.Draw(sprite.Texture, new Vector2(tile.rectangle.X, tile.rectangle.Y), sprite.Bounds, tile.color); | ||
} | ||
} | ||
/*foreach (TileShared tile in tilemap.allTiles) { | ||
BlockSprites blockSprites = BlockSpritesManager.AllBlocksSprites[tile.SourceBlock.blockID]; | ||
Drawable sprite = blockSprites.spriteSheet.OrderedSprites[tile.bitmask]; | ||
spriteBatch.Draw(sprite.Texture, new Vector2(tile.rectangle.X, tile.rectangle.Y), sprite.Bounds, tile.color); | ||
}*/ | ||
} | ||
} | ||
} |
Oops, something went wrong.