Commit 21d77371 authored by 18손재민's avatar 18손재민

프레스 만들고 있음 현재 프레스 압축은 잘 작동함 이제 프레스 펼쳐지고 떨어지는거 만들면 된다

parent 7a20aadd
...@@ -45,10 +45,6 @@ public class MapManager : MonoBehaviour { ...@@ -45,10 +45,6 @@ public class MapManager : MonoBehaviour {
/// The time taken for a press to be collapsed. /// The time taken for a press to be collapsed.
/// </summary> /// </summary>
public float collapseTime; public float collapseTime;
/// <summary>
/// Time press has started to collapsed.
/// </summary>
private float initialCollapseTime;
public static int height = 24, width = 10, realHeight = height - 5; public static int height = 24, width = 10, realHeight = height - 5;
...@@ -83,7 +79,7 @@ public class MapManager : MonoBehaviour { ...@@ -83,7 +79,7 @@ public class MapManager : MonoBehaviour {
/// <summary> /// <summary>
/// Presses one row. /// Presses one row.
/// </summary> /// </summary>
public GameObject tetrisPress; public Press press;
/// <summary> /// <summary>
/// Current tetrimino waiting for falling. /// Current tetrimino waiting for falling.
/// </summary> /// </summary>
...@@ -188,12 +184,13 @@ public class MapManager : MonoBehaviour { ...@@ -188,12 +184,13 @@ public class MapManager : MonoBehaviour {
if (IsRowFull(y) && !isRowDeleting[y]) if (IsRowFull(y) && !isRowDeleting[y])
{ {
isRowDeleting[y] = true; isRowDeleting[y] = true;
initialCollapseTime = Time.time; Press leftPress = Instantiate(press, new Vector3(0, y * 24, 0), Quaternion.identity);
GameObject leftPress = Instantiate(tetrisPress, new Vector3(0, y * 24, 0), Quaternion.identity); Press rightPress = Instantiate(press, new Vector3(240, y * 24, 0), Quaternion.identity);
leftPress.GetComponent<Press>().isLeft = true; leftPress.initialCollapseTime = Time.time;
GameObject rightPress = Instantiate(tetrisPress, new Vector3(240, y * 24, 0), Quaternion.identity); leftPress.row = y;
rightPress.GetComponent<Press>().isLeft = false; rightPress.initialCollapseTime = Time.time;
StartCoroutine(TetrisPress(y, leftPress, rightPress)); rightPress.row = y;
StartCoroutine(TetrisPress(leftPress.initialCollapseTime, leftPress, rightPress));
/*for (int x = 0; x < width; x++) /*for (int x = 0; x < width; x++)
{ {
Destroy(mapGrid[x, y].gameObject); Destroy(mapGrid[x, y].gameObject);
...@@ -203,7 +200,7 @@ public class MapManager : MonoBehaviour { ...@@ -203,7 +200,7 @@ public class MapManager : MonoBehaviour {
} }
} }
} }
public IEnumerator TetrisPress(int row, GameObject leftPress, GameObject rightPress) public IEnumerator TetrisPress(float initialCollapseTime, Press leftPress, Press rightPress)
{ {
while (Time.time - initialCollapseTime < collapseTime) while (Time.time - initialCollapseTime < collapseTime)
{ {
...@@ -212,6 +209,13 @@ public class MapManager : MonoBehaviour { ...@@ -212,6 +209,13 @@ public class MapManager : MonoBehaviour {
leftPress.transform.localScale = new Vector3(collapseRate * 20, 1, 1); leftPress.transform.localScale = new Vector3(collapseRate * 20, 1, 1);
rightPress.transform.localScale = new Vector3(-collapseRate * 20, 1, 1); rightPress.transform.localScale = new Vector3(-collapseRate * 20, 1, 1);
} }
while (leftPress.transform.localScale.x > 1)
{
yield return new WaitForSeconds(0.01f);
leftPress.transform.localScale -= new Vector3(5, 0, 0);
rightPress.transform.localScale -= new Vector3(-5, 0, 0);
}
int row = leftPress.GetComponent<Press>().row;
for (int x = 0; x < width; x++) for (int x = 0; x < width; x++)
{ {
Destroy(mapGrid[x, row].gameObject); Destroy(mapGrid[x, row].gameObject);
...@@ -219,8 +223,8 @@ public class MapManager : MonoBehaviour { ...@@ -219,8 +223,8 @@ public class MapManager : MonoBehaviour {
} }
isRowDeleting[row] = false; isRowDeleting[row] = false;
DecreaseRowsAbove(row); DecreaseRowsAbove(row);
Destroy(leftPress); Destroy(leftPress.gameObject);
Destroy(rightPress); Destroy(rightPress.gameObject);
} }
/// <summary> /// <summary>
/// Decrease all rows above this row. /// Decrease all rows above this row.
...@@ -242,6 +246,15 @@ public class MapManager : MonoBehaviour { ...@@ -242,6 +246,15 @@ public class MapManager : MonoBehaviour {
} }
} }
Press[] presses = FindObjectsOfType<Press>();
foreach(Press child in presses)
{
if (child.row > row)
{
child.row -= 1;
child.transform.position += new Vector3(0, -24, 0);
}
}
} }
/// <summary> /// <summary>
/// Check row if it is full. /// Check row if it is full.
...@@ -421,6 +434,8 @@ public class MapManager : MonoBehaviour { ...@@ -421,6 +434,8 @@ public class MapManager : MonoBehaviour {
fallSpeed += gravity * fallTime * fallTime; fallSpeed += gravity * fallTime * fallTime;
te.transform.position += new Vector3(0, -fallSpeed, 0); te.transform.position += new Vector3(0, -fallSpeed, 0);
} }
GameObject camera = GameObject.Find("Tetris Camera");
StartCoroutine(Shake(10, camera.transform.position, camera));
EndTetrimino(currentTetrimino); EndTetrimino(currentTetrimino);
} }
/// <summary> /// <summary>
...@@ -508,6 +523,23 @@ public class MapManager : MonoBehaviour { ...@@ -508,6 +523,23 @@ public class MapManager : MonoBehaviour {
{ {
}*/ }*/
public IEnumerator Shake(float _amount, Vector3 originPos, GameObject camera)
{
float amount = _amount;
while (amount > 0)
{
//transform.localPosition = (Vector3)Random.insideUnitCircle * amount + originPos;
camera.transform.localPosition = new Vector3(0.2f * Random.insideUnitCircle.x * amount + originPos.x, Random.insideUnitCircle.y * amount + originPos.y, originPos.z);
//transform.localPosition = new Vector3(Random.insideUnitCircle.x * amount + originPos.x, originPos.y, originPos.z);
//transform.localPosition = new Vector3(originPos.x, Random.insideUnitCircle.y * amount + originPos.y, originPos.z);
amount -= _amount / 25;
//Debug.Log(amount);
yield return null;
}
camera.transform.localPosition = originPos;
}
void Awake () void Awake ()
{ {
......
...@@ -7,11 +7,14 @@ public class Press : MonoBehaviour ...@@ -7,11 +7,14 @@ public class Press : MonoBehaviour
/* /*
* variables * variables
* */ * */
/// <summary> /// <summary>
/// If this press is on left side or not. /// Time press has started to collapsed.
/// </summary>
public float initialCollapseTime;
/// <summary>
/// Time press has started to collapsed.
/// </summary> /// </summary>
public bool isLeft; public int row;
// Use this for initialization // Use this for initialization
......
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