Fix shop System

add food indicator
This commit is contained in:
Vladimir Koshevarov
2022-11-17 17:24:00 +02:00
parent be3161d7e4
commit c8047bd170
16 changed files with 663 additions and 286 deletions
+408 -18
View File
@@ -274,7 +274,7 @@ Transform:
- {fileID: 1152324441}
- {fileID: 1382752553}
m_Father: {fileID: 0}
m_RootOrder: 8
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &107380536
GameObject:
@@ -2773,7 +2773,7 @@ Transform:
- {fileID: 712058892}
- {fileID: 723568106}
m_Father: {fileID: 0}
m_RootOrder: 7
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!1 &307039698
GameObject:
@@ -2804,8 +2804,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 98af8458d80ad3a489a169272f679b4c, type: 3}
m_Name:
m_EditorClassIdentifier:
_timeMultiplier: 2000
_startHour: 12
_startHour: 9
_sunLight: {fileID: 705507994}
_sunriseHour: 7
_sunsetHour: 20.5
@@ -2847,6 +2846,7 @@ MonoBehaviour:
_maxSunLightIntensity: 1
_moonLight: {fileID: 448269317}
_maxMoonLightIntensity: 0.5
_minuteToRealTime: 0.5
--- !u!4 &307039700
Transform:
m_ObjectHideFlags: 0
@@ -3204,12 +3204,12 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 448269316}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: -22.298813, y: -3.8542924, z: 7.9937162}
m_LocalPosition: {x: -223.0188, y: -581.07855, z: 8.663528}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_Father: {fileID: 1504187455}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &497576565
GameObject:
@@ -3243,6 +3243,7 @@ RectTransform:
- {fileID: 1006389537}
- {fileID: 1235246448}
- {fileID: 1613486730}
- {fileID: 737469174}
m_Father: {fileID: 329780516}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@@ -3251,6 +3252,82 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 22.531006}
m_SizeDelta: {x: 0, y: -45.062}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &548419713
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 548419714}
- component: {fileID: 548419716}
- component: {fileID: 548419715}
m_Layer: 5
m_Name: Border
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &548419714
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 548419713}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1326618497}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -0.22940063, y: 0}
m_SizeDelta: {x: 0.4588, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &548419715
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 548419713}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.2677999, g: 0.3081395, b: 0.3207547, 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_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &548419716
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 548419713}
m_CullTransparentMesh: 1
--- !u!1 &631616956
GameObject:
m_ObjectHideFlags: 0
@@ -3604,12 +3681,12 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 705507993}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalPosition: {x: 0, y: 100, z: 0}
m_LocalPosition: {x: -200.71999, y: -477.22424, z: 0.6698125}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 2
m_Father: {fileID: 1504187455}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
--- !u!1 &712058891
GameObject:
@@ -3806,6 +3883,44 @@ Transform:
m_Father: {fileID: 274182514}
m_RootOrder: 18
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &737469173
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 737469174}
m_Layer: 5
m_Name: Food
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &737469174
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 737469173}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1326618497}
- {fileID: 1764865642}
m_Father: {fileID: 497576566}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -337.8, y: -17.039}
m_SizeDelta: {x: 100, y: 21.462}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &779251533
GameObject:
m_ObjectHideFlags: 0
@@ -3991,7 +4106,7 @@ PrefabInstance:
m_Modifications:
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_RootOrder
value: 10
value: 9
objectReference: {fileID: 0}
- target: {fileID: -8679921383154817045, guid: 32790d47acc86814982f18993097a759, type: 3}
propertyPath: m_LocalScale.x
@@ -4909,7 +5024,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -4.39, y: -0.6}
m_AnchoredPosition: {x: -4.200001, y: -0.000024795532}
m_SizeDelta: {x: -16.4603, y: -13.6867}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &910851332
@@ -4959,7 +5074,7 @@ MonoBehaviour:
m_MinValue: 0
m_MaxValue: 100
m_WholeNumbers: 0
m_Value: 0
m_Value: 52.4
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
@@ -6297,8 +6412,98 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 6
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1326618496
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1326618497}
- component: {fileID: 1326618498}
m_Layer: 5
m_Name: Bar
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1326618497
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1326618496}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 548419714}
- {fileID: 2085197806}
m_Father: {fileID: 737469174}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: -4.200001, y: -0.000024795532}
m_SizeDelta: {x: -16.4603, y: -13.6867}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1326618498
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1326618496}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67db9e8f0e2ae9c40bc1e2b64352a6b4, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 0
m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 0
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: 0}
m_FillRect: {fileID: 2085197806}
m_HandleRect: {fileID: 0}
m_Direction: 0
m_MinValue: 0
m_MaxValue: 100
m_WholeNumbers: 0
m_Value: 51.7
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
--- !u!1 &1328115571
GameObject:
m_ObjectHideFlags: 0
@@ -11251,7 +11456,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 11
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: -90, y: 0, z: 0}
--- !u!1 &1366991730
GameObject:
@@ -11495,6 +11700,39 @@ Rigidbody:
m_Interpolate: 0
m_Constraints: 0
m_CollisionDetection: 0
--- !u!1 &1504187454
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1504187455}
m_Layer: 0
m_Name: Lights
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1504187455
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1504187454}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 200.71999, y: 577.22424, z: -0.6698125}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 705507995}
- {fileID: 448269318}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1550470208
GameObject:
m_ObjectHideFlags: 0
@@ -11561,7 +11799,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1552961642
GameObject:
@@ -11941,7 +12179,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.9245283, g: 0.6511125, b: 0.12646852, a: 1}
m_Color: {r: 0.5529412, g: 0.9254902, b: 0.1254902, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
@@ -12432,6 +12670,82 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1726465720}
m_CullTransparentMesh: 1
--- !u!1 &1764865641
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1764865642}
- component: {fileID: 1764865644}
- component: {fileID: 1764865643}
m_Layer: 5
m_Name: Icon
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1764865642
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1764865641}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 737469174}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -42.5, y: 0}
m_SizeDelta: {x: 13, y: 14}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1764865643
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1764865641}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
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_Sprite: {fileID: 21300000, guid: bc479ad3f781c4540995d023a62d8c1d, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &1764865644
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1764865641}
m_CullTransparentMesh: 1
--- !u!1 &1791787532
GameObject:
m_ObjectHideFlags: 0
@@ -12756,7 +13070,7 @@ Transform:
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2051386990
GameObject:
@@ -12969,6 +13283,82 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2068384140}
m_CullTransparentMesh: 1
--- !u!1 &2085197805
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2085197806}
- component: {fileID: 2085197808}
- component: {fileID: 2085197807}
m_Layer: 5
m_Name: Fill
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2085197806
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2085197805}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1326618497}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -0.16749573, y: 0}
m_SizeDelta: {x: 0.58259, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2085197807
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2085197805}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.5539218, g: 0.9254902, b: 0.1254902, 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_Sprite: {fileID: 10911, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!222 &2085197808
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2085197805}
m_CullTransparentMesh: 1
--- !u!1 &2089282901
GameObject:
m_ObjectHideFlags: 0
+15 -15
View File
@@ -1,16 +1,16 @@
namespace Assets.Scripts.Actions
{
public abstract class BaseAction
{
protected int DurationInTicks { get; }
protected int ElapsedTicks { get; }
protected BaseAction(int durationTicks)
{
DurationInTicks = durationTicks;
}
public abstract void ApplyAction(PlayerController playerController);
}
namespace Assets.Scripts.Actions
{
public abstract class BaseAction
{
protected int DurationInTicks { get; }
protected int ElapsedTicks { get; }
protected BaseAction(int durationTicks)
{
DurationInTicks = durationTicks;
}
public abstract void ApplyAction(PlayerManager playerController);
}
}
+5 -5
View File
@@ -5,17 +5,17 @@ namespace Assets.Scripts.Actions
public class Eat : BaseAction, ISellableItem
{
public float Price { get; private set; }
private int _energyPerTick;
public Eat(int duration, int energyPerTick, float price) : base(duration)
private int _energy;
public Eat(int duration, int energy, float price) : base(duration)
{
Price = price;
_energyPerTick = energyPerTick;
_energy = energy;
}
public override void ApplyAction(PlayerController playerController)
public override void ApplyAction(PlayerManager playerController)
{
playerController.foodEnergy.increase(_energyPerTick);
playerController.food.increase(_energy);
}
}
}
+1 -1
View File
@@ -7,7 +7,7 @@
{
_energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
public override void ApplyAction(PlayerManager playerController)
{
playerController.energy.increase(_energyPerTick);
}
+17 -17
View File
@@ -1,17 +1,17 @@
namespace Assets.Scripts.Actions
{
public class Work : BaseAction
{
private PlayerController playerController;
private int energyPerTick;
public Work(PlayerController player, int duration, int energyPerTick) : base(duration)
{
this.playerController = player;
this.energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerController playerController)
{
throw new System.NotImplementedException();
}
}
}
namespace Assets.Scripts.Actions
{
public class Work : BaseAction
{
private PlayerManager playerController;
private int energyPerTick;
public Work(PlayerManager player, int duration, int energyPerTick) : base(duration)
{
this.playerController = player;
this.energyPerTick = energyPerTick;
}
public override void ApplyAction(PlayerManager playerController)
{
throw new System.NotImplementedException();
}
}
}
+23 -23
View File
@@ -1,23 +1,23 @@
using Assets.Scripts.Actions;
namespace Assets.Scripts.Buildings
{
public class Burger : BaseCell
{
protected override void Initialize()
{
_name = "Monolith burger";
}
protected override void BuildOptionsList()
{
_optionsList.Add("Hamburgers - 83$", new Eat(6, 1, 83));
_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
}
}
}
using Assets.Scripts.Actions;
namespace Assets.Scripts.Buildings
{
public class Burger : BaseCell
{
protected override void Initialize()
{
_name = "Monolith burger";
}
protected override void BuildOptionsList()
{
_optionsList.Add("Hamburgers - 83$", new Eat(6, 10, 83));
_optionsList.Add("Cheesburger - 94$", new Eat(6, 1, 94));
_optionsList.Add("Astro chicken - 131$", new Eat(6, 1, 131));
_optionsList.Add("Fries - 68$", new Eat(6, 1, 68));
_optionsList.Add("Shakes - 108$", new Eat(6, 1, 108));
_optionsList.Add("Colas - 73$", new Eat(6, 1, 73));
}
}
}
-47
View File
@@ -1,47 +0,0 @@
using UnityEngine;
using UnityEngine.AI;
public class CharacterMovement : MonoBehaviour
{
public NavMeshAgent player;
public Animator playerAnimator;
public Camera playerCamera;
public ParticleSystem targetDest;
public bool allowMovement=true;
void Start()
{
allowMovement = true;
}
// Update is called once per frame
void Update()
{
if (allowMovement)
{
if (Input.GetMouseButton(0))
{
Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(myRay, out RaycastHit hit))
{
targetDest.transform.position = hit.point;
targetDest.Play();
player.SetDestination(hit.point);
}
}
}
else
{
player.SetDestination(player.transform.position);
player.velocity=Vector3.zero;
}
if(player.velocity!=Vector3.zero)
{
playerAnimator.SetBool("IsWalking",true);
}
else if (player.velocity == Vector3.zero)
{
playerAnimator.SetBool("IsWalking", false);
}
}
}
-11
View File
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: e34d78101f2c2b842864fce206379a7c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,61 +1,46 @@
using Assets.Scripts.Actions;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[System.Serializable]
public class ConversationChangeEvent : UnityEvent<BaseAction> { }
public class ChoiceController : MonoBehaviour
{
public PlayerController playerController;
public KeyValuePair<string, BaseAction> _option;
public ConversationChangeEvent conversationChangeEvent;
// Update is called once per frame
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, KeyValuePair<string, BaseAction> option, int index)
{
int buttonSpacing = -50;
Button button = Instantiate(choiceButtonTemplate);
button.transform.SetParent(choiceButtonTemplate.transform.parent);
button.transform.localScale = Vector3.one;
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
button.name = option.Key;
button.gameObject.SetActive(true);
ChoiceController choiceController = button.GetComponent<ChoiceController>();
choiceController._option = option;
return choiceController;
}
private void Start()
{
if (conversationChangeEvent == null)
conversationChangeEvent = new ConversationChangeEvent();
var btn = GetComponent<Button>();
var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
txt.text = _option.Key;
}
public void MakeChoice()
{
if (playerController.TryBuyAction(_option.Value))
{
conversationChangeEvent.Invoke(_option.Value);
}
else
{
YesNoDialogUI.Instance.ShowQuestion("not enouth money",
() =>
{
},
() =>
{
//do nothing
});
}
}
}
using Assets.Scripts.Actions;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[System.Serializable]
public class ConversationChangeEvent : UnityEvent<BaseAction> { }
public class ChoiceController : MonoBehaviour
{
public KeyValuePair<string, BaseAction> _option;
public ConversationChangeEvent conversationChangeEvent;
// Update is called once per frame
public static ChoiceController AddChoiceButton(Button choiceButtonTemplate, KeyValuePair<string, BaseAction> option, int index)
{
int buttonSpacing = -50;
Button button = Instantiate(choiceButtonTemplate);
button.transform.SetParent(choiceButtonTemplate.transform.parent);
button.transform.localScale = Vector3.one;
button.transform.localPosition = choiceButtonTemplate.transform.localPosition + new Vector3(0, index * buttonSpacing, 0);
button.name = option.Key;
button.gameObject.SetActive(true);
ChoiceController choiceController = button.GetComponent<ChoiceController>();
choiceController._option = option;
return choiceController;
}
private void Start()
{
if (conversationChangeEvent == null)
conversationChangeEvent = new ConversationChangeEvent();
var btn = GetComponent<Button>();
var txt = btn.GetComponentInChildren<TextMeshProUGUI>();
txt.text = _option.Key;
}
public void MakeChoice()
{
conversationChangeEvent.Invoke(_option.Value);
}
}
@@ -1,67 +1,85 @@
using Assets.Scripts.Actions;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ConversationController : MonoBehaviour
{
[SerializeField]
public TextMeshProUGUI _title;
[SerializeField]
public Button _choiceButton;
[SerializeField]
using Assets.Scripts.Actions;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ConversationController : MonoBehaviour
{
[SerializeField]
public TextMeshProUGUI _title;
[SerializeField]
public Button _choiceButton;
[SerializeField]
private Button _closeBtn;
[SerializeField]
CharacterMovement _player;
public ConversationChangeEvent conversationChangeEvent;
private List<ChoiceController> choiceControllers = new();
private void Awake()
{
Hide();
}
public void Change(string title, Dictionary<string, BaseAction> options)
[SerializeField]
PlayerManager _playerManager;
public ConversationChangeEvent conversationChangeEvent;
private List<ChoiceController> choiceControllers = new();
private void Awake()
{
Hide();
}
public void Change(string title, Dictionary<string, BaseAction> options)
{
_closeBtn.onClick.AddListener(() =>
{
Hide();
});
_player.allowMovement = false;
RemoveChoices();
_title.text = title;
gameObject.SetActive(true);
for (var count = 0; count < options.Count; count++)
{
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
choiceControllers.Add(c);
}
StopAllCoroutines();
Time.timeScale = 0;
_choiceButton.gameObject.SetActive(false);
}
private void RemoveChoices()
{
foreach (ChoiceController c in choiceControllers)
Destroy(c.gameObject);
choiceControllers.Clear();
}
public void Hide()
{
RemoveChoices();
gameObject.SetActive(false);
Time.timeScale = 1;
_player.allowMovement = true;
}
}
});
_playerManager.allowMovement = false;
RemoveChoices();
_title.text = title;
gameObject.SetActive(true);
for (var count = 0; count < options.Count; count++)
{
ChoiceController c = ChoiceController.AddChoiceButton(_choiceButton, options.ElementAt(count), count);
c.conversationChangeEvent.AddListener(ApplyActionOnPlayer);
choiceControllers.Add(c);
}
StopAllCoroutines();
Time.timeScale = 0;
_choiceButton.gameObject.SetActive(false);
}
private void ApplyActionOnPlayer(BaseAction action)
{
if (!_playerManager.TryBuyAction(action))
{
YesNoDialogUI.Instance.ShowQuestion("not enouth money",
() =>
{
},
() =>
{
//do nothing
});
}
}
private void RemoveChoices()
{
foreach (ChoiceController c in choiceControllers)
{
c.conversationChangeEvent.RemoveAllListeners();
Destroy(c.gameObject);
}
choiceControllers.Clear();
}
public void Hide()
{
RemoveChoices();
gameObject.SetActive(false);
Time.timeScale = 1;
_playerManager.allowMovement = true;
}
}
+20 -20
View File
@@ -1,20 +1,20 @@
using UnityEngine;
public class GameController : MonoBehaviour
{
public Map GameMap;
public PlayerController Player;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
using UnityEngine;
public class GameController : MonoBehaviour
{
public Map GameMap;
public PlayerManager Player;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
@@ -2,10 +2,10 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GameUIController : MonoBehaviour
public class GameUIManager : MonoBehaviour
{
[SerializeField]
private PlayerController _playerController;
private PlayerManager _playerController;
[SerializeField]
private TextMeshProUGUI _timeText;
@@ -16,6 +16,9 @@ public class GameUIController : MonoBehaviour
[SerializeField]
public Slider _energy;
[SerializeField]
public Slider _food;
// Start is called before the first frame update
private void OnEnable()
{
@@ -31,7 +34,7 @@ public class GameUIController : MonoBehaviour
void Update()
{
_moneyText.text = $"${_playerController.money.Value}";
_energy.value = _playerController.energy.Value;
}
@@ -41,5 +44,8 @@ public class GameUIController : MonoBehaviour
{
_timeText.text = TimeManager.CurrentTime.ToString(@"hh\:mm");
}
_energy.value = _playerController.energy.Value;
_food.value = _playerController.food.Value;
}
}
@@ -1,12 +1,13 @@
using Assets.Scripts.Actions;
using Assets.Scripts.Actions.Interfaces;
using UnityEngine;
using UnityEngine.AI;
public class PlayerController : MonoBehaviour
public class PlayerManager : MonoBehaviour
{
public Stat money = new Stat("Money", 100.0f);
public Stat money = new Stat("Money", 1000.0f);
public Stat rentAccount = new Stat("Rent Account", 0);
public Stat foodEnergy = new Stat("Food Energy", 0);
public Stat food = new Stat("Food Energy", 100);
public Stat energy = new Stat("Energy", 100);
// bank
@@ -40,6 +41,12 @@ public class PlayerController : MonoBehaviour
public Stat tvItem = new Stat("Tv Item", 1500, 1);
public Stat laptopItem = new Stat("Laptop Item", 3000, 1);
public NavMeshAgent player;
public Animator playerAnimator;
public Camera playerCamera;
public ParticleSystem targetDest;
public bool allowMovement = true;
private void OnEnable()
{
TimeManager.OnMinuteChanged += DecreaseEnergy;
@@ -50,17 +57,46 @@ public class PlayerController : MonoBehaviour
TimeManager.OnMinuteChanged -= DecreaseEnergy;
}
// Start is called before the first frame update
void Start()
{
allowMovement = true;
}
// Update is called once per frame
void Update()
{
if (allowMovement)
{
if (Input.GetMouseButton(0))
{
Ray myRay = playerCamera.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(myRay, out RaycastHit hit))
{
targetDest.transform.position = hit.point;
targetDest.Play();
player.SetDestination(hit.point);
}
}
}
else
{
player.SetDestination(player.transform.position);
player.velocity = Vector3.zero;
}
if (player.velocity != Vector3.zero)
{
playerAnimator.SetBool("IsWalking", true);
}
else if (player.velocity == Vector3.zero)
{
playerAnimator.SetBool("IsWalking", false);
}
}
public void DecreaseEnergy()
{
food.deduct(1f);
energy.deduct(0.096f); // 24 hours it's 100, 100/1440=~0.096 per minute
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB