Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
c669048
rendering terrain
pcen Jun 19, 2023
c47f8a8
add Camera2D
pcen Jun 19, 2023
a3f0a4e
test drawing units in word coordinates
pcen Jun 19, 2023
37e9b95
wip
pcen Jun 19, 2023
8bc8951
simplify unit sprite test demo - AnimationManager could be simpler bu…
pcen Jun 19, 2023
487ef48
enable pixel snapping - removes world seams
pcen Jun 19, 2023
46427a3
render roads in tilemap
pcen Jun 20, 2023
1b9bf26
add logic for drawing rails on tilemap - missing separate layer
pcen Jun 21, 2023
6af39d6
working rails layer
pcen Jun 21, 2023
d5031ea
simple abstraction for loading atlas sources
pcen Jun 21, 2023
7bcdafb
add resources and clear cells when empty
pcen Jun 21, 2023
e633c15
track net lines changed
pcen Jun 21, 2023
0c3a0e7
working rivers
pcen Jun 21, 2023
e9395cb
separate notion of layer and atlas in MapView
pcen Jun 21, 2023
623ae5a
add mountains
pcen Jun 21, 2023
4d203f5
get rid of incorrect y offsets (tiles are already centered)
pcen Jun 21, 2023
70fcead
offset is necessary for oversized tiles...
pcen Jun 21, 2023
1ca5aac
add volcanos
pcen Jun 21, 2023
0c7aab2
single terrain overlay
pcen Jun 21, 2023
58e8743
add full left skirt to terrain layer
pcen Jun 21, 2023
f414884
detect edges of map in world space
pcen Jun 22, 2023
9c26362
fix bad bounds for forest tiles and use full resource tileset
pcen Jun 22, 2023
f4ed915
wip
pcen Jun 22, 2023
2eaefdd
tile set loader so specific assets can be overwritten in the future
pcen Jun 22, 2023
871471b
add marsh to tilemap terrain overlay layer
pcen Jun 22, 2023
2d3e98e
camera can center on tiles
pcen Jun 22, 2023
a28145b
buildings on tilemap
pcen Jun 22, 2023
08b85f3
remove ported code
pcen Jun 22, 2023
6b78afa
load goodyhut pcx
pcen Jun 22, 2023
57867f5
pixel perfect transforms
pcen Jun 22, 2023
697f910
dedupe code
pcen Jun 22, 2023
74c354c
enable Y sort for each tilemap layer
pcen Jun 25, 2023
6ebfcab
fix rebase issue
pcen Jul 9, 2023
e46a094
implement grid layer
pcen Jul 31, 2023
eec5457
rendering terrain
pcen Jun 19, 2023
74a9208
fix rebase
pcen Jul 31, 2023
aa7877f
simplify unit selection with null coalescing operator
pcen Aug 20, 2023
1ffb61a
rendering terrain
pcen Jun 19, 2023
331463c
rendering terrain
pcen Jun 19, 2023
af12135
add Camera2D
pcen Jun 19, 2023
e040293
load fog of war pcx
pcen Aug 1, 2023
224b613
reveal fog when units move
pcen Aug 1, 2023
fcf32a7
z indices
pcen Aug 1, 2023
233c114
use Z index readonly for city scene
pcen Aug 1, 2023
00c2152
rendering terrain
pcen Jun 19, 2023
e094e72
terrain and tiles wrap horizontally, not cities or units
pcen Aug 2, 2023
a41febe
clearer enum name, use enum values instead of booleans
pcen Aug 2, 2023
5c2d568
wrap units
pcen Aug 2, 2023
6802edd
do wrap checks in Camera
pcen Aug 3, 2023
42cbaf3
wrap horizontally with fewer map jumps
pcen Aug 3, 2023
e565a55
horizontally wrap cities
pcen Aug 3, 2023
062391c
dry up wrap offset code
pcen Aug 3, 2023
bfed72f
clean up
pcen Aug 3, 2023
c8002a2
fix left wrap
pcen Aug 3, 2023
b881fe0
simpler predicate functions, less error prone state in camera
pcen Aug 3, 2023
fc20ce4
add tile leeway for wrapping to hide temporary map tear
pcen Aug 3, 2023
6fc22f0
only check for wrapping when camera moves, better naming, comment mai…
pcen Aug 3, 2023
289eae6
remove unused code
pcen Sep 17, 2023
48aecb4
fix issue where getVisibleWorld initially uses invalid GlobalCanvasTr…
pcen Sep 17, 2023
ae178c6
Fixed issue with rivers not showing, added deltas
benskywalker Sep 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ data_*/

# Below here are ignores imported from Puppeteer's project
sav/
*.png
*.pcx
*.flc
*.mp4
Expand All @@ -43,7 +42,7 @@ project.lock.json
*.sln.docstates
C7.ini
log.txt
*.csproj.old
*.csproj.old*

# Build results
[Dd]ebug/
Expand Down
29 changes: 16 additions & 13 deletions C7/AnimationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@ public string getUnitFlicFilepath(UnitPrototype unit, MapUnit.AnimatedAction act
// The flic loading code parses the animations into a 2D array, where each row is an animation
// corresponding to a tile direction. flicRowToAnimationDirection maps row number -> direction.
private static TileDirection flicRowToAnimationDirection(int row) {
switch (row) {
case 0: return TileDirection.SOUTHWEST;
case 1: return TileDirection.SOUTH;
case 2: return TileDirection.SOUTHEAST;
case 3: return TileDirection.EAST;
case 4: return TileDirection.NORTHEAST;
case 5: return TileDirection.NORTH;
case 6: return TileDirection.NORTHWEST;
case 7: return TileDirection.WEST;
}
// TODO: I wanted to add a TileDirection.INVALID enum value when implementing this,
// but adding an INVALID value broke stuff: https://github.com/C7-Game/Prototype/issues/397
return TileDirection.NORTH;
return row switch {
0 => TileDirection.SOUTHWEST,
1 => TileDirection.SOUTH,
2 => TileDirection.SOUTHEAST,
3 => TileDirection.EAST,
4 => TileDirection.NORTHEAST,
5 => TileDirection.NORTH,
6 => TileDirection.NORTHWEST,
7 => TileDirection.WEST,
_ => TileDirection.NORTH,
};
}

public static void loadFlicAnimation(string path, string name, ref SpriteFrames frames, ref SpriteFrames tint) {
Expand All @@ -123,10 +123,9 @@ public static void loadFlicAnimation(string path, string name, ref SpriteFrames
}
}

public static void loadCursorAnimation(string path, ref SpriteFrames frames) {
public static void loadCursorAnimation(string path, string name, ref SpriteFrames frames) {
Flic flic = Util.LoadFlic(path);
int row = 0;
string name = "cursor";
frames.AddAnimation(name);

for (int col = 0; col < flic.Images.GetLength(1); col++) {
Expand Down Expand Up @@ -247,4 +246,8 @@ public double getDuration() {
double frameCount = flicSheet.indices.GetWidth() / flicSheet.spriteWidth;
return frameCount / 20.0; // Civ 3 anims often run at 20 FPS TODO: Do they all? How could we tell? Is it exactly 20 FPS?
}

public override string ToString() {
return $"{unit.name}: {action}";
}
}
26 changes: 10 additions & 16 deletions C7/AnimationTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Threading;
using System.Linq;
using C7GameData;
using C7Engine;

public partial class AnimationTracker {
private AnimationManager civ3AnimData;
Expand All @@ -22,12 +21,9 @@ public struct ActiveAnimation {
public C7Animation anim;
}

private Dictionary<string, ActiveAnimation> activeAnims = new Dictionary<string, ActiveAnimation>();
public Dictionary<string, ActiveAnimation> activeAnims = new Dictionary<string, ActiveAnimation>();

public long getCurrentTimeMS()
{
return DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
}
public long getCurrentTimeMS() => DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

private string getTileID(Tile tile)
{
Expand All @@ -45,8 +41,9 @@ private void startAnimation(string id, C7Animation anim, AutoResetEvent completi
if (activeAnims.TryGetValue(id, out aa)) {
// If there's already an animation playing for this unit, end it first before replacing it
// TODO: Consider instead queueing up the new animation until after the first one is completed
if (aa.completionEvent != null)
if (aa.completionEvent is not null) {
aa.completionEvent.Set();
}
}
aa = new ActiveAnimation { startTimeMS = currentTimeMS, endTimeMS = currentTimeMS + animDurationMS, completionEvent = completionEvent,
ending = ending, anim = anim };
Expand Down Expand Up @@ -110,19 +107,19 @@ public bool hasCurrentAction(MapUnit unit)

public void update()
{
long currentTimeMS = (! endAllImmediately) ? getCurrentTimeMS() : long.MaxValue;
long currentTimeMS = !endAllImmediately ? getCurrentTimeMS() : long.MaxValue;
var keysToRemove = new List<string>();
foreach (var guidAAPair in activeAnims.Where(guidAAPair => guidAAPair.Value.endTimeMS <= currentTimeMS)) {
var (id, aa) = (guidAAPair.Key, guidAAPair.Value);
if (aa.completionEvent != null) {
if (aa.completionEvent is not null) {
aa.completionEvent.Set();
aa.completionEvent = null; // So event is only triggered once
}
if (aa.ending == AnimationEnding.Stop)
if (aa.ending == AnimationEnding.Stop) {
keysToRemove.Add(id);
}
}
foreach (var key in keysToRemove)
activeAnims.Remove(key);
keysToRemove.ForEach(key => activeAnims.Remove(key));
}

public MapUnit.Appearance getUnitAppearance(MapUnit unit)
Expand Down Expand Up @@ -158,9 +155,6 @@ public MapUnit.Appearance getUnitAppearance(MapUnit unit)
public C7Animation getTileEffect(Tile tile)
{
ActiveAnimation aa;
if (activeAnims.TryGetValue(getTileID(tile), out aa))
return aa.anim;
else
return null;
return activeAnims.TryGetValue(getTileID(tile), out aa) ? aa.anim : null;
}
}
2 changes: 1 addition & 1 deletion C7/Art/Title_Screen.jpg.import
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

importer="texture"
type="CompressedTexture2D"
uid="uid://ds3dwrouk7g55"
uid="uid://bkxkefpbld468"
path="res://.godot/imported/Title_Screen.jpg-067f940f7a89fae79632e2159c786062.ctex"
metadata={
"vram_texture": false
Expand Down
Binary file added C7/Art/grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 15 additions & 5 deletions C7/C7Game.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=14 format=3 uid="uid://cldl5nk4n61m2"]
[gd_scene load_steps=15 format=3 uid="uid://cldl5nk4n61m2"]

[ext_resource type="Script" path="res://Game.cs" id="1"]
[ext_resource type="Script" path="res://Map/MapViewCamera.cs" id="2_xrlqh"]
[ext_resource type="Script" path="res://UIElements/Advisors/Advisors.cs" id="3"]
[ext_resource type="Script" path="res://UIElements/UpperLeftNav/MenuButton.cs" id="4"]
[ext_resource type="Script" path="res://UIElements/UpperLeftNav/CivilopediaButton.cs" id="5"]
Expand Down Expand Up @@ -61,12 +62,19 @@ _data = {
[node name="C7Game" type="Node2D"]
script = ExtResource("1")

[node name="MapViewCamera" type="Camera2D" parent="."]
script = ExtResource("2_xrlqh")

[node name="CanvasLayer" type="CanvasLayer" parent="."]

[node name="Advisor" type="CenterContainer" parent="CanvasLayer"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -574.0
offset_top = -322.0
offset_right = -574.0
offset_bottom = -322.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource("10")
Expand All @@ -86,6 +94,7 @@ script = ExtResource("9")

[node name="Control" type="Control" parent="CanvasLayer"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = 10.0
Expand Down Expand Up @@ -173,12 +182,14 @@ text = "End Turn"

[node name="SlideOutBar" type="Control" parent="CanvasLayer/Control"]
layout_mode = 1
anchors_preset = 11
anchor_left = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = 50.0
offset_right = -10.0
offset_bottom = -200.0
offset_left = -108.0
offset_top = 80.0
offset_right = -108.0
offset_bottom = -170.0
grow_horizontal = 0
grow_vertical = 2
mouse_filter = 1
Expand Down Expand Up @@ -248,7 +259,6 @@ libraries = {
[connection signal="TurnStarted" from="." to="CanvasLayer/Control/GameStatus" method="OnTurnStarted"]
[connection signal="BuildCity" from="CanvasLayer/PopupOverlay" to="." method="OnBuildCity"]
[connection signal="HidePopup" from="CanvasLayer/PopupOverlay" to="CanvasLayer/PopupOverlay" method="OnHidePopup"]
[connection signal="Quit" from="CanvasLayer/PopupOverlay" to="." method="OnQuitTheGame"]
[connection signal="UnitDisbanded" from="CanvasLayer/PopupOverlay" to="." method="OnUnitDisbanded"]
[connection signal="BlinkyEndTurnButtonPressed" from="CanvasLayer/Control/GameStatus" to="." method="OnPlayerEndTurn"]
[connection signal="pressed" from="CanvasLayer/Control/ToolBar/MarginContainer/HBoxContainer/AdvisorButton" to="CanvasLayer/Advisor" method="ShowLatestAdvisor"]
Expand Down
98 changes: 0 additions & 98 deletions C7/Civ3Map/Civ3Map.cs

This file was deleted.

Loading