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
61a58c6a
Commit
61a58c6a
authored
Feb 17, 2018
by
16도재형
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Camera zoom works (This and previous commits are about
#7
)
parent
a370fe31
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
35 deletions
+33
-35
MainScene.unity
Assets/Scenes/MainScene.unity
+2
-1
GameManager.cs
Assets/Scripts/GameManager.cs
+31
-34
No files found.
Assets/Scenes/MainScene.unity
View file @
61a58c6a
...
@@ -14236,7 +14236,8 @@ MonoBehaviour:
...
@@ -14236,7 +14236,8 @@ MonoBehaviour:
m_Name
:
m_Name
:
m_EditorClassIdentifier
:
m_EditorClassIdentifier
:
mainCamera
:
{
fileID
:
1006940699
}
mainCamera
:
{
fileID
:
1006940699
}
cameraMoveSpeed
:
3
cameraMoveSpeed
:
4
cameraZoomSpeed
:
6
outerRadius
:
1
outerRadius
:
1
innerRadius
:
0
innerRadius
:
0
cellPrefab
:
{
fileID
:
1823159130722898
,
guid
:
ef12b8f6d512e104b979d4a75f3e60c0
,
type
:
2
}
cellPrefab
:
{
fileID
:
1823159130722898
,
guid
:
ef12b8f6d512e104b979d4a75f3e60c0
,
type
:
2
}
...
...
Assets/Scripts/GameManager.cs
View file @
61a58c6a
...
@@ -14,17 +14,19 @@ public class GameManager : MonoBehaviour {
...
@@ -14,17 +14,19 @@ public class GameManager : MonoBehaviour {
// Main Camera for Focus()
// Main Camera for Focus()
[
SerializeField
]
[
SerializeField
]
Camera
mainCamera
;
Camera
mainCamera
;
//
Camera move speed
//
For camera controll
[
SerializeField
]
[
SerializeField
]
float
cameraMoveSpeed
;
float
cameraMoveSpeed
;
enum
CameraMoveDirection
{
Up
,
Down
,
Left
,
Right
}
[
SerializeField
]
float
cameraZoomSpeed
;
// For drawing hex tile
// For drawing hex tile
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.
// Hex tile cells
// Hex tile cells
public
GameObject
cellPrefab
;
[
SerializeField
]
GameObject
cellPrefab
;
private
GameObject
[,]
_cells
;
private
GameObject
[,]
_cells
;
// Current game
// Current game
...
@@ -104,25 +106,38 @@ public class GameManager : MonoBehaviour {
...
@@ -104,25 +106,38 @@ public class GameManager : MonoBehaviour {
}
}
}
}
}
}
// Camera movement
// Camera movement
Vector3
mousePos
=
Input
.
mousePosition
;
Vector3
mousePos
=
Input
.
mousePosition
;
if
(
mousePos
.
x
<
10
)
if
(
mousePos
.
x
<
10
)
{
{
CameraMove
(
CameraMoveDirection
.
L
eft
);
CameraMove
(
Vector3
.
l
eft
);
}
}
else
if
(
mousePos
.
x
>
Screen
.
width
-
10
)
else
if
(
mousePos
.
x
>
Screen
.
width
-
10
)
{
{
CameraMove
(
CameraMoveDirection
.
R
ight
);
CameraMove
(
Vector3
.
r
ight
);
}
}
if
(
mousePos
.
y
<
10
)
if
(
mousePos
.
y
<
10
)
{
{
CameraMove
(
CameraMoveDirection
.
Down
);
CameraMove
(
Vector3
.
back
);
}
}
else
if
(
mousePos
.
y
>
Screen
.
height
-
10
)
else
if
(
mousePos
.
y
>
Screen
.
height
-
10
)
{
{
CameraMove
(
CameraMoveDirection
.
Up
);
CameraMove
(
Vector3
.
forward
);
}
}
}
CameraZoom
();
}
// Method that gives "(x,y)" string with input of CivModel.Position or 2 ints
public
string
Pos2Str
(
CivModel
.
Position
pos
)
{
return
Pos2Str
(
pos
.
X
,
pos
.
Y
);
}
public
string
Pos2Str
(
int
x
,
int
y
)
{
return
"("
+
x
+
","
+
y
+
")"
;
}
// Instantiate hex tiles
// Instantiate hex tiles
void
DrawMap
()
void
DrawMap
()
...
@@ -237,35 +252,17 @@ public class GameManager : MonoBehaviour {
...
@@ -237,35 +252,17 @@ public class GameManager : MonoBehaviour {
mainCamera
.
transform
.
position
=
new
Vector3
(
x
,
6.75f
,
z
);
mainCamera
.
transform
.
position
=
new
Vector3
(
x
,
6.75f
,
z
);
}
}
//
Method that gives "(x,y)" string with input of CivModel.Position or 2 int
s
//
Camera controlling
s
public
string
Pos2Str
(
CivModel
.
Position
pos
)
void
CameraMove
(
Vector3
vec
)
{
{
return
Pos2Str
(
pos
.
X
,
pos
.
Y
);
mainCamera
.
transform
.
Translate
(
vec
*
cameraMoveSpeed
*
Time
.
deltaTime
,
Space
.
World
);
}
}
public
string
Pos2Str
(
int
x
,
int
y
)
void
CameraZoom
(
)
{
{
return
"("
+
x
+
","
+
y
+
")"
;
Vector2
vec2
=
Input
.
mouseScrollDelta
;
}
Vector3
vec3
=
new
Vector3
(
vec2
.
x
,
0
,
vec2
.
y
);
mainCamera
.
transform
.
Translate
(
vec3
*
cameraZoomSpeed
*
Time
.
deltaTime
,
Space
.
Self
);
// Camera move
}
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
;
}
}
// For state change of pseudo-FSM
// For state change of pseudo-FSM
// There are enter, exit methods for move and attack states. Enter methods are public, exit methods are default.
// There are enter, exit methods for move and attack states. Enter methods are public, exit methods are default.
...
...
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