Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
civilization-iii
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
true-history-committee
civilization-iii
Commits
a6b2fdb6
Commit
a6b2fdb6
authored
Feb 12, 2018
by
16도재형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#7
Unit visualize & Camera moving
parent
7467a90a
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
552 additions
and
15 deletions
+552
-15
Test Unit.prefab
Assets/Prefabs/Test Unit.prefab
+97
-0
Test Unit.prefab.meta
Assets/Prefabs/Test Unit.prefab.meta
+10
-0
hextile 1.prefab
Assets/Prefabs/hextile 1.prefab
+266
-0
hextile 1.prefab.meta
Assets/Prefabs/hextile 1.prefab.meta
+10
-0
MainScene.unity
Assets/Scenes/MainScene.unity
+4
-2
GameInfo.cs
Assets/Scripts/GameInfo.cs
+2
-2
GameManager.cs
Assets/Scripts/GameManager.cs
+88
-11
HexTile.cs
Assets/Scripts/HexTile.cs
+44
-0
HexTile.cs.meta
Assets/Scripts/HexTile.cs.meta
+13
-0
Units.cs
Assets/Scripts/Units.cs
+5
-0
Units.cs.meta
Assets/Scripts/Units.cs.meta
+13
-0
No files found.
Assets/Prefabs/Test Unit.prefab
0 → 100644
View file @
a6b2fdb6
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1001
&100100000
Prefab
:
m_ObjectHideFlags
:
1
serializedVersion
:
2
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
[]
m_RemovedComponents
:
[]
m_ParentPrefab
:
{
fileID
:
0
}
m_RootGameObject
:
{
fileID
:
1273638483437158
}
m_IsPrefabParent
:
1
---
!u!1
&1273638483437158
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4004406348481458
}
-
component
:
{
fileID
:
33698271314838724
}
-
component
:
{
fileID
:
65421259870004496
}
-
component
:
{
fileID
:
23745117509427088
}
m_Layer
:
0
m_Name
:
Test Unit
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&4004406348481458
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1273638483437158
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0.4
,
z
:
0
}
m_LocalScale
:
{
x
:
0.5
,
y
:
0.8
,
z
:
0.5
}
m_Children
:
[]
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!23
&23745117509427088
MeshRenderer
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1273638483437158
}
m_Enabled
:
1
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_Materials
:
-
{
fileID
:
10303
,
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_PreserveUVs
:
1
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
0
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!33
&33698271314838724
MeshFilter
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1273638483437158
}
m_Mesh
:
{
fileID
:
10202
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
---
!u!65
&65421259870004496
BoxCollider
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1273638483437158
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
Assets/Prefabs/Test Unit.prefab.meta
0 → 100644
View file @
a6b2fdb6
fileFormatVersion: 2
guid: f14f897ac3d838d449a39957d5448b9c
timeCreated: 1518400069
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
Assets/Prefabs/hextile 1.prefab
0 → 100644
View file @
a6b2fdb6
%YAML
1.1
%TAG
!u!
tag:unity3d.com,2011:
---
!u!1001
&100100000
Prefab
:
m_ObjectHideFlags
:
1
serializedVersion
:
2
m_Modification
:
m_TransformParent
:
{
fileID
:
0
}
m_Modifications
:
[]
m_RemovedComponents
:
[]
m_ParentPrefab
:
{
fileID
:
0
}
m_RootGameObject
:
{
fileID
:
1823159130722898
}
m_IsPrefabParent
:
1
---
!u!1
&1187391223902348
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4245987888127746
}
-
component
:
{
fileID
:
33102233136240168
}
-
component
:
{
fileID
:
65451473139732646
}
-
component
:
{
fileID
:
23861829496503386
}
m_Layer
:
0
m_Name
:
Pioneer
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1823159130722898
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4624084589808502
}
-
component
:
{
fileID
:
33382563896309128
}
-
component
:
{
fileID
:
23842930406273546
}
-
component
:
{
fileID
:
114528188812766900
}
m_Layer
:
0
m_Name
:
hextile
1
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!1
&1864306018844118
GameObject
:
m_ObjectHideFlags
:
0
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
serializedVersion
:
5
m_Component
:
-
component
:
{
fileID
:
4094104317531802
}
-
component
:
{
fileID
:
33070008573188642
}
-
component
:
{
fileID
:
65133615766084452
}
-
component
:
{
fileID
:
23332174040222252
}
m_Layer
:
0
m_Name
:
Jedi Knight
m_TagString
:
Untagged
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
---
!u!4
&4094104317531802
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1864306018844118
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0.4
,
z
:
0
}
m_LocalScale
:
{
x
:
0.5
,
y
:
0.8
,
z
:
0.5
}
m_Children
:
[]
m_Father
:
{
fileID
:
4624084589808502
}
m_RootOrder
:
1
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4245987888127746
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1187391223902348
}
m_LocalRotation
:
{
x
:
0
,
y
:
0
,
z
:
0
,
w
:
1
}
m_LocalPosition
:
{
x
:
0
,
y
:
0.4
,
z
:
0
}
m_LocalScale
:
{
x
:
0.5
,
y
:
0.8
,
z
:
0.5
}
m_Children
:
[]
m_Father
:
{
fileID
:
4624084589808502
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!4
&4624084589808502
Transform
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
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
:
4245987888127746
}
-
{
fileID
:
4094104317531802
}
m_Father
:
{
fileID
:
0
}
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!23
&23332174040222252
MeshRenderer
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1864306018844118
}
m_Enabled
:
0
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_Materials
:
-
{
fileID
:
10303
,
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_PreserveUVs
:
1
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
0
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!23
&23842930406273546
MeshRenderer
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_Enabled
:
1
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_Materials
:
-
{
fileID
:
2100000
,
guid
:
93b23d960c7fd2645bed567627e2e6db
,
type
:
3
}
m_StaticBatchInfo
:
firstSubMesh
:
0
subMeshCount
:
0
m_StaticBatchRoot
:
{
fileID
:
0
}
m_ProbeAnchor
:
{
fileID
:
0
}
m_LightProbeVolumeOverride
:
{
fileID
:
0
}
m_ScaleInLightmap
:
1
m_PreserveUVs
:
0
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
0
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!23
&23861829496503386
MeshRenderer
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1187391223902348
}
m_Enabled
:
0
m_CastShadows
:
1
m_ReceiveShadows
:
1
m_DynamicOccludee
:
1
m_MotionVectors
:
1
m_LightProbeUsage
:
1
m_ReflectionProbeUsage
:
1
m_Materials
:
-
{
fileID
:
10303
,
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_PreserveUVs
:
1
m_IgnoreNormalsForChartDetection
:
0
m_ImportantGI
:
0
m_StitchLightmapSeams
:
0
m_SelectedEditorRenderState
:
3
m_MinimumChartSize
:
4
m_AutoUVMaxDistance
:
0.5
m_AutoUVMaxAngle
:
89
m_LightmapParameters
:
{
fileID
:
0
}
m_SortingLayerID
:
0
m_SortingLayer
:
0
m_SortingOrder
:
0
---
!u!33
&33070008573188642
MeshFilter
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1864306018844118
}
m_Mesh
:
{
fileID
:
10202
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
---
!u!33
&33102233136240168
MeshFilter
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1187391223902348
}
m_Mesh
:
{
fileID
:
10202
,
guid
:
0000000000000000e000000000000000
,
type
:
0
}
---
!u!33
&33382563896309128
MeshFilter
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_Mesh
:
{
fileID
:
4300000
,
guid
:
93b23d960c7fd2645bed567627e2e6db
,
type
:
3
}
---
!u!65
&65133615766084452
BoxCollider
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1864306018844118
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!65
&65451473139732646
BoxCollider
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1187391223902348
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
2
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
---
!u!114
&114528188812766900
MonoBehaviour
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
784c3f2942f405c47bd30667f0395f5a
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
Assets/Prefabs/hextile 1.prefab.meta
0 → 100644
View file @
a6b2fdb6
fileFormatVersion: 2
guid: ef12b8f6d512e104b979d4a75f3e60c0
timeCreated: 1518406688
licenseType: Free
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
Assets/Scenes/MainScene.unity
View file @
a6b2fdb6
...
@@ -38,7 +38,7 @@ RenderSettings:
...
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity
:
1
m_ReflectionIntensity
:
1
m_CustomReflection
:
{
fileID
:
0
}
m_CustomReflection
:
{
fileID
:
0
}
m_Sun
:
{
fileID
:
0
}
m_Sun
:
{
fileID
:
0
}
m_IndirectSpecularColor
:
{
r
:
0.446578
44
,
g
:
0.49641222
,
b
:
0.57481694
,
a
:
1
}
m_IndirectSpecularColor
:
{
r
:
0.446578
98
,
g
:
0.4964133
,
b
:
0.5748178
,
a
:
1
}
---
!u!157
&3
---
!u!157
&3
LightmapSettings
:
LightmapSettings
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -14235,9 +14235,11 @@ MonoBehaviour:
...
@@ -14235,9 +14235,11 @@ MonoBehaviour:
m_Script
:
{
fileID
:
11500000
,
guid
:
112f8b62e41ed9842a4ad52cdb5b87df
,
type
:
3
}
m_Script
:
{
fileID
:
11500000
,
guid
:
112f8b62e41ed9842a4ad52cdb5b87df
,
type
:
3
}
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
mainCamera
:
{
fileID
:
1006940699
}
cameraMoveSpeed
:
3
outerRadius
:
1
outerRadius
:
1
innerRadius
:
0
innerRadius
:
0
cellPrefab
:
{
fileID
:
18
39775916168536
,
guid
:
900341537233caf489d432cff5440dd3
,
type
:
2
}
cellPrefab
:
{
fileID
:
18
23159130722898
,
guid
:
ef12b8f6d512e104b979d4a75f3e60c0
,
type
:
2
}
---
!u!4
&1056054509
---
!u!4
&1056054509
Transform
:
Transform
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
...
Assets/Scripts/GameInfo.cs
View file @
a6b2fdb6
public
class
GameInfo
public
class
GameInfo
{
{
public
static
int
numOfPlayer
=
2
;
public
static
int
numOfPlayer
=
2
;
public
static
int
mapWidth
=
1
28
;
public
static
int
mapWidth
=
1
0
;
public
static
int
mapHeight
=
8
0
;
public
static
int
mapHeight
=
8
;
}
}
Assets/Scripts/GameManager.cs
View file @
a6b2fdb6
...
@@ -8,11 +8,18 @@ public class GameManager : MonoBehaviour {
...
@@ -8,11 +8,18 @@ public class GameManager : MonoBehaviour {
private
static
GameManager
_manager
=
null
;
private
static
GameManager
_manager
=
null
;
public
static
GameManager
I
{
get
{
return
_manager
;
}
}
public
static
GameManager
I
{
get
{
return
_manager
;
}
}
// Main Camera for Focus()
[
SerializeField
]
Camera
mainCamera
;
// Camera move speed
[
SerializeField
]
float
cameraMoveSpeed
;
enum
CameraMoveDirection
{
Up
,
Down
,
Left
,
Right
}
// Current game
// Current game
private
CivModel
.
Game
_game
;
private
CivModel
.
Game
_game
;
// Selected unit
// Currently playing country
private
CivModel
.
Unit
_currentUnit
;
public
float
outerRadius
=
1f
;
// Outer&inner radius of hex tile.
public
float
outerRadius
=
1f
;
// Outer&inner radius of hex tile.
public
float
innerRadius
;
// These variables can be deleted if there are no use.
public
float
innerRadius
;
// These variables can be deleted if there are no use.
...
@@ -35,22 +42,44 @@ public class GameManager : MonoBehaviour {
...
@@ -35,22 +42,44 @@ public class GameManager : MonoBehaviour {
// Use this when scene changing exists
// Use this when scene changing exists
// DontDestroyOnLoad(gameObject);
// DontDestroyOnLoad(gameObject);
// Instantiate game
instance
// Instantiate game
_game
=
new
CivModel
.
Game
(
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
,
GameInfo
.
numOfPlayer
,
new
CivModel
.
Common
.
GameSchemeFactory
());
_game
=
new
CivModel
.
Game
(
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
,
GameInfo
.
numOfPlayer
,
new
CivModel
.
Common
.
GameSchemeFactory
());
// Map tiling
// Map tiling
innerRadius
=
outerRadius
*
Mathf
.
Sqrt
(
3.0f
)
/
2
;
innerRadius
=
outerRadius
*
Mathf
.
Sqrt
(
3.0f
)
/
2
;
_cells
=
new
GameObject
[
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
];
DrawMap
();
DrawMap
();
}
}
// Update is called once per frame
// Update is called once per frame
void
Update
()
{
void
Update
()
{
RenderTile
(
_game
.
Terrain
);
Render
(
_game
.
Terrain
);
// Camera movement
Vector3
mousePos
=
Input
.
mousePosition
;
if
(
mousePos
.
x
<
10
)
{
CameraMove
(
CameraMoveDirection
.
Left
);
}
else
if
(
mousePos
.
x
>
Screen
.
width
-
10
)
{
CameraMove
(
CameraMoveDirection
.
Right
);
}
if
(
mousePos
.
y
<
10
)
{
CameraMove
(
CameraMoveDirection
.
Down
);
}
else
if
(
mousePos
.
y
>
Screen
.
height
-
10
)
{
CameraMove
(
CameraMoveDirection
.
Up
);
}
Debug
.
Log
(
"width, height: "
+
Screen
.
width
+
", "
+
Screen
.
height
);
Debug
.
Log
(
Input
.
mousePosition
);
}
}
void
DrawMap
()
// Instantiate hex tiles
void
DrawMap
()
// Instantiate hex tiles
{
{
_cells
=
new
GameObject
[
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
];
for
(
int
i
=
0
;
i
<
GameInfo
.
mapWidth
;
i
++)
for
(
int
i
=
0
;
i
<
GameInfo
.
mapWidth
;
i
++)
{
{
for
(
int
j
=
0
;
j
<
GameInfo
.
mapHeight
;
j
++)
for
(
int
j
=
0
;
j
<
GameInfo
.
mapHeight
;
j
++)
...
@@ -61,13 +90,13 @@ public class GameManager : MonoBehaviour {
...
@@ -61,13 +90,13 @@ public class GameManager : MonoBehaviour {
pos
.
x
-=
innerRadius
;
pos
.
x
-=
innerRadius
;
}
}
_cells
[
i
,
j
]
=
Instantiate
(
cellPrefab
,
pos
,
Quaternion
.
identity
);
_cells
[
i
,
j
]
=
Instantiate
(
cellPrefab
,
pos
,
Quaternion
.
identity
);
_cells
[
i
,
j
].
name
=
"("
+
i
+
","
+
j
+
")"
;
_cells
[
i
,
j
].
name
=
Pos2Str
(
i
,
j
)
;
}
}
}
}
}
}
// Read game terrain and update hex tile resource
// Read game terrain and update hex tile resource
void
Render
Tile
(
CivModel
.
Terrain
terrain
)
void
Render
(
CivModel
.
Terrain
terrain
)
{
{
for
(
int
i
=
0
;
i
<
terrain
.
Width
;
i
++)
for
(
int
i
=
0
;
i
<
terrain
.
Width
;
i
++)
{
{
...
@@ -75,10 +104,58 @@ public class GameManager : MonoBehaviour {
...
@@ -75,10 +104,58 @@ public class GameManager : MonoBehaviour {
{
{
CivModel
.
Terrain
.
Point
point
=
terrain
.
GetPoint
(
i
,
j
);
CivModel
.
Terrain
.
Point
point
=
terrain
.
GetPoint
(
i
,
j
);
// TODO: Make prefab component
// TODO: Make prefab component
// _cells[i, j].GetComponent<
TilePrefab
>().ChangeTile(point);
// _cells[i, j].GetComponent<
HexTile
>().ChangeTile(point);
// _cells[i, j].GetComponent<
TilePrefab
>().BuildDistrict(point.TileBuilding);
// _cells[i, j].GetComponent<
HexTile
>().BuildDistrict(point.TileBuilding);
// _cells[i, j].GetComponent<TilePrefab
>().DrawUnit(point.Unit);
_cells
[
i
,
j
].
GetComponent
<
HexTile
>().
DrawUnit
(
point
.
Unit
);
}
}
}
}
}
}
// Camera focus
void
Focus
(
CivModel
.
Unit
unit
)
{
if
(
unit
==
null
)
{
return
;
}
Focus
(
unit
.
PlacedPoint
.
Value
);
}
void
Focus
(
CivModel
.
Terrain
.
Point
point
)
{
GameObject
tile
=
GameObject
.
Find
(
Pos2Str
(
point
.
Position
));
Vector3
tilePos
=
tile
.
transform
.
position
;
float
x
=
tilePos
.
x
;
float
z
=
tilePos
.
z
-
(
6.75f
/
Mathf
.
Tan
(
40
*
Mathf
.
Deg2Rad
));
mainCamera
.
transform
.
position
=
new
Vector3
(
x
,
6.75f
,
z
);
}
// Method that gives "(x,y)" string with input of CivModel.Position or 2 ints
string
Pos2Str
(
CivModel
.
Position
pos
)
{
return
Pos2Str
(
pos
.
X
,
pos
.
Y
);
}
string
Pos2Str
(
int
x
,
int
y
)
{
return
"("
+
x
+
","
+
y
+
")"
;
}
void
CameraMove
(
CameraMoveDirection
moveDirection
)
{
switch
(
moveDirection
)
{
case
CameraMoveDirection
.
Up
:
mainCamera
.
transform
.
Translate
(
Vector3
.
forward
*
cameraMoveSpeed
*
Time
.
deltaTime
,
Space
.
World
);
break
;
case
CameraMoveDirection
.
Down
:
mainCamera
.
transform
.
Translate
(
Vector3
.
back
*
cameraMoveSpeed
*
Time
.
deltaTime
,
Space
.
World
);
break
;
case
CameraMoveDirection
.
Left
:
mainCamera
.
transform
.
Translate
(
Vector3
.
left
*
cameraMoveSpeed
*
Time
.
deltaTime
,
Space
.
World
);
break
;
case
CameraMoveDirection
.
Right
:
mainCamera
.
transform
.
Translate
(
Vector3
.
right
*
cameraMoveSpeed
*
Time
.
deltaTime
,
Space
.
World
);
break
;
}
}
}
}
Assets/Scripts/HexTile.cs
0 → 100644
View file @
a6b2fdb6
using
System.Collections
;
using
System.Collections.Generic
;
using
UnityEngine
;
using
CivModel
;
using
CivModel.Common
;
public
class
HexTile
:
MonoBehaviour
{
// Use this for initialization
void
Start
()
{
}
// Update is called once per frame
void
Update
()
{
}
// This method should be changed when
public
void
DrawUnit
(
CivModel
.
Unit
unit
)
{
if
(
unit
==
null
)
{
foreach
(
Transform
child
in
transform
)
{
child
.
gameObject
.
GetComponent
<
MeshRenderer
>().
enabled
=
false
;
}
}
else
{
foreach
(
Transform
child
in
transform
)
{
if
(
child
.
gameObject
.
name
==
"Pioneer"
)
{
child
.
gameObject
.
GetComponent
<
MeshRenderer
>().
enabled
=
true
;
}
else
{
child
.
gameObject
.
GetComponent
<
MeshRenderer
>().
enabled
=
false
;
}
}
}
}
}
Assets/Scripts/HexTile.cs.meta
0 → 100644
View file @
a6b2fdb6
fileFormatVersion: 2
guid: 784c3f2942f405c47bd30667f0395f5a
timeCreated: 1518401981
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Units.cs
0 → 100644
View file @
a6b2fdb6
public
enum
Units
{
Pioneer
,
JediKnight
}
\ No newline at end of file
Assets/Scripts/Units.cs.meta
0 → 100644
View file @
a6b2fdb6
fileFormatVersion: 2
guid: 525a0ad12ac679345ac3f4583828089f
timeCreated: 1518409259
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment