/// <summary> /// ピースを新しいものに入れ替える /// </summary> /// <param name="target"></param> /// <param name="id"></param> public void ReplacementPiece(Piece target, int id) { Debug.Log("StartReplace"); //targetが配列中のどの要素なのか検索 for (int i = 0; i < pieceArray.Length; i++) { Debug.Log(pieceArray[i].position + " " + target.position); if (pieceArray[i].position == target.position) { Vector2 position = target.transform.localPosition; pieceArray[i] = StageGenerator.EditPieceID(target, id); Destroy(target.gameObject); //設定 pieceArray[i].noCollision = true; pieceArray[i].transform.SetParent(transform); pieceArray[i].GetComponent <BoxCollider2D>().enabled = false; pieceArray[i].transform.localPosition = position; Debug.Log("replace"); return; } } }
/// <summary> /// 挟まれた場合にidを通常ブロックと同じ4にする /// </summary> void Sandwiched(int id) { switch (id) { case 6: //遅延して実行 StageGenerator.lateExecution += () => { //id = 4; //パーティクル削除 ps.transform.SetParent(null); ParticleManager.ParticleDestroy(ps); //音再生 AudioManager.Play(SEType.Cold, 1); //エフェクト発生 ParticleManager.PlayOneShot( ParticleType.ChangeBlockTemp, transform.position, Quaternion.identity, 2.0f); //判定がない = コンテナの中にいる if (noCollision) { Player.currentPieceContainer.ReplacementPiece(this, 4); } else { StageGenerator.EditPieceID(this, 4); } }; break; default: break; } }