🎉 Initial Commit

 Grid system, player movement etc
This commit is contained in:
2025-08-26 18:36:50 +08:00
commit 31723217ea
31 changed files with 453 additions and 0 deletions

4
.editorconfig Normal file
View File

@@ -0,0 +1,4 @@
root = true
[*]
charset = utf-8

2
.gitattributes vendored Normal file
View File

@@ -0,0 +1,2 @@
# Normalize EOL for all files that Git considers text files.
* text=auto eol=lf

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
# Godot 4+ specific ignores
.godot/
/android/

13
.idea/.idea.AceField New Horizon/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/contentModel.xml
/projectSettingsUpdater.xml
/modules.xml
/.idea.AceField New Horizon.iml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1 @@
AceField New Horizon

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>

View File

@@ -0,0 +1,9 @@
<component name="libraryTable">
<library name="GdSdk" type="GdScript">
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://$APPLICATION_HOME_DIR$/plugins/rider-gdscript/sdk/extracted/4.4.1" />
</SOURCES>
</library>
</component>

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MaterialThemeProjectNewConfig">
<option name="metadata">
<MTProjectMetadataState>
<option name="migrated" value="true" />
<option name="pristineConfig" value="false" />
<option name="userId" value="418fb2ef:193a063a4c7:-7ffe" />
</MTProjectMetadataState>
</option>
</component>
</project>

View File

@@ -0,0 +1,7 @@
<Project Sdk="Godot.NET.Sdk/4.4.1">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<RootNamespace>AceFieldNewHorizon</RootNamespace>
</PropertyGroup>
</Project>

19
AceField New Horizon.sln Normal file
View File

@@ -0,0 +1,19 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AceField New Horizon", "AceField New Horizon.csproj", "{CE3B1579-E05C-445D-8D60-44193679F36A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
ExportDebug|Any CPU = ExportDebug|Any CPU
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CE3B1579-E05C-445D-8D60-44193679F36A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE3B1579-E05C-445D-8D60-44193679F36A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE3B1579-E05C-445D-8D60-44193679F36A}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{CE3B1579-E05C-445D-8D60-44193679F36A}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{CE3B1579-E05C-445D-8D60-44193679F36A}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{CE3B1579-E05C-445D-8D60-44193679F36A}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal

BIN
Scenes/Entities/Player.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 893 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://jye6c2ehuxtg"
path="res://.godot/imported/Player.png-a47763ac98e2bfa7959d9f7899f4e3bc.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Scenes/Entities/Player.png"
dest_files=["res://.godot/imported/Player.png-a47763ac98e2bfa7959d9f7899f4e3bc.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3 uid="uid://doxy60afddg1m"]
[ext_resource type="Script" uid="uid://dgm1o21sv2o1x" path="res://Scripts/Entities/Player.cs" id="1_08t41"]
[ext_resource type="Texture2D" uid="uid://jye6c2ehuxtg" path="res://Scenes/Entities/Player.png" id="1_ucweq"]
[node name="Player" type="CharacterBody2D"]
script = ExtResource("1_08t41")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.1, 0.1)
texture = ExtResource("1_ucweq")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
position = Vector2(1, 2.5)
polygon = PackedVector2Array(54, 87.5, 62, 76.5, 7, -89.5, -1, -92.5, -10, -89.5, -64, 76.5, -55, 87.5)
[node name="Camera2D" type="Camera2D" parent="."]
process_callback = 0
position_smoothing_enabled = true

22
Scenes/Root.tscn Normal file
View File

@@ -0,0 +1,22 @@
[gd_scene load_steps=5 format=3 uid="uid://c22aprj452aha"]
[ext_resource type="Script" uid="uid://cudpc3w17mbsw" path="res://Scripts/System/GridManager.cs" id="1_knkkn"]
[ext_resource type="Script" uid="uid://bx1wj7gn6vrqe" path="res://Scripts/System/PlacementManager.cs" id="2_sxhdm"]
[ext_resource type="PackedScene" uid="uid://doxy60afddg1m" path="res://Scenes/Entities/Player.tscn" id="3_oss8w"]
[ext_resource type="PackedScene" uid="uid://d1pudmkg5nnhj" path="res://Scenes/Tiles/WallTile.tscn" id="3_sxhdm"]
[node name="Root" type="Node2D"]
[node name="GridSystem" type="Node2D" parent="."]
script = ExtResource("1_knkkn")
[node name="PlacementSystem" type="Node2D" parent="." node_paths=PackedStringArray("Grid")]
script = ExtResource("2_sxhdm")
BuildingScene = ExtResource("3_sxhdm")
Grid = NodePath("../GridSystem")
[node name="WallTile" parent="." instance=ExtResource("3_sxhdm")]
[node name="Player" parent="." instance=ExtResource("3_oss8w")]
position = Vector2(602, 324)
scale = Vector2(0.5, 0.5)

