Commit 2ba10c31 authored by 18강현모's avatar 18강현모

생명석에 AddNewRow 메소드 추가, 일부 컨벤션 안 지킨 노테이션 수정, 생명석 프리팹 이름을 생명석L프리팹으로 수정,...

생명석에 AddNewRow 메소드 추가, 일부 컨벤션 안 지킨 노테이션 수정, 생명석 프리팹 이름을 생명석L프리팹으로 수정, ***TestUI 씬 업로드(씬 업로드 가능한지 테스트)***
parent 98830534
...@@ -1341,11 +1341,13 @@ MonoBehaviour: ...@@ -1341,11 +1341,13 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3a9b430bb1c39ea4e9820b5c6510da1f, type: 3} m_Script: {fileID: 11500000, guid: 3a9b430bb1c39ea4e9820b5c6510da1f, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
cellSprites: [] cellSprites:
- {fileID: 21300004, guid: 137b0e8d2160bab45893f33e02df312a, type: 3}
- {fileID: 21300000, guid: 137b0e8d2160bab45893f33e02df312a, type: 3}
- {fileID: 21300002, guid: 137b0e8d2160bab45893f33e02df312a, type: 3}
cellObj: {fileID: 1322655041097828, guid: a413c94742056eb42a0fb2896e81d287, type: 2} cellObj: {fileID: 1322655041097828, guid: a413c94742056eb42a0fb2896e81d287, type: 2}
rowObj: {fileID: 1211859245884242, guid: 64e119a3b05f7e643a2873db8c703f88, type: 2} rowObj: {fileID: 1211859245884242, guid: 64e119a3b05f7e643a2873db8c703f88, type: 2}
isDead: 0 isDead: 0
textUI: {fileID: 0}
--- !u!114 &114934012017033118 --- !u!114 &114934012017033118
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 1 m_ObjectHideFlags: 1
......
This diff is collapsed.
fileFormatVersion: 2
guid: bf635dd77ac1012428fad326c391af96
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
using Random = UnityEngine.Random;
/// <summary> /// <summary>
/// Healthbar manager /// Healthbar manager
...@@ -51,10 +53,6 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -51,10 +53,6 @@ public class LifeCrystalUI : MonoBehaviour
/// LifeCrystal enabled if isDead == false /// LifeCrystal enabled if isDead == false
/// </summary> /// </summary>
public bool isDead; public bool isDead;
/// <summary>
/// Text output, for debugging purpose
/// </summary>
public Text textUI;
////////////////////////////////////////////////// Protected variables ////////////////////////////////////////////////// Protected variables
private int lifeCount, goldCount, height; private int lifeCount, goldCount, height;
/// <summary> /// <summary>
...@@ -98,7 +96,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -98,7 +96,7 @@ public class LifeCrystalUI : MonoBehaviour
{ {
if (cell[x][y] == CellType.Gold) if (cell[x][y] == CellType.Gold)
goldCount--; goldCount--;
updateCell(x, y, CellType.Empty); UpdateCell(x, y, CellType.Empty);
dmg--; dmg--;
lifeCount--; lifeCount--;
} }
...@@ -145,7 +143,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -145,7 +143,7 @@ public class LifeCrystalUI : MonoBehaviour
if (cell[x][y] == CellType.Life) if (cell[x][y] == CellType.Life)
{ {
if (mixer[redLifeIndex] == 1) if (mixer[redLifeIndex] == 1)
updateCell(x, y, CellType.Gold); UpdateCell(x, y, CellType.Gold);
redLifeIndex++; redLifeIndex++;
} }
} }
...@@ -173,7 +171,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -173,7 +171,7 @@ public class LifeCrystalUI : MonoBehaviour
{ {
if (isDead) return false; if (isDead) return false;
Vector2Int dropxy = dropSimulation(frag.grid); Vector2Int dropxy = DropSimulation(frag.grid);
if (dropxy.y == 0) return false; if (dropxy.y == 0) return false;
StartCoroutine(DropBlock(frag, dropxy)); StartCoroutine(DropBlock(frag, dropxy));
...@@ -196,11 +194,42 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -196,11 +194,42 @@ public class LifeCrystalUI : MonoBehaviour
for (int x = 2; x >= 0; x--) for (int x = 2; x >= 0; x--)
if (cell[x][y] == CellType.Gold && gold > 0) if (cell[x][y] == CellType.Gold && gold > 0)
{ {
updateCell(x, y, CellType.Life); UpdateCell(x, y, CellType.Life);
gold--; gold--;
} }
return true; return true;
} }
/// <summary>
/// Adds a new row to LifeCrystalUI
/// </summary>
public void AddNewRow()
{
if (height >= 33) return;
GameObject newRow = Instantiate(rowObj, pivotPosition + gridSize * new Vector3(0, height, 0), Quaternion.Euler(Vector3.zero), transform.Find("Frame"));
newRow.name = "Row" + height;
CellType[][] temp = new CellType[3][] { new CellType[height + 1], new CellType[height + 1], new CellType[height + 1] };
Image[][] temp2 = new Image[3][] { new Image[height + 1], new Image[height + 1], new Image[height + 1] };
for (int i = 0; i < 3; i++)
{
Array.Copy(cell[i], temp[i], height + 1);
Array.Copy(cellImg[i], temp2[i], height + 1);
}
cell = temp; cellImg = temp2;
cell[0][height] = cell[1][height] = cell[2][height] = CellType.Empty;
GameObject[] newCells = new GameObject[3];
for (int i = 0; i < 3; i++)
{
newCells[i] = Instantiate(cellObj, pivotPosition + gridSize * new Vector3(i - 1, height, 0),
Quaternion.Euler(Vector3.zero), transform.Find("Cells"));
newCells[i].name = "LC" + (1 + 3 * height + i).ToString("00");
cellImg[i][height] = newCells[i].GetComponent<Image>();
UpdateCell(i, height, 0);
}
height++;
}
////////////////////////////////////////////////// Basic functions ////////////////////////////////////////////////// Basic functions
/// <summary> /// <summary>
/// Initialization /// Initialization
...@@ -237,7 +266,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -237,7 +266,7 @@ public class LifeCrystalUI : MonoBehaviour
/// <param name="x">X position of the cell to update: 0~2 (0 on the left)</param> /// <param name="x">X position of the cell to update: 0~2 (0 on the left)</param>
/// <param name="y">Y position of the cell to update: 0~(height-1) (0 on the bottom)</param> /// <param name="y">Y position of the cell to update: 0~(height-1) (0 on the bottom)</param>
/// <param name="value"></param> /// <param name="value"></param>
void updateCell(int x, int y, CellType value) void UpdateCell(int x, int y, CellType value)
{ {
cell[x][y] = value; cell[x][y] = value;
cellImg[x][y].sprite = cellSprites[(int)value]; cellImg[x][y].sprite = cellSprites[(int)value];
...@@ -259,7 +288,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -259,7 +288,7 @@ public class LifeCrystalUI : MonoBehaviour
/// <para/> X: 0~2 (0 on the bottom) /// <para/> X: 0~2 (0 on the bottom)
/// <para/> Y: 0~(height-1) (0 on the left)</param> /// <para/> Y: 0~(height-1) (0 on the left)</param>
/// <returns>Vector2(drop position(0~2), drop depth(0~height))</returns> /// <returns>Vector2(drop position(0~2), drop depth(0~height))</returns>
Vector2Int dropSimulation(CellType[][] grid) Vector2Int DropSimulation(CellType[][] grid)
{ {
int bWidth = grid.Length; int bWidth = grid.Length;
int bHeight = grid[0].Length; int bHeight = grid[0].Length;
...@@ -333,7 +362,7 @@ public class LifeCrystalUI : MonoBehaviour ...@@ -333,7 +362,7 @@ public class LifeCrystalUI : MonoBehaviour
{ {
if (frag.grid[x][y] != CellType.Empty) if (frag.grid[x][y] != CellType.Empty)
{ {
updateCell(dropxy.x + x, height - dropxy.y + y, frag.grid[x][y]); UpdateCell(dropxy.x + x, height - dropxy.y + y, frag.grid[x][y]);
droppingCells.Add(new Vector2Int(dropxy.x + x, height - dropxy.y + y)); droppingCells.Add(new Vector2Int(dropxy.x + x, height - dropxy.y + y));
lifeCount++; lifeCount++;
} }
......
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