void Shuffle(List <BMObj> list) { for (int i = 0; i < list.Count; i++) { int j = Random.Range(0, list.Count); BMObj tmp = list[i]; list[i] = list[j]; list[j] = tmp; } }
bool IsObstruct(BMObj bo) { switch (bo) { case BMObj.HardBlock: case BMObj.SoftBlock: return(true); default: return(false); } }
bool IsEmpty(BMObj obj) { switch (obj) { case BMObj.HardBlock: case BMObj.SoftBlock: case BMObj.Bomb: return(false); default: return(true); } }
void InitBObjects() { int maxRow = stage.GetComponent <StageController>().GetHeight(); int maxCol = stage.GetComponent <StageController>().GetWidth(); int count = 0; for (int i = 0; i < maxRow; i++) { List <BMObj> tmpLine = new List <BMObj>(); for (int j = 0; j < maxCol; j++) { BMObj tmpCol = BMObj.Empty; // top, bottom, right, left wall if (i == 0 || i == (maxRow - 1) || j == 0 || j == (maxCol - 1)) { tmpCol = BMObj.HardBlock; } // HardBlock else if ((i % 2 == 0) && (j % 2 == 0)) { tmpCol = BMObj.HardBlock; } // Player else if (i == 1 && j == 1) { //tmpCol = BMObj.Player; tmpCol = BMObj.Empty; } // Player right side, bottom side else if ((i == 1 && j == 2) || (i == 2 && j == 1)) { tmpCol = BMObj.Empty; } else { count++; if (queObj.Count > 0) { tmpCol = queObj.Dequeue(); } } tmpLine.Add(tmpCol); } map.Add(tmpLine); } }
void LoadMapText() { TextAsset textAsset = new TextAsset(); textAsset = Resources.Load("testmap", typeof(TextAsset)) as TextAsset; string text = textAsset.text; string[] lines = text.Split('\n'); for (int i = 0; i < lines.Length; i++) { for (int j = 0; j < lines[i].Length; j++) { if (false) { continue; } // ダミーコード else if (i == 0) { continue; } // 1行目 else if (i == (GetStageHeight() - 1)) { continue; } // 最終行 else if (j == 0) { continue; } // 1列目 else if (j == (GetStageWidth() - 1)) { continue; } // 最終列 else if (i == 1 && j == 1) { continue; } // 1マス目(プレイヤー初期位置) else if (i == 1 && j == 2) { continue; } // プレイヤーの右隣 else if (i == 2 && j == 1) { continue; } // プレイヤーの真下 else if ((i % 2) == 0 && (j % 2) == 0) { continue; } // 柱 else { BMObj obj = BMObj.Empty; Addr addr = new Addr(j, i); switch (lines[i][j]) { case '*': obj = BMObj.SoftBlock; break; case 'A': Debug.Log("Ballom"); GameObject Ballom = Instantiate(BallomPrefab, Addr2Pos(addr), Quaternion.identity); Ballom.transform.parent = GameObject.Find("Ballom").transform; break; case 'B': Debug.Log("Onil"); GameObject Onil = Instantiate(OnilPrefab, Addr2Pos(addr), Quaternion.identity); Onil.transform.parent = GameObject.Find("Onil").transform; break; case 'C': Debug.Log("Daru"); break; case 'D': Debug.Log("Minbo"); break; case 'E': Debug.Log("Chondria"); break; case 'F': Debug.Log("Obapi"); break; case 'G': Debug.Log("Pass"); break; case 'H': Debug.Log("Pontan"); break; default: obj = BMObj.Empty; break; } queObj.Enqueue(obj); } } } //Debug.Log("queobj.count=" + queObj.Count); }
public void SetObj(Vector3 pos, BMObj bmObj) { map[6 - (int)Mathf.Round(pos.z)][15 + (int)Mathf.Round(pos.x)] = bmObj; }
IEnumerator Explosion() { //GetComponent<AudioSource>().PlayOneShot(ExplosionSE); controller.PlayExplosionSE(); explosion = true; GameObject Fire; Fire = Instantiate(FirePrefab); Fire.transform.position = transform.position; int explode = player.GetPlayerStatus(PowerUpItem.Fire); bool[] stop = { false, false, false, false }; for (int j = 0; j < explode; j++) { for (int i = 0; i < 4; i++) { if (stop[i]) { continue; } Vector3 power = new Vector3(dx[i] * (j + 1), 0, dz[i] * (j + 1)); Vector3 pos = transform.position + power; if (pos.x + 15 < 0 || pos.x > 30 || 6 - pos.z < 0 || 6 - pos.z > 12) { continue; } BMObj tmp = controller.GetObj(pos); switch (tmp) { case BMObj.HardBlock: stop[i] = true; break; default: if (tmp == BMObj.SoftBlock) { stop[i] = true; } Fire = Instantiate(FirePrefab); //Fire.transform.position = new Vector3(transform.position.x + dx[i], transform.position.y, transform.position.z + dz[i]); Fire.GetComponent <FireController>().SetPower(power); Fire.transform.position = transform.position; break; } } } controller.SetObj(transform.position, BMObj.Empty); Destroy(gameObject); yield return(null); }