Basic fighting logic.

pull/2/head
jacky_cai 2022-03-15 03:20:00 -07:00
parent bf845f2d14
commit 68b933460d
23 changed files with 2887 additions and 313 deletions

8
Assets/Images.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: df4fefeddb469004f82410794f5c6483
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

View File

@ -0,0 +1,158 @@
fileFormatVersion: 2
guid: 83ea6c9d3156a3f44a313f2572de90f1
TextureImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 11
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMasterTextureLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: 1
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
platformSettings:
- serializedVersion: 3
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 2
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Server
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Android
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: iPhone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 3
buildTarget: Windows Store Apps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 5e97eb03825dee720800000000000000
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
nameFileIdTable: {}
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u5B98\u519B\u5F13\u5175"
m_EditorClassIdentifier:
name: "\u5B98\u519B\u5F13\u5175"
description:
artwork: {fileID: 21300000, guid: f153be50357d5f64fa2d2aac875de6fd, type: 3}
cost: 1
attack: 5
defense: 10
movement: 1
cardTags:
- {fileID: 11400000, guid: 099176a69eb9a6d408b4d4dba5232c84, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: adc3952bb833a224895877477b4ce92e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u5B98\u519B\u6B65\u5175"
m_EditorClassIdentifier:
name: "\u5B98\u519B\u6B65\u5175"
description:
artwork: {fileID: 21300000, guid: 2d97ce419675f1c459311efd175bb108, type: 3}
cost: 1
attack: 5
defense: 20
movement: 1
cardTags:
- {fileID: 11400000, guid: cf728e5d8a62fa3418d2f3daa01f93df, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5d7c6bbedeba24e4f98ea1ca65fc5c0a
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u5B98\u519B\u9A91\u5175"
m_EditorClassIdentifier:
name: "\u5B98\u519B\u9A91\u5175"
description:
artwork: {fileID: 21300000, guid: 9f8190d43e6478049bac4f07a59438ab, type: 3}
cost: 1
attack: 10
defense: 10
cardTags:
- {fileID: 11400000, guid: 53185ea05ebfbd843b009cb14101377a, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9eb62481994b51e4897a57499081c3db
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u9EC4\u5DFE\u5F13\u5175"
m_EditorClassIdentifier:
name: "\u9EC4\u5DFE\u5F13\u5175"
description:
artwork: {fileID: 21300000, guid: 6cda0587e4f968a40a41c5d55b75637c, type: 3}
cost: 1
attack: 5
defense: 10
movement: 1
cardTags:
- {fileID: 11400000, guid: 099176a69eb9a6d408b4d4dba5232c84, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 675490af7d7c9c142ae76d1b2e4920b1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,23 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u9EC4\u5DFE\u6B65\u5175"
m_EditorClassIdentifier:
name: "\u9EC4\u5DFE\u6B65\u5175"
description:
artwork: {fileID: 21300000, guid: f8ac336e7fbacfb4c8bfff09cc239572, type: 3}
cost: 1
attack: 3
defense: 18
movement: 1
cardTags:
- {fileID: 11400000, guid: cf728e5d8a62fa3418d2f3daa01f93df, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bc0d9030782a4164a9b9d7f1862a2a1b
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,22 @@
%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: ff8753e834c907545942bdfe8de31484, type: 3}
m_Name: "\u9EC4\u5DFE\u9A91\u5175"
m_EditorClassIdentifier:
name: "\u9EC4\u5DFE\u9A91\u5175"
description:
artwork: {fileID: 21300000, guid: f5a556db390732345bab89bd18306f44, type: 3}
cost: 1
attack: 7
defense: 8
cardTags:
- {fileID: 11400000, guid: 53185ea05ebfbd843b009cb14101377a, type: 2}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 155d6c1a6daf61943aec6158856d2336
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,722 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2394601693270377322
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601693270377321}
- component: {fileID: 2394601693270377320}
m_Layer: 0
m_Name: Art
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2394601693270377321
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693270377322}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.1, y: 0.1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2394601694276102724}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2394601693270377320
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693270377322}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 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_Sprite: {fileID: 21300000, guid: 2d97ce419675f1c459311efd175bb108, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 7.32, y: 10.24}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2394601693285929057
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601693285929056}
- component: {fileID: 2394601693285929061}
- component: {fileID: 2394601693285929062}
- component: {fileID: 2394601693285929063}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2394601693285929056
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693285929057}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2394601694591385740}
- {fileID: 2394601693922879817}
- {fileID: 2394601694177360926}
- {fileID: 2394601695001609612}
m_Father: {fileID: 2394601695013244675}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!223 &2394601693285929061
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693285929057}
m_Enabled: 1
serializedVersion: 3
m_RenderMode: 2
m_Camera: {fileID: 0}
m_PlaneDistance: 100
m_PixelPerfect: 0
m_ReceivesEvents: 1
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 5
m_TargetDisplay: 0
--- !u!114 &2394601693285929062
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693285929057}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
m_FallbackScreenDPI: 96
m_DefaultSpriteDPI: 96
m_DynamicPixelsPerUnit: 1
m_PresetInfoIsWorld: 1
--- !u!114 &2394601693285929063
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693285929057}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3}
m_Name:
m_EditorClassIdentifier:
m_IgnoreReversedGraphics: 1
m_BlockingObjects: 0
m_BlockingMask:
serializedVersion: 2
m_Bits: 4294967295
--- !u!1 &2394601693922879818
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601693922879817}
- component: {fileID: 2394601693922879816}
m_Layer: 5
m_Name: AttackBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2394601693922879817
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693922879818}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.304, y: -0.441, z: -2.15}
m_LocalScale: {x: 0.0798525, y: 0.0798525, z: 0.31941}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2394601693285929056}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2394601693922879816
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601693922879818}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 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_Sprite: {fileID: 21300000, guid: 83ea6c9d3156a3f44a313f2572de90f1, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.49, y: 5.39}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2394601694177360927
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601694177360926}
- component: {fileID: 2394601694177360924}
- component: {fileID: 2394601694177360925}
m_Layer: 5
m_Name: Defense
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2394601694177360926
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694177360927}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -2.15}
m_LocalScale: {x: 0.25, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2394601693285929056}
m_RootOrder: 2
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: 0.30900002, y: -0.441}
m_SizeDelta: {x: 10, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2394601694177360924
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694177360927}
m_CullTransparentMesh: 1
--- !u!114 &2394601694177360925
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694177360927}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, 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_text: 20
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 1
m_fontSizeBase: 1
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2394601694276102725
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601694276102724}
- component: {fileID: 2394601694276102747}
m_Layer: 0
m_Name: "\u5C0F\u5175"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2394601694276102724
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694276102725}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -0.5, y: -0.5, z: -1}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2394601693270377321}
- {fileID: 2394601695013244675}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2394601694276102747
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694276102725}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 985a1b81fb93ea54b8f8d9671fd543e8, type: 3}
m_Name:
m_EditorClassIdentifier:
unitName:
cardData: {fileID: 11400000, guid: 5d7c6bbedeba24e4f98ea1ca65fc5c0a, type: 2}
basicAttack: 5
currentDefense: 20
basicMaxDefense: 20
cardTags: []
attackRange: 1
movement: 1
currentCommand: 1
standingCell: {fileID: 0}
destinationCell: {fileID: 0}
side: 1
modelArt: {fileID: 2394601693270377321}
attackText: {fileID: 2394601694591385740}
defenseText: {fileID: 2394601694177360926}
walkingToDestination: 0
--- !u!1 &2394601694591385741
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601694591385740}
- component: {fileID: 2394601694591385730}
- component: {fileID: 2394601694591385731}
m_Layer: 5
m_Name: Attack
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2394601694591385740
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694591385741}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -2.15}
m_LocalScale: {x: 0.25, y: 0.25, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2394601693285929056}
m_RootOrder: 0
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: -0.28100002, y: -0.441}
m_SizeDelta: {x: 10, y: 10}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2394601694591385730
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694591385741}
m_CullTransparentMesh: 1
--- !u!114 &2394601694591385731
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601694591385741}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, 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_text: 5
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 1
m_fontSizeBase: 1
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!1 &2394601695001609613
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601695001609612}
- component: {fileID: 2394601695001609603}
m_Layer: 5
m_Name: DefenseBackground
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2394601695001609612
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601695001609613}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.286, y: -0.441, z: -2.15}
m_LocalScale: {x: 0.0798525, y: 0.0798525, z: 0.31941}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 2394601693285929056}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &2394601695001609603
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601695001609613}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_StaticShadowCaster: 0
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RayTracingMode: 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_Sprite: {fileID: 21300000, guid: 83ea6c9d3156a3f44a313f2572de90f1, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.49, y: 5.39}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &2394601695013244684
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2394601695013244675}
m_Layer: 0
m_Name: Status
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2394601695013244675
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2394601695013244684}
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: 2394601693285929056}
m_Father: {fileID: 2394601694276102724}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 81eab03836e5b52448e4ad61de8f2406
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,6 @@ public class CardData : ScriptableObject
public int cost; public int cost;
public int attack; public int attack;
public int defense; public int defense;
public int movement = 1;
public CardTag[] cardTags; public CardTag[] cardTags;
} }

