Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
tetra-tower
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Oenos
tetra-tower
Commits
8def52ca
Commit
8def52ca
authored
Nov 19, 2018
by
abpo11
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
망멩미
parent
29bd902f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
6 deletions
+136
-6
PlayScene.unity
Assets/Scenes/PlayScene.unity
+34
-0
CameraController.cs
Assets/Scripts/CameraController.cs
+97
-5
Player.cs
Assets/Scripts/Characters/Player.cs
+5
-1
No files found.
Assets/Scenes/PlayScene.unity
View file @
8def52ca
...
@@ -254,6 +254,8 @@ GameObject:
...
@@ -254,6 +254,8 @@ GameObject:
-
component
:
{
fileID
:
489222435
}
-
component
:
{
fileID
:
489222435
}
-
component
:
{
fileID
:
489222434
}
-
component
:
{
fileID
:
489222434
}
-
component
:
{
fileID
:
489222438
}
-
component
:
{
fileID
:
489222438
}
-
component
:
{
fileID
:
489222440
}
-
component
:
{
fileID
:
489222439
}
m_Layer
:
0
m_Layer
:
0
m_Name
:
Player
m_Name
:
Player
m_TagString
:
Untagged
m_TagString
:
Untagged
...
@@ -385,6 +387,38 @@ BoxCollider2D:
...
@@ -385,6 +387,38 @@ BoxCollider2D:
serializedVersion
:
2
serializedVersion
:
2
m_Size
:
{
x
:
0.7
,
y
:
1.4
}
m_Size
:
{
x
:
0.7
,
y
:
1.4
}
m_EdgeRadius
:
0
m_EdgeRadius
:
0
---
!u!114
&489222439
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
489222433
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
d7635365ab870ce46bd38a4af729df1b
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
LCUI
:
{
fileID
:
0
}
---
!u!114
&489222440
MonoBehaviour
:
m_ObjectHideFlags
:
0
m_CorrespondingSourceObject
:
{
fileID
:
0
}
m_PrefabInternal
:
{
fileID
:
0
}
m_GameObject
:
{
fileID
:
489222433
}
m_Enabled
:
1
m_EditorHideFlags
:
0
m_Script
:
{
fileID
:
11500000
,
guid
:
f289cad4933d4bf42ae5c82c57bd88e4
,
type
:
3
}
m_Name
:
m_EditorClassIdentifier
:
maxSpeed
:
0
speed
:
0
speedAir
:
0
jumpSpeed
:
0
doubleJumpSpeed
:
0
groundLayer
:
serializedVersion
:
2
m_Bits
:
0
rayDistance
:
0
---
!u!1
&519420028
---
!u!1
&519420028
GameObject
:
GameObject
:
m_ObjectHideFlags
:
0
m_ObjectHideFlags
:
0
...
...
Assets/Scripts/CameraController.cs
View file @
8def52ca
...
@@ -3,13 +3,14 @@ using System.Collections.Generic;
...
@@ -3,13 +3,14 @@ using System.Collections.Generic;
using
UnityEngine
;
using
UnityEngine
;
public
class
CameraController
:
MonoBehaviour
{
public
class
CameraController
:
MonoBehaviour
{
public
LayerMask
roomLayer
;
public
GameObject
player
;
/*
/*
* If camera is in Tetris view, ideal position is (108, 240, -1)
* If camera is in Tetris view, ideal position is (108, 240, -1)
* size 300
* size 300
* */
* */
readonly
float
camX
=
9.5f
;
readonly
float
camY
=
4f
;
GameManager
.
GameState
lastGameState
;
GameManager
.
GameState
lastGameState
;
...
@@ -56,9 +57,100 @@ public class CameraController : MonoBehaviour {
...
@@ -56,9 +57,100 @@ public class CameraController : MonoBehaviour {
void
GotoDestination
()
void
GotoDestination
()
{
{
// TODO: Change this.
// TODO: Change this.
Vector3
pos
=
GameObject
.
Find
(
"Player"
).
transform
.
position
;
/*
Vector3 pos = GameObject.Find("Player").transform.position;
pos.z = -1;
pos.z = -1;
transform
.
position
=
pos
;
transform.position = pos;*/
float
posx
=
player
.
transform
.
position
.
x
;
float
posy
=
player
.
transform
.
position
.
y
;
if
(
RoomCol
(
1
)
!=
-
1
)
{
posy
=
RoomCol
(
1
)
-
camY
;
}
if
(
RoomCol
(
2
)
!=
-
1
)
{
posy
=
RoomCol
(
2
)
+
camY
;
}
if
(
RoomCol
(
3
)
!=
-
1
)
{
posx
=
RoomCol
(
3
)
+
camX
;
}
if
(
RoomCol
(
4
)
!=
-
1
)
{
posx
=
RoomCol
(
4
)
-
camX
;
}
if
(
RoomCol
(
3
)
!=
-
1
&&
RoomCol
(
4
)
!=
-
1
)
{
float
middle
=
Player
.
tx
*
24f
+
12f
;
if
(
middle
-
RoomCol
(
3
)
>
20f
)
{
posx
=
RoomCol
(
3
)
+
camX
;
}
else
if
(
RoomCol
(
4
)
-
middle
>
20f
)
{
posx
=
RoomCol
(
4
)
-
camX
;
}
else
{
posx
=
player
.
transform
.
position
.
x
;
}
//방의 중심과 비교하여 어느게 더 가까운가
}
if
(
Camera
.
main
!=
null
)
{
Camera
.
main
.
transform
.
position
=
Vector3
.
Lerp
(
Camera
.
main
.
transform
.
position
,
new
Vector3
(
posx
,
posy
,
0
),
2f
*
Time
.
deltaTime
);
Camera
.
main
.
transform
.
position
=
new
Vector3
(
Camera
.
main
.
transform
.
position
.
x
,
Camera
.
main
.
transform
.
position
.
y
,
-
10
);
//카메라를 원래 z축으로 이동
}
// Camera.main.transform.position = new Vector3(posx, posy, -10);
}
float
RoomCol
(
int
dir
)
{
//1:up
//2:down
//3:left
//4:right
if
(!(
dir
>=
0
&&
dir
<=
4
))
return
-
1
;
float
distance
=
0f
;
Vector2
direction
=
Vector2
.
up
;
Vector2
position
=
new
Vector2
(
player
.
transform
.
position
.
x
,
player
.
transform
.
position
.
y
);
if
(
dir
==
1
)
{
direction
=
Vector2
.
up
;
distance
=
camY
;
}
if
(
dir
==
2
)
{
direction
=
Vector2
.
down
;
distance
=
camY
;
}
if
(
dir
==
3
)
{
direction
=
Vector2
.
left
;
distance
=
camX
;
}
if
(
dir
==
4
)
{
direction
=
Vector2
.
right
;
distance
=
camX
;
}
RaycastHit2D
hit1
=
Physics2D
.
Raycast
(
position
,
direction
,
distance
,
roomLayer
);
//Debug.DrawRay(position, direction,Color.yellow);
if
(
hit1
.
collider
!=
null
)
{
if
(
dir
==
1
||
dir
==
2
)
return
hit1
.
point
.
y
;
else
return
hit1
.
point
.
x
;
}
return
-
1
;
}
}
...
...
Assets/Scripts/Characters/Player.cs
View file @
8def52ca
...
@@ -4,6 +4,9 @@ using UnityEngine;
...
@@ -4,6 +4,9 @@ using UnityEngine;
public
class
Player
:
MonoBehaviour
{
public
class
Player
:
MonoBehaviour
{
public
LifeCrystalUI
LCUI
;
public
LifeCrystalUI
LCUI
;
public
static
int
tx
,
ty
;
public
int
ttx
;
// Use this for initialization
// Use this for initialization
void
Start
()
{
void
Start
()
{
...
@@ -11,6 +14,7 @@ public class Player : MonoBehaviour {
...
@@ -11,6 +14,7 @@ public class Player : MonoBehaviour {
// Update is called once per frame
// Update is called once per frame
void
Update
()
{
void
Update
()
{
tx
=
(
int
)(
transform
.
position
.
x
/
24f
);
ttx
=
tx
;
}
}
}
}
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