Merge branch 'Alexei' into Zakhar
This commit is contained in:
commit
37d7562f85
@ -17,7 +17,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!224 &4726489279989878082
|
--- !u!224 &4726489279989878082
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -1706,7 +1706,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 4572196853266583038}
|
- component: {fileID: 4572196853266583038}
|
||||||
- component: {fileID: 4105327572543419563}
|
- component: {fileID: 4105327572543419563}
|
||||||
- component: {fileID: 5011141071925245406}
|
|
||||||
- component: {fileID: 1900872271281143359}
|
- component: {fileID: 1900872271281143359}
|
||||||
- component: {fileID: 5890376687783205851}
|
- component: {fileID: 5890376687783205851}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@ -1768,20 +1767,6 @@ Animator:
|
|||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
--- !u!114 &5011141071925245406
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 3762867976042010436}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
barCanvas: {fileID: 0}
|
|
||||||
aimCanvas: {fileID: 0}
|
|
||||||
--- !u!136 &1900872271281143359
|
--- !u!136 &1900872271281143359
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -2933,7 +2933,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 7150739129758644021}
|
- component: {fileID: 7150739129758644021}
|
||||||
- component: {fileID: -4568693640035559416}
|
- component: {fileID: -4568693640035559416}
|
||||||
- component: {fileID: 8989822822968797088}
|
|
||||||
- component: {fileID: 8911891366586862002}
|
- component: {fileID: 8911891366586862002}
|
||||||
- component: {fileID: 3288245434296440335}
|
- component: {fileID: 3288245434296440335}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@ -2995,20 +2994,6 @@ Animator:
|
|||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
--- !u!114 &8989822822968797088
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 7527582019267571087}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
barCanvas: {fileID: 0}
|
|
||||||
aimCanvas: {fileID: 0}
|
|
||||||
--- !u!136 &8911891366586862002
|
--- !u!136 &8911891366586862002
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -312,7 +312,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 73672630868547665}
|
- component: {fileID: 73672630868547665}
|
||||||
- component: {fileID: -4047225411828250527}
|
- component: {fileID: -4047225411828250527}
|
||||||
- component: {fileID: 8353965929846142445}
|
|
||||||
- component: {fileID: 1571523103774403885}
|
- component: {fileID: 1571523103774403885}
|
||||||
- component: {fileID: 8290923392032443996}
|
- component: {fileID: 8290923392032443996}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@ -374,20 +373,6 @@ Animator:
|
|||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
--- !u!114 &8353965929846142445
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 742650227762578155}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
barCanvas: {fileID: 0}
|
|
||||||
aimCanvas: {fileID: 0}
|
|
||||||
--- !u!136 &1571523103774403885
|
--- !u!136 &1571523103774403885
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -3438,7 +3438,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 8075972121593568698}
|
- component: {fileID: 8075972121593568698}
|
||||||
- component: {fileID: -1510388322638865353}
|
- component: {fileID: -1510388322638865353}
|
||||||
- component: {fileID: 7120083236827966330}
|
|
||||||
- component: {fileID: 2198464067484123790}
|
- component: {fileID: 2198464067484123790}
|
||||||
- component: {fileID: 5657146932405139005}
|
- component: {fileID: 5657146932405139005}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@ -3500,20 +3499,6 @@ Animator:
|
|||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
--- !u!114 &7120083236827966330
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8887939040951305984}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
barCanvas: {fileID: 0}
|
|
||||||
aimCanvas: {fileID: 0}
|
|
||||||
--- !u!136 &2198464067484123790
|
--- !u!136 &2198464067484123790
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -97,7 +97,6 @@ GameObject:
|
|||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 609351601165668828}
|
- component: {fileID: 609351601165668828}
|
||||||
- component: {fileID: -1148229131982139879}
|
- component: {fileID: -1148229131982139879}
|
||||||
- component: {fileID: 7312803781132825500}
|
|
||||||
- component: {fileID: 6373024555497604353}
|
- component: {fileID: 6373024555497604353}
|
||||||
- component: {fileID: 3412540945423151583}
|
- component: {fileID: 3412540945423151583}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
@ -159,20 +158,6 @@ Animator:
|
|||||||
m_HasTransformHierarchy: 1
|
m_HasTransformHierarchy: 1
|
||||||
m_AllowConstantClipSamplingOptimization: 1
|
m_AllowConstantClipSamplingOptimization: 1
|
||||||
m_KeepAnimatorControllerStateOnDisable: 0
|
m_KeepAnimatorControllerStateOnDisable: 0
|
||||||
--- !u!114 &7312803781132825500
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 233917392663333734}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 11500000, guid: 04619977b07331e43a21b8d1bc33b6e9, type: 3}
|
|
||||||
m_Name:
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
barCanvas: {fileID: 0}
|
|
||||||
aimCanvas: {fileID: 0}
|
|
||||||
--- !u!136 &6373024555497604353
|
--- !u!136 &6373024555497604353
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
@ -26,7 +26,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 5503245665281670417}
|
m_GameObject: {fileID: 5503245665281670417}
|
||||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 0.11548259, y: 0.11548259, z: 0.11548259}
|
m_LocalScale: {x: 0.11548259, y: 0.11548259, z: 0.11548259}
|
||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1687892424394123116}
|
- {fileID: 1687892424394123116}
|
||||||
@ -40,7 +40,7 @@ MeshFilter:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 5503245665281670417}
|
m_GameObject: {fileID: 5503245665281670417}
|
||||||
m_Mesh: {fileID: 4300000, guid: e161d2913bca37a44a645d97c1e0c715, type: 3}
|
m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
--- !u!23 &5478883122182798693
|
--- !u!23 &5478883122182798693
|
||||||
MeshRenderer:
|
MeshRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -115,7 +115,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
- target: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
||||||
propertyPath: m_LocalPosition.y
|
propertyPath: m_LocalPosition.y
|
||||||
value: -6.920007
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
- target: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
||||||
propertyPath: m_LocalPosition.z
|
propertyPath: m_LocalPosition.z
|
||||||
@ -169,7 +169,6 @@ PrefabInstance:
|
|||||||
m_SourcePrefab: {fileID: 100100000, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
||||||
--- !u!4 &1687892424394123116 stripped
|
--- !u!4 &1687892424394123116 stripped
|
||||||
Transform:
|
Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e,
|
m_CorrespondingSourceObject: {fileID: 460430, guid: 3b671081e44be1c4aa4355e8ba6e8a5e, type: 3}
|
||||||
type: 3}
|
|
||||||
m_PrefabInstance: {fileID: 1687892424393925090}
|
m_PrefabInstance: {fileID: 1687892424393925090}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
@ -23,6 +23,8 @@ MonoBehaviour:
|
|||||||
_spawnChance: 0.705
|
_spawnChance: 0.705
|
||||||
- item: {fileID: 11400000, guid: 98f59e15ea7ad2d47b2e3ffd67e2a650, type: 2}
|
- item: {fileID: 11400000, guid: 98f59e15ea7ad2d47b2e3ffd67e2a650, type: 2}
|
||||||
_spawnChance: 0.64
|
_spawnChance: 0.64
|
||||||
|
- item: {fileID: 11400000, guid: 7605998bd1a481543a96857fa015169b, type: 2}
|
||||||
|
_spawnChance: 0.848
|
||||||
- item: {fileID: 11400000, guid: 133e523fdd159754e8bf8927faec5b0f, type: 2}
|
- item: {fileID: 11400000, guid: 133e523fdd159754e8bf8927faec5b0f, type: 2}
|
||||||
_spawnChance: 0.833
|
_spawnChance: 0.833
|
||||||
- item: {fileID: 11400000, guid: 133e523fdd159754e8bf8927faec5b0f, type: 2}
|
- item: {fileID: 11400000, guid: 133e523fdd159754e8bf8927faec5b0f, type: 2}
|
||||||
|
30
Assets/Resources/Data/Items/Rocket.asset
Normal file
30
Assets/Resources/Data/Items/Rocket.asset
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!114 &11400000
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 30d4ee04b4d04d47ad8f932a004c1728, type: 3}
|
||||||
|
m_Name: Rocket
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
icon: {fileID: 21300000, guid: f591ebc6dc1028948aa740d86f44adb9, type: 3}
|
||||||
|
type: 0
|
||||||
|
_weapon:
|
||||||
|
name: Rocket
|
||||||
|
icon: {fileID: 0}
|
||||||
|
objectToThrow: {fileID: 5503245665281670417, guid: 857de15730a382b48a9d497d078336cd, type: 3}
|
||||||
|
VFXGameObject: {fileID: 8032726150168125150, guid: 65c8920b6d1553a4d885992e8f7dff6a, type: 3}
|
||||||
|
modifiedDamage: 0
|
||||||
|
damage: 100
|
||||||
|
speed: 1
|
||||||
|
disnatce: 10
|
||||||
|
reloadTime: 1
|
||||||
|
shots: 1
|
||||||
|
shotSound: {fileID: 0}
|
||||||
|
hitSound: {fileID: 0}
|
||||||
|
_aimGameObject: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3}
|
@ -1,8 +1,8 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: cde640b28d28d9d44884fde46fe58fbf
|
guid: 7605998bd1a481543a96857fa015169b
|
||||||
folderAsset: yes
|
NativeFormatImporter:
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 11400000
|
||||||
userData:
|
userData:
|
||||||
assetBundleName:
|
assetBundleName:
|
||||||
assetBundleVariant:
|
assetBundleVariant:
|
@ -14,6 +14,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_units:
|
_units:
|
||||||
- isPlayer: 0
|
- isPlayer: 0
|
||||||
|
isAI: 1
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 19
|
x: 19
|
||||||
z: 4
|
z: 4
|
||||||
@ -23,7 +24,8 @@ MonoBehaviour:
|
|||||||
maxMana: 1000
|
maxMana: 1000
|
||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 1
|
- isPlayer: 0
|
||||||
|
isAI: 1
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: 3
|
x: 3
|
||||||
z: 4
|
z: 4
|
||||||
@ -33,7 +35,8 @@ MonoBehaviour:
|
|||||||
maxMana: 1000
|
maxMana: 1000
|
||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 1
|
||||||
|
isAI: 0
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: -1
|
x: -1
|
||||||
z: 42
|
z: 42
|
||||||
@ -44,6 +47,7 @@ MonoBehaviour:
|
|||||||
maxHP: 100
|
maxHP: 100
|
||||||
inventoryCapacity: 4
|
inventoryCapacity: 4
|
||||||
- isPlayer: 0
|
- isPlayer: 0
|
||||||
|
isAI: 1
|
||||||
spawnPos:
|
spawnPos:
|
||||||
x: -17
|
x: -17
|
||||||
z: 40
|
z: 40
|
||||||
|
@ -1,179 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &573487771985128269
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 7336257010221584373}
|
|
||||||
- component: {fileID: 2261832089206299311}
|
|
||||||
- component: {fileID: 3682028664096015806}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Layer1
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &7336257010221584373
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 573487771985128269}
|
|
||||||
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_Children: []
|
|
||||||
m_Father: {fileID: 6325281106960576957}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!1839735485 &2261832089206299311
|
|
||||||
Tilemap:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 573487771985128269}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_Tiles: {}
|
|
||||||
m_AnimatedTiles: {}
|
|
||||||
m_TileAssetArray: []
|
|
||||||
m_TileSpriteArray: []
|
|
||||||
m_TileMatrixArray: []
|
|
||||||
m_TileColorArray: []
|
|
||||||
m_TileObjectToInstantiateArray: []
|
|
||||||
m_AnimationFrameRate: 1
|
|
||||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
m_Origin: {x: 0, y: 0, z: 0}
|
|
||||||
m_Size: {x: 0, y: 0, z: 1}
|
|
||||||
m_TileAnchor: {x: 0, y: 0, z: 0}
|
|
||||||
m_TileOrientation: 0
|
|
||||||
m_TileOrientationMatrix:
|
|
||||||
e00: 1
|
|
||||||
e01: 0
|
|
||||||
e02: 0
|
|
||||||
e03: 0
|
|
||||||
e10: 0
|
|
||||||
e11: 1
|
|
||||||
e12: 0
|
|
||||||
e13: 0
|
|
||||||
e20: 0
|
|
||||||
e21: 0
|
|
||||||
e22: 1
|
|
||||||
e23: 0
|
|
||||||
e30: 0
|
|
||||||
e31: 0
|
|
||||||
e32: 0
|
|
||||||
e33: 1
|
|
||||||
--- !u!483693784 &3682028664096015806
|
|
||||||
TilemapRenderer:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 573487771985128269}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_CastShadows: 0
|
|
||||||
m_ReceiveShadows: 0
|
|
||||||
m_DynamicOccludee: 0
|
|
||||||
m_MotionVectors: 1
|
|
||||||
m_LightProbeUsage: 0
|
|
||||||
m_ReflectionProbeUsage: 0
|
|
||||||
m_RayTracingMode: 0
|
|
||||||
m_RayTraceProcedural: 0
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_RendererPriority: 0
|
|
||||||
m_Materials:
|
|
||||||
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
|
||||||
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: 0
|
|
||||||
m_MinimumChartSize: 4
|
|
||||||
m_AutoUVMaxDistance: 0.5
|
|
||||||
m_AutoUVMaxAngle: 89
|
|
||||||
m_LightmapParameters: {fileID: 0}
|
|
||||||
m_SortingLayerID: 0
|
|
||||||
m_SortingLayer: 0
|
|
||||||
m_SortingOrder: 0
|
|
||||||
m_ChunkSize: {x: 32, y: 32, z: 32}
|
|
||||||
m_ChunkCullingBounds: {x: 0, y: 0, z: 0}
|
|
||||||
m_MaxChunkCount: 16
|
|
||||||
m_MaxFrameAge: 16
|
|
||||||
m_SortOrder: 0
|
|
||||||
m_Mode: 0
|
|
||||||
m_DetectChunkCullingBounds: 0
|
|
||||||
m_MaskInteraction: 0
|
|
||||||
--- !u!1 &5709523213856216068
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 6325281106960576957}
|
|
||||||
- component: {fileID: 4694445811689797251}
|
|
||||||
m_Layer: 31
|
|
||||||
m_Name: New Palette
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &6325281106960576957
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5709523213856216068}
|
|
||||||
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_Children:
|
|
||||||
- {fileID: 7336257010221584373}
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
||||||
--- !u!156049354 &4694445811689797251
|
|
||||||
Grid:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5709523213856216068}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_CellSize: {x: 1, y: 1, z: 0}
|
|
||||||
m_CellGap: {x: 0, y: 0, z: 0}
|
|
||||||
m_CellLayout: 1
|
|
||||||
m_CellSwizzle: 0
|
|
||||||
--- !u!114 &1048497982843186255
|
|
||||||
MonoBehaviour:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 0}
|
|
||||||
m_Enabled: 1
|
|
||||||
m_EditorHideFlags: 0
|
|
||||||
m_Script: {fileID: 12395, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
m_Name: Palette Settings
|
|
||||||
m_EditorClassIdentifier:
|
|
||||||
cellSizing: 0
|
|
||||||
m_TransparencySortMode: 2
|
|
||||||
m_TransparencySortAxis: {x: 0, y: 0, z: 1}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6129d4bf5c9ee654394c0733076e9b2e
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
File diff suppressed because it is too large
Load Diff
@ -124,13 +124,15 @@ namespace AI
|
|||||||
var item = GetNearestItem(agent);
|
var item = GetNearestItem(agent);
|
||||||
if (((item.dist > 0 && item.dist <= _data.DistaceToCollectBonus) ||
|
if (((item.dist > 0 && item.dist <= _data.DistaceToCollectBonus) ||
|
||||||
agent.Unit.Mana <= agent.Unit.Data.maxMana * _data.ManaPercentToCollectBonus) &&
|
agent.Unit.Mana <= agent.Unit.Data.maxMana * _data.ManaPercentToCollectBonus) &&
|
||||||
agent.Unit.Inventory.Count < agent.Unit.InventoryCapacity)
|
(item.hex.Item.Type == ItemType.DEFENCE
|
||||||
|
? agent.Unit.InventoryDefence.Count
|
||||||
|
: agent.Unit.Inventory.Count) < agent.Unit.InventoryCapacity / 2)
|
||||||
{
|
{
|
||||||
SetBehaviour(BotState.CollectingBonus, agent);
|
SetBehaviour(BotState.CollectingBonus, agent);
|
||||||
return BotState.CollectingBonus;
|
return BotState.CollectingBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
var protect = agent.Unit.Inventory.Where(x => x is Bonus { BonusType: BonusType.Defence }).ToList();
|
var protect = agent.Unit.InventoryDefence.Where(x => x is Bonus { BonusType: BonusType.Defence }).ToList();
|
||||||
if (protect.Count > 0 && agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToUseProtectBonus &&
|
if (protect.Count > 0 && agent.Unit.Hp <= agent.Unit.Data.maxHP * _data.PercentToUseProtectBonus &&
|
||||||
agent.Unit.DefenceBonus == 0)
|
agent.Unit.DefenceBonus == 0)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@ using Runtime.Controller;
|
|||||||
|
|
||||||
namespace Controller
|
namespace Controller
|
||||||
{
|
{
|
||||||
public class Controllers : IExecute, IInitialization, ILateExecute, ICleanup
|
public class Controllers : IExecute, IInitialization, ILateExecute, ICleanup, IFixedExecute, IAwake
|
||||||
{
|
{
|
||||||
private readonly List<IInitialization> _initializeControllers;
|
private readonly List<IInitialization> _initializeControllers;
|
||||||
private readonly List<IExecute> _executeControllers;
|
private readonly List<IExecute> _executeControllers;
|
||||||
|
@ -39,7 +39,7 @@ namespace Controller
|
|||||||
hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units);
|
hexGrid.OnGridLoaded += () => unitFactory.SpawnList(data.UnitData.Units);
|
||||||
|
|
||||||
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
hexGrid.OnHexPainted += paintedController.SetHexColors;
|
||||||
hexGrid.OnHexPainted += paintedController.CheckDeathOrDestroy;
|
|
||||||
hexGrid.SpawnField();
|
hexGrid.SpawnField();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ namespace Data
|
|||||||
public struct UnitInfo
|
public struct UnitInfo
|
||||||
{
|
{
|
||||||
public bool isPlayer;
|
public bool isPlayer;
|
||||||
|
public bool isAI;
|
||||||
public HexCoordinates spawnPos;
|
public HexCoordinates spawnPos;
|
||||||
public GameObject unitPrefa;
|
public GameObject unitPrefa;
|
||||||
public UnitColor color;
|
public UnitColor color;
|
||||||
|
@ -87,6 +87,10 @@ namespace GameUI
|
|||||||
ability.Invoke(() => SwitchButton(button));
|
ability.Invoke(() => SwitchButton(button));
|
||||||
OnBuildingInvoked?.Invoke(ability);
|
OnBuildingInvoked?.Invoke(ability);
|
||||||
break;
|
break;
|
||||||
|
case SpecialWeapon specialWeapon:
|
||||||
|
specialWeapon.Invoke(() => SwitchButton(button));
|
||||||
|
OnBuildingInvoked?.Invoke(specialWeapon);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -10,22 +10,23 @@ namespace HexFiled
|
|||||||
public class HexCell : MonoBehaviour
|
public class HexCell : MonoBehaviour
|
||||||
{
|
{
|
||||||
public HexCoordinates coordinates;
|
public HexCoordinates coordinates;
|
||||||
|
public int index;
|
||||||
public event Action<HexCell> OnHexPainted;
|
public event Action<HexCell> OnHexPainted;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[SerializeField] private HexCell[] neighbors;
|
[SerializeField] private HexCell[] neighbors;
|
||||||
[SerializeField] private Item _item;
|
[SerializeField] private Item _item;
|
||||||
private UnitColor _color;
|
private UnitColor _color;
|
||||||
private MeshRenderer _renderer;
|
private MeshRenderer _renderer;
|
||||||
|
|
||||||
public UnitColor Color => _color;
|
public UnitColor Color => _color;
|
||||||
|
|
||||||
public Item Item
|
public Item Item
|
||||||
{
|
{
|
||||||
get => _item;
|
get => _item;
|
||||||
set => _item = _item == null ? value : null;
|
set => _item = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private GameObject _building;
|
private GameObject _building;
|
||||||
|
|
||||||
public GameObject Building
|
public GameObject Building
|
||||||
@ -40,26 +41,35 @@ namespace HexFiled
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SerializibleHexCell ToSerializibleHexCell()
|
||||||
|
{
|
||||||
|
SerializibleHexCell cell = new SerializibleHexCell();
|
||||||
|
cell.HexCoordinates = coordinates;
|
||||||
|
cell.index = index;
|
||||||
|
return cell;
|
||||||
|
}
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
_renderer = GetComponent<MeshRenderer>();
|
_renderer = GetComponent<MeshRenderer>();
|
||||||
_color = UnitColor.Grey;
|
_color = UnitColor.Grey;
|
||||||
|
if (HexManager.CellByColor == null) return;
|
||||||
if (!HexManager.CellByColor.ContainsKey(_color))
|
if (!HexManager.CellByColor.ContainsKey(_color))
|
||||||
{
|
{
|
||||||
HexManager.CellByColor.Add(_color, new List<HexCell>(){this});
|
HexManager.CellByColor.Add(_color, new List<HexCell>() { this });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
HexManager.CellByColor[_color].Add(this);
|
HexManager.CellByColor[_color].Add(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<HexCell> GetListNeighbours()
|
public List<HexCell> GetListNeighbours()
|
||||||
{
|
{
|
||||||
return neighbors.ToList();
|
return neighbors.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HexCell GetNeighbor(HexDirection direction)
|
public HexCell GetNeighbor(HexDirection direction)
|
||||||
{
|
{
|
||||||
@ -68,32 +78,60 @@ namespace HexFiled
|
|||||||
|
|
||||||
public void SetNeighbor(HexDirection direction, HexCell cell)
|
public void SetNeighbor(HexDirection direction, HexCell cell)
|
||||||
{
|
{
|
||||||
|
neighbors ??= new HexCell[6];
|
||||||
|
|
||||||
neighbors[(int)direction] = cell;
|
neighbors[(int)direction] = cell;
|
||||||
|
|
||||||
|
if (cell == null) return;
|
||||||
|
cell.neighbors ??= new HexCell[6];
|
||||||
cell.neighbors[(int)direction.Back()] = this;
|
cell.neighbors[(int)direction.Back()] = this;
|
||||||
|
cell.neighbors ??= new HexCell[6];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PaintHex(UnitColor color)
|
public void PaintHex(UnitColor color, bool isSetting = false)
|
||||||
{
|
{
|
||||||
if (color == _color) return;
|
if (color == _color) return;
|
||||||
|
|
||||||
if (!HexManager.CellByColor.ContainsKey(color))
|
if (!HexManager.CellByColor.ContainsKey(color))
|
||||||
{
|
{
|
||||||
HexManager.CellByColor.Add(color, new List<HexCell>(){this});
|
HexManager.CellByColor.Add(color, new List<HexCell>() { this });
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderer.material.mainTexture = HexGrid.Colors[color].Texture;
|
_renderer.material.mainTexture = HexGrid.Colors[color].Texture;
|
||||||
var previousColor = _color;
|
|
||||||
HexManager.CellByColor[previousColor].Remove(this);
|
HexManager.CellByColor[_color].Remove(this);
|
||||||
|
|
||||||
_color = color;
|
_color = color;
|
||||||
HexManager.CellByColor[_color].Add(this);
|
HexManager.CellByColor[_color].Add(this);
|
||||||
OnHexPainted?.Invoke(this);
|
if (!isSetting)
|
||||||
if(color == UnitColor.Grey) return;
|
OnHexPainted?.Invoke(this);
|
||||||
|
|
||||||
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab, transform.position + new Vector3(0,0.1f,0));
|
if (_building != null)
|
||||||
|
{
|
||||||
|
Destroy(_building);
|
||||||
|
}
|
||||||
|
|
||||||
|
HexManager.UnitCurrentCell
|
||||||
|
.Where(cells
|
||||||
|
=> HexManager.CellByColor[cells.Key].Count < 3
|
||||||
|
|| (cells.Value.cell == this && cells.Value.unit.Color != Color))
|
||||||
|
.Select(cells => cells.Value.unit)
|
||||||
|
.ToList().ForEach(x => x.Death());
|
||||||
|
|
||||||
|
if (color == UnitColor.Grey)
|
||||||
|
{
|
||||||
|
if (_item != null)
|
||||||
|
{
|
||||||
|
_item.Despawn();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var vfx = VFXController.Instance.PlayEffect(HexGrid.Colors[color].VFXCellCapturePrefab,
|
||||||
|
transform.position + new Vector3(0, 0.1f, 0));
|
||||||
MusicController.Instance.AddAudioSource(vfx);
|
MusicController.Instance.AddAudioSource(vfx);
|
||||||
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures, vfx);
|
MusicController.Instance.PlayRandomClip(MusicController.Instance.MusicData.SfxMusic.Captures, vfx);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,10 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public struct HexCoordinates {
|
public struct HexCoordinates : IComparable<HexCoordinates> {
|
||||||
|
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int x, z;
|
private int x, z;
|
||||||
@ -44,6 +45,10 @@ namespace HexFiled
|
|||||||
return new HexCoordinates(x - z / 2, z);
|
return new HexCoordinates(x - z / 2, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static (int x, int z) ToOffsetCoordinates(HexCoordinates coordinates)
|
||||||
|
{
|
||||||
|
return (coordinates.X + coordinates.Z / 2, coordinates.Z);
|
||||||
|
}
|
||||||
public static HexCoordinates FromPosition (Vector3 position) {
|
public static HexCoordinates FromPosition (Vector3 position) {
|
||||||
float x = position.x / (HexMetrics.innerRadius * 2f);
|
float x = position.x / (HexMetrics.innerRadius * 2f);
|
||||||
float y = -x;
|
float y = -x;
|
||||||
@ -72,12 +77,18 @@ namespace HexFiled
|
|||||||
return new HexCoordinates(iX, iZ);
|
return new HexCoordinates(iX, iZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 ToPosition (HexCoordinates position) {
|
public static Vector3 ToPosition(HexCoordinates position) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
position.x = (x + z * 0.5f - z / 2) * (HexMetrics.innerRadius * 2f);
|
||||||
|
position.y = 0f;
|
||||||
|
position.z = z * (HexMetrics.outerRadius * 1.5f);
|
||||||
|
*/
|
||||||
|
var hexPos = ToOffsetCoordinates(position);
|
||||||
Vector3 pos;
|
Vector3 pos;
|
||||||
pos.x = (position.x + position.z * 0.5f - position.z / 2) * (HexMetrics.innerRadius * 2f);
|
pos.x = (hexPos.x + hexPos.z * 0.5f - hexPos.z / 2) * (HexMetrics.innerRadius * 2f);
|
||||||
pos.y = 0f;
|
pos.y = 0f;
|
||||||
pos.z = position.z * (HexMetrics.outerRadius * 1.5f);
|
pos.z = hexPos.z * (HexMetrics.outerRadius * 1.5f);
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@ -86,8 +97,17 @@ namespace HexFiled
|
|||||||
X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + ")";
|
X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public string ToStringOnSeparateLines () {
|
public string ToStringOnSeparateLines () {
|
||||||
return X.ToString() + "\n" + Y.ToString() + "\n" + Z.ToString();
|
return X.ToString() + "\n" + Y.ToString() + "\n" + Z.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int CompareTo(HexCoordinates other)
|
||||||
|
{
|
||||||
|
var xComparison = x.CompareTo(other.X);
|
||||||
|
if (xComparison != 0) return xComparison;
|
||||||
|
return z.CompareTo(other.Z);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -37,11 +37,8 @@ namespace HexFiled
|
|||||||
{
|
{
|
||||||
_fieldData = fieldData;
|
_fieldData = fieldData;
|
||||||
_baseGameObject = new GameObject("HexGrid");
|
_baseGameObject = new GameObject("HexGrid");
|
||||||
_colors = new Dictionary<UnitColor, CellColor>(fieldData.colors.Count);
|
_colors = fieldData.colors.ToDictionary(x => x.UnitColor, x => x);
|
||||||
foreach (var color in fieldData.colors)
|
|
||||||
{
|
|
||||||
_colors.Add(color.UnitColor, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
_gridCanvas = Object.Instantiate(fieldData.CoordinatesCanvas, _baseGameObject.transform)
|
_gridCanvas = Object.Instantiate(fieldData.CoordinatesCanvas, _baseGameObject.transform)
|
||||||
.GetComponent<Canvas>();
|
.GetComponent<Canvas>();
|
||||||
@ -85,7 +82,7 @@ namespace HexFiled
|
|||||||
position.z = z * (HexMetrics.outerRadius * 1.5f);
|
position.z = z * (HexMetrics.outerRadius * 1.5f);
|
||||||
var cellGO = Object.Instantiate(_fieldData.cellPrefab);
|
var cellGO = Object.Instantiate(_fieldData.cellPrefab);
|
||||||
HexCell cell = _cells[i] = cellGO.GetComponent<HexCell>();
|
HexCell cell = _cells[i] = cellGO.GetComponent<HexCell>();
|
||||||
cell.PaintHex(UnitColor.Grey);
|
cell.PaintHex(UnitColor.Grey, true);
|
||||||
cell.transform.SetParent(_baseGameObject.transform, false);
|
cell.transform.SetParent(_baseGameObject.transform, false);
|
||||||
cell.transform.localPosition = position;
|
cell.transform.localPosition = position;
|
||||||
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
||||||
|
@ -56,7 +56,7 @@ namespace HexFiled
|
|||||||
public static void PaintHexList(List<HexCell> field, UnitColor color, float time)
|
public static void PaintHexList(List<HexCell> field, UnitColor color, float time)
|
||||||
{
|
{
|
||||||
|
|
||||||
List<Action<UnitColor>> actions = new List<Action<UnitColor>>();
|
List<Action<UnitColor, bool>> actions = new List<Action<UnitColor, bool>>();
|
||||||
|
|
||||||
field.ForEach(x => actions.Add(x.PaintHex));
|
field.ForEach(x => actions.Add(x.PaintHex));
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace HexFiled
|
|||||||
|
|
||||||
cells.AddRange(field);
|
cells.AddRange(field);
|
||||||
|
|
||||||
cells.ForEach(x => x.PaintHex(color));
|
cells.ForEach(x => x.PaintHex(color, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,220 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!1 &5177366465263722279
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 5177366465263722277}
|
|
||||||
- component: {fileID: 5177366465263722276}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Directional Light Left
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &5177366465263722277
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5177366465263722279}
|
|
||||||
m_LocalRotation: {x: 0.38302222, y: 0.38302222, z: -0.17860618, w: 0.82139385}
|
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 5177366466773781006}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 50, y: 50, z: 0}
|
|
||||||
--- !u!108 &5177366465263722276
|
|
||||||
Light:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5177366465263722279}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 10
|
|
||||||
m_Type: 1
|
|
||||||
m_Shape: 0
|
|
||||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
|
||||||
m_Intensity: 0.7
|
|
||||||
m_Range: 10
|
|
||||||
m_SpotAngle: 30
|
|
||||||
m_InnerSpotAngle: 21.80208
|
|
||||||
m_CookieSize: 10
|
|
||||||
m_Shadows:
|
|
||||||
m_Type: 2
|
|
||||||
m_Resolution: -1
|
|
||||||
m_CustomResolution: -1
|
|
||||||
m_Strength: 0.408
|
|
||||||
m_Bias: 0.05
|
|
||||||
m_NormalBias: 0.4
|
|
||||||
m_NearPlane: 0.2
|
|
||||||
m_CullingMatrixOverride:
|
|
||||||
e00: 1
|
|
||||||
e01: 0
|
|
||||||
e02: 0
|
|
||||||
e03: 0
|
|
||||||
e10: 0
|
|
||||||
e11: 1
|
|
||||||
e12: 0
|
|
||||||
e13: 0
|
|
||||||
e20: 0
|
|
||||||
e21: 0
|
|
||||||
e22: 1
|
|
||||||
e23: 0
|
|
||||||
e30: 0
|
|
||||||
e31: 0
|
|
||||||
e32: 0
|
|
||||||
e33: 1
|
|
||||||
m_UseCullingMatrixOverride: 0
|
|
||||||
m_Cookie: {fileID: 0}
|
|
||||||
m_DrawHalo: 0
|
|
||||||
m_Flare: {fileID: 0}
|
|
||||||
m_RenderMode: 0
|
|
||||||
m_CullingMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_Lightmapping: 1
|
|
||||||
m_LightShadowCasterMode: 0
|
|
||||||
m_AreaSize: {x: 1, y: 1}
|
|
||||||
m_BounceIntensity: 1
|
|
||||||
m_ColorTemperature: 6570
|
|
||||||
m_UseColorTemperature: 0
|
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_UseBoundingSphereOverride: 0
|
|
||||||
m_UseViewFrustumForShadowCasterCull: 1
|
|
||||||
m_ShadowRadius: 0
|
|
||||||
m_ShadowAngle: 0
|
|
||||||
--- !u!1 &5177366465427951230
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 5177366465427951228}
|
|
||||||
- component: {fileID: 5177366465427951231}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Directional Light Right
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &5177366465427951228
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5177366465427951230}
|
|
||||||
m_LocalRotation: {x: 0.32139382, y: 0.32139382, z: -0.8830222, w: 0.11697779}
|
|
||||||
m_LocalPosition: {x: 35.65, y: 0, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children: []
|
|
||||||
m_Father: {fileID: 5177366466773781006}
|
|
||||||
m_RootOrder: 1
|
|
||||||
m_LocalEulerAnglesHint: {x: 140, y: 140, z: 0}
|
|
||||||
--- !u!108 &5177366465427951231
|
|
||||||
Light:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5177366465427951230}
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 10
|
|
||||||
m_Type: 1
|
|
||||||
m_Shape: 0
|
|
||||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
|
||||||
m_Intensity: 0.6
|
|
||||||
m_Range: 10
|
|
||||||
m_SpotAngle: 30
|
|
||||||
m_InnerSpotAngle: 21.80208
|
|
||||||
m_CookieSize: 10
|
|
||||||
m_Shadows:
|
|
||||||
m_Type: 2
|
|
||||||
m_Resolution: -1
|
|
||||||
m_CustomResolution: -1
|
|
||||||
m_Strength: 0
|
|
||||||
m_Bias: 0.05
|
|
||||||
m_NormalBias: 0.4
|
|
||||||
m_NearPlane: 0.2
|
|
||||||
m_CullingMatrixOverride:
|
|
||||||
e00: 1
|
|
||||||
e01: 0
|
|
||||||
e02: 0
|
|
||||||
e03: 0
|
|
||||||
e10: 0
|
|
||||||
e11: 1
|
|
||||||
e12: 0
|
|
||||||
e13: 0
|
|
||||||
e20: 0
|
|
||||||
e21: 0
|
|
||||||
e22: 1
|
|
||||||
e23: 0
|
|
||||||
e30: 0
|
|
||||||
e31: 0
|
|
||||||
e32: 0
|
|
||||||
e33: 1
|
|
||||||
m_UseCullingMatrixOverride: 0
|
|
||||||
m_Cookie: {fileID: 0}
|
|
||||||
m_DrawHalo: 0
|
|
||||||
m_Flare: {fileID: 0}
|
|
||||||
m_RenderMode: 0
|
|
||||||
m_CullingMask:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 4294967295
|
|
||||||
m_RenderingLayerMask: 1
|
|
||||||
m_Lightmapping: 1
|
|
||||||
m_LightShadowCasterMode: 0
|
|
||||||
m_AreaSize: {x: 1, y: 1}
|
|
||||||
m_BounceIntensity: 1
|
|
||||||
m_ColorTemperature: 6570
|
|
||||||
m_UseColorTemperature: 0
|
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
m_UseBoundingSphereOverride: 0
|
|
||||||
m_UseViewFrustumForShadowCasterCull: 1
|
|
||||||
m_ShadowRadius: 0
|
|
||||||
m_ShadowAngle: 0
|
|
||||||
--- !u!1 &5177366466773781009
|
|
||||||
GameObject:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
serializedVersion: 6
|
|
||||||
m_Component:
|
|
||||||
- component: {fileID: 5177366466773781006}
|
|
||||||
m_Layer: 0
|
|
||||||
m_Name: Light
|
|
||||||
m_TagString: Untagged
|
|
||||||
m_Icon: {fileID: 0}
|
|
||||||
m_NavMeshLayer: 0
|
|
||||||
m_StaticEditorFlags: 0
|
|
||||||
m_IsActive: 1
|
|
||||||
--- !u!4 &5177366466773781006
|
|
||||||
Transform:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 5177366466773781009}
|
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
|
||||||
m_LocalPosition: {x: -14.18, y: 11.79, z: 0}
|
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
|
||||||
m_Children:
|
|
||||||
- {fileID: 5177366465263722277}
|
|
||||||
- {fileID: 5177366465427951228}
|
|
||||||
m_Father: {fileID: 0}
|
|
||||||
m_RootOrder: 0
|
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
|
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a7fb19d4a93bce94bba24aacfe92a572
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,8 +1,7 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Units;
|
using Units;
|
||||||
using UnityEngine.SceneManagement;
|
|
||||||
using Object = UnityEngine.Object;
|
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
@ -17,80 +16,42 @@ namespace HexFiled
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void CheckDeathOrDestroy(HexCell cell)
|
|
||||||
{
|
|
||||||
HexManager.UnitCurrentCell
|
|
||||||
.Where(cells
|
|
||||||
=> HexManager.CellByColor[cells.Key].Count < 3
|
|
||||||
|| (cells.Value.cell == cell && cells.Value.unit.Color != cell.Color))
|
|
||||||
.Select(cells => cells.Value.unit)
|
|
||||||
.ToList().ForEach(x => x.Death());
|
|
||||||
|
|
||||||
if (cell.Building != null)
|
|
||||||
{
|
|
||||||
Object.Destroy(cell.Building);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cell.Item != null)
|
|
||||||
{
|
|
||||||
cell.Item.Despawn();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetHexColors(HexCell cell)
|
public void SetHexColors(HexCell cell)
|
||||||
{
|
{
|
||||||
_cell = cell;
|
_cell = cell;
|
||||||
|
|
||||||
|
|
||||||
var hexByColorDict = DifferentHexByColor(cell.GetListNeighbours());
|
var hexByColorDict = Enum.GetValues(typeof(UnitColor)).Cast<UnitColor>().ToDictionary(color => color,
|
||||||
foreach (var item in hexByColorDict)
|
color => cell.GetListNeighbours().Where(x => x != null && x.Color == color).ToList());
|
||||||
|
|
||||||
|
cell.GetListNeighbours().Where(x => x != null && x.Color != cell.Color).ToList().ForEach(neighbour =>
|
||||||
{
|
{
|
||||||
if (item.Key == cell.Color && item.Value.Count >= 2 && item.Value.Count < 6 &&
|
if (hexByColorDict.TryGetValue(neighbour.Color, out var value) &&
|
||||||
HexManager.UnitCurrentCell.ContainsKey(cell.Color))
|
value.Count >= 2 && value.Count < 6)
|
||||||
{
|
{
|
||||||
cell.GetListNeighbours().ForEach(x =>
|
value.ForEach(x =>
|
||||||
{
|
{
|
||||||
if (x != null && x.Color != cell.Color)
|
var path = Round(x, null);
|
||||||
|
if (!path.hasPath)
|
||||||
{
|
{
|
||||||
var path = Round(x, null);
|
HexManager.PaintHexList(path.field, cell.Color, 0.05f);
|
||||||
if (!path.hasPath)
|
|
||||||
HexManager.PaintHexList(path.field, cell.Color, 0.05f);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Value.Count >= 2 && item.Key != UnitColor.Grey && item.Key != cell.Color)
|
|
||||||
{
|
|
||||||
item.Value.ForEach(neighbour =>
|
|
||||||
{
|
|
||||||
if (HexManager.UnitCurrentCell.TryGetValue(item.Key, out var unitCel) &&
|
|
||||||
!HasPath(neighbour, unitCel.cell, out var path).hasPath)
|
|
||||||
{
|
|
||||||
HexManager.PaintHexList(path.field, UnitColor.Grey);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (neighbour.Color != UnitColor.Grey
|
||||||
private Dictionary<UnitColor, List<HexCell>> DifferentHexByColor(List<HexCell> cellsList)
|
&& HexManager.UnitCurrentCell.TryGetValue(neighbour.Color, out var unit)
|
||||||
{
|
&& hexByColorDict.TryGetValue(neighbour.Color, out var cells)
|
||||||
Dictionary<UnitColor, List<HexCell>> resultDict = new Dictionary<UnitColor, List<HexCell>>();
|
&& cells.Count >= 2 && cells.Count < 5
|
||||||
cellsList.ForEach(cell =>
|
&& !HasPath(neighbour, unit.cell, out var path))
|
||||||
{
|
|
||||||
if (cell != null && resultDict.ContainsKey(cell.Color))
|
|
||||||
{
|
{
|
||||||
resultDict[cell.Color].Add(cell);
|
HexManager.PaintHexList(path, UnitColor.Grey);
|
||||||
}
|
|
||||||
else if (cell != null)
|
|
||||||
{
|
|
||||||
resultDict.Add(cell.Color, new List<HexCell> { cell });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return resultDict;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end)
|
private (bool hasPath, List<HexCell> field) Round(HexCell start, HexCell end)
|
||||||
{
|
{
|
||||||
if (start == null || start.Color == _cell.Color)
|
if (start == null || start.Color == _cell.Color)
|
||||||
@ -153,13 +114,13 @@ namespace HexFiled
|
|||||||
return (false, closedList);
|
return (false, closedList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ( bool hasPath, List<HexCell> field ) HasPath(HexCell start, HexCell end,
|
private bool HasPath(HexCell start, HexCell end,
|
||||||
out ( bool hasPath, List<HexCell> field ) value)
|
out List<HexCell> value)
|
||||||
{
|
{
|
||||||
if (start.Color == _cell.Color || end.Color == _cell.Color)
|
if (start.Color == _cell.Color || end.Color == _cell.Color)
|
||||||
{
|
{
|
||||||
value = (true, null);
|
value = null;
|
||||||
return (true, null);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HexCell> closedList = new List<HexCell>();
|
List<HexCell> closedList = new List<HexCell>();
|
||||||
@ -170,13 +131,12 @@ namespace HexFiled
|
|||||||
|
|
||||||
closedList.Add(currentCell);
|
closedList.Add(currentCell);
|
||||||
|
|
||||||
|
|
||||||
while (stackIterators.Count >= 0)
|
while (stackIterators.Count >= 0)
|
||||||
{
|
{
|
||||||
if (currentCell == end)
|
if (currentCell == end)
|
||||||
{
|
{
|
||||||
value = (true, null);
|
value = null;
|
||||||
return (true, null);
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<HexCell> openList = currentCell.GetListNeighbours()
|
List<HexCell> openList = currentCell.GetListNeighbours()
|
||||||
@ -195,8 +155,8 @@ namespace HexFiled
|
|||||||
{
|
{
|
||||||
if (stackIterators.Count == 0)
|
if (stackIterators.Count == 0)
|
||||||
{
|
{
|
||||||
value = (false, closedList);
|
value = closedList;
|
||||||
return (false, closedList);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
currentCell = stackIterators.Pop();
|
currentCell = stackIterators.Pop();
|
||||||
@ -204,13 +164,13 @@ namespace HexFiled
|
|||||||
|
|
||||||
if (currentCell.GetListNeighbours().Contains(end))
|
if (currentCell.GetListNeighbours().Contains(end))
|
||||||
{
|
{
|
||||||
value = (true, null);
|
value = null;
|
||||||
return (true, null);
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
value = (false, closedList);
|
value = closedList;
|
||||||
return (false, closedList);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,61 +1,143 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Purchasing.MiniJSON;
|
using UnityEngine.Purchasing.MiniJSON;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
namespace DefaultNamespace
|
namespace DefaultNamespace
|
||||||
{
|
{
|
||||||
|
[Serializable]
|
||||||
|
public class GridToSave
|
||||||
|
{
|
||||||
|
public SerializibleHexCell[] cells;
|
||||||
|
public int height;
|
||||||
|
public int width;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class SerializibleHexCell
|
||||||
|
{
|
||||||
|
public HexCoordinates HexCoordinates;
|
||||||
|
public int index;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class HexMapEditor : MonoBehaviour
|
public class HexMapEditor : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private List<CellColor> cellColors;
|
|
||||||
[SerializeField] private GameObject hexPrefab;
|
[SerializeField] private GameObject hexPrefab;
|
||||||
[SerializeField] private GameObject labelPrefab;
|
[SerializeField] private TMP_Text labelPrefab;
|
||||||
|
[SerializeField] private GameObject gridCanvas;
|
||||||
|
|
||||||
|
private GameObject gridCanvasInstance;
|
||||||
|
private HexCell[] _cells;
|
||||||
private HexGrid hexGrid;
|
private HexGrid hexGrid;
|
||||||
|
private int _width;
|
||||||
|
private int _height;
|
||||||
|
|
||||||
private Color activeColor;
|
private Color activeColor;
|
||||||
private GameObject fieldBaseGameObject;
|
private GameObject fieldBaseGameObject;
|
||||||
|
private GameObject labelCanvas;
|
||||||
|
|
||||||
|
|
||||||
[EditorButton]
|
[EditorButton]
|
||||||
private void DrawMap(int x, int y)
|
private void DrawMap(int x, int y)
|
||||||
{
|
{
|
||||||
if (hexGrid != null)
|
if (fieldBaseGameObject != null)
|
||||||
{
|
{
|
||||||
Destroy(fieldBaseGameObject);
|
DestroyImmediate(fieldBaseGameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
hexGrid = new HexGrid(x, y, hexPrefab, cellColors, labelPrefab);
|
if (gridCanvasInstance == null)
|
||||||
WriteToBinaryFile("HexField", hexGrid);
|
{
|
||||||
fieldBaseGameObject = hexGrid.SpawnField();
|
DestroyImmediate(gridCanvasInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
gridCanvasInstance = Instantiate(gridCanvas);
|
||||||
|
|
||||||
|
fieldBaseGameObject = new GameObject("HexField");
|
||||||
|
_cells = new HexCell[x * y];
|
||||||
|
_width = x;
|
||||||
|
_height = y;
|
||||||
|
|
||||||
|
SpawnField();
|
||||||
}
|
}
|
||||||
|
|
||||||
[EditorButton]
|
[EditorButton]
|
||||||
private void LoadMap(string name)
|
private void LoadMap(string fileName)
|
||||||
{
|
{
|
||||||
if (File.Exists(name))
|
if (File.Exists(Application.persistentDataPath
|
||||||
|
+ $"/{fileName}.dat"))
|
||||||
{
|
{
|
||||||
hexGrid = ReadFromBinaryFile<HexGrid>("HexField");
|
BinaryFormatter bf = new BinaryFormatter();
|
||||||
hexGrid.SpawnField();
|
FileStream file =
|
||||||
}
|
File.Open(Application.persistentDataPath
|
||||||
}
|
+ $"/{fileName}.dat", FileMode.Open);
|
||||||
|
GridToSave data = (GridToSave)bf.Deserialize(file);
|
||||||
public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
|
file.Close();
|
||||||
{
|
|
||||||
using (Stream stream = File.Open(filePath, append ? FileMode.Append : FileMode.Create))
|
if (fieldBaseGameObject != null)
|
||||||
{
|
{
|
||||||
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
DestroyImmediate(fieldBaseGameObject);
|
||||||
binaryFormatter.Serialize(stream, objectToWrite);
|
}
|
||||||
|
|
||||||
|
if (gridCanvasInstance == null)
|
||||||
|
{
|
||||||
|
DestroyImmediate(gridCanvasInstance);
|
||||||
|
}
|
||||||
|
|
||||||
|
gridCanvasInstance = Instantiate(gridCanvas);
|
||||||
|
|
||||||
|
fieldBaseGameObject = new GameObject("HexField");
|
||||||
|
_height = data.height;
|
||||||
|
_width = data.width;
|
||||||
|
_cells = new HexCell[_width * _height];
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var cell in data.cells)
|
||||||
|
{
|
||||||
|
if (cell == null)
|
||||||
|
continue;
|
||||||
|
CreateCell(cell.HexCoordinates.X, cell.HexCoordinates.Z, cell.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Log("Game data loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
else
|
||||||
|
Debug.LogError("There is no save data!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[EditorButton]
|
||||||
|
void SaveGrid(string fileName)
|
||||||
|
{
|
||||||
|
BinaryFormatter bf = new BinaryFormatter();
|
||||||
|
FileStream file = File.Create(Application.persistentDataPath
|
||||||
|
+ $"/{fileName}.dat");
|
||||||
|
GridToSave data = new GridToSave();
|
||||||
|
var tmp = new List<SerializibleHexCell>();
|
||||||
|
_cells.ToList().ForEach(cell => { tmp.Add(cell == null ? null : cell.ToSerializibleHexCell()); });
|
||||||
|
|
||||||
|
data.cells = tmp.ToArray();
|
||||||
|
data.width = _width;
|
||||||
|
data.height = _height;
|
||||||
|
|
||||||
|
bf.Serialize(file, data);
|
||||||
|
file.Close();
|
||||||
|
Debug.Log("Game data saved!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static T ReadFromBinaryFile<T>(string filePath)
|
public static T ReadFromBinaryFile<T>(string filePath)
|
||||||
{
|
{
|
||||||
using (Stream stream = File.Open(filePath, FileMode.Open))
|
using (Stream stream = File.Open(filePath, FileMode.Open))
|
||||||
{
|
{
|
||||||
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
|
var binaryFormatter = new BinaryFormatter();
|
||||||
return (T)binaryFormatter.Deserialize(stream);
|
return (T)binaryFormatter.Deserialize(stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -71,11 +153,83 @@ namespace DefaultNamespace
|
|||||||
void HandleInput()
|
void HandleInput()
|
||||||
{
|
{
|
||||||
Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
|
Ray inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
RaycastHit hit;
|
|
||||||
if (Physics.Raycast(inputRay, out hit))
|
if (Physics.Raycast(inputRay, out var hit))
|
||||||
{
|
{
|
||||||
var coord = HexCoordinates.FromPosition(hit.point);
|
var coord = HexCoordinates.FromPosition(hit.transform.position);
|
||||||
hexGrid.GetCellFromCoord(coord).PaintHex(UnitColor.Green);
|
_cells.First(x => x.coordinates.Equals(coord)).gameObject.GetComponent<MeshRenderer>().material.color =
|
||||||
|
Color.green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateCell(int x, int z, int i, bool isHexCoord = false)
|
||||||
|
{
|
||||||
|
Vector3 position;
|
||||||
|
var cellGO = Object.Instantiate(hexPrefab);
|
||||||
|
HexCell cell = _cells[i] = cellGO.AddComponent<HexCell>();
|
||||||
|
if (isHexCoord)
|
||||||
|
{
|
||||||
|
HexCoordinates coordinates = new HexCoordinates(x, z);
|
||||||
|
position = HexCoordinates.ToPosition(coordinates);
|
||||||
|
(x, z) = HexCoordinates.ToOffsetCoordinates(coordinates);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
position.x = (x + z * 0.5f - z / 2) * (HexMetrics.innerRadius * 2f);
|
||||||
|
position.y = 0f;
|
||||||
|
position.z = z * (HexMetrics.outerRadius * 1.5f);
|
||||||
|
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
cell.transform.SetParent(fieldBaseGameObject.transform, false);
|
||||||
|
cell.transform.localPosition = position;
|
||||||
|
|
||||||
|
cell.index = i;
|
||||||
|
|
||||||
|
if (x > 0)
|
||||||
|
{
|
||||||
|
cell.SetNeighbor(HexDirection.W, _cells[i - 1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (z > 0)
|
||||||
|
{
|
||||||
|
if ((z & 1) == 0)
|
||||||
|
{
|
||||||
|
cell.SetNeighbor(HexDirection.SE, _cells[i - _width]);
|
||||||
|
if (x > 0)
|
||||||
|
{
|
||||||
|
cell.SetNeighbor(HexDirection.SW, _cells[i - _width - 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cell.SetNeighbor(HexDirection.SW, _cells[i - _width]);
|
||||||
|
|
||||||
|
|
||||||
|
if (x < _width - 1)
|
||||||
|
{
|
||||||
|
cell.SetNeighbor(HexDirection.SE, _cells[i - _width + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
TMP_Text label = Object.Instantiate(labelPrefab, gridCanvasInstance.transform, false);
|
||||||
|
label.rectTransform.anchoredPosition =
|
||||||
|
new Vector2(position.x, position.z);
|
||||||
|
label.text = cell.coordinates.ToStringOnSeparateLines();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SpawnField()
|
||||||
|
{
|
||||||
|
for (int z = 0, i = 0; z < _height; z++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < _width; x++)
|
||||||
|
{
|
||||||
|
CreateCell(x, z, i++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ MonoImporter:
|
|||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
defaultReferences:
|
defaultReferences:
|
||||||
- hexPrefab: {fileID: 1661242500252451528, guid: bcea5b4a96735bd4b936f8f3fefcc688, type: 3}
|
- hexPrefab: {fileID: 1661242500252451528, guid: bcea5b4a96735bd4b936f8f3fefcc688, type: 3}
|
||||||
- labelPrefab: {fileID: 4726489279989878083, guid: f31e0880dd078104bb31dc0fd7ef9f19, type: 3}
|
- labelPrefab: {fileID: 3836123284387241147, guid: efd47cbd22ddfee4aa2b1391914116fc, type: 3}
|
||||||
|
- gridCanvas: {fileID: 4726489279989878083, guid: f31e0880dd078104bb31dc0fd7ef9f19, type: 3}
|
||||||
executionOrder: 0
|
executionOrder: 0
|
||||||
icon: {instanceID: 0}
|
icon: {instanceID: 0}
|
||||||
userData:
|
userData:
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
|
using Units;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Items
|
namespace Items
|
||||||
@ -21,16 +22,16 @@ namespace Items
|
|||||||
|
|
||||||
public BonusType BonusType => bonusType;
|
public BonusType BonusType => bonusType;
|
||||||
|
|
||||||
public override void PickUp(UnitColor color)
|
public override void PickUp(Unit unit)
|
||||||
{
|
{
|
||||||
if(bonusType != BonusType.Heal)
|
if(bonusType != BonusType.Heal)
|
||||||
base.PickUp(color);
|
base.PickUp(unit);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Unit = HexManager.UnitCurrentCell[color].unit;
|
Unit = unit;
|
||||||
VFXController.Instance.PlayEffect(usisngVFX, Unit.Instance.transform);
|
VFXController.Instance.PlayEffect(usisngVFX, Unit.Instance.transform);
|
||||||
Unit.UnitView.OnHit.Invoke(-value);
|
Unit.UnitView.OnHit.Invoke(-value);
|
||||||
|
Despawn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,11 +9,13 @@ namespace Items
|
|||||||
public class Building : Item
|
public class Building : Item
|
||||||
{
|
{
|
||||||
[SerializeField] private GameObject buildingPrefab;
|
[SerializeField] private GameObject buildingPrefab;
|
||||||
|
private Action _action;
|
||||||
|
|
||||||
public void Invoke(Action action)
|
public void Invoke(Action action)
|
||||||
{
|
{
|
||||||
OnItemUsed += action;
|
if(_action != null) return;
|
||||||
|
_action = action;
|
||||||
|
OnItemUsed += _action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +28,7 @@ namespace Items
|
|||||||
|
|
||||||
cell.Building = obj;
|
cell.Building = obj;
|
||||||
OnItemUsed.Invoke();
|
OnItemUsed.Invoke();
|
||||||
OnItemUsed = null;
|
OnItemUsed = _action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,6 +2,7 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using DefaultNamespace;
|
using DefaultNamespace;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
|
using Items.ItemViews;
|
||||||
using Units;
|
using Units;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
@ -29,13 +30,10 @@ namespace Items
|
|||||||
{
|
{
|
||||||
private GameObject _instance;
|
private GameObject _instance;
|
||||||
[SerializeField] private Sprite icon;
|
[SerializeField] private Sprite icon;
|
||||||
[SerializeField] private bool isInvokeOnPickUp = false;
|
|
||||||
[SerializeField] private ItemType type;
|
[SerializeField] private ItemType type;
|
||||||
|
|
||||||
public ItemType Type => type;
|
public ItemType Type => type;
|
||||||
|
|
||||||
public bool IsInvokeOnPickUp => isInvokeOnPickUp;
|
|
||||||
|
|
||||||
public Sprite Icon => icon;
|
public Sprite Icon => icon;
|
||||||
|
|
||||||
protected Unit Unit;
|
protected Unit Unit;
|
||||||
@ -45,22 +43,24 @@ namespace Items
|
|||||||
|
|
||||||
public GameObject Spawn(HexCell cell, GameObject parent, GameObject iconPrefab)
|
public GameObject Spawn(HexCell cell, GameObject parent, GameObject iconPrefab)
|
||||||
{
|
{
|
||||||
_instance = GameObject.Instantiate(iconPrefab, cell.transform.position + new Vector3(0, 1, 0),Quaternion.identity, parent.transform);
|
_instance = GameObject.Instantiate(iconPrefab, cell.transform.position + new Vector3(0, 1, 0),
|
||||||
|
Quaternion.identity, parent.transform);
|
||||||
_instance.AddComponent<ItemView>().SetUp(this);
|
_instance.AddComponent<ItemView>().SetUp(this);
|
||||||
cell.Item = this;
|
cell.Item = this;
|
||||||
_instance.AddComponent<CapsuleCollider>().isTrigger = true;
|
_instance.AddComponent<CapsuleCollider>().isTrigger = true;
|
||||||
return _instance;
|
return _instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void PickUp(UnitColor color)
|
public virtual void PickUp(Unit unit)
|
||||||
{
|
{
|
||||||
if (HexManager.UnitCurrentCell.TryGetValue(color, out var value))
|
Unit = unit;
|
||||||
Unit = value.unit;
|
unit.PickUpItem(this);
|
||||||
|
Despawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Despawn()
|
public void Despawn()
|
||||||
{
|
{
|
||||||
Object.Destroy(_instance);
|
Destroy(_instance.gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
using DG.Tweening;
|
||||||
using DG.Tweening;
|
|
||||||
using Units;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Items
|
namespace Items.ItemViews
|
||||||
{
|
{
|
||||||
public class ItemView : MonoBehaviour
|
public class ItemView : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -12,16 +10,12 @@ namespace Items
|
|||||||
public string itemName;
|
public string itemName;
|
||||||
public Item Item => _item;
|
public Item Item => _item;
|
||||||
|
|
||||||
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
pickedUp = false;
|
|
||||||
itemName = _item.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetUp(Item item)
|
public void SetUp(Item item)
|
||||||
{
|
{
|
||||||
_item = item;
|
_item = item;
|
||||||
|
pickedUp = false;
|
||||||
|
itemName = _item.name;
|
||||||
Rotate();
|
Rotate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,10 +26,16 @@ namespace Items
|
|||||||
|
|
||||||
private void Rotate()
|
private void Rotate()
|
||||||
{
|
{
|
||||||
|
|
||||||
transform.DORotate(transform.rotation.eulerAngles + new Vector3(0, 10, 0), 0.1f)
|
transform.DORotate(transform.rotation.eulerAngles + new Vector3(0, 10, 0), 0.1f)
|
||||||
.SetEase(Ease.InQuad)
|
.SetEase(Ease.InQuad)
|
||||||
.SetLoops(-1, LoopType.Incremental);
|
.SetLoops(-1, LoopType.Incremental)
|
||||||
|
.OnUpdate(() =>
|
||||||
|
{
|
||||||
|
if (pickedUp)
|
||||||
|
{
|
||||||
|
Destroy(gameObject);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
52
Assets/Scripts/Items/SpecialWeapon.cs
Normal file
52
Assets/Scripts/Items/SpecialWeapon.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using DefaultNamespace;
|
||||||
|
using HexFiled;
|
||||||
|
using UnityEngine;
|
||||||
|
using Weapons;
|
||||||
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
|
namespace Items
|
||||||
|
{
|
||||||
|
[CreateAssetMenu(fileName = "SpecialWeapon", menuName = "Item/Special Weapon")]
|
||||||
|
public class SpecialWeapon : Item
|
||||||
|
{
|
||||||
|
[SerializeField] private Weapon _weapon;
|
||||||
|
[SerializeField] private GameObject _aimGameObject;
|
||||||
|
|
||||||
|
private GameObject _aimInstance;
|
||||||
|
private HexDirection _direction;
|
||||||
|
|
||||||
|
public void Invoke(Action action)
|
||||||
|
{
|
||||||
|
OnItemUsed ??= action;
|
||||||
|
|
||||||
|
if(_aimInstance == null || !_aimInstance.activeSelf)
|
||||||
|
_aimInstance = Object.Instantiate(_aimGameObject, Unit.Instance.transform);
|
||||||
|
_aimInstance.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Aim(HexDirection direction)
|
||||||
|
{
|
||||||
|
_aimInstance.SetActive(true);
|
||||||
|
_aimInstance.transform.LookAt(HexManager.UnitCurrentCell[Unit.Color].cell
|
||||||
|
.GetNeighbor(direction).transform);
|
||||||
|
_direction = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeAim()
|
||||||
|
{
|
||||||
|
_aimInstance.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Fire()
|
||||||
|
{
|
||||||
|
var cell = HexManager.UnitCurrentCell[Unit.Color].cell.GetNeighbor(_direction);
|
||||||
|
Unit.RotateUnit(new Vector2((cell.transform.position - Unit.Instance.transform.position).normalized.x,
|
||||||
|
(cell.transform.position - Unit.Instance.transform.position).normalized.z));
|
||||||
|
_aimInstance.SetActive(false);
|
||||||
|
var dir = DirectionHelper.DirectionTo(Unit.Instance.transform.position, cell.transform.position);
|
||||||
|
_weapon.Fire(Unit.Instance.transform, new Vector2(dir.x, dir.z));
|
||||||
|
OnItemUsed?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/Scripts/Items/SpecialWeapon.cs.meta
Normal file
3
Assets/Scripts/Items/SpecialWeapon.cs.meta
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 30d4ee04b4d04d47ad8f932a004c1728
|
||||||
|
timeCreated: 1644227001
|
@ -40,6 +40,10 @@ namespace DefaultNamespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void StartTimer<T>(List<Action<T>> actions, float time, T param)
|
public void StartTimer<T>(List<Action<T>> actions, float time, T param)
|
||||||
|
{
|
||||||
|
StartCoroutine(Timer(actions, time, param));
|
||||||
|
}
|
||||||
|
public void StartTimer<T>(List<Action<T, bool>> actions, float time, T param)
|
||||||
{
|
{
|
||||||
StartCoroutine(Timer(actions, time, param));
|
StartCoroutine(Timer(actions, time, param));
|
||||||
}
|
}
|
||||||
@ -63,6 +67,14 @@ namespace DefaultNamespace
|
|||||||
yield return new WaitForSeconds(time);
|
yield return new WaitForSeconds(time);
|
||||||
action?.Invoke(param);
|
action?.Invoke(param);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
IEnumerator Timer<T>(List<Action<T, bool>> actions, float time, T param)
|
||||||
|
{
|
||||||
|
foreach (var action in actions)
|
||||||
|
{
|
||||||
|
yield return new WaitForSeconds(time);
|
||||||
|
action?.Invoke(param, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,6 +22,7 @@ namespace Chars
|
|||||||
private Joystick _placeJoystick;
|
private Joystick _placeJoystick;
|
||||||
private UnitView _unitView;
|
private UnitView _unitView;
|
||||||
private Vector2 _attackDircetion;
|
private Vector2 _attackDircetion;
|
||||||
|
private HexDirection previousDir;
|
||||||
|
|
||||||
private bool returnedMoveJoystick = false;
|
private bool returnedMoveJoystick = false;
|
||||||
|
|
||||||
@ -84,6 +85,9 @@ namespace Chars
|
|||||||
case CaptureAbility ability:
|
case CaptureAbility ability:
|
||||||
ability.UseAbility();
|
ability.UseAbility();
|
||||||
break;
|
break;
|
||||||
|
case SpecialWeapon weapon:
|
||||||
|
weapon.Fire();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,17 +154,22 @@ namespace Chars
|
|||||||
ability.DeAim();
|
ability.DeAim();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ability.Aim(DirectionHelper.VectorToDirection(placeDir.normalized));
|
ability.Aim(DirectionHelper.VectorToDirection(placeDir.normalized));
|
||||||
_aimCount = 1;
|
_aimCount = 1;
|
||||||
break;
|
break;
|
||||||
|
case SpecialWeapon weapon:
|
||||||
|
weapon.Aim(DirectionHelper.VectorToDirection(placeDir.normalized));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FixedExecute()
|
public void FixedExecute()
|
||||||
{
|
{
|
||||||
if (_moveJoystick.Direction.normalized.Equals(Vector2.zero) || _unit.IsHardToCapture)
|
if ((previousDir != DirectionHelper.VectorToDirection(_moveJoystick.Direction.normalized) ||
|
||||||
|
_moveJoystick.isJoysticDirectionZero) && _unit.IsHardToCapture)
|
||||||
|
{
|
||||||
returnedMoveJoystick = _unit.IsHardToCapture;
|
returnedMoveJoystick = _unit.IsHardToCapture;
|
||||||
|
}
|
||||||
|
|
||||||
if (!_unit.IsAlive || _moveJoystick.Direction == Vector2.zero) return;
|
if (!_unit.IsAlive || _moveJoystick.Direction == Vector2.zero) return;
|
||||||
|
|
||||||
@ -175,6 +184,9 @@ namespace Chars
|
|||||||
case Building building:
|
case Building building:
|
||||||
_unitView.AimCanvas.SetActive(false);
|
_unitView.AimCanvas.SetActive(false);
|
||||||
break;
|
break;
|
||||||
|
case SpecialWeapon weapon:
|
||||||
|
weapon.DeAim();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,6 +202,8 @@ namespace Chars
|
|||||||
{
|
{
|
||||||
_unit.Move(DirectionHelper.VectorToDirection(_moveJoystick.Direction.normalized));
|
_unit.Move(DirectionHelper.VectorToDirection(_moveJoystick.Direction.normalized));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
previousDir = DirectionHelper.VectorToDirection(_moveJoystick.Direction.normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -104,14 +104,15 @@ namespace Units
|
|||||||
public void Retreet(HexDirection dir)
|
public void Retreet(HexDirection dir)
|
||||||
{
|
{
|
||||||
if (!_isCapturing) return;
|
if (!_isCapturing) return;
|
||||||
var openList = _cell.GetListNeighbours().Where(x => x.Color == _data.color).ToList();
|
var openList = _cell.GetListNeighbours().Where(x => x != null && x.Color == _data.color).ToList();
|
||||||
if (openList.Contains(_cell.GetNeighbor(dir)))
|
if (!openList.Contains(_cell.GetNeighbor(dir)))
|
||||||
{
|
{
|
||||||
_isBusy = false;
|
return;
|
||||||
_isHardToCapture = false;
|
|
||||||
_unitView.StopHardCapture();
|
|
||||||
Move(dir);
|
|
||||||
}
|
}
|
||||||
|
_isBusy = false;
|
||||||
|
_isHardToCapture = false;
|
||||||
|
_unitView.StopHardCapture();
|
||||||
|
Move(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Move(HexDirection direction)
|
public void Move(HexDirection direction)
|
||||||
@ -210,19 +211,24 @@ namespace Units
|
|||||||
if (!_isAlive)
|
if (!_isAlive)
|
||||||
{
|
{
|
||||||
_cell = _hexGrid.GetCellFromCoord(hexCoordinates);
|
_cell = _hexGrid.GetCellFromCoord(hexCoordinates);
|
||||||
_cell.PaintHex(_data.color);
|
_cell.PaintHex(_data.color, true);
|
||||||
_cell.GetListNeighbours().ForEach(x => x?.PaintHex(Color));
|
_cell.GetListNeighbours().ForEach(x =>
|
||||||
|
{
|
||||||
|
x?.PaintHex(Color, true);
|
||||||
|
|
||||||
|
});
|
||||||
_inventory = new List<Item>();
|
_inventory = new List<Item>();
|
||||||
_inventoryDefence = new List<Item>();
|
_inventoryDefence = new List<Item>();
|
||||||
|
|
||||||
HexManager.UnitCurrentCell.Add(_data.color, (_cell, this));
|
HexManager.UnitCurrentCell.Add(_data.color, (_cell, this));
|
||||||
|
|
||||||
_instance = Object.Instantiate(_data.unitPrefa, _cell.transform.parent);
|
_instance = Object.Instantiate(_data.unitPrefa, _cell.transform.parent);
|
||||||
|
|
||||||
_instance.transform.localPosition = _cell.transform.localPosition;
|
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||||
|
|
||||||
_isAlive = true;
|
_isAlive = true;
|
||||||
_animator = _instance.GetComponent<Animator>();
|
_animator = _instance.GetComponent<Animator>();
|
||||||
_unitView = _instance.GetComponent<UnitView>();
|
_unitView = _instance.AddComponent<UnitView>();
|
||||||
|
|
||||||
|
|
||||||
_unitView.SetUp(_weapon, RegenMana, _data.manaRegen, CaptureHex,
|
_unitView.SetUp(_weapon, RegenMana, _data.manaRegen, CaptureHex,
|
||||||
@ -245,6 +251,30 @@ namespace Units
|
|||||||
UpdateBarCanvas();
|
UpdateBarCanvas();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanPickUpItem(Item item)
|
||||||
|
{
|
||||||
|
switch (item.Type)
|
||||||
|
{
|
||||||
|
case ItemType.ATTACK:
|
||||||
|
if (_inventory.Count < _data.inventoryCapacity / 2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case ItemType.DEFENCE:
|
||||||
|
if (_inventoryDefence.Count < _data.inventoryCapacity / 2)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool PickUpItem(Item item)
|
public bool PickUpItem(Item item)
|
||||||
{
|
{
|
||||||
switch (item.Type)
|
switch (item.Type)
|
||||||
@ -252,7 +282,6 @@ namespace Units
|
|||||||
case ItemType.ATTACK:
|
case ItemType.ATTACK:
|
||||||
if (_inventory.Count < _data.inventoryCapacity / 2)
|
if (_inventory.Count < _data.inventoryCapacity / 2)
|
||||||
{
|
{
|
||||||
item.PickUp(_data.color);
|
|
||||||
_inventory.Add(item);
|
_inventory.Add(item);
|
||||||
OnItemPickUp?.Invoke(item);
|
OnItemPickUp?.Invoke(item);
|
||||||
_cell.Item = null;
|
_cell.Item = null;
|
||||||
@ -263,18 +292,18 @@ namespace Units
|
|||||||
case ItemType.DEFENCE:
|
case ItemType.DEFENCE:
|
||||||
if (_inventoryDefence.Count < _data.inventoryCapacity / 2)
|
if (_inventoryDefence.Count < _data.inventoryCapacity / 2)
|
||||||
{
|
{
|
||||||
item.PickUp(_data.color);
|
|
||||||
_inventoryDefence.Add(item);
|
_inventoryDefence.Add(item);
|
||||||
OnItemPickUp?.Invoke(item);
|
OnItemPickUp?.Invoke(item);
|
||||||
_cell.Item = null;
|
_cell.Item = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException();
|
throw new ArgumentOutOfRangeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,7 +467,7 @@ namespace Units
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetUpBonus(0, 0, BonusType.Defence);
|
|
||||||
_hp -= dmg;
|
_hp -= dmg;
|
||||||
|
|
||||||
UpdateBarCanvas();
|
UpdateBarCanvas();
|
||||||
|
@ -69,12 +69,14 @@ namespace Chars
|
|||||||
{
|
{
|
||||||
var enemy = new Unit(unitInfo,
|
var enemy = new Unit(unitInfo,
|
||||||
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid);
|
_data.WeaponsData.WeaponsList[Random.Range(0, _data.WeaponsData.WeaponsList.Count - 1)], _hexGrid);
|
||||||
|
|
||||||
|
if (unitInfo.isAI)
|
||||||
AIAgent agent = new AIAgent(unitInfo, enemy);
|
{
|
||||||
enemy.OnPlayerSpawned += x => _controllers.Add(agent);
|
AIAgent agent = new AIAgent(unitInfo, enemy);
|
||||||
enemy.OnDeath += x => { _controllers.Remove(agent); };
|
enemy.OnPlayerSpawned += x => _controllers.Add(agent);
|
||||||
|
enemy.OnDeath += x => { _controllers.Remove(agent); };
|
||||||
|
}
|
||||||
|
|
||||||
enemy.Spawn(unitInfo.spawnPos);
|
enemy.Spawn(unitInfo.spawnPos);
|
||||||
|
|
||||||
enemy.UnitView.SetBar(_data.UnitData.BotBarCanvas, _data.UnitData.AttackAimCanvas);
|
enemy.UnitView.SetBar(_data.UnitData.BotBarCanvas, _data.UnitData.AttackAimCanvas);
|
||||||
|
@ -6,6 +6,7 @@ using DefaultNamespace;
|
|||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
using Items;
|
using Items;
|
||||||
|
using Items.ItemViews;
|
||||||
using Units;
|
using Units;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Weapons;
|
using Weapons;
|
||||||
@ -175,10 +176,11 @@ public class UnitView : MonoBehaviour
|
|||||||
{
|
{
|
||||||
ItemView itemView = other.GetComponent<ItemView>();
|
ItemView itemView = other.GetComponent<ItemView>();
|
||||||
|
|
||||||
if (itemView == null || itemView.pickedUp || !_unit.PickUpItem(itemView.Item)) return;
|
if (itemView == null || itemView.pickedUp || !_unit.CanPickUpItem(itemView.Item)) return;
|
||||||
itemView.pickedUp = true;
|
itemView.pickedUp = true;
|
||||||
|
itemView.Item.PickUp(_unit);
|
||||||
ItemFabric.Items.Remove(itemView.gameObject);
|
ItemFabric.Items.Remove(itemView.gameObject);
|
||||||
Destroy(itemView.gameObject);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerator Reload()
|
private IEnumerator Reload()
|
||||||
|
@ -44,6 +44,7 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
|||||||
public event Action OnTouchUp;
|
public event Action OnTouchUp;
|
||||||
public event Action OnTouchDown;
|
public event Action OnTouchDown;
|
||||||
public event Action<Vector2> OnDrug;
|
public event Action<Vector2> OnDrug;
|
||||||
|
public bool isJoysticDirectionZero;
|
||||||
|
|
||||||
private Canvas canvas;
|
private Canvas canvas;
|
||||||
private Camera cam;
|
private Camera cam;
|
||||||
@ -90,6 +91,8 @@ public class Joystick : MonoBehaviour, IPointerDownHandler, IDragHandler, IPoint
|
|||||||
FormatInput();
|
FormatInput();
|
||||||
HandleInput(input.magnitude, input.normalized, radius, cam);
|
HandleInput(input.magnitude, input.normalized, radius, cam);
|
||||||
handle.anchoredPosition = input * radius * handleRange;
|
handle.anchoredPosition = input * radius * handleRange;
|
||||||
|
isJoysticDirectionZero = Direction.Equals(Vector2.zero);
|
||||||
|
|
||||||
OnDrug?.Invoke(Direction);
|
OnDrug?.Invoke(Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ public class DynamicJoystick : Joystick
|
|||||||
private Vector2 starPos;
|
private Vector2 starPos;
|
||||||
|
|
||||||
[SerializeField] private float moveThreshold = 1;
|
[SerializeField] private float moveThreshold = 1;
|
||||||
|
[SerializeField] private float returnDuration = 0.5f;
|
||||||
|
|
||||||
protected override void Start()
|
protected override void Start()
|
||||||
{
|
{
|
||||||
@ -26,6 +27,7 @@ public class DynamicJoystick : Joystick
|
|||||||
|
|
||||||
public override void OnPointerDown(PointerEventData eventData)
|
public override void OnPointerDown(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
|
background.DOComplete();
|
||||||
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
|
||||||
FadeJoystick(true);
|
FadeJoystick(true);
|
||||||
base.OnPointerDown(eventData);
|
base.OnPointerDown(eventData);
|
||||||
@ -34,7 +36,8 @@ public class DynamicJoystick : Joystick
|
|||||||
public override void OnPointerUp(PointerEventData eventData)
|
public override void OnPointerUp(PointerEventData eventData)
|
||||||
{
|
{
|
||||||
FadeJoystick(false);
|
FadeJoystick(false);
|
||||||
background.anchoredPosition = starPos;
|
background.DOAnchorPos(starPos, returnDuration);
|
||||||
|
|
||||||
base.OnPointerUp(eventData);
|
base.OnPointerUp(eventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user