Compare commits
9 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b1593f0094 | |
|
|
5d0a0fa622 | |
|
|
94f353af5b | |
|
|
c400fd62fe | |
|
|
7e71ade965 | |
|
|
22b5f6e62d | |
|
|
82fddae704 | |
|
|
08249fc196 | |
|
|
8525ea8c69 |
|
|
@ -22,11 +22,18 @@ jobs:
|
|||
- name: Build
|
||||
run: dotnet build --no-restore
|
||||
- name: Publish
|
||||
run: dotnet publish -r linux-x64 --self-contained
|
||||
run: cd Mine2d && make
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
with:
|
||||
# Artifact name
|
||||
name: Linux build
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: Mine2d/bin/Debug/net6.0/linux-x64/publish/Mine2d
|
||||
path: Mine2d/build/linux-64.zip
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.0
|
||||
with:
|
||||
# Artifact name
|
||||
name: Windows build
|
||||
# A file, directory or wildcard pattern that describes what to upload
|
||||
path: Mine2d/build/win-64.zip
|
||||
|
|
|
|||
|
|
@ -2,10 +2,12 @@ all: win-64 linux-64
|
|||
|
||||
win-64:
|
||||
dotnet publish --runtime win-x64 --output build/win-64
|
||||
cp credits.md build/win-64
|
||||
zip -r build/win-64.zip build/win-64
|
||||
|
||||
linux-64:
|
||||
dotnet publish --runtime linux-x64 --output build/linux-64
|
||||
cp credits.md build/linux-64
|
||||
zip -r build/linux-64.zip build/linux-64
|
||||
|
||||
clean:
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 255 B After Width: | Height: | Size: 279 B |
Binary file not shown.
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 200 B |
Binary file not shown.
|
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 284 B |
|
|
@ -0,0 +1,17 @@
|
|||
# Credits of used assets and Libraries
|
||||
|
||||
## Assets
|
||||
|
||||
* Character - [CutieCatTv](https://github.com/CutieCatTv)
|
||||
* Nova Mono Font - Open Font License
|
||||
* audio/block_break.wav - dxeyes - CC BY 4.0
|
||||
* audio/block_hit.wav - MattRuthSound - CC BY 4.0
|
||||
* audio/block_hit_alt.wav - MattRuthSound - CC BY 4.0
|
||||
* audio/music-loop.wav - [Chris aka el3usis](https://www.youtube.com/@Eleusis/featured)
|
||||
|
||||
## Libraries
|
||||
|
||||
* SDL2# - zlib
|
||||
* SDL2 - zlib
|
||||
* Newtonsoft.Json - MIT
|
||||
* WatsonTcp - MIT
|
||||
|
|
@ -5,6 +5,13 @@ public enum Sound
|
|||
BlockHit,
|
||||
BlockBreak,
|
||||
ItemPickup,
|
||||
MusicLoop,
|
||||
Step0,
|
||||
Step1,
|
||||
Step2,
|
||||
Step3,
|
||||
Step4,
|
||||
Step5,
|
||||
}
|
||||
|
||||
public class AudioPlayer
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using Mine2d.engine;
|
||||
using Mine2d.engine.system.annotations;
|
||||
using Mine2d.game.backend.network.packets;
|
||||
using Mine2d.game.core;
|
||||
|
||||
namespace Mine2d.game.backend.interactor;
|
||||
|
||||
|
|
@ -13,4 +14,35 @@ public class Audio
|
|||
var ctx = Context.Get();
|
||||
ctx.GameAudio.Play(Sound.BlockBreak);
|
||||
}
|
||||
|
||||
[Interaction(InteractorKind.Client, PacketType.Tick)]
|
||||
public static void Tick()
|
||||
{
|
||||
var ctx = Context.Get();
|
||||
if (ctx.FrontendGameState.NextMusicPlay < DateTime.Now)
|
||||
{
|
||||
ctx.GameAudio.Play(Sound.MusicLoop);
|
||||
ctx.FrontendGameState.NextMusicPlay = DateTime.Now.AddSeconds(130);
|
||||
}
|
||||
if (false && ctx.FrontendGameState.NextStepPlay < DateTime.Now && PlayerEntity.GetSelf().PlayerMovementState.CurrentVelocity != Vector2.Zero)
|
||||
{
|
||||
ctx.GameAudio.Play(GetRandomStepSound());
|
||||
ctx.FrontendGameState.NextStepPlay = DateTime.Now.AddSeconds(0.2);
|
||||
}
|
||||
}
|
||||
|
||||
private static Sound GetRandomStepSound()
|
||||
{
|
||||
var sound = new Random().NextInt64(0, 6);
|
||||
return sound switch
|
||||
{
|
||||
0 => Sound.Step0,
|
||||
1 => Sound.Step1,
|
||||
2 => Sound.Step2,
|
||||
3 => Sound.Step3,
|
||||
4 => Sound.Step4,
|
||||
5 => Sound.Step5,
|
||||
_ => Sound.Step0
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class Breaking
|
|||
{
|
||||
var tileRegistry = ctx.TileRegistry;
|
||||
var hardness = tileRegistry.GetTile(tileId).Hardness;
|
||||
var hardnessBonus = Math.Min(1, player.GetHarvestLevel() / hardness);
|
||||
player.MiningCooldown = 50 - (player.GetMiningSpeed() * hardnessBonus);
|
||||
var hardnessBonus = Math.Min(1, player.GetHarvestLevel() / (double)hardness);
|
||||
player.MiningCooldown = (int)(50 - (player.GetMiningSpeed() * hardnessBonus));
|
||||
if(tile.Hits == 0) {
|
||||
ctx.GameState.World.Cracks.Enqueue(new CrackQueueEntry
|
||||
{
|
||||
|
|
@ -83,7 +83,7 @@ public class Breaking
|
|||
}
|
||||
|
||||
[Interaction(InteractorKind.Server, PacketType.BlockBroken)]
|
||||
public static void BreakServer(BlockBrokenPacket packet)
|
||||
public static void BlockBrokenServer(BlockBrokenPacket packet)
|
||||
{
|
||||
var ctx = Context.Get();
|
||||
var tile = ctx.TileRegistry.GetTile(packet.Tile.Id);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,6 @@ public class Camera
|
|||
var scale = ctx.FrontendGameState.Settings.GameScale;
|
||||
var windowWidth = ctx.FrontendGameState.WindowWidth;
|
||||
var windowHeight = ctx.FrontendGameState.WindowHeight;
|
||||
this.Position = target - (new Vector2(windowWidth, windowHeight) / 2) / scale;
|
||||
this.Position = target - (new Vector2(windowWidth, windowHeight) / 2 / scale);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Mine2d.game.core;
|
||||
|
||||
public static class Debugger
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ public class PlayerEntity
|
|||
bool hasCollision;
|
||||
do
|
||||
{
|
||||
var pL = player.Position + new Vector2(0, -8);
|
||||
var pL2 = player.Position + new Vector2(0, -24);
|
||||
var pL = player.Position + new Vector2(3, -2);
|
||||
var pL2 = player.Position + new Vector2(3, -24);
|
||||
hasCollision =
|
||||
(world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL))
|
||||
|| (world.HasChunkAt(pL2) && world.GetChunkAt(pL2).HasSolidTileAt(pL2));
|
||||
|
|
@ -89,8 +89,8 @@ public class PlayerEntity
|
|||
} while (hasCollision);
|
||||
do
|
||||
{
|
||||
var pR = player.Position + new Vector2(14, -8);
|
||||
var pR2 = player.Position + new Vector2(14, -24);
|
||||
var pR = player.Position + new Vector2(12, -2);
|
||||
var pR2 = player.Position + new Vector2(12, -24);
|
||||
hasCollision =
|
||||
(world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR))
|
||||
|| (world.HasChunkAt(pR2) && world.GetChunkAt(pR2).HasSolidTileAt(pR2));
|
||||
|
|
@ -102,8 +102,8 @@ public class PlayerEntity
|
|||
} while (hasCollision);
|
||||
do
|
||||
{
|
||||
var pL = player.Position + new Vector2(0, 0);
|
||||
var pR = player.Position + new Vector2(14, 0);
|
||||
var pL = player.Position + new Vector2(3, 0);
|
||||
var pR = player.Position + new Vector2(12, 0);
|
||||
hasCollision =
|
||||
(world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL))
|
||||
|| (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR));
|
||||
|
|
@ -115,8 +115,8 @@ public class PlayerEntity
|
|||
} while (hasCollision);
|
||||
do
|
||||
{
|
||||
var pL = player.Position + new Vector2(0, -28);
|
||||
var pR = player.Position + new Vector2(14, -28);
|
||||
var pL = player.Position + new Vector2(3, -28);
|
||||
var pR = player.Position + new Vector2(12, -28);
|
||||
hasCollision =
|
||||
(world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL))
|
||||
|| (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR));
|
||||
|
|
@ -129,8 +129,8 @@ public class PlayerEntity
|
|||
|
||||
{
|
||||
var groundCheckPosition = player.Position - new Vector2(0, -1f);
|
||||
var pL = groundCheckPosition + new Vector2(0, 0);
|
||||
var pR = groundCheckPosition + new Vector2(14, 0);
|
||||
var pL = groundCheckPosition + new Vector2(3, 0);
|
||||
var pR = groundCheckPosition + new Vector2(12, 0);
|
||||
movement.IsGrounded = (world.HasChunkAt(pL) && world.GetChunkAt(pL).HasSolidTileAt(pL))
|
||||
|| (world.HasChunkAt(pR) && world.GetChunkAt(pR).HasSolidTileAt(pR));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,9 @@ public class ItemStack
|
|||
{
|
||||
return Context.Get().ItemRegistry.GetItem(this.Id).GetKind();
|
||||
}
|
||||
|
||||
public ItemStack Clone()
|
||||
{
|
||||
return new ItemStack(this.Id, this.Count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ public class ItemRegistry
|
|||
// Pickaxes
|
||||
this.Register(ItemId.PickaxeBasic, new PickaxeItem(ItemId.PickaxeBasic, "Basic Pickaxe", "items.pickaxe-basic", 15, 4));
|
||||
this.Register(ItemId.PickaxeStone, new PickaxeItem(ItemId.PickaxeStone, "Stone Pickaxe", "items.pickaxe-stone", 25, 6));
|
||||
this.Register(ItemId.PickaxeIron, new PickaxeItem(ItemId.PickaxeIron, "Iron Pickaxe", "items.pickaxe-iron", 40, 7));
|
||||
this.Register(ItemId.PickaxeGold, new PickaxeItem(ItemId.PickaxeGold, "Gold Pickaxe", "items.pickaxe-gold", 60, 8));
|
||||
this.Register(ItemId.PickaxeIron, new PickaxeItem(ItemId.PickaxeIron, "Iron Pickaxe", "items.pickaxe-iron", 30, 7));
|
||||
this.Register(ItemId.PickaxeGold, new PickaxeItem(ItemId.PickaxeGold, "Gold Pickaxe", "items.pickaxe-gold", 35, 9));
|
||||
// Materials
|
||||
this.Register(ItemId.CopperWire, new Item(ItemId.CopperWire, "Copper Wire", "items.copper-wire" ));
|
||||
this.Register(ItemId.Silicon, new Item(ItemId.Silicon, "Silicon", "items.silicon" ));
|
||||
|
|
|
|||
|
|
@ -33,17 +33,13 @@ public class TileRegistry
|
|||
public void RegisterTile()
|
||||
{
|
||||
this.Tiles.Add(1, new Tile("stone", "stone", 5, ItemId.Stone));
|
||||
this.Tiles.Add(2, new OreTile("ore1", new[] { "stone", "ore1" }, 5));
|
||||
this.Tiles.Add(3, new OreTile("ore2", new[] { "stone", "ore2" }, 7));
|
||||
this.Tiles.Add(4, new OreTile("ore3", new[] { "stone", "ore3" }, 8));
|
||||
this.Tiles.Add(5, new OreTile("ore4", new[] { "stone", "ore4" }, 10));
|
||||
this.Tiles.Add(6, new Workbench("workbench", "workbench", 10));
|
||||
this.Tiles.Add(7, new OreTile("iron-ore", new[] { "stone", "iron-ore" }, 6, ItemId.RawIron));
|
||||
this.Tiles.Add(8, new OreTile("copper-ore", new[] { "stone", "copper-ore" }, 6, ItemId.RawCopper));
|
||||
this.Tiles.Add(9, new OreTile("tin-ore", new[] { "stone", "tin-ore" }, 6, ItemId.RawTin));
|
||||
this.Tiles.Add(9, new OreTile("tin-ore", new[] { "stone", "tin-ore" }, 7, ItemId.RawTin));
|
||||
this.Tiles.Add(10, new OreTile("silver-ore", new[] { "stone", "silver-ore" }, 7, ItemId.RawSilver));
|
||||
this.Tiles.Add(11, new OreTile("gold-ore", new[] { "stone", "gold-ore" }, 8, ItemId.RawGold));
|
||||
this.Tiles.Add(12, new OreTile("lead-ore", new[] { "stone", "lead-ore" }, 9, ItemId.RawLead));
|
||||
this.Tiles.Add(12, new OreTile("lead-ore", new[] { "stone", "lead-ore" }, 8, ItemId.RawLead));
|
||||
this.Tiles.Add(11, new OreTile("gold-ore", new[] { "stone", "gold-ore" }, 9, ItemId.RawGold));
|
||||
this.Tiles.Add(13, new OreTile("platinum-ore", new[] { "stone", "platinum-ore" }, 10, ItemId.RawPlatinum));
|
||||
this.Tiles.Add(14, new OreTile("cobalt-ore", new[] { "stone", "cobalt-ore" }, 11, ItemId.RawCobalt));
|
||||
this.Tiles.Add(15, new OreTile("tungsten-ore", new[] { "stone", "tungsten-ore" }, 15, ItemId.RawTungsten));
|
||||
|
|
|
|||
|
|
@ -134,6 +134,16 @@ public class Workbench : Tile
|
|||
new ItemStack(ItemId.Fuse, 1),
|
||||
}
|
||||
});
|
||||
Recipes.Add(new Recipe
|
||||
{
|
||||
Result = new ItemStack(ItemId.Workbench, 1),
|
||||
Ingredients = new List<ItemStack>
|
||||
{
|
||||
new ItemStack(ItemId.Stone, 1),
|
||||
new ItemStack(ItemId.Fuse, 1),
|
||||
new ItemStack(ItemId.CopperWire, 3),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public override bool IsSolid()
|
||||
|
|
|
|||
|
|
@ -33,8 +33,8 @@ public class ChunkGenerator
|
|||
{
|
||||
for (var j = 0; j < Constants.ChunkSize; j++)
|
||||
{
|
||||
var n = (Noise.coherentNoise(i + (x * 32), j + (y * 32), 0, 1, 25, 0.5f, 0.9f));
|
||||
var n2 = (Noise2.coherentNoise(i + (x * 32), j + (y * 32), 0, 1, 25, 0.5f, 0.9f));
|
||||
var n = Noise.coherentNoise((int)((i + (x * 32)) * 0.6), (int)((j + (y * 32)) * 1), 0, 1, 25, 0.5f, 0.9f);
|
||||
var n2 = Noise2.coherentNoise((int)((i + (x * 32)) * 0.6), (int)((j + (y * 32)) * 1), 0, 1, 25, 0.5f, 0.9f);
|
||||
// Console.WriteLine(i * (x * 32) + " "+ j * (y * 32));
|
||||
if (n > 0.08 || n2 > 0.08) continue;
|
||||
chunk.SetTile(i, j, fill);
|
||||
|
|
@ -65,10 +65,30 @@ public class ChunkGenerator
|
|||
else
|
||||
{
|
||||
fill.Id = (int)WG.GetRandomOreAt(j + (y * 32));
|
||||
if (new Random().NextInt64(0, 130) < 1)
|
||||
if (new Random().NextInt64(0, 100) < 1)
|
||||
{
|
||||
fill.Id = (int)Tiles.CoalOre;
|
||||
}
|
||||
if (fill.Id != 1)
|
||||
{
|
||||
var pX = i;
|
||||
var pY = j;
|
||||
var maxCount = new Random().NextInt64(fill.Id == (int)Tiles.CoalOre ? 3 : 1, fill.Id == (int)Tiles.CoalOre ? 10 : 6);
|
||||
for (var count = 0; count < maxCount; count++)
|
||||
{
|
||||
var delta = new Random().NextInt64(-1, 2);
|
||||
var dir = new Random().NextInt64(0, 2);
|
||||
pX += (int)(dir == 0 ? delta : 0);
|
||||
pY += (int)(dir == 1 ? delta : 0);
|
||||
Console.WriteLine("Try Adding ader");
|
||||
Console.WriteLine(pX + " " + pY);
|
||||
if (chunk.HasTile(pX, pY))
|
||||
{
|
||||
chunk.SetTile(pX, pY, STile.From(fill.Id));
|
||||
Console.WriteLine("Adding ader");
|
||||
}
|
||||
}
|
||||
}
|
||||
chunk.SetTile(i, j, fill);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ public class WorldGenerator
|
|||
}
|
||||
}
|
||||
|
||||
var rng = random.Next(0, 700);
|
||||
var rng = random.Next(0, 1050);
|
||||
if (rng < ores.Count)
|
||||
{
|
||||
return ores[rng];
|
||||
|
|
|
|||
|
|
@ -12,6 +12,13 @@ public class GameAudio
|
|||
this.audioPlayer.Register(Sound.BlockBreak, "assets.audio.block_break.wav");
|
||||
this.audioPlayer.Register(Sound.BlockHit, "assets.audio.block_hit_alt.wav");
|
||||
this.audioPlayer.Register(Sound.ItemPickup, "assets.audio.item_pickup.wav");
|
||||
this.audioPlayer.Register(Sound.MusicLoop, "assets.audio.music-loop.wav");
|
||||
this.audioPlayer.Register(Sound.Step0, "assets.audio.step0.wav");
|
||||
this.audioPlayer.Register(Sound.Step1, "assets.audio.step1.wav");
|
||||
this.audioPlayer.Register(Sound.Step2, "assets.audio.step2.wav");
|
||||
this.audioPlayer.Register(Sound.Step3, "assets.audio.step3.wav");
|
||||
this.audioPlayer.Register(Sound.Step4, "assets.audio.step4.wav");
|
||||
this.audioPlayer.Register(Sound.Step5, "assets.audio.step5.wav");
|
||||
}
|
||||
|
||||
public void Play(Sound sound)
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class WorkbenchInventory : Inventory
|
|||
{
|
||||
player.Inventory.RemoveItemStack(i);
|
||||
}
|
||||
player.Inventory.PickupItemStack(r.Result);
|
||||
player.Inventory.PickupItemStack(r.Result.Clone());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public class WorldRenderer : IRenderer
|
|||
{
|
||||
ctx.Renderer.DrawText("" + Math.Round(ChunkGenerator.Noise.coherentNoise(
|
||||
(chunk.X * Constants.ChunkSize) + x,
|
||||
(chunk.Y * Constants.ChunkSize) + y,
|
||||
(int)(((chunk.Y * Constants.ChunkSize) + y)*0.6),
|
||||
0
|
||||
), 4),
|
||||
(drawX - (int)camera.Position.X) * scale,
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ public class FrontendGameState
|
|||
public InventoryKind OpenInventory { get; set; } = InventoryKind.None;
|
||||
public InputState InputState { get; set; } = new();
|
||||
public DebugState DebugState { get; set; } = new();
|
||||
public DateTime NextMusicPlay { get; set; } = DateTime.MinValue;
|
||||
public DateTime NextStepPlay { get; set; } = DateTime.MinValue;
|
||||
}
|
||||
|
||||
public class DebugState {
|
||||
|
|
|
|||
Loading…
Reference in New Issue