Add backend projects with core models and tests, setup Godot frontend
This commit is contained in:
4
frontend/icon.svg
Normal file
4
frontend/icon.svg
Normal file
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128">
|
||||
<rect x="10" y="10" width="108" height="108" fill="#4CAF50" rx="20"/>
|
||||
<text x="64" y="80" font-family="Arial" font-size="60" fill="white" text-anchor="middle">$</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 245 B |
55
frontend/project.godot
Normal file
55
frontend/project.godot
Normal file
@@ -0,0 +1,55 @@
|
||||
; 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="MyBiz - Economic Simulator"
|
||||
run/main_scene="res://scenes/main.tscn"
|
||||
config/features=PackedStringArray("4.0", "Forward Plus")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=1280
|
||||
window/size/viewport_height=720
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[input]
|
||||
|
||||
move_up={
|
||||
"deadzone": 0.5,
|
||||
"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,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_down={
|
||||
"deadzone": 0.5,
|
||||
"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,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_left={
|
||||
"deadzone": 0.5,
|
||||
"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,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
move_right={
|
||||
"deadzone": 0.5,
|
||||
"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,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
2d_physics/layer_1="Default"
|
||||
2d_physics/layer_2="Buildings"
|
||||
2d_physics/layer_3="UI"
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="forward_plus"
|
||||
14
frontend/scenes/main.tscn
Normal file
14
frontend/scenes/main.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scene format="3" uid="1" namespaced="false" unique_name_in_tree="true">
|
||||
<node name="Main" type="Node2D">
|
||||
<node name="GameManager" instance="res://scripts/core/GameManager.cs" parent="." index="0"/>
|
||||
<node name="UI" type="CanvasLayer" parent="." index="1">
|
||||
<node name="TopBar" type="Panel" parent="UI">
|
||||
<node name="HBoxContainer" type="HBoxContainer" parent="TopBar">
|
||||
<node name="MoneyLabel" type="Label" parent="HBoxContainer"/>
|
||||
<node name="DateLabel" type="Label" parent="HBoxContainer"/>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</node>
|
||||
</scene>
|
||||
13
frontend/scripts/core/GameData.cs
Normal file
13
frontend/scripts/core/GameData.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class GameData : Resource
|
||||
{
|
||||
[Export] public string CompanyName { get; set; } = "My Company";
|
||||
[Export] public int StartYear { get; set; } = 1980;
|
||||
[Export] public decimal StartingCash { get; set; } = 100000m;
|
||||
|
||||
// Настройки карты
|
||||
[Export] public int CityCount { get; set; } = 10;
|
||||
[Export] public bool EnableImports { get; set; } = true;
|
||||
}
|
||||
59
frontend/scripts/core/GameManager.cs
Normal file
59
frontend/scripts/core/GameManager.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using Godot;
|
||||
|
||||
/// <summary>
|
||||
/// Менеджер игры - управляет состоянием игры
|
||||
/// </summary>
|
||||
public partial class GameManager : Node
|
||||
{
|
||||
public static GameManager Instance { get; private set; } = null!;
|
||||
|
||||
[Signal] public delegate void MoneyChangedEventHandler(decimal newAmount);
|
||||
[Signal] public delegate void DateChangedEventHandler(int year, int month, int day);
|
||||
|
||||
public decimal Money { get; private set; } = 100000m;
|
||||
public int GameYear { get; private set; } = 1980;
|
||||
public int GameMonth { get; private set; } = 1;
|
||||
public int GameDay { get; private set; } = 1;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
if (Instance != null && Instance != this)
|
||||
{
|
||||
QueueFree();
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void AddMoney(decimal amount)
|
||||
{
|
||||
Money += amount;
|
||||
EmitSignal(SignalName.MoneyChanged, Money);
|
||||
}
|
||||
|
||||
public void SpendMoney(decimal amount)
|
||||
{
|
||||
if (Money >= amount)
|
||||
{
|
||||
Money -= amount;
|
||||
EmitSignal(SignalName.MoneyChanged, Money);
|
||||
}
|
||||
}
|
||||
|
||||
public void AdvanceTime(int ticks)
|
||||
{
|
||||
GameDay += ticks;
|
||||
if (GameDay > 30)
|
||||
{
|
||||
GameDay = 1;
|
||||
GameMonth++;
|
||||
if (GameMonth > 12)
|
||||
{
|
||||
GameMonth = 1;
|
||||
GameYear++;
|
||||
}
|
||||
}
|
||||
EmitSignal(SignalName.DateChanged, GameYear, GameMonth, GameDay);
|
||||
}
|
||||
}
|
||||
13
frontend/scripts/core/Main.cs
Normal file
13
frontend/scripts/core/Main.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
|
||||
public partial class Main : Node2D
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
GD.Print("MyBiz - Game Started!");
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
}
|
||||
35
frontend/scripts/ui/GameUI.cs
Normal file
35
frontend/scripts/ui/GameUI.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Godot;
|
||||
|
||||
/// <summary>
|
||||
/// Базовый класс для всех UI элементов
|
||||
/// </summary>
|
||||
public partial class GameUI : Control
|
||||
{
|
||||
protected GameManager GameManager => GameManager.Instance;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
ConnectSignals();
|
||||
}
|
||||
|
||||
protected virtual void ConnectSignals()
|
||||
{
|
||||
if (GameManager != null)
|
||||
{
|
||||
GameManager.MoneyChanged += OnMoneyChanged;
|
||||
GameManager.DateChanged += OnDateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnMoneyChanged(decimal newAmount) { }
|
||||
protected virtual void OnDateChanged(int year, int month, int day) { }
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
if (GameManager != null)
|
||||
{
|
||||
GameManager.MoneyChanged -= OnMoneyChanged;
|
||||
GameManager.DateChanged -= OnDateChanged;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user