Commit d052546b authored by 18강현모's avatar 18강현모

CameraController, GameState 등 코드 넣음. TetrisMap scale 동기화, UI 요소들 Canvas에 담음.

parent f7585de5
......@@ -52,7 +52,7 @@ Transform:
m_GameObject: {fileID: 1690644780631946}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -4.3699484, y: 1.660439, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4653007209432888}
m_Father: {fileID: 0}
......@@ -82,7 +82,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -129,7 +129,7 @@ Transform:
m_GameObject: {fileID: 1986824515730090}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 7.85, y: 2.58, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4959807369913172}
- {fileID: 4417427676875474}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -209,7 +209,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -247,7 +247,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -155,7 +155,7 @@ Transform:
m_GameObject: {fileID: 1058256109692646}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.15, y: -0.97, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4770256559059570}
- {fileID: 4403275080892776}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -209,7 +209,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -226,7 +226,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -142,7 +142,7 @@ Transform:
m_GameObject: {fileID: 1409840693504816}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 2.77, y: 3.1, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4480540641426352}
- {fileID: 4890462092246654}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -209,7 +209,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -226,7 +226,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -103,7 +103,7 @@ Transform:
m_GameObject: {fileID: 1599875259397162}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5.6, y: -0.21, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4959495535370206}
- {fileID: 4534782373203126}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -230,7 +230,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -247,7 +247,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -142,7 +142,7 @@ Transform:
m_GameObject: {fileID: 1051411815441030}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10.24, y: 0.14, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4996993573163862}
- {fileID: 4153319652066896}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -209,7 +209,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -247,7 +247,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -142,7 +142,7 @@ Transform:
m_GameObject: {fileID: 1216064749225226}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 14.87, y: 0.76, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4373465258801912}
- {fileID: 4268777523006110}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -192,7 +192,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -209,7 +209,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -226,7 +226,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
......@@ -116,7 +116,7 @@ Transform:
m_GameObject: {fileID: 1597348377621660}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 11.8, y: 3.97, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalScale: {x: 24, y: 24, z: 1}
m_Children:
- {fileID: 4665049468911534}
- {fileID: 4244611340582260}
......@@ -175,7 +175,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -213,7 +213,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -230,7 +230,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......@@ -247,7 +247,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f935789f55ec07f4ca6b334fba78ddb1, type: 3}
m_Name:
m_EditorClassIdentifier:
mapLocation: {x: 0, y: 0, z: 0}
mapCoord: {x: 0, y: 0, z: 0}
doorInfo:
stage: 0
roomConcept: 0
......
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour {
GameManager.GameState lastGameState;
Vector3 destination;
// Use this for initialization
void Start()
{
lastGameState = GameManager.GameState.Ingame;
destination = transform.position;
}
// Update is called once per frame
void Update()
{
if (lastGameState != GameManager.gameState)
{
StartCoroutine("ChangeScene");
lastGameState = GameManager.gameState;
}
else if (lastGameState == GameManager.GameState.Ingame)
{
SetDestination();
}
GotoDestination();
}
IEnumerator ChangeScene()
{
yield return null;
}
void SetDestination()
{
}
void GotoDestination()
{
}
}
fileFormatVersion: 2
guid: 6ef4279cf32e10f4dbc71e2206514212
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour {
public LifeCrystalUI LCUI;
// Use this for initialization
void Start () {
......
......@@ -7,10 +7,15 @@ public class PlayerController : MonoBehaviour {
// Speeds of player
[SerializeField]
private float maxSpeed;
[SerializeField]
private float speed;
[SerializeField]
private float speedAir;
[SerializeField]
private float jumpSpeed;
[SerializeField]
private float doubleJumpSpeed;
// Bool values for jump & doublejump
......@@ -19,6 +24,7 @@ public class PlayerController : MonoBehaviour {
// Inputs
private float horizontal = 0;
private float horizontalRaw = 0;
private bool jump = false;
// Variables for IsGrounded()
......@@ -35,6 +41,8 @@ public class PlayerController : MonoBehaviour {
// Update is called once per frame
void Update () {
horizontal = Input.GetAxis("Horizontal");
horizontalRaw = Input.GetAxisRaw("Horizontal");
if (Input.GetButtonDown("Jump"))
{
jump = true;
......@@ -60,10 +68,21 @@ public class PlayerController : MonoBehaviour {
isJumpable = false;
}
}
rb.velocity = new Vector2(horizontal * speed * Time.fixedDeltaTime, vertical);
jump = false;
//rb.velocity = new Vector2(horizontal * speed * Time.fixedDeltaTime, vertical);
// rb.velocity = new Vector2(rb.velocity.x, vertical);
rb.AddForce(horizontalRaw * speed * Time.fixedDeltaTime * Vector2.right);
if (((horizontalRaw==0) || (rb.velocity.x > 0 && horizontalRaw < 0)
|| (rb.velocity.x < 0 && horizontalRaw > 0)) &&(isGrounded))
{
rb.AddForce(rb.velocity.x * (-10f) * Vector2.right);
}
rb.velocity = new Vector2(Mathf.Clamp(rb.velocity.x, -maxSpeed*Time.fixedDeltaTime, maxSpeed * Time.fixedDeltaTime), vertical);
jump = false;
}
bool IsGrounded() // Is player grounded?
{
RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance, groundLayer);
......
......@@ -4,9 +4,17 @@ using UnityEngine;
public class GameManager : MonoBehaviour {
public enum GameState { MainMenu, Ingame, Tetris, Pause, Inventory }
/// <summary>
/// Which state this game is.
/// change later
/// </summary>
public static GameState gameState;
// Use this for initialization
void Start () {
gameState = GameState.Ingame;
}
// Update is called once per frame
......
......@@ -7,11 +7,7 @@ public class MapManager : MonoBehaviour {
/*
* variables
* */
/// <summary>
/// If camera is at tetris map, it is true.
/// If camera is at player, it is false.
/// </summary>
public bool inTetris;
/// <summary>
/// Tetris map's size.
/// </summary>
......@@ -206,14 +202,14 @@ public class MapManager : MonoBehaviour {
}*/
public void TetriminoMove(Tetrimino TE)
{
if (Input.GetKeyDown(KeyCode.LeftArrow) && inTetris)
if (Input.GetKeyDown(KeyCode.LeftArrow) && GameManager.gameState == GameManager.GameState.Tetris)
{
TE.mapCoord += new Vector3(-1, 0, 0);
SetRoomMapCoord(currentTetrimino);
if (IsRightTetrimino(TE) != 0)
TE.mapCoord += new Vector3(1, 0, 0);
}
else if (Input.GetKeyDown(KeyCode.RightArrow) && inTetris)
else if (Input.GetKeyDown(KeyCode.RightArrow) && GameManager.gameState == GameManager.GameState.Tetris)
{
TE.mapCoord += new Vector3(1, 0, 0);
SetRoomMapCoord(currentTetrimino);
......@@ -244,7 +240,7 @@ public class MapManager : MonoBehaviour {
// Use this for initialization
void Start () {
inTetris = true;
}
// Update is called once per frame
......
......@@ -228,7 +228,7 @@ public class LifeCrystalUI : MonoBehaviour
/// </summary>
void FixedUpdate ()
{
textUI.text = "Life: " + lifeCount + ", Gold: " + goldCount;
//textUI.text = "Life: " + lifeCount + ", Gold: " + goldCount;
}
////////////////////////////////////////////////// Hidden functions
/// <summary>
......
......@@ -31,7 +31,7 @@ TextureImporter:
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
......@@ -63,7 +63,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......@@ -74,7 +74,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......@@ -85,7 +85,7 @@ TextureImporter:
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
textureCompression: 0
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
......
......@@ -90,7 +90,7 @@ InputManager:
descriptiveName:
descriptiveNegativeName:
negativeButton:
positiveButton: space
positiveButton: up
altNegativeButton:
altPositiveButton:
gravity: 1000
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment