Commit fe5df774 authored by 18류지석's avatar 18류지석

생명석 잘려서 튀어나오는거 직관적으로 바뀜

parent a7668b1f
......@@ -62,6 +62,8 @@ public class LifeStoneManager : Singleton<LifeStoneManager> {
public float popoutStrengthMultiplier;
public float popoutTime;
bool stoneCut;
void Start () {
lifeStoneUI.transform.position = new Vector3(lifeStoneLocation.x, lifeStoneLocation.y, 0);
frameSuper.GetComponent<LifeStoneFrame>().Init(frameSuper.transform, standardImage, lifeStoneRowNum, lifeStoneSize, sprites, frameBorder);
......@@ -318,20 +320,26 @@ public class LifeStoneManager : Singleton<LifeStoneManager> {
for (int pj = 0; pj < pSize.y; pj++)
{
if (selectedRow + pj >= lifeStoneRowNum)
if (cutRow == pSize.y && selectedRow + pj >= lifeStoneRowNum)
{
cutRow = pj;
break;
//break;
}
for (int pi = 0; pi < pSize.x; pi++)
if (pFill[pj * pSize.x + pi] != ' ')
{
int xtmp = selectedCol + pi, ytmp = selectedRow + pj;
GameObject tmpObj;
tmpObj = Instantiate(lifeUnitPrefab, stoneSuper.transform);
if (pj < cutRow)
{
lifeStoneArray[ytmp, xtmp] = pFill[pj * pSize.x + pi] - 'A' + 1;
lifeStoneUnit[ytmp, xtmp] = Instantiate(lifeUnitPrefab, stoneSuper.transform);
lifeStoneUnit[ytmp, xtmp] = tmpObj;
}
lifeStoneUnit[ytmp, xtmp].GetComponent<LifeUnitInFrame>().Init(
lifeStoneArray[ytmp, xtmp],
tmpObj.GetComponent<LifeUnitInFrame>().Init(
pFill[pj * pSize.x + pi] - 'A' + 1,
lifeStoneSize,
new Vector2Int(xtmp, ytmp),
new Vector2Int(xtmp, lifeStoneRowNum + pj),
......@@ -341,8 +349,27 @@ public class LifeStoneManager : Singleton<LifeStoneManager> {
vibration = 0;
}
}
stoneCut = false;
if (cutRow < pSize.y)
{
StartCoroutine(CutCoroutine(cutRow, pSize, pFill));
}
return true;
}
public void StoneCutStart()
{
stoneCut = true;
}
IEnumerator CutCoroutine(int cutRow, Vector2Int pSize, string pFill)
{
while (!stoneCut)
{
yield return null;
}
char[] chFill = pFill.ToCharArray();
for (int i = 0; i < pSize.x; i++)
{
......@@ -357,21 +384,18 @@ public class LifeStoneManager : Singleton<LifeStoneManager> {
Vector2Int vtmp = queue.Dequeue();
newFill[(vtmp.y - cutRow) * pSize.x + vtmp.x] = chFill[vtmp.y * pSize.x + vtmp.x];
chFill[vtmp.y * pSize.x + vtmp.x] = ' ';
if (vtmp.x + 1 < pSize.x && chFill[ vtmp.y * pSize.x + (vtmp.x + 1)] != ' ') queue.Enqueue(new Vector2Int(vtmp.x + 1, vtmp.y ));
if (vtmp.x - 1 >= 0 && chFill[ vtmp.y * pSize.x + (vtmp.x - 1)] != ' ') queue.Enqueue(new Vector2Int(vtmp.x - 1, vtmp.y ));
if (vtmp.y + 1 < pSize.y && chFill[(vtmp.y + 1) * pSize.x + vtmp.x ] != ' ') queue.Enqueue(new Vector2Int(vtmp.x , vtmp.y + 1));
if (vtmp.y - 1 >= cutRow && chFill[(vtmp.y - 1) * pSize.x + vtmp.x ] != ' ') queue.Enqueue(new Vector2Int(vtmp.x , vtmp.y - 1));
if (vtmp.x + 1 < pSize.x && chFill[vtmp.y * pSize.x + (vtmp.x + 1)] != ' ') queue.Enqueue(new Vector2Int(vtmp.x + 1, vtmp.y));
if (vtmp.x - 1 >= 0 && chFill[vtmp.y * pSize.x + (vtmp.x - 1)] != ' ') queue.Enqueue(new Vector2Int(vtmp.x - 1, vtmp.y));
if (vtmp.y + 1 < pSize.y && chFill[(vtmp.y + 1) * pSize.x + vtmp.x] != ' ') queue.Enqueue(new Vector2Int(vtmp.x, vtmp.y + 1));
if (vtmp.y - 1 >= cutRow && chFill[(vtmp.y - 1) * pSize.x + vtmp.x] != ' ') queue.Enqueue(new Vector2Int(vtmp.x, vtmp.y - 1));
}
InstantiateDroppedLifeStone(CreateLifeStoneInfo(
new LifeStoneInfo(new Vector2Int(pSize.x, pSize.y - cutRow), new string(newFill))),
GameObject.Find("Player").transform.position + new Vector3(droppedLifeStonePrefab.GetComponent<DroppedLifeStone>().unitSprite.GetComponent<SpriteRenderer>().bounds.size.x * i,0,0),
GameObject.Find("Player").transform.position + new Vector3(droppedLifeStonePrefab.GetComponent<DroppedLifeStone>().unitSprite.GetComponent<SpriteRenderer>().bounds.size.x * i, 0, 0),
1f);
}
}
}
return true;
}
/// <summary>
/// count lifestoneunit in lifestoneframe by type
......
......@@ -61,11 +61,11 @@ public class LifeUnitInFrame : MonoBehaviour {
float fadeTime = 0.3f;
while (alpha <= 1f)
{
GetComponent<Image>().color = new Color(255, 255, 255, alpha);
GetComponent<Image>().color = new Color(1, 1, 1, alpha);
alpha += 1f / fadeTime * Time.deltaTime;
yield return null;
}
GetComponent<Image>().color = new Color(255, 255, 255, 1f);
GetComponent<Image>().color = new Color(1, 1, 1, 1f);
}
IEnumerator FallEnumerator()
......@@ -84,6 +84,24 @@ public class LifeUnitInFrame : MonoBehaviour {
if (vibration != 0)
StartCoroutine(LifeStoneManager.Instance.VibrateEnumerator(vibration));
if (pos.y >= LifeStoneManager.Instance.lifeStoneRowNum)
StartCoroutine(FadeOutEnumerator());
}
IEnumerator FadeOutEnumerator()
{
float alpha = 1f;
float fadeTime = 0.3f;
while (alpha >= 0f)
{
GetComponent<Image>().color = new Color(1, 1, 1, alpha);
alpha -= 1f / fadeTime * Time.deltaTime;
yield return null;
}
GetComponent<Image>().color = new Color(1, 1, 1, 0f);
LifeStoneManager.Instance.StoneCutStart();
Destroy(gameObject);
}
}
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