View File

@ -1,7 +1,9 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
using UnityEngine.Assertions; using UnityEngine.Assertions;
using TMPro;
public enum CurrentCommand { defend, moveForward, retreat } public enum CurrentCommand { defend, moveForward, retreat }
@ -11,6 +13,7 @@ public enum Side { left = 1, right = -1 }
public class Unit : MonoBehaviour public class Unit : MonoBehaviour
{ {
public string unitName; public string unitName;
public CardData cardData;
[SerializeField] [SerializeField]
private int basicAttack; private int basicAttack;
@ -34,13 +37,16 @@ public class Unit : MonoBehaviour
[SerializeField] [SerializeField]
private CurrentCommand currentCommand; private CurrentCommand currentCommand;
public Cell standingCell;
[SerializeField] [SerializeField]
private Cell standingCell;
private Cell destinationCell; private Cell destinationCell;
private CellMap cellMap; private CellMap cellMap;
[SerializeField] public Side side;
private Side side;
public Transform modelArt;
public Transform attackText;
public Transform defenseText;
public bool walkingToDestination = false; public bool walkingToDestination = false;
@ -52,6 +58,25 @@ public class Unit : MonoBehaviour
transform.position = standingCell.transform.position; transform.position = standingCell.transform.position;
transform.position = new Vector3(transform.position.x, transform.position.y, -1); transform.position = new Vector3(transform.position.x, transform.position.y, -1);
standingCell.standingUnit = this; standingCell.standingUnit = this;
basicAttack = cardData.attack;
basicMaxDefense = cardData.defense;
currentDefense = basicMaxDefense;
cardTags = cardData.cardTags;
foreach (var tag in cardData.cardTags)
{
if (tag.name == "Archer")
{
attackRange += 2;
}
else if (tag.name == "Cavalry")
{
movement += 1;
}
}
modelArt.GetComponent<SpriteRenderer>().sprite = cardData.artwork;
} }
// Update is called once per frame // Update is called once per frame
@ -62,7 +87,7 @@ public class Unit : MonoBehaviour
Vector3 moveVec = destinationCell.transform.position - transform.position; Vector3 moveVec = destinationCell.transform.position - transform.position;
transform.position = new Vector3(transform.position.x + moveVec.x * 5.0f * Time.deltaTime, transform.position.y + moveVec.y * 5.0f * Time.deltaTime, -1); transform.position = new Vector3(transform.position.x + moveVec.x * 5.0f * Time.deltaTime, transform.position.y + moveVec.y * 5.0f * Time.deltaTime, -1);
Debug.Log("Manitude: " + moveVec.magnitude); //Debug.Log("Manitude: " + moveVec.magnitude);
if ((Mathf.Approximately(transform.position.x, destinationCell.transform.position.x) if ((Mathf.Approximately(transform.position.x, destinationCell.transform.position.x)
&& Mathf.Approximately(transform.position.y, destinationCell.transform.position.y)) && Mathf.Approximately(transform.position.y, destinationCell.transform.position.y))
@ -71,36 +96,82 @@ public class Unit : MonoBehaviour
walkingToDestination = false; walkingToDestination = false;
transform.position = new Vector3(destinationCell.transform.position.x, destinationCell.transform.position.y, -1); transform.position = new Vector3(destinationCell.transform.position.x, destinationCell.transform.position.y, -1);
destinationCell = null; destinationCell = null;
Debug.Log("Arrived."); //Debug.Log("Arrived.");
} }
} }
finalAttack = basicAttack; // For now.
attackText.GetComponent<TextMeshProUGUI>().text = finalAttack.ToString();
defenseText.GetComponent<TextMeshProUGUI>().text = currentDefense.ToString();
}
public void MoveAndAttack()
{
MoveAction();
AttackAction();
} }
public void MoveAction() public void MoveAction()
{ {
if (walkingToDestination) if (walkingToDestination)
{ {
Debug.Log("Can start a new move action. Unit is still moving.");
return; return;
} }
foreach (var tag in cardData.cardTags)
{
if (tag.name == "Archer")
{
for (int i = 0; i < attackRange; ++i)
{
int attackXPos = standingCell.xPos + (i + 1) * (int)side;
if (attackXPos >= cellMap.column || attackXPos < 0)
{
// Attack Camp
currentCommand = CurrentCommand.defend;
break;
}
Debug.Log("Call MoveAction()."); Cell nextCellInRange = cellMap.GetCell(attackXPos, standingCell.yPos);
Unit targetUnit = nextCellInRange.standingUnit;
if (targetUnit)
{
if (targetUnit.side != side)
{
// Add units to attack list.
currentCommand = CurrentCommand.defend;
break;
}
}
currentCommand = CurrentCommand.moveForward;
}
break;
}
}
//Debug.Log("Call MoveAction().");
switch (currentCommand) switch (currentCommand)
{ {
case CurrentCommand.defend: case CurrentCommand.defend:
break; break;
case CurrentCommand.moveForward: case CurrentCommand.moveForward:
Debug.Log("Try Move Forward."); //Debug.Log("Try Move Forward.");
for (int i = 0; i < movement; i++)
{
if (checkDestinationCellEmpty()) if (checkDestinationCellEmpty())
{ {
// Attack() // Attack()
Debug.Log("Start Moving."); //Debug.Log("Start Moving.");
MoveToCell(destinationCell); MoveToCell(destinationCell);
walkingToDestination = true; walkingToDestination = true;
} }
else else
{ {
Debug.Log("Can't Move."); //Debug.Log("Can't Move.");
// Check the unit is facing the camp or unit. // Check the unit is facing the camp or unit.
if (destinationCell) if (destinationCell)
{ {
@ -108,16 +179,33 @@ public class Unit : MonoBehaviour
if (destinationCell.standingUnit.side == side) if (destinationCell.standingUnit.side == side)
{ {
// Check the Allie is swappable or not. // Check the Allie is swappable or not.
if (!inDogFight(destinationCell.standingUnit))
{
//standingCell = cell;
//cell.standingUnit = this;
destinationCell.standingUnit.walkingToDestination = true;
standingCell.standingUnit = destinationCell.standingUnit;
standingCell.standingUnit.standingCell = standingCell;
standingCell.standingUnit.destinationCell = standingCell;
standingCell = destinationCell;
destinationCell.standingUnit = this;
walkingToDestination = true;
}
} }
else else
{ {
// Can't move to cell this is standed by enemy. // Can't move to cell this is standed by enemy.
break;
} }
} }
else else
{ {
// Facing the camp. // Facing the camp.
break;
}
destinationCell = standingCell;
} }
} }
break; break;
@ -128,6 +216,86 @@ public class Unit : MonoBehaviour
} }
} }
public void AttackAction()
{
// Check Attack Range
if (inDogFight(this))
{
foreach (var tag in cardData.cardTags)
{
if (tag.name == "Archer")
{
// Archer can't dog fight.
return;
}
}
}
List<Unit> unitsInRange = new List<Unit>();
for (int i = 0; i < attackRange; ++i)
{
int attackXPos = standingCell.xPos + (i+1) * (int)side;
if (attackXPos >= cellMap.column || attackXPos < 0)
{
// Attack Camp
return;
}
Cell nextCellInRange = cellMap.GetCell(attackXPos, standingCell.yPos);
Unit targetUnit = nextCellInRange.standingUnit;
if (targetUnit)
{
if (targetUnit.side != side)
{
// Add units to attack list.
unitsInRange.Add(targetUnit);
}
else
{
// It is allies. We don't attack it unless we are under some debuff.
}
}
else
{
// Nothing to attack.
//Debug.Log("No unit to attack.");
}
}
if (side == Side.left)
{
unitsInRange = unitsInRange.OrderBy(x => x.standingCell.xPos).ToList<Unit>();
}
else
{
unitsInRange = unitsInRange.OrderByDescending(x => x.standingCell.xPos).ToList<Unit>();
}
for (int i = 0; i < unitsInRange.Count; i++)
{
Debug.Log(unitsInRange[i].unitName + ": " + unitsInRange[i].standingCell.xPos + " , " + unitsInRange[i].standingCell.yPos);
// Do attack
//Debug.Log("Attack!");
unitsInRange[i].currentDefense -= finalAttack;
if (unitsInRange[i].currentDefense <= 0)
{
unitsInRange[i].standingCell.standingUnit = null;
unitsInRange[i].gameObject.SetActive(false); // For now
Unit unit = unitsInRange[i];
FindObjectOfType<UnitManager>().handleDiedUnit(unit);
//Debug.Log("Defeat Enemy");
}
break; // Most of units can only attack one target.
}
}
public bool isUnitAlive()
{
return currentDefense > 0;
}
bool checkDestinationCellEmpty(bool retreat = false) bool checkDestinationCellEmpty(bool retreat = false)
{ {
int currentXPos = standingCell.xPos; int currentXPos = standingCell.xPos;
@ -135,17 +303,17 @@ public class Unit : MonoBehaviour
if (retreat) if (retreat)
{ {
movePath = movement * -(int)side; movePath = 1 * -(int)side;
} }
else else
{ {
movePath = movement * (int)side; movePath = 1 * (int)side;
} }
int destinationXPos = standingCell.xPos + movePath; int destinationXPos = standingCell.xPos + movePath;
// Mean the destination cell is the Camp. // Mean the destination cell is the Camp.
if (destinationXPos < 0 || destinationXPos >= cellMap.column) if (!checkPosInMap(destinationXPos))
{ {
return false; return false;
} }
@ -158,6 +326,7 @@ public class Unit : MonoBehaviour
} }
else else
{ {
// Check privous cell is standable if we have more than 1 movement ability.
return false; return false;
} }
} }
@ -170,4 +339,28 @@ public class Unit : MonoBehaviour
standingCell = cell; standingCell = cell;
cell.standingUnit = this; cell.standingUnit = this;
} }
// Check the allies is near by an enemy or not.
bool inDogFight(Unit unit)
{
int checkPos = unit.standingCell.xPos + (int)side * 1;
if (!checkPosInMap(checkPos))
{
return false;
}
var checkCell = cellMap.GetCell(checkPos, standingCell.yPos);
if (checkCell.standingUnit && checkCell.standingUnit.side != side)
{
return true;
}
return false;
}
bool checkPosInMap(int pos)
{
return pos >= 0 && pos < cellMap.column;
}
} }

View File

@ -0,0 +1,100 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class UnitManager : MonoBehaviour
{
public List<Unit> leftSideUnits = new List<Unit>();
public List<Unit> rightSideUnits = new List<Unit>();
// Start is called before the first frame update
void Start()
{
var units = FindObjectsOfType<Unit>();
foreach (var unit in units)
{
if (unit.side == Side.left)
{
leftSideUnits.Add(unit);
}
else
{
rightSideUnits.Add(unit);
}
}
}
// Update is called once per frame
void Update()
{
}
public void handleDiedUnit(Unit unit)
{
if (unit.side == Side.left)
{
leftSideUnits.Remove(unit);
}
else if (unit.side == Side.right)
{
leftSideUnits.Remove(unit);
}
}
bool test = true;
public void SideAction()
{
if (test)
{
SortActionOrder(Side.right);
foreach (var unit in rightSideUnits)
{
if (unit.isUnitAlive())
{
unit.MoveAction();
}
if (unit.isUnitAlive())
{
unit.AttackAction();
}
}
}
else
{
SortActionOrder(Side.left);
foreach (var unit in leftSideUnits)
{
if (unit.isUnitAlive())
{
unit.MoveAction();
}
if (unit.isUnitAlive())
{
unit.AttackAction();
}
}
}
test = !test;
}
private void SortActionOrder(Side side)
{
switch (side)
{
case Side.left:
leftSideUnits = leftSideUnits.OrderByDescending(x => x.standingCell.xPos).ThenByDescending(y => y.standingCell.yPos).ToList<Unit>();
break;
case Side.right:
rightSideUnits = rightSideUnits.OrderBy(x => x.standingCell.xPos).ThenBy(y => y.standingCell.yPos).ToList<Unit>();
break;
default:
break;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a7b5cc2948c19154e96390c013689e09
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,7 +9,7 @@ Material:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_Name: LiberationSans SDF Material m_Name: LiberationSans SDF Material
m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3} m_Shader: {fileID: 4800000, guid: fe393ace9b354375a9cb14cdbbc28be4, type: 3}
m_ShaderKeywords: m_ShaderKeywords: OUTLINE_ON
m_LightmapFlags: 1 m_LightmapFlags: 1
m_EnableInstancingVariants: 0 m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0 m_DoubleSidedGI: 0
@ -32,7 +32,7 @@ Material:
- _MaskSoftnessX: 0 - _MaskSoftnessX: 0
- _MaskSoftnessY: 0 - _MaskSoftnessY: 0
- _OutlineSoftness: 0 - _OutlineSoftness: 0
- _OutlineWidth: 0 - _OutlineWidth: 0.16
- _PerspectiveFilter: 0.875 - _PerspectiveFilter: 0.875
- _ScaleRatioA: 0.9 - _ScaleRatioA: 0.9
- _ScaleRatioB: 1 - _ScaleRatioB: 1