BIN
Scenes/Tiles/WallTile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 942 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://14ohvtl6eroj"
path="res://.godot/imported/WallTile.png-6f272ac3f660cd90075e54aa0a66efaf.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Scenes/Tiles/WallTile.png"
dest_files=["res://.godot/imported/WallTile.png-6f272ac3f660cd90075e54aa0a66efaf.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,17 @@
[gd_scene load_steps=4 format=3 uid="uid://d1pudmkg5nnhj"]
[ext_resource type="Texture2D" uid="uid://14ohvtl6eroj" path="res://Scenes/Tiles/WallTile.png" id="1_8o613"]
[ext_resource type="Script" uid="uid://cywgb6hvlw8lr" path="res://Scripts/Tiles/WallTile.cs" id="1_ph7y3"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_8o613"]
size = Vector2(54, 54)
[node name="WallTile" type="StaticBody2D"]
script = ExtResource("1_ph7y3")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.05, 0.05)
texture = ExtResource("1_8o613")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_8o613")

View File

@@ -0,0 +1,26 @@
using System;
using Godot;
namespace AceFieldNewHorizon.Scripts.Entities;
public partial class Player : CharacterBody2D
{
[Export] public float Speed = 400.0f;
public override void _Process(double delta)
{
// Get direction to mouse and calculate angle
var mousePos = GetGlobalMousePosition();
var direction = GlobalPosition.DirectionTo(mousePos);
Rotation = direction.Angle() + (float)Math.PI / 2;
}
public override void _PhysicsProcess(double delta)
{
// Get movement input
var inputDirection = Input.GetVector("move_left", "move_right", "move_up", "move_down");
Velocity = inputDirection * Speed;
MoveAndSlide();
}
}

View File

@@ -0,0 +1 @@
uid://dgm1o21sv2o1x

View File

@@ -0,0 +1,45 @@
using System.Collections.Generic;
using Godot;
namespace AceFieldNewHorizon.Scripts.System;
public partial class GridManager : Node
{
private Dictionary<Vector2I, Node2D> _grid = new();
public bool IsCellFree(Vector2I cell)
{
return !_grid.ContainsKey(cell);
}
public void OccupyCell(Vector2I cell, Node2D building)
{
_grid[cell] = building;
}
public void FreeCell(Vector2I cell)
{
_grid.Remove(cell);
}
}
public static class GridUtils
{
public const int TileSize = 54;
public static Vector2I WorldToGrid(Vector2 pos)
{
return new Vector2I(
Mathf.FloorToInt(pos.X / TileSize),
Mathf.FloorToInt(pos.Y / TileSize)
);
}
public static Vector2 GridToWorld(Vector2I cell)
{
return new Vector2(
cell.X * TileSize,
cell.Y * TileSize
);
}
}

View File

@@ -0,0 +1 @@
uid://cudpc3w17mbsw

View File

@@ -0,0 +1,40 @@
using AceFieldNewHorizon.Scripts.Tiles;
using Godot;
namespace AceFieldNewHorizon.Scripts.System;
public partial class PlacementManager : Node2D
{
[Export] public PackedScene BuildingScene { get; set; }
[Export] public GridManager Grid { get; set; }
private Vector2I _hoveredCell;
private BaseTile _ghostBuilding;
public override void _Process(double delta)
{
// Snap mouse to grid
var mousePos = GetGlobalMousePosition();
_hoveredCell = GridUtils.WorldToGrid(mousePos);
if (_ghostBuilding == null)
{
_ghostBuilding = (BaseTile)BuildingScene.Instantiate();
_ghostBuilding.SetGhostMode(true);
AddChild(_ghostBuilding);
}
_ghostBuilding.Position = GridUtils.GridToWorld(_hoveredCell);
_ghostBuilding.SetGhostMode(true);
// Left click to place
if (!Input.IsActionPressed("build_tile") || !Grid.IsCellFree(_hoveredCell)) return;
_ghostBuilding.SetGhostMode(false);
Grid.OccupyCell(_hoveredCell, _ghostBuilding);
_ghostBuilding = (BaseTile)BuildingScene.Instantiate();
_ghostBuilding.SetGhostMode(true);
AddChild(_ghostBuilding);
}
}

View File

@@ -0,0 +1 @@
uid://bx1wj7gn6vrqe

30
Scripts/Tiles/BaseTile.cs Normal file
View File

@@ -0,0 +1,30 @@
using Godot;
namespace AceFieldNewHorizon.Scripts.Tiles;
public partial class BaseTile : Node2D
{
protected CollisionShape2D CollisionShape;
protected Sprite2D Sprite;
public override void _Ready()
{
// Get references (optional: you can also Export and assign in editor)
CollisionShape = GetNode<CollisionShape2D>("CollisionShape2D");
Sprite = GetNode<Sprite2D>("Sprite2D");
}
public void SetGhostMode(bool ghost)
{
if (CollisionShape != null)
CollisionShape.Disabled = ghost;
if (Sprite != null)
{
if (ghost)
Sprite.Modulate = new Color(1, 1, 1, 0.5f); // semi-transparent
else
Sprite.Modulate = Colors.White;
}
}
}

View File

@@ -0,0 +1 @@
uid://clw4adumlgw43

View File

@@ -0,0 +1,8 @@
using Godot;
namespace AceFieldNewHorizon.Scripts.Tiles;
public partial class WallTile : BaseTile
{
}

View File

@@ -0,0 +1 @@
uid://cywgb6hvlw8lr

1
icon.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>

After

Width:  |  Height:  |  Size: 994 B

37
icon.svg.import Normal file
View File

@@ -0,0 +1,37 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ca07uqmtp40q3"
path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://icon.svg"
dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
svg/scale=1.0
editor/scale_with_editor_scale=false
editor/convert_colors_with_editor_theme=false

53
project.godot Normal file
View File

@@ -0,0 +1,53 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="AceField New Horizon"
run/main_scene="uid://c22aprj452aha"
config/features=PackedStringArray("4.4", "C#", "GL Compatibility")
config/icon="res://icon.svg"
[dotnet]
project/assembly_name="AceField New Horizon"
[input]
move_up={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
move_down={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
build_tile={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(680, 19),"global_position":Vector2(699, 115),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"