// 消されたドロップの種類ごとのカウント public void ElementCheck(PuzzleDrop.DROP_TYPE type) { totalCount++; switch (type) { case PuzzleDrop.DROP_TYPE.RED: RedCount = true; //RedCount++; break; case PuzzleDrop.DROP_TYPE.BLUE: BlueCount = true; //BlueCount++; break; case PuzzleDrop.DROP_TYPE.GREEN: GreenCount = true; //GreenCount++; break; case PuzzleDrop.DROP_TYPE.PURPLE: PurpleCount = true; break; case PuzzleDrop.DROP_TYPE.YELLOW: YellowCount = true; break; //case PuzzleDrop.DROP_TYPE.CURE: //CureCount++; //break; } }
public void AnimationSet(PuzzleDrop.DROP_TYPE type) { switch (type) { case PuzzleDrop.DROP_TYPE.BLUE: animation.namePrefix = "BlueDestroy"; break; case PuzzleDrop.DROP_TYPE.GREEN: animation.namePrefix = "GreenDestroy"; break; case PuzzleDrop.DROP_TYPE.PURPLE: animation.namePrefix = "PurpleDestroy"; break; case PuzzleDrop.DROP_TYPE.RED: animation.namePrefix = "RedDestroy"; break; case PuzzleDrop.DROP_TYPE.YELLOW: animation.namePrefix = "YellowDestroy"; break; } }
// 4個以上つながっているドロップを削除する true:つながりがある private bool DropDestroyCheck() { bool destroyTrigger = false; // チェックしたかどうかのトリガー //bool[] checkTrigger = new bool[mainPanelWidth * mainPanelHeight]; // 左下からメインパネルのドロップが4つ以上つながっていないかチェックする for (int y = 0; y < mainPanelHeight; y++) { for (int x = 0; x < mainPanelWidth; x++) { // ドロップがなければスキップ if (mainPanel[y * mainPanelWidth + x] == null) { continue; } // すでにチェックされていればスキップする //if(checkTrigger[y * mainPanelWidth + x]) { continue; } foreach (Vector2 vec2 in checkTriggerPos) { if (vec2 == new Vector2(x, y)) { continue; } } // チェックトリガーをオンにする //checkTrigger[y * mainPanelWidth + x] = true; // 現在選択されている色を取得する PuzzleDrop.DROP_TYPE currentType = mainPanel[y * mainPanelWidth + x].GetComponent <PuzzleDrop>().dropType; // 同じ色のdropを取得して数が4個以上なら削除する if (4 <= GetMainNodeColorCount(currentType, new Vector2(x, y))) { foreach (Vector2 vec2 in destroyTargetArrayPos) { //Destroy(mainPanel[(int)vec2.y * mainPanelWidth + (int)vec2.x].gameObject); //mainPanel[(int)vec2.y * mainPanelWidth + (int)vec2.x].Destroy(); mainPanel[(int)vec2.y * mainPanelWidth + (int)vec2.x].DropDestroy(); mainPanel[(int)vec2.y * mainPanelWidth + (int)vec2.x] = null; } destroyTrigger = true; } // カウントをリセットする destroyTargetArrayPos.Clear(); } } checkTriggerPos.Clear(); return(destroyTrigger); }
public bool SpriteChenge() { int y = 5; int width = 8; for (int x = 0; x < 8; x++) { if (gameManager.subPanel[y * width + x] == null) { sprites[x].spriteName = ""; continue; } PuzzleDrop.DROP_TYPE currentType = gameManager.subPanel[y * width + x].dropType; string spriteName = ""; switch (currentType) { case PuzzleDrop.DROP_TYPE.BLUE: spriteName = "blueSDrop"; break; case PuzzleDrop.DROP_TYPE.GREEN: spriteName = "greenSDrop"; break; case PuzzleDrop.DROP_TYPE.PURPLE: spriteName = "purpleSDrop"; break; case PuzzleDrop.DROP_TYPE.RED: spriteName = "redSDrop"; break; case PuzzleDrop.DROP_TYPE.YELLOW: spriteName = "yellowSDrop"; break; } // スプライトの画像を更新する sprites[x].spriteName = spriteName; } return(true); }
private bool StartSubPanelComboCheck() { bool destroyTrigger = false; // 左下からメインパネルのドロップが4つ以上つながっていないかチェックする for (int y = 0; y < subPanelHeight; y++) { for (int x = 0; x < subPanelWidth; x++) { // ドロップがなければスキップ if (subPanel[y * subPanelWidth + x] == null) { continue; } // すでにチェックされていればスキップする foreach (Vector2 vec2 in checkTriggerPos) { if (vec2 == new Vector2(x, y)) { continue; } } // 現在選択されている色を取得する PuzzleDrop.DROP_TYPE currentType = subPanel[y * subPanelWidth + x].GetComponent <PuzzleDrop>().dropType; // 同じ色のdropを取得して数が4個以上なら削除する if (4 <= GetSubNodeColorCount(currentType, new Vector2(x, y))) { destroyTrigger = true; } // カウントをリセットする destroyTargetArrayPos.Clear(); } } checkTriggerPos.Clear(); return(destroyTrigger); }
// subPanelの同じ色のdropを取得する private int GetSubNodeColorCount(PuzzleDrop.DROP_TYPE type, Vector2 arrayPos) { foreach (Vector2 vec2 in checkTriggerPos) { if (vec2 == arrayPos) { return(0); } } checkTriggerPos.Add(arrayPos); if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x] == null) { return(0); } int count = 0; // 自身の色が目的の色と同じならカウントを増加させる PuzzleDrop drop = subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x]; if (drop.dropType == type) { destroyTargetArrayPos.Add(arrayPos); count++; } else { return(0); } // 下方向をチェック if (!((int)arrayPos.y + 1 >= subPanelHeight)) { if (subPanel[((int)arrayPos.y + 1) * subPanelWidth + (int)arrayPos.x] != null) { if (subPanel[((int)arrayPos.y + 1) * subPanelWidth + (int)arrayPos.x].dropType == type) { count += GetSubNodeColorCount(type, new Vector2(arrayPos.x, arrayPos.y + 1)); } } } // 上方向をチェック if (!((int)arrayPos.y - 1 <= -1)) { if (subPanel[((int)arrayPos.y - 1) * subPanelWidth + (int)arrayPos.x] != null) { if (subPanel[((int)arrayPos.y - 1) * subPanelWidth + (int)arrayPos.x].dropType == type) { count += GetSubNodeColorCount(type, new Vector2(arrayPos.x, arrayPos.y - 1)); } } } // 左方向をチェック if (!((int)arrayPos.x - 1 <= -1)) { if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x - 1] != null) { if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x - 1].dropType == type) { count += GetSubNodeColorCount(type, new Vector2(arrayPos.x - 1, arrayPos.y)); } } } // 右方向をチェック if (!((int)arrayPos.x + 1 >= subPanelWidth)) { if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x + 1] != null) { if (subPanel[(int)arrayPos.y * subPanelWidth + (int)arrayPos.x + 1].dropType == type) { count += GetSubNodeColorCount(type, new Vector2(arrayPos.x + 1, arrayPos.y)); } } } return(count); }