Исправлены файлы BuildingUI и ResourceCollector после конфликта

This commit is contained in:
2026-09-05 16:39:40 +03:00
parent 1bf238d2ff
commit 629b5016df
4 changed files with 419 additions and 194 deletions
+306 -5
View File
@@ -482,6 +482,306 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165797562} m_GameObject: {fileID: 165797562}
m_CullTransparentMesh: 1 m_CullTransparentMesh: 1
--- !u!1 &191012908
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 191012909}
- component: {fileID: 191012915}
- component: {fileID: 191012914}
- component: {fileID: 191012913}
- component: {fileID: 191012912}
- component: {fileID: 191012911}
- component: {fileID: 191012910}
m_Layer: 5
m_Name: Canvas (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &191012909
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.43890655, y: 0.42053616, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 289613111}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0.64400417, y: -3.4722366}
m_SizeDelta: {x: 5.3081, y: 1.2404}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &191012910
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 9541d86e2fd84c1d9990edf0852d74ab, type: 3}
m_Name:
m_EditorClassIdentifier: Unity.TextMeshPro::TMPro.TextMeshPro
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text:
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_characterHorizontalScale: 1
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_TextWrappingMode: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 0
m_ActiveFontFeatures: 6e72656b
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_EmojiFallbackSupport: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 0
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
_SortingLayer: 0
_SortingLayerID: 0
_SortingOrder: 0
m_hasFontAssetChanged: 0
m_renderer: {fileID: 191012911}
m_maskType: 0
--- !u!23 &191012911
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 2
m_RayTraceProcedural: 0
m_RayTracingAccelStructBuildFlagsOverride: 0
m_RayTracingAccelStructBuildFlags: 1
m_SmallMeshCulling: 1
m_ForceMeshLod: -1
m_MeshLodSelectionBias: 0
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_ReceiveGI: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 1
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_GlobalIlluminationMeshLod: 0
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_MaskInteraction: 0
m_AdditionalVertexStreams: {fileID: 0}
--- !u!114 &191012912
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.Slider
m_Navigation:
m_Mode: 3
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 191012910}
m_FillRect: {fileID: 0}
m_HandleRect: {fileID: 0}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 1
m_WholeNumbers: 0
m_Value: 0
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!114 &191012913
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.GraphicRaycaster
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!114 &191012914
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier: UnityEngine.UI::UnityEngine.UI.CanvasScaler
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 10
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
--- !u!223 &191012915
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 191012908}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_UseReflectionProbes: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!1 &204590793 --- !u!1 &204590793
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@@ -1530,7 +1830,8 @@ Transform:
m_LocalPosition: {x: -14.599976, y: 5.399994, z: 0} m_LocalPosition: {x: -14.599976, y: 5.399994, z: 0}
m_LocalScale: {x: 2.2783892, y: 2.3779166, z: 1} m_LocalScale: {x: 2.2783892, y: 2.3779166, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children:
- {fileID: 191012909}
m_Father: {fileID: 730896379} m_Father: {fileID: 730896379}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &289613112 --- !u!114 &289613112
@@ -1628,15 +1929,15 @@ RectTransform:
m_GameObject: {fileID: 290395353} m_GameObject: {fileID: 290395353}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.61637074, y: 0.35242996, z: 1} m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 1140293331} m_Father: {fileID: 1140293331}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0.1278, y: 0.847} m_AnchoredPosition: {x: 1, y: 1.5}
m_SizeDelta: {x: 5.3081, y: 1.2404} m_SizeDelta: {x: 200, y: 80}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &290395355 --- !u!114 &290395355
MonoBehaviour: MonoBehaviour:
@@ -1658,7 +1959,7 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: m_text: 0/100
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
+7 -22
View File
@@ -1,49 +1,35 @@
using System;
<<<<<<< HEAD
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using TMPro; using TMPro;
=======
using Unity.VisualScripting;
using UnityEditor.Build.Player;
using UnityEngine;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.UI;
>>>>>>> origin/main
public class BuildingUI : MonoBehaviour public class BuildingUI : MonoBehaviour
{ {
[Header("Настройки")] [Header("Настройки")]
public ResourceCollector building;
public TMP_Text stokText;
public Slider progressBar;
public ResourceCollector building; void Start()
<<<<<<< HEAD
public TMP_Text stokText;
=======
public Text stokText;
>>>>>>> origin/main
public Slider progressBar;
void Start()
{ {
if (building == null) if (building == null)
{ {
Debug.LogError("Ошибка BuildingUI: не назначено здание (Buildint)!"); Debug.LogError("Ошибка BuildingUI: не назначено здание (Building)!");
enabled = false; enabled = false;
return; return;
} }
UpdateUI(); UpdateUI();
} }
void Update() void Update()
{ {
UpdateUI(); UpdateUI();
} }
void UpdateUI() void UpdateUI()
{ {
if (stokText != null) if (stokText != null)
{ {
stokText.text = $"{building.GetCurrentStock():F1} / {building.GetMaxCapacity()}"; stokText.text = $"{building.GetCurrentStock():F1} / {building.GetMaxCapacity()}";
} }
if (progressBar != null) if (progressBar != null)
{ {
@@ -51,5 +37,4 @@ public class BuildingUI : MonoBehaviour
progressBar.value = Mathf.Clamp01(fill); progressBar.value = Mathf.Clamp01(fill);
} }
} }
} }
+15 -80
View File
@@ -1,9 +1,4 @@
using UnityEngine; using UnityEngine;
using System.Collections;
<<<<<<< HEAD
using System;
=======
>>>>>>> origin/main
public class ResourceCollector : MonoBehaviour public class ResourceCollector : MonoBehaviour
{ {
@@ -39,7 +34,6 @@ public class ResourceCollector : MonoBehaviour
currentStock = 0f; currentStock = 0f;
} }
// НОВЫЙ МЕТОД: Чтобы UI мог спрашивать: "Сколько там сейчас?"
public float GetCurrentStock() public float GetCurrentStock()
{ {
return currentStock; return currentStock;
@@ -52,105 +46,46 @@ public class ResourceCollector : MonoBehaviour
void OnMouseDown() void OnMouseDown()
{ {
<<<<<<< HEAD if (isRecharging)
// Если уже идёт восстановление — ничего не делаем
if (isRecharging)
{
Debug.Log($"[КЛИК] {gameObject.name}: уже идёт восстановление, ждём.");
return;
}
// Если запас есть — забираем ресурсы
if (currentStock > 0)
{
float finalAmount = amountPerClick * Mathf.Pow(perLevelMultiplier, level - 1);
float reward = currentStock; // берём всё, что накопилось
_manager.AddResource(resourceType, reward);
currentStock = 0f;
Debug.Log($"[СБОР] Получено {reward:F1} {resourceType}. Запас сброшен в 0.");
// Сразу запускаем восстановление после сбора
=======
if (currentStock <= 0)
{ {
Debug.Log($"[КЛИК] {gameObject.name} пуст. Идет восстановление..."); Debug.Log($"[КЛИК] {gameObject.name}: уже идёт восстановление, ждём.");
return; return;
} }
float finalAmount = amountPerClick * Mathf.Pow(perLevelMultiplier, level - 1); if (currentStock > 0)
// Отдаем всё, что накопилось
float reward = currentStock;
_manager.AddResource(resourceType, reward);
// СБРОС В НОЛЬ
currentStock = 0f;
Debug.Log($"[СБОР] Получено {reward:F1} {resourceType}. Запас сброшен в 0.");
>>>>>>> origin/main
if (!isRecharging)
{ {
float reward = currentStock; // берём всё, что накопилось
_manager.AddResource(resourceType, reward);
currentStock = 0f;
Debug.Log($"[СБОР] Получено {reward:F1} {resourceType}. Запас сброшен в 0.");
StartCoroutine(RechargeRoutine());
}
else
{
Debug.Log($"[КЛИК] {gameObject.name} пуст, запускаем восстановление.");
StartCoroutine(RechargeRoutine()); StartCoroutine(RechargeRoutine());
} }
} }
<<<<<<< HEAD
else
{
// Если запаса нет и восстановление ещё не запущено — запускаем его
Debug.Log($"[КЛИК] {gameObject.name} пуст, запускаем восстановление.");
if (!isRecharging)
{
StartCoroutine(RechargeRoutine());
}
}
}
System.Collections.IEnumerator RechargeRoutine()
{
if (isRecharging) yield break;
isRecharging = true;
float rechargeRate = 5f; // единиц в секунду
float timeToFill = (maxCapacity - currentStock) / rechargeRate;
float elapsed = 0f;
while (elapsed < timeToFill)
{
elapsed += Time.deltaTime;
float progress = Mathf.Clamp01(elapsed / timeToFill);
currentStock = Mathf.Lerp(currentStock, maxCapacity, progress);
yield return null;
}
currentStock = maxCapacity;
isRecharging = false;
Debug.Log($"[ГОТОВО] {gameObject.name} полностью заполнен!");
}
=======
System.Collections.IEnumerator RechargeRoutine() System.Collections.IEnumerator RechargeRoutine()
{ {
if (isRecharging) yield break; if (isRecharging) yield break;
isRecharging = true; isRecharging = true;
float rechargeRate = 5f; // Единиц в секунду float rechargeRate = 5f; // единиц в секунду
while (currentStock < maxCapacity) while (currentStock < maxCapacity)
{ {
currentStock += rechargeRate * Time.deltaTime; currentStock += rechargeRate * Time.deltaTime;
if (currentStock > maxCapacity) currentStock = maxCapacity; if (currentStock > maxCapacity) currentStock = maxCapacity;
yield return null; yield return null;
} }
isRecharging = false; isRecharging = false;
Debug.Log($"[ГОТОВО] {gameObject.name} полностью заполнен!"); Debug.Log($"[ГОТОВО] {gameObject.name} полностью заполнен!");
} }
>>>>>>> origin/main
public void Upgrade() public void Upgrade()
{ {
File diff suppressed because one or more lines are too long