//Rockからよう 移動 成功ならtrue失敗ならfalse public bool RockDestroyM(o_Rock rockA, int row) { //Rockの位置検索 for (int listNum = 0; listNum < rocksCol; listNum++) { if (rockA.EqualsRocksPos(list_rocksR[listNum][row])) { if (rockA.Equals(list_rocksR[listNum][row])) { list_rocksR[listNum][row] = null; } else { list_rocksR[listNum][row].CalcMass(); } return(true); } else if (rockA.EqualsRocksPos(list_rocksL[listNum][row])) { if (rockA.Equals(list_rocksL[listNum][row])) { list_rocksL[listNum][row] = null; } else { list_rocksL[listNum][row].CalcMass(); } return(true); } } return(false); }
//Rockからよう 移動 成功ならtrue失敗ならfalse public bool RockMoveM(o_Rock rockA /*, int col*/, int row, o_RockManager.MOVE caseNum) { int[] adr = new int[2] { 0, 0 }; //Rockの位置検索 for (int listNum = 0; listNum < rocksCol; listNum++) { if (rockA.EqualsRocksPos(list_rocksR[listNum][row])) { adr[0] = (int)MOVE.RIGHT; adr[1] = listNum; break; } else if (rockA.EqualsRocksPos(list_rocksL[listNum][row])) { adr[0] = (int)MOVE.LEFT; adr[1] = listNum; break; } } //移動先岩マネージャー o_RockManager moveToRockManager = this; //移動先用アドレス int[] adr2 = { adr[0], adr[1], row }; //移動先調整 switch (caseNum) { case MOVE.UP: adr2[1]--; if (adr2[1] < 0) { adr2[1]++; if (adr[0] == (int)MOVE.RIGHT) { adr2[0] = (int)MOVE.LEFT; } else { adr2[0] = (int)MOVE.RIGHT; } } break; case MOVE.DOWN: adr2[1]++; if (adr2[1] >= rocksCol) { adr2[1]--; if (adr[0] == (int)MOVE.RIGHT) { adr2[0] = (int)MOVE.LEFT; } else { adr2[0] = (int)MOVE.RIGHT; } } break; case MOVE.FRONT: adr2[2]--; if (adr2[2] < 0) { if (moveToRockManager.frontRM == null) { return(false); } moveToRockManager = moveToRockManager.frontRM; adr2[2] = moveToRockManager.rocksRow - 1; } break; case MOVE.BACK: adr2[2]++; if (adr2[2] >= rocksRow) { if (moveToRockManager.backRM == null) { return(false); } moveToRockManager = moveToRockManager.backRM; adr2[2] = 0; } break; default: break; } //Debug.Log("adr2:" + adr2[0] + adr2[1] + adr2[2]); //移動 成功ならtrue失敗ならfalse switch (adr2[0]) { case (int)MOVE.RIGHT: //移動先が空なら突っ込む if (moveToRockManager.list_rocksR[adr2[1]][adr2[2]] == null) { moveToRockManager.list_rocksR[adr2[1]][adr2[2]] = rockA; if (!rockA.GetOffRock()) { if (adr[0] == (int)MOVE.RIGHT) { list_rocksR[adr[1]][row] = null; } else { list_rocksL[adr[1]][row] = null; } } else { if (adr[0] == (int)MOVE.RIGHT) { list_rocksR[adr[1]][row].CalcMass(); } else { list_rocksL[adr[1]][row].CalcMass(); } } } //移動先にあるなら乗せる else if (moveToRockManager.list_rocksR[adr2[1]][adr2[2]].RideRock(rockA)) { if (adr[0] == (int)MOVE.RIGHT) { if (rockA.Equals(list_rocksR[adr[1]][row])) { list_rocksR[adr[1]][row] = null; } else { list_rocksR[adr[1]][row].CalcMass(); } } else { if (rockA.Equals(list_rocksL[adr[1]][row])) { list_rocksL[adr[1]][row] = null; } else { list_rocksL[adr[1]][row].CalcMass(); } } } else { //乗せるのに失敗したらfalse return(false); } // rockA.Move(moveToRockManager, (MOVE)adr2[0], adr2[1], adr2[2], CalcMoveToPosition(adr2[0], adr2[1], adr2[2])); moveToRockManager.list_rocksR[adr2[1]][adr2[2]].CalcMass(); CalcMassRL(); return(true); break; case (int)MOVE.LEFT: if (moveToRockManager.list_rocksL[adr2[1]][adr2[2]] == null) { moveToRockManager.list_rocksL[adr2[1]][adr2[2]] = rockA; if (!rockA.GetOffRock()) { if (adr[0] == (int)MOVE.RIGHT) { list_rocksR[adr[1]][row] = null; } else { list_rocksL[adr[1]][row] = null; } } else { if (adr[0] == (int)MOVE.RIGHT) { list_rocksR[adr[1]][row].CalcMass(); } else { list_rocksL[adr[1]][row].CalcMass(); } } } else if (moveToRockManager.list_rocksL[adr2[1]][adr2[2]].RideRock(rockA)) { if (adr[0] == (int)MOVE.RIGHT) { if (rockA.Equals(list_rocksR[adr[1]][row])) { list_rocksR[adr[1]][row] = null; } else { list_rocksR[adr[1]][row].CalcMass(); } } else { if (rockA.Equals(list_rocksL[adr[1]][row])) { list_rocksL[adr[1]][row] = null; } else { list_rocksL[adr[1]][row].CalcMass(); } } } else { //乗せるのに失敗したらfalse return(false); } rockA.Move(moveToRockManager, (MOVE)adr2[0], adr2[1], adr2[2], CalcMoveToPosition(adr2[0], adr2[1], adr2[2])); moveToRockManager.list_rocksL[adr2[1]][adr2[2]].CalcMass(); CalcMassRL(); return(true); break; } return(false); }