From 010b0437af20c15c8d4683d5b2378e7657bd0ff9 Mon Sep 17 00:00:00 2001 From: Valdemar Date: Tue, 22 Sep 2026 18:20:36 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=81=D0=B8=D1=81=D0=B5=D1=82=D0=BC=D1=8B=20?= =?UTF-8?q?=D1=81=D0=BE=D1=85=D1=80=D0=B0=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F,?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=BA=D0=BE=D0=BF=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D1=80=D0=B5=D1=81=D1=83=D1=80=D1=81=D0=BE=D0=B2.=20=D0=9F?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B0=20=D1=80?= =?UTF-8?q?=D0=B0=D1=82=D1=83=D1=88=D0=B0.=20=D0=A3=D0=B2=D0=B5=D0=BB?= =?UTF-8?q?=D0=B8=D1=87=D0=B8=D0=B2=D0=B0=D0=B5=D1=82=D1=81=D1=8F=20=D1=83?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D0=BD,=20=D0=BE=D1=82=D0=BA=D1=80?= =?UTF-8?q?=D1=8B=D0=B2=D0=B0=D1=8E=D1=82=D1=81=D1=8F=20=D0=BD=D0=BE=D0=B2?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=BF=D0=BE=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA?= =?UTF-8?q?=D0=B8.=20=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=BE=D0=B9=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0=20=D0=BF=D0=BE=D1=8F=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D1=8E=D1=82=D1=81=D1=8F=20=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=86?= =?UTF-8?q?=D1=8B.=20=D0=9D=D0=B0=20=D0=BA=D0=B0=D0=B6=D0=B4=D0=BE=D0=BC?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=BE=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D0=B8=D1=82=20=D1=86=D0=B5=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D1=80=D0=BE=D0=B9=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Prefab/Buildings/Food.prefab | 16 +- Assets/Prefab/Buildings/GoldMine.prefab | 16 +- Assets/Prefab/Buildings/Kamenolomnia.prefab | 16 +- Assets/Prefab/Buildings/Kristall.prefab | 16 +- Assets/Prefab/Buildings/Lesopilka.prefab | 16 +- Assets/Prefab/Buildings/People.prefab | 16 +- Assets/Prefab/Buildings/Shaxta.prefab | 16 +- Assets/Scenes/MVP1.unity | 65 +++++- .../Construction of buildings/BuildManager.cs | 86 +++++--- .../PlaceBuilding.cs | 13 ++ .../PlaceBuilding.cs.meta | 2 + Assets/Scripts/Economy/ResourceManager.cs | 38 ++-- Assets/Scripts/Other.meta | 8 + Assets/Scripts/Other/GameBootstrap.cs | 20 ++ Assets/Scripts/Other/GameBootstrap.cs.meta | 2 + Assets/Scripts/Other/SaveManager.cs | 195 ++++++++++++++++++ Assets/Scripts/Other/SaveManager.cs.meta | 2 + ProjectSettings/TagManager.asset | 7 +- 18 files changed, 455 insertions(+), 95 deletions(-) create mode 100644 Assets/Scripts/Construction of buildings/PlaceBuilding.cs create mode 100644 Assets/Scripts/Construction of buildings/PlaceBuilding.cs.meta create mode 100644 Assets/Scripts/Other.meta create mode 100644 Assets/Scripts/Other/GameBootstrap.cs create mode 100644 Assets/Scripts/Other/GameBootstrap.cs.meta create mode 100644 Assets/Scripts/Other/SaveManager.cs create mode 100644 Assets/Scripts/Other/SaveManager.cs.meta diff --git a/Assets/Prefab/Buildings/Food.prefab b/Assets/Prefab/Buildings/Food.prefab index db75da4..eaf491e 100644 --- a/Assets/Prefab/Buildings/Food.prefab +++ b/Assets/Prefab/Buildings/Food.prefab @@ -11,7 +11,7 @@ GameObject: - component: {fileID: 4002742518979284527} - component: {fileID: 8064382219512370799} - component: {fileID: 330444905078661864} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} @@ -86,7 +86,7 @@ GameObject: - component: {fileID: 3793951204597816762} - component: {fileID: 5506546141177425958} - component: {fileID: 6781712769009624993} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -164,7 +164,7 @@ GameObject: - component: {fileID: 3086347143011804087} - component: {fileID: 8366624895868613416} - component: {fileID: 4191623656792219752} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (2) m_TagString: Untagged m_Icon: {fileID: 0} @@ -408,7 +408,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1927015835945780662} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -446,7 +446,7 @@ GameObject: - component: {fileID: 8228770704062114076} - component: {fileID: 7921213300567708335} - component: {fileID: 3141608278938106867} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -519,7 +519,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2872642912252838387} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -556,7 +556,7 @@ GameObject: m_Component: - component: {fileID: 3726670482220635953} - component: {fileID: 2968453288331483779} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -650,7 +650,7 @@ GameObject: - component: {fileID: 1471241643215355356} - component: {fileID: 1708035113988781431} - component: {fileID: 4191590240474693017} - m_Layer: 0 + m_Layer: 3 m_Name: Food m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/GoldMine.prefab b/Assets/Prefab/Buildings/GoldMine.prefab index fbd9323..3c917f0 100644 --- a/Assets/Prefab/Buildings/GoldMine.prefab +++ b/Assets/Prefab/Buildings/GoldMine.prefab @@ -13,7 +13,7 @@ GameObject: - component: {fileID: 5709127527925679652} - component: {fileID: 1072887893553875685} - component: {fileID: 5409824492356627158} - m_Layer: 0 + m_Layer: 3 m_Name: GoldMine m_TagString: Untagged m_Icon: {fileID: 0} @@ -189,7 +189,7 @@ GameObject: - component: {fileID: 3720488835216638398} - component: {fileID: 1210843985261880390} - component: {fileID: 5676831441011161224} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (2) m_TagString: Untagged m_Icon: {fileID: 0} @@ -435,7 +435,7 @@ GameObject: - component: {fileID: 577155313112453847} - component: {fileID: 5412168892413979765} - component: {fileID: 6009320542041345824} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -508,7 +508,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 8624740838421467304} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -544,7 +544,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1484526957430814939} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -581,7 +581,7 @@ GameObject: m_Component: - component: {fileID: 5653634108450285178} - component: {fileID: 2746946344350271564} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -672,7 +672,7 @@ GameObject: - component: {fileID: 1806860104537654056} - component: {fileID: 2796826311491354681} - component: {fileID: 5293240414597355417} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} @@ -747,7 +747,7 @@ GameObject: - component: {fileID: 900962119107375790} - component: {fileID: 3444417998701724978} - component: {fileID: 3205612178821969769} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/Kamenolomnia.prefab b/Assets/Prefab/Buildings/Kamenolomnia.prefab index 0ad4e6f..5c5dc07 100644 --- a/Assets/Prefab/Buildings/Kamenolomnia.prefab +++ b/Assets/Prefab/Buildings/Kamenolomnia.prefab @@ -9,7 +9,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3969154243212091243} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -47,7 +47,7 @@ GameObject: - component: {fileID: 310966372095626978} - component: {fileID: 1501310501853857812} - component: {fileID: 8858725208427347718} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -124,7 +124,7 @@ GameObject: - component: {fileID: 6081852666575568307} - component: {fileID: 6066509456273779269} - component: {fileID: 257481779865871796} - m_Layer: 0 + m_Layer: 3 m_Name: Kamenolomnia m_TagString: Untagged m_Icon: {fileID: 0} @@ -297,7 +297,7 @@ GameObject: - component: {fileID: 6856921113830922206} - component: {fileID: 7675630323752410891} - component: {fileID: 2351731012890206024} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -370,7 +370,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 8654331807705166329} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -408,7 +408,7 @@ GameObject: - component: {fileID: 582854950046736703} - component: {fileID: 8249385852799821456} - component: {fileID: 7373747027848728310} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} @@ -482,7 +482,7 @@ GameObject: m_Component: - component: {fileID: 8652593581461747968} - component: {fileID: 8435780551198638127} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -576,7 +576,7 @@ GameObject: - component: {fileID: 3951695076526408292} - component: {fileID: 5237439105164938095} - component: {fileID: 8911905189307943166} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (2) m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/Kristall.prefab b/Assets/Prefab/Buildings/Kristall.prefab index 6ba4a0a..4417f4a 100644 --- a/Assets/Prefab/Buildings/Kristall.prefab +++ b/Assets/Prefab/Buildings/Kristall.prefab @@ -14,7 +14,7 @@ GameObject: - component: {fileID: 7428043993242197720} - component: {fileID: 8876229628118969147} - component: {fileID: 4809400745550651630} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (2) m_TagString: Untagged m_Icon: {fileID: 0} @@ -258,7 +258,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 2219371244321850613} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -296,7 +296,7 @@ GameObject: - component: {fileID: 5394567590597037228} - component: {fileID: 5006164066123729041} - component: {fileID: 6956128874796247178} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -371,7 +371,7 @@ GameObject: - component: {fileID: 7131657856732036943} - component: {fileID: 5730540684975491652} - component: {fileID: 960580518922019974} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -445,7 +445,7 @@ GameObject: m_Component: - component: {fileID: 4322642769442097139} - component: {fileID: 4741032704856435982} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -534,7 +534,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3406416985991052905} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -575,7 +575,7 @@ GameObject: - component: {fileID: 3238156261450020092} - component: {fileID: 6835409609226383739} - component: {fileID: 6451544488071506654} - m_Layer: 0 + m_Layer: 3 m_Name: Kristall m_TagString: Untagged m_Icon: {fileID: 0} @@ -765,7 +765,7 @@ GameObject: - component: {fileID: 5352715714053848194} - component: {fileID: 5999212797332437909} - component: {fileID: 858267319036784839} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/Lesopilka.prefab b/Assets/Prefab/Buildings/Lesopilka.prefab index 5dbf8f6..6d34efc 100644 --- a/Assets/Prefab/Buildings/Lesopilka.prefab +++ b/Assets/Prefab/Buildings/Lesopilka.prefab @@ -13,7 +13,7 @@ GameObject: - component: {fileID: 5306320879243393515} - component: {fileID: 4347759638798865807} - component: {fileID: 8080049013686760202} - m_Layer: 0 + m_Layer: 3 m_Name: Lesopilka m_TagString: Untagged m_Icon: {fileID: 0} @@ -189,7 +189,7 @@ GameObject: m_Component: - component: {fileID: 7241778671202181995} - component: {fileID: 8635198783164890612} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -283,7 +283,7 @@ GameObject: - component: {fileID: 6507110458437413086} - component: {fileID: 1583811796485460241} - component: {fileID: 3881444792252716484} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas m_TagString: Untagged m_Icon: {fileID: 0} @@ -527,7 +527,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 7246166311783535450} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -565,7 +565,7 @@ GameObject: - component: {fileID: 5641726130355626710} - component: {fileID: 6219326034010900823} - component: {fileID: 167073955797870126} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -638,7 +638,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3245991593120377230} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -676,7 +676,7 @@ GameObject: - component: {fileID: 2782416422371965892} - component: {fileID: 5314180381471706409} - component: {fileID: 8839952233946098354} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -751,7 +751,7 @@ GameObject: - component: {fileID: 6144247887862302617} - component: {fileID: 1418222646644384381} - component: {fileID: 6527831730433201755} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/People.prefab b/Assets/Prefab/Buildings/People.prefab index d1bbd22..dc1947a 100644 --- a/Assets/Prefab/Buildings/People.prefab +++ b/Assets/Prefab/Buildings/People.prefab @@ -11,7 +11,7 @@ GameObject: - component: {fileID: 2800474039428411781} - component: {fileID: 3946903823023915250} - component: {fileID: 4695968121406322393} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -86,7 +86,7 @@ GameObject: - component: {fileID: 9128744184370430097} - component: {fileID: 7362341572727941915} - component: {fileID: 3253308405779028863} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -161,7 +161,7 @@ GameObject: - component: {fileID: 7368589938815255286} - component: {fileID: 2635063965737862624} - component: {fileID: 4856851583400535072} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} @@ -234,7 +234,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 8808706617047054436} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -275,7 +275,7 @@ GameObject: - component: {fileID: 4109876596211566975} - component: {fileID: 6763315523887852349} - component: {fileID: 6446373148616658521} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (3) m_TagString: Untagged m_Icon: {fileID: 0} @@ -520,7 +520,7 @@ GameObject: m_Component: - component: {fileID: 5913247723073291300} - component: {fileID: 1065437750742842432} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -613,7 +613,7 @@ GameObject: - component: {fileID: 7603893054635625423} - component: {fileID: 6686164845870214523} - component: {fileID: 8733527051286464462} - m_Layer: 0 + m_Layer: 3 m_Name: People m_TagString: Untagged m_Icon: {fileID: 0} @@ -784,7 +784,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 5261766043013034418} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefab/Buildings/Shaxta.prefab b/Assets/Prefab/Buildings/Shaxta.prefab index ff1c5c4..d58a179 100644 --- a/Assets/Prefab/Buildings/Shaxta.prefab +++ b/Assets/Prefab/Buildings/Shaxta.prefab @@ -10,7 +10,7 @@ GameObject: m_Component: - component: {fileID: 9049021842245786191} - component: {fileID: 6798716856179431755} - m_Layer: 5 + m_Layer: 3 m_Name: Slider m_TagString: Untagged m_Icon: {fileID: 0} @@ -101,7 +101,7 @@ GameObject: - component: {fileID: 2773622439927167709} - component: {fileID: 8619355614463974451} - component: {fileID: 5892695595717621851} - m_Layer: 5 + m_Layer: 3 m_Name: Fill m_TagString: Untagged m_Icon: {fileID: 0} @@ -174,7 +174,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4877085052740413173} - m_Layer: 5 + m_Layer: 3 m_Name: Fill Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -212,7 +212,7 @@ GameObject: - component: {fileID: 2500375828274013755} - component: {fileID: 6895100105936511138} - component: {fileID: 281306229817890815} - m_Layer: 5 + m_Layer: 3 m_Name: Handle m_TagString: Untagged m_Icon: {fileID: 0} @@ -285,7 +285,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 4099470492338002646} - m_Layer: 5 + m_Layer: 3 m_Name: Handle Slide Area m_TagString: Untagged m_Icon: {fileID: 0} @@ -325,7 +325,7 @@ GameObject: - component: {fileID: 2720790236691513585} - component: {fileID: 2564761440770285527} - component: {fileID: 2796556761884381038} - m_Layer: 0 + m_Layer: 3 m_Name: Shaxta m_TagString: Untagged m_Icon: {fileID: 0} @@ -498,7 +498,7 @@ GameObject: - component: {fileID: 7392134504014982642} - component: {fileID: 625637881806047824} - component: {fileID: 6938675845369349677} - m_Layer: 5 + m_Layer: 3 m_Name: Background m_TagString: Untagged m_Icon: {fileID: 0} @@ -576,7 +576,7 @@ GameObject: - component: {fileID: 6923797281547489874} - component: {fileID: 4994502127451470438} - component: {fileID: 4777902828861520343} - m_Layer: 5 + m_Layer: 3 m_Name: Canvas (1) m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Scenes/MVP1.unity b/Assets/Scenes/MVP1.unity index 83aab70..2f42d0c 100644 --- a/Assets/Scenes/MVP1.unity +++ b/Assets/Scenes/MVP1.unity @@ -892,6 +892,10 @@ MonoBehaviour: - {fileID: 11400000, guid: 184fe08ef84b141408ea8a5a1b2df34e, type: 2} - {fileID: 11400000, guid: d532fc647f7aa5548ac381061942d96c, type: 2} - {fileID: 11400000, guid: 22e88ea411e586447bbb5a7ef6dfca16, type: 2} + buildingsLayerMask: + serializedVersion: 2 + m_Bits: 8 + placementPadding: 0.1 validPlacementColor: {r: 1, g: 1, b: 1, a: 0.6} invalidPlacementColor: {r: 1, g: 0.3, b: 0.3, a: 0.6} --- !u!4 &250861323 @@ -1761,6 +1765,64 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 386246546} m_CullTransparentMesh: 1 +--- !u!1 &387332240 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 387332243} + - component: {fileID: 387332242} + - component: {fileID: 387332241} + m_Layer: 0 + m_Name: SaveManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &387332241 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 387332240} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0f2bb66f2486f084b813736d3a8768d7, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::GameBootstrap +--- !u!114 &387332242 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 387332240} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 749721a5613594941adaed89b39ea5fe, type: 3} + m_Name: + m_EditorClassIdentifier: Assembly-CSharp::SaveManager + autoSaveInterval: 30 +--- !u!4 &387332243 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 387332240} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -11.03001, y: 0.33877, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &398976250 GameObject: m_ObjectHideFlags: 0 @@ -4875,7 +4937,7 @@ MonoBehaviour: amount: 250 - type: 3 amount: 160 - - type: 3 + - type: 4 amount: 25 costMultiplierPerLevel: 1.5 --- !u!212 &908634057 @@ -9472,3 +9534,4 @@ SceneRoots: - {fileID: 205733165} - {fileID: 250861323} - {fileID: 209860290} + - {fileID: 387332243} diff --git a/Assets/Scripts/Construction of buildings/BuildManager.cs b/Assets/Scripts/Construction of buildings/BuildManager.cs index 59cede1..b302145 100644 --- a/Assets/Scripts/Construction of buildings/BuildManager.cs +++ b/Assets/Scripts/Construction of buildings/BuildManager.cs @@ -2,7 +2,7 @@ using UnityEngine; using System.Collections.Generic; // Управляет режимом строительства: показывает "призрак" здания под курсором, -// проверяет ресурсы, спавнит здание в подтверждённой позиции. +// проверяет ресурсы И пересечение с другими зданиями, спавнит здание в подтверждённой позиции. public class BuildManager : MonoBehaviour { @@ -11,12 +11,21 @@ public class BuildManager : MonoBehaviour [Header("Все типы зданий в игре")] public List allBuildings; + [Header("Проверка пересечения")] + [Tooltip("Слой, на котором находятся коллайдеры уже построенных зданий")] + public LayerMask buildingsLayerMask; + [Tooltip("Небольшой отступ вокруг здания, чтобы дома не лепились впритык друг к другу")] + public float placementPadding = 0.1f; + [Header("Визуал 'призрака' здания при размещении")] - public Color validPlacementColor = new Color(1, 1, 1, 0.6f); - public Color invalidPlacementColor = new Color(1, 0.3f, 0.3f, 0.6f); + [Tooltip("Белая зона -- можно строить")] + public Color validPlacementColor = new Color(1f, 1f, 1f, 0.6f); + [Tooltip("Красная зона -- нельзя (либо не хватает ресурсов, либо место занято)")] + public Color invalidPlacementColor = new Color(1f, 0.2f, 0.2f, 0.6f); private BuildingData currentlyPlacing; private GameObject ghostObject; + private Vector2 ghostSize; private Camera mainCam; void Awake() @@ -31,29 +40,42 @@ public class BuildManager : MonoBehaviour } void Update() -{ - if (currentlyPlacing == null || ghostObject == null) - return; - - Vector3 worldPos = GetPointerWorldPosition(); - worldPos.z = 0; - ghostObject.transform.position = worldPos; - - bool canAfford = currentlyPlacing.CanAfford(); - SpriteRenderer sr = ghostObject.GetComponent(); - if (sr != null) - sr.color = canAfford ? validPlacementColor : invalidPlacementColor; - - if (Input.GetMouseButtonDown(0)) { - TryConfirmPlacement(worldPos); + if (currentlyPlacing == null) return; // не в режиме строительства -- ничего не делаем + + // Двигаем "призрак" здания за пальцем/мышкой + Vector3 worldPos = GetPointerWorldPosition(); + worldPos.z = 0; + ghostObject.transform.position = worldPos; + + bool canAfford = currentlyPlacing.CanAfford(); + bool overlapping = IsOverlapping(worldPos); + bool canPlace = canAfford && !overlapping; + + SpriteRenderer sr = ghostObject.GetComponent(); + if (sr != null) + sr.color = canPlace ? validPlacementColor : invalidPlacementColor; + + // Подтверждение размещения по клику/тапу + if (Input.GetMouseButtonDown(0)) + { + TryConfirmPlacement(worldPos, canAfford, overlapping); + } + + // Отмена по правой кнопке / Escape + if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) + { + CancelPlacement(); + } } - if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) + // Проверка: пересекается ли здание в этой позиции с уже существующими постройками + bool IsOverlapping(Vector3 position) { - CancelPlacement(); + Vector2 checkSize = ghostSize + new Vector2(placementPadding, placementPadding); + Collider2D hit = Physics2D.OverlapBox(position, checkSize, 0f, buildingsLayerMask); + return hit != null; } -} // Список зданий, доступных для стройки ПРЯМО СЕЙЧАС (по уровню Ратуши) public List GetAvailableBuildings() @@ -80,6 +102,11 @@ public class BuildManager : MonoBehaviour currentlyPlacing = data; ghostObject = Instantiate(data.prefab); + + // Замеряем размер здания по спрайту (работает даже если коллайдер потом выключим) + SpriteRenderer ghostSr = ghostObject.GetComponent(); + ghostSize = ghostSr != null ? ghostSr.bounds.size : Vector2.one; + // Отключаем на "призраке" всё, что мешает (коллайдер, скрипты сбора ресурсов и т.д.) Collider2D col = ghostObject.GetComponent(); if (col != null) col.enabled = false; @@ -91,9 +118,15 @@ public class BuildManager : MonoBehaviour } } - void TryConfirmPlacement(Vector3 position) + void TryConfirmPlacement(Vector3 position, bool canAfford, bool overlapping) { - if (!currentlyPlacing.CanAfford()) + if (overlapping) + { + Debug.Log("[СТРОЙКА] Здесь уже что-то построено!"); + return; + } + + if (!canAfford) { Debug.Log("[СТРОЙКА] Не хватает ресурсов!"); return; @@ -102,6 +135,11 @@ public class BuildManager : MonoBehaviour currentlyPlacing.PayCost(); GameObject built = Instantiate(currentlyPlacing.prefab, position, Quaternion.identity); + + // Ставим маркер, чтобы SaveManager потом знал, что это за здание при сохранении + PlacedBuildingId idMarker = built.AddComponent(); + idMarker.buildingName = currentlyPlacing.buildingName; + Debug.Log($"[СТРОЙКА] Построено: {currentlyPlacing.buildingName} в {position}"); Destroy(ghostObject); @@ -120,4 +158,4 @@ public class BuildManager : MonoBehaviour Vector3 screenPos = Input.mousePosition; return mainCam.ScreenToWorldPoint(screenPos); } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Construction of buildings/PlaceBuilding.cs b/Assets/Scripts/Construction of buildings/PlaceBuilding.cs new file mode 100644 index 0000000..4b22f24 --- /dev/null +++ b/Assets/Scripts/Construction of buildings/PlaceBuilding.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +// Небольшой "маркер", который автоматически ставится на КАЖДОЕ здание, +// построенное через BuildManager. Хранит имя типа здания (совпадает с +// BuildingData.buildingName), чтобы SaveManager знал, что именно это за постройка, +// когда будет сохранять/восстанавливать сцену. +// +// НЕ добавляй этот компонент вручную -- BuildManager делает это сам при постройке. + +public class PlacedBuildingId : MonoBehaviour +{ + public string buildingName; +} diff --git a/Assets/Scripts/Construction of buildings/PlaceBuilding.cs.meta b/Assets/Scripts/Construction of buildings/PlaceBuilding.cs.meta new file mode 100644 index 0000000..748fc36 --- /dev/null +++ b/Assets/Scripts/Construction of buildings/PlaceBuilding.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d25db0d2362937c4b8bbdeffa97b1860 \ No newline at end of file diff --git a/Assets/Scripts/Economy/ResourceManager.cs b/Assets/Scripts/Economy/ResourceManager.cs index 9c31c55..5497611 100644 --- a/Assets/Scripts/Economy/ResourceManager.cs +++ b/Assets/Scripts/Economy/ResourceManager.cs @@ -7,14 +7,14 @@ using UnityEngine; public enum ResourceType { - Population = 0, //люди - Food =1 , // еда - Wood= 2, - Stone =3, - Iron =4, - Gold =5, - Krystall =6, - Power =7 + Population = 0, // люди + Food = 1, // еда + Wood = 2, // дерево + Stone = 3, // камень + Iron = 4, // металл + Gold = 5, // золото + Gems = 6, // кристаллы + Power = 7 // "сила" -- как в референсе HUD } public class ResourceManager : MonoBehaviour @@ -26,7 +26,7 @@ public class ResourceManager : MonoBehaviour public event Action OnResourceChanged; [Header("Стартовые значения (для теста/баланса)")] - public float startWood = 0f; + public float startWood = 0f; public float startStone = 0f; public float startIron = 0f; public float startFood = 0f; @@ -35,7 +35,6 @@ public class ResourceManager : MonoBehaviour public float startPower = 0f; public float startPopulation = 0f; - private Dictionary resources = new Dictionary(); void Awake() @@ -49,12 +48,12 @@ public class ResourceManager : MonoBehaviour Instance = this; DontDestroyOnLoad(gameObject); // менеджер ресурсов должен жить между сценами (меню -> игра) - resources[ResourceType.Wood] = startWood; + resources[ResourceType.Wood] = startWood; resources[ResourceType.Stone] = startStone; resources[ResourceType.Iron] = startIron; resources[ResourceType.Food] = startFood; resources[ResourceType.Gold] = startGold; - resources[ResourceType.Krystall] = startGems; + resources[ResourceType.Gems] = startGems; resources[ResourceType.Power] = startPower; resources[ResourceType.Population] = startPopulation; } @@ -89,4 +88,19 @@ public class ResourceManager : MonoBehaviour { return resources.TryGetValue(type, out float value) ? value : 0f; } + + // Устанавливает значение напрямую, БЕЗ проверок и без учёта прошлого значения. + // Используется только при загрузке сохранения -- обычная игровая логика должна + // использовать AddResource/TrySpend, а не этот метод. + public void SetResource(ResourceType type, float value) + { + resources[type] = value; + OnResourceChanged?.Invoke(type, value); + } + + // Все ресурсы разом -- удобно для сохранения + public Dictionary GetAllResources() + { + return new Dictionary(resources); + } } diff --git a/Assets/Scripts/Other.meta b/Assets/Scripts/Other.meta new file mode 100644 index 0000000..4e3a107 --- /dev/null +++ b/Assets/Scripts/Other.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b6bbf7a2c03f7634e98cbddcadb423da +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Other/GameBootstrap.cs b/Assets/Scripts/Other/GameBootstrap.cs new file mode 100644 index 0000000..b74ad13 --- /dev/null +++ b/Assets/Scripts/Other/GameBootstrap.cs @@ -0,0 +1,20 @@ +using UnityEngine; + +// Вешается на любой объект, который есть в игровой сцене с самого начала +// (например, на сам SaveManager или на ResourceManager). +// При старте сцены пытается загрузить сохранение, если оно есть. + +public class GameBootstrap : MonoBehaviour +{ + void Start() + { + if (SaveManager.Instance != null && SaveManager.Instance.HasSaveFile()) + { + SaveManager.Instance.LoadGame(); + } + else + { + Debug.Log("[СТАРТ] Сохранения нет, начинаем новую игру."); + } + } +} diff --git a/Assets/Scripts/Other/GameBootstrap.cs.meta b/Assets/Scripts/Other/GameBootstrap.cs.meta new file mode 100644 index 0000000..fa58017 --- /dev/null +++ b/Assets/Scripts/Other/GameBootstrap.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0f2bb66f2486f084b813736d3a8768d7 \ No newline at end of file diff --git a/Assets/Scripts/Other/SaveManager.cs b/Assets/Scripts/Other/SaveManager.cs new file mode 100644 index 0000000..e280845 --- /dev/null +++ b/Assets/Scripts/Other/SaveManager.cs @@ -0,0 +1,195 @@ +using UnityEngine; +using System.Collections.Generic; +using System.IO; +using Unity.Microsoft.GDK; + +[System.Serializable] +public class ResourceSaveEntry +{ + public ResourceType type; + public float amount; +} + +[System.Serializable] +public class PlacedBuildingSaveEntry +{ + public string buildingName; + public float posX; + public float posY; + public int level; +} + +[System.Serializable] +public class SaveData +{ + public List resources = new List(); + public int townHallLevel =1; + public List placedBuildings = new List(); + +} +public class SaveManager : MonoBehaviour +{ + public static SaveManager Instance { get; private set;} + + [Header("Автосохранение")] + [Tooltip("Частота сохранения прогресса, в секундах")] + public float autoSaveInterval = 30f; + + private string SavePath => Path.Combine(Application.persistentDataPath, "save.json"); + + void Awake() + { + if (Instance != null && Instance != this) + { + Destroy(gameObject); + return; + } + Instance = this; + DontDestroyOnLoad(gameObject); + } + + void Start() + { + InvokeRepeating(nameof(SaveGame), autoSaveInterval, autoSaveInterval); + } + + void OnApplicationPause(bool pauseStatus) + { + if (pauseStatus) + { + SaveGame(); + } + } + void OnApplicationQuit() + { + SaveGame(); + } + + //-----------Сохранение----------------- + public void SaveGame() + { + SaveData data = new SaveData(); + + // Ресурсы + if (ResourceManager.Instance != null) + { + foreach (var kvp in ResourceManager.Instance.GetAllResources()) + { + data.resources.Add(new ResourceSaveEntry { type = kvp.Key, amount = kvp.Value }); + } + } + + // Ратуша + if (TownHall.Instance != null) + { + data.townHallLevel = TownHall.Instance.currentLevel; + } + + // Все построенные здания на сцене (найдёт каждый объект с маркером PlacedBuildingId) + PlacedBuildingId[] allPlaced = Object.FindObjectsByType(FindObjectsSortMode.None); + foreach (var placed in allPlaced) + { + int level = 1; + ResourceCollector collector = placed.GetComponent(); + if (collector != null) level = collector.level; + + data.placedBuildings.Add(new PlacedBuildingSaveEntry + { + buildingName = placed.buildingName, + posX = placed.transform.position.x, + posY = placed.transform.position.y, + level = level + }); + } + + string json = JsonUtility.ToJson(data, true); + File.WriteAllText(SavePath, json); + + Debug.Log($"[СОХРАНЕНИЕ] Игра сохранена: {SavePath}"); + } + + // ---------------- ЗАГРУЗКА ---------------- + + public bool HasSaveFile() + { + return File.Exists(SavePath); + } + + public void LoadGame() + { + if (!HasSaveFile()) + { + Debug.Log("[ЗАГРУЗКА] Файл сохранения не найден, начинаем новую игру."); + return; + } + + string json = File.ReadAllText(SavePath); + SaveData data = JsonUtility.FromJson(json); + + // Ресурсы + if (ResourceManager.Instance != null) + { + foreach (var entry in data.resources) + { + ResourceManager.Instance.SetResource(entry.type, entry.amount); + } + } + + // Ратуша + if (TownHall.Instance != null) + { + TownHall.Instance.currentLevel = data.townHallLevel; + } + + // Сначала удаляем все здания, которые уже могли быть заспавнены на сцене + // (например, если LoadGame вызывается повторно, не хотим задваивать постройки) + PlacedBuildingId[] existing = Object.FindObjectsByType(FindObjectsSortMode.None); + foreach (var e in existing) + { + Destroy(e.gameObject); + } + + // Восстанавливаем здания из сохранения + foreach (var entry in data.placedBuildings) + { + BuildingData matchingData = FindBuildingDataByName(entry.buildingName); + if (matchingData == null) + { + Debug.LogWarning($"[ЗАГРУЗКА] Не найден BuildingData для '{entry.buildingName}', здание пропущено."); + continue; + } + + Vector3 pos = new Vector3(entry.posX, entry.posY, 0f); + GameObject built = Instantiate(matchingData.prefab, pos, Quaternion.identity); + + PlacedBuildingId idMarker = built.AddComponent(); + idMarker.buildingName = entry.buildingName; + + ResourceCollector collector = built.GetComponent(); + if (collector != null) collector.level = entry.level; + } + + Debug.Log($"[ЗАГРУЗКА] Игра загружена. Построек восстановлено: {data.placedBuildings.Count}"); + } + + BuildingData FindBuildingDataByName(string buildingName) + { + if (BuildManager.Instance == null) return null; + + foreach (var b in BuildManager.Instance.allBuildings) + { + if (b.buildingName == buildingName) return b; + } + return null; + } + + // Полностью стирает сохранение (например, для кнопки "Начать заново" в настройках) + public void DeleteSave() + { + if (File.Exists(SavePath)) + { + File.Delete(SavePath); + Debug.Log("[СОХРАНЕНИЕ] Файл сохранения удалён."); + } + } +} diff --git a/Assets/Scripts/Other/SaveManager.cs.meta b/Assets/Scripts/Other/SaveManager.cs.meta new file mode 100644 index 0000000..0cc55ee --- /dev/null +++ b/Assets/Scripts/Other/SaveManager.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 749721a5613594941adaed89b39ea5fe \ No newline at end of file diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 1c92a78..c81a027 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -2,13 +2,13 @@ %TAG !u! tag:unity3d.com,2011: --- !u!78 &1 TagManager: - serializedVersion: 2 + serializedVersion: 3 tags: [] layers: - Default - TransparentFX - Ignore Raycast - - + - Building - Water - UI - @@ -41,3 +41,6 @@ TagManager: - name: Default uniqueID: 0 locked: 0 + m_RenderingLayers: + - Default + m_MigratedRenderPipelines: []