Skip to content

Commit

Permalink
smoll changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jossse69 committed Aug 14, 2023
1 parent 7873e78 commit cea42ec
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 16 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": "0.2.0",
"configurations": [
{
// Use IntelliSense to find out which attributes exist for C# debugging
// Use hover for the description of the existing attributes
// For further information visit https://github.com/dotnet/vscode-csharp/blob/main/debugger-launchjson.md
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/bin/Debug/net7.0/LilRogue.dll",
"args": [],
"cwd": "${workspaceFolder}",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
}
]
}
41 changes: 41 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/LilRogue.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "publish",
"command": "dotnet",
"type": "process",
"args": [
"publish",
"${workspaceFolder}/LilRogue.csproj",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary"
],
"problemMatcher": "$msCompile"
},
{
"label": "watch",
"command": "dotnet",
"type": "process",
"args": [
"watch",
"run",
"--project",
"${workspaceFolder}/LilRogue.csproj"
],
"problemMatcher": "$msCompile"
}
]
}
4 changes: 2 additions & 2 deletions Grid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private struct CellData

private CellData[,] gridArray;

public int Width { get; }
public int Height { get; }
public int Width { get; set; }
public int Height { get; set; }

public Grid(int width, int height)
{
Expand Down
6 changes: 3 additions & 3 deletions Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class Player : Entity
private SchedulingSystem _schedulingSystem;
private List<Mob> mobs = new List<Mob>();


public static SoundBuffer DMGsoundBuffer = new SoundBuffer("hitHurt.wav");
public Sound DMGsound = new Sound(DMGsoundBuffer);
public static SoundBuffer attacksoundBuffer = new SoundBuffer("attack.wav");
Expand All @@ -34,7 +35,6 @@ public Player(Grid<char> grid, Vector2i position, Color fillColor, Color backgro
{
movementTimer.Start();
_schedulingSystem = schedulingSystem;
this.mobs = mobs;
if (map != null)
{
map.ComputeFov(Position.X, Position.Y, 10, true);
Expand Down Expand Up @@ -129,7 +129,7 @@ public void tryToMove(int x, int y, Map map, List<Mob> mobs)
}
else
{
Console.WriteLine("already dead, moving on...");
return;
}
}
}
Expand Down Expand Up @@ -171,7 +171,7 @@ public void TakeDamage(double damage)
var DMGmuti = Math.Clamp(RNG.NextDouble(), 0.8, 1);
var finalDMG = (double) damage * (DMGmuti * (armor + 1 - 0.6));

this.HP -= (int) Math.Round(Math.Clamp(finalDMG * 1.25, 0, 999999), 1);
this.HP -= (int) Math.Round(Math.Clamp(finalDMG * 0.75, 0, 999999), 1);

DMGsound.Play();
}
Expand Down
4 changes: 2 additions & 2 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ static void Main(string[] args)
//UI and ui grid
var UIgrid = new Grid<char> (UIWidth, UIHeight);
var popupwindowgrid = new Grid<char> (mapWidth, mapHeight);
var ui = new UI(UIgrid);
var popupui = new UI(popupwindowgrid);
var ui = new UI(UIgrid, UIWidth, UIHeight);
var popupui = new UI(popupwindowgrid, UIWidth, UIHeight);
var upStairsPosition = FindWalkableCell(gameMap);
var downStairsPosition = FindWalkableCell(gameMap);

Expand Down
7 changes: 5 additions & 2 deletions UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@

namespace LilRogue
{
public class UI
public class UI : Grid<char>
{
private Grid<char> grid;

public UI(Grid<char> grid)
public UI(Grid<char> grid, int width, int height)
: base(width, height)
{
this.grid = grid;
this.grid.Width = width;
this.grid.Height = height;
}

public void DrawBorderedBox(int x, int y, int width, int height, Color borderColor, Color fillColor)
Expand Down
Binary file modified bin/Debug/net7.0/LilRogue.dll
Binary file not shown.
18 changes: 11 additions & 7 deletions mob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public Vector2i GoToLocation(int x, int y, Map map)
return new Vector2i(x, y);
}

PathFinder pathFinder = new PathFinder(map.getMap(),0);
PathFinder pathFinder = new PathFinder(map.getMap(),1);
RogueSharp.Path path = pathFinder.ShortestPath(map.GetCell(Position.X, Position.Y), map.GetCell(x, y));

if (path != null)
Expand Down Expand Up @@ -69,7 +69,7 @@ public void Update(Map map, Player player, SchedulingSystem schedulingSystem, Li
//update state
if (CanbeSeen(map))
{
lastSeenPlayerPosition = new Vector2i(player.Position.X, player.Position.Y);

state = "chase";
}
else if (lastSeenPlayerPosition.X != -1 && lastSeenPlayerPosition.Y != -1)
Expand All @@ -81,24 +81,28 @@ public void Update(Map map, Player player, SchedulingSystem schedulingSystem, Li

for (int i = 0; i < schedulingSystem.calculateTimeSteps(schedulingSystem.time, schedulingSystem.time + 1, 2); i++)
{
if (CanbeSeen(map))
{
lastSeenPlayerPosition = new Vector2i(player.Position.X, player.Position.Y);
}

ToGoalPosition = GoToLocation(lastSeenPlayerPosition.X, lastSeenPlayerPosition.Y, map);
//check if the mob has reached the goal position
foreach (var mob in mobs)
if (ToGoalPosition.X == player.Position.X && ToGoalPosition.Y == player.Position.Y)
{
Console.WriteLine("player reached! damaging player...");

player.TakeDamage(4.25);
break;
}
else if (ToGoalPosition.X == mob.Position.X && ToGoalPosition.Y == mob.Position.Y) //blocked by another mob
{
Console.WriteLine("blocked by another mob...");

break;
}
else if (ToGoalPosition.X == mob.Position.X && ToGoalPosition.Y == mob.Position.Y)
{
Console.WriteLine("cant see player...");

lastSeenPlayerPosition = new Vector2i(-1, -1);
break;
}
Expand All @@ -122,12 +126,12 @@ public void Update(Map map, Player player, SchedulingSystem schedulingSystem, Li
foreach (var mob in mobs)
if (ToGoalPosition.X == player.Position.X && ToGoalPosition.Y == player.Position.Y)
{
Console.WriteLine("blocked by player...");

break;
}
else if (ToGoalPosition.X == mob.Position.X && ToGoalPosition.Y == mob.Position.Y) //blocked by another mob
{
Console.WriteLine("blocked by another mob...");

break;
}
else
Expand Down

0 comments on commit cea42ec

Please sign in to comment.