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
2e0a2048
Commit
2e0a2048
authored
Feb 12, 2018
by
16도재형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now we can select unit
parent
a6b2fdb6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
17 deletions
+109
-17
hextile 1.prefab
Assets/Prefabs/hextile 1.prefab
+17
-2
MainScene.unity
Assets/Scenes/MainScene.unity
+4
-4
GameManager.cs
Assets/Scripts/GameManager.cs
+82
-6
HexTile.cs
Assets/Scripts/HexTile.cs
+6
-5
No files found.
Assets/Prefabs/hextile 1.prefab
View file @
2e0a2048
...
@@ -40,6 +40,7 @@ GameObject:
...
@@ -40,6 +40,7 @@ GameObject:
-
component
:
{
fileID
:
33382563896309128
}
-
component
:
{
fileID
:
33382563896309128
}
-
component
:
{
fileID
:
23842930406273546
}
-
component
:
{
fileID
:
23842930406273546
}
-
component
:
{
fileID
:
114528188812766900
}
-
component
:
{
fileID
:
114528188812766900
}
-
component
:
{
fileID
:
64357967316059052
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
hextile
1
m_Name
:
hextile
1
m_TagString
:
Untagged
m_TagString
:
Untagged
...
@@ -229,6 +230,20 @@ MeshFilter:
...
@@ -229,6 +230,20 @@ MeshFilter:
m_PrefabInternal
:
{
fileID
:
100100000
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_Mesh
:
{
fileID
:
4300000
,
guid
:
93b23d960c7fd2645bed567627e2e6db
,
type
:
3
}
m_Mesh
:
{
fileID
:
4300000
,
guid
:
93b23d960c7fd2645bed567627e2e6db
,
type
:
3
}
---
!u!64
&64357967316059052
MeshCollider
:
m_ObjectHideFlags
:
1
m_PrefabParentObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
100100000
}
m_GameObject
:
{
fileID
:
1823159130722898
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_Enabled
:
1
serializedVersion
:
3
m_Convex
:
1
m_CookingOptions
:
14
m_SkinWidth
:
0.01
m_Mesh
:
{
fileID
:
4300000
,
guid
:
93b23d960c7fd2645bed567627e2e6db
,
type
:
3
}
---
!u!65
&65133615766084452
---
!u!65
&65133615766084452
BoxCollider
:
BoxCollider
:
m_ObjectHideFlags
:
1
m_ObjectHideFlags
:
1
...
@@ -237,7 +252,7 @@ BoxCollider:
...
@@ -237,7 +252,7 @@ BoxCollider:
m_GameObject
:
{
fileID
:
1864306018844118
}
m_GameObject
:
{
fileID
:
1864306018844118
}
m_Material
:
{
fileID
:
0
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_IsTrigger
:
0
m_Enabled
:
1
m_Enabled
:
0
serializedVersion
:
2
serializedVersion
:
2
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
@@ -249,7 +264,7 @@ BoxCollider:
...
@@ -249,7 +264,7 @@ BoxCollider:
m_GameObject
:
{
fileID
:
1187391223902348
}
m_GameObject
:
{
fileID
:
1187391223902348
}
m_Material
:
{
fileID
:
0
}
m_Material
:
{
fileID
:
0
}
m_IsTrigger
:
0
m_IsTrigger
:
0
m_Enabled
:
1
m_Enabled
:
0
serializedVersion
:
2
serializedVersion
:
2
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Size
:
{
x
:
1
,
y
:
1
,
z
:
1
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_Center
:
{
x
:
0
,
y
:
0
,
z
:
0
}
...
...
Assets/Scenes/MainScene.unity
View file @
2e0a2048
...
@@ -11875,7 +11875,7 @@ RectTransform:
...
@@ -11875,7 +11875,7 @@ RectTransform:
m_AnchorMin
:
{
x
:
0.5
,
y
:
0
}
m_AnchorMin
:
{
x
:
0.5
,
y
:
0
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0
}
m_AnchorMax
:
{
x
:
0.5
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
250
,
y
:
9
0
}
m_Pivot
:
{
x
:
0.5
,
y
:
0
}
m_Pivot
:
{
x
:
0.5
,
y
:
0
}
---
!u!114
&863695363
---
!u!114
&863695363
MonoBehaviour
:
MonoBehaviour
:
...
@@ -14492,7 +14492,7 @@ RectTransform:
...
@@ -14492,7 +14492,7 @@ RectTransform:
m_RootOrder
:
0
m_RootOrder
:
0
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_LocalEulerAnglesHint
:
{
x
:
0
,
y
:
0
,
z
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMin
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
0
,
y
:
0
}
m_AnchorMax
:
{
x
:
1
,
y
:
1
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_AnchoredPosition
:
{
x
:
0
,
y
:
0
}
m_SizeDelta
:
{
x
:
20
,
y
:
20
}
m_SizeDelta
:
{
x
:
20
,
y
:
20
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
m_Pivot
:
{
x
:
0.5
,
y
:
0.5
}
...
@@ -20689,7 +20689,7 @@ GameObject:
...
@@ -20689,7 +20689,7 @@ GameObject:
m_Icon
:
{
fileID
:
0
}
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
m_IsActive
:
0
---
!u!224
&1558743810
---
!u!224
&1558743810
RectTransform
:
RectTransform
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
@@ -24158,7 +24158,7 @@ GameObject:
...
@@ -24158,7 +24158,7 @@ GameObject:
m_Icon
:
{
fileID
:
0
}
m_Icon
:
{
fileID
:
0
}
m_NavMeshLayer
:
0
m_NavMeshLayer
:
0
m_StaticEditorFlags
:
0
m_StaticEditorFlags
:
0
m_IsActive
:
1
m_IsActive
:
0
---
!u!224
&1831636215
---
!u!224
&1831636215
RectTransform
:
RectTransform
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
...
Assets/Scripts/GameManager.cs
View file @
2e0a2048
using
System.Collections
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
UnityEngine
;
using
UnityEngine
;
using
UnityEngine.EventSystems
;
using
CivModel
;
using
CivModel
;
using
CivModel.Common
;
using
CivModel.Common
;
...
@@ -18,8 +21,12 @@ public class GameManager : MonoBehaviour {
...
@@ -18,8 +21,12 @@ public class GameManager : MonoBehaviour {
// Current game
// Current game
private
CivModel
.
Game
_game
;
private
CivModel
.
Game
_game
;
// Selected unit
// Selected actor
private
CivModel
.
Unit
_currentUnit
;
private
CivModel
.
Unit
_selectedActor
=
null
;
public
bool
IsThereTodos
;
private
CivModel
.
Unit
[]
_standbyUnits
;
private
int
_standbyUnitIndex
;
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.
...
@@ -54,6 +61,20 @@ public class GameManager : MonoBehaviour {
...
@@ -54,6 +61,20 @@ public class GameManager : MonoBehaviour {
void
Update
()
{
void
Update
()
{
Render
(
_game
.
Terrain
);
Render
(
_game
.
Terrain
);
if
(
Input
.
GetMouseButtonDown
(
0
)
&&
!
EventSystem
.
current
.
IsPointerOverGameObject
())
{
Ray
ray
=
Camera
.
main
.
ScreenPointToRay
(
Input
.
mousePosition
);
RaycastHit
hit
;
if
(
Physics
.
Raycast
(
ray
,
out
hit
))
{
Unit
unit
=
hit
.
collider
.
gameObject
.
GetComponent
<
HexTile
>().
point
.
Unit
;
if
(
unit
!=
null
)
{
SelectUnit
(
unit
);
}
}
}
// Camera movement
// Camera movement
Vector3
mousePos
=
Input
.
mousePosition
;
Vector3
mousePos
=
Input
.
mousePosition
;
if
(
mousePos
.
x
<
10
)
if
(
mousePos
.
x
<
10
)
...
@@ -72,11 +93,10 @@ public class GameManager : MonoBehaviour {
...
@@ -72,11 +93,10 @@ public class GameManager : MonoBehaviour {
{
{
CameraMove
(
CameraMoveDirection
.
Up
);
CameraMove
(
CameraMoveDirection
.
Up
);
}
}
Debug
.
Log
(
"width, height: "
+
Screen
.
width
+
", "
+
Screen
.
height
);
Debug
.
Log
(
Input
.
mousePosition
);
}
}
void
DrawMap
()
// Instantiate hex tiles
// Instantiate hex tiles
void
DrawMap
()
{
{
_cells
=
new
GameObject
[
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
];
_cells
=
new
GameObject
[
GameInfo
.
mapWidth
,
GameInfo
.
mapHeight
];
...
@@ -91,6 +111,7 @@ public class GameManager : MonoBehaviour {
...
@@ -91,6 +111,7 @@ public class GameManager : MonoBehaviour {
}
}
_cells
[
i
,
j
]
=
Instantiate
(
cellPrefab
,
pos
,
Quaternion
.
identity
);
_cells
[
i
,
j
]
=
Instantiate
(
cellPrefab
,
pos
,
Quaternion
.
identity
);
_cells
[
i
,
j
].
name
=
Pos2Str
(
i
,
j
);
_cells
[
i
,
j
].
name
=
Pos2Str
(
i
,
j
);
_cells
[
i
,
j
].
GetComponent
<
HexTile
>().
point
=
_game
.
Terrain
.
GetPoint
(
i
,
j
);
}
}
}
}
}
}
...
@@ -111,7 +132,61 @@ public class GameManager : MonoBehaviour {
...
@@ -111,7 +132,61 @@ public class GameManager : MonoBehaviour {
}
}
}
}
// Make unit array and iterate while all units consume all AP
// From Presenter.cs
void
SelectNextUnit
()
{
int
tryNumber
=
(
_standbyUnitIndex
==
-
1
)
?
1
:
2
;
for
(
int
j
=
0
;
j
<
tryNumber
;
++
j
)
{
if
(
_standbyUnitIndex
==
-
1
)
{
_standbyUnits
=
_game
.
PlayerInTurn
.
Units
.
ToArray
();
}
int
idx
=
_standbyUnitIndex
+
1
;
for
(;
idx
<
_standbyUnits
.
Length
;
++
idx
)
{
var
unit
=
_standbyUnits
[
idx
];
if
(
unit
.
RemainAP
>
0
&&
!
unit
.
SkipFlag
&&
unit
.
PlacedPoint
.
HasValue
)
{
_standbyUnitIndex
=
idx
;
_selectedActor
=
_standbyUnits
[
idx
];
IsThereTodos
=
true
;
Focus
();
return
;
}
}
_selectedActor
=
null
;
_standbyUnitIndex
=
-
1
;
IsThereTodos
=
false
;
}
}
void
SelectUnit
(
Unit
unit
)
{
Debug
.
Log
(
unit
.
ToString
()
+
" selected"
);
var
units
=
_game
.
PlayerInTurn
.
Units
.
ToArray
();
int
idx
=
Array
.
IndexOf
(
units
,
unit
);
if
(
idx
==
-
1
)
return
;
_selectedActor
=
unit
;
unit
.
SkipFlag
=
false
;
_standbyUnits
=
units
;
_standbyUnitIndex
=
idx
;
IsThereTodos
=
true
;
Focus
();
}
// Camera focus
// Camera focus
void
Focus
()
{
Focus
(
_selectedActor
);
}
void
Focus
(
CivModel
.
Unit
unit
)
void
Focus
(
CivModel
.
Unit
unit
)
{
{
if
(
unit
==
null
)
if
(
unit
==
null
)
...
@@ -140,6 +215,7 @@ public class GameManager : MonoBehaviour {
...
@@ -140,6 +215,7 @@ public class GameManager : MonoBehaviour {
return
"("
+
x
+
","
+
y
+
")"
;
return
"("
+
x
+
","
+
y
+
")"
;
}
}
// Camera move
void
CameraMove
(
CameraMoveDirection
moveDirection
)
void
CameraMove
(
CameraMoveDirection
moveDirection
)
{
{
switch
(
moveDirection
)
switch
(
moveDirection
)
...
...
Assets/Scripts/HexTile.cs
View file @
2e0a2048
...
@@ -5,10 +5,11 @@ using CivModel;
...
@@ -5,10 +5,11 @@ using CivModel;
using
CivModel.Common
;
using
CivModel.Common
;
public
class
HexTile
:
MonoBehaviour
{
public
class
HexTile
:
MonoBehaviour
{
public
CivModel
.
Terrain
.
Point
point
;
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
}
}
// Update is called once per frame
// Update is called once per frame
...
@@ -16,14 +17,14 @@ public class HexTile : MonoBehaviour {
...
@@ -16,14 +17,14 @@ public class HexTile : MonoBehaviour {
}
}
// This method should be changed when
// This method should be changed when
unit type increses
public
void
DrawUnit
(
CivModel
.
Unit
unit
)
public
void
DrawUnit
(
CivModel
.
Unit
unit
)
{
{
if
(
unit
==
null
)
if
(
unit
==
null
)
{
{
foreach
(
Transform
child
in
transform
)
foreach
(
Transform
child
in
transform
)
{
{
child
.
gameObject
.
GetComponent
<
Mesh
Renderer
>().
enabled
=
false
;
child
.
gameObject
.
GetComponent
<
Renderer
>().
enabled
=
false
;
}
}
}
}
else
else
...
@@ -32,11 +33,11 @@ public class HexTile : MonoBehaviour {
...
@@ -32,11 +33,11 @@ public class HexTile : MonoBehaviour {
{
{
if
(
child
.
gameObject
.
name
==
"Pioneer"
)
if
(
child
.
gameObject
.
name
==
"Pioneer"
)
{
{
child
.
gameObject
.
GetComponent
<
Mesh
Renderer
>().
enabled
=
true
;
child
.
gameObject
.
GetComponent
<
Renderer
>().
enabled
=
true
;
}
}
else
else
{
{
child
.
gameObject
.
GetComponent
<
Mesh
Renderer
>().
enabled
=
false
;
child
.
gameObject
.
GetComponent
<
Renderer
>().
enabled
=
false
;
}
}
}
}
}
}
...
...
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