/// <summary> /// VirtualBoardコンストラクタ /// </summary> /// <param name="gtArray_1">1Pのゴースト初期配置</param> /// <param name="gtArray_2">2Pのゴースト初期配置</param> public GameState(GhostAttribute[,] gtArray_1, GhostAttribute[,] gtArray_2, int finalTurn) { FinalTurn = finalTurn; //1Pは下側 for (int i = 0; i < gtArray_1.GetLength(0); i++) { for (int j = 0; j < gtArray_1.GetLength(1); j++) { //初期位置に配置 if (gtArray_1[i, j] == GhostAttribute.good) { //M_Board[i + 5, j + 1] = Square.P1Good; P1ghostList.Add(new Ghost(GhostAttribute.good, new Position(i + 5, j + 1))); } else if (gtArray_1[i, j] == GhostAttribute.evil) { //M_Board[i + 5, j + 1] = Square.P1Evil; P1ghostList.Add(new Ghost(GhostAttribute.evil, new Position(i + 5, j + 1))); } else { //M_Board[i + 5, j + 1] = Square.Blank; } } } //2Pは上側なので反転して代入 for (int i = 0; i < gtArray_2.GetLength(0); i++) { for (int j = 0; j < gtArray_2.GetLength(1); j++) { if (gtArray_2[i, j] == GhostAttribute.good) { //M_Board[2 - i, 4 - j] = Square.P2Good; P2ghostList.Add(new Ghost(GhostAttribute.good, new Position(2 - i, 4 - j))); } else if (gtArray_2[i, j] == GhostAttribute.evil) { //M_Board[2 - i, 4 - j] = Square.P2Evil; P2ghostList.Add(new Ghost(GhostAttribute.evil, new Position(2 - i, 4 - j))); } else { //M_Board[2 - i, 4 - j] = Square.Blank; } } } ResetGhostPostion(); SetGhostPostionInVirtual(); SetBoardState(); ResetGhostPositionInBoard(); SetGhostPositionInBoard(); }
public Boolean IsGhostAtExit(FieldObject o) { //Ghostlistを検索し出口にいないかチェック if (o.Equals(FieldObject.P1)) { foreach (Ghost g in P1ghostList) { if (g.P.Row == 0 && g.P.Col == 0 || g.P.Row == 0 && g.P.Col == 5) { P1ghostList.Remove(g); if (g.Gt.Equals((GhostAttribute.good))) { return(true); } else { break; } } } } else if (o.Equals(FieldObject.P2)) { foreach (Ghost g in P2ghostList) { if (g.P.Row == 7 && g.P.Col == 0 || g.P.Row == 7 && g.P.Col == 5) { P2ghostList.Remove(g); if (g.Gt.Equals((GhostAttribute.good))) { return(true); } else { break; } } } } return(false); }