public override void generateVaild(System.Random rand , WorldCondition worldCond ) { IdxContent = rand.Next() % 2; if (IdxContent == 0) { elements = new CondExprElement[3]; elements[0].type = CondExprElemntType.WallName; elements[0].meta = rand.Next()%4; elements[2].type = CondExprElemntType.Dir; elements[2].meta = (int)dirMap[rand.Next() % 2]; elements[1].type = CondExprElemntType.WallName; elements[1].meta = (int)worldCond.getRelDirWall( (WallName)elements[0].meta , (CondDir)elements[2].meta ); } else { elements = new CondExprElement[5]; int idx = rand.Next() % 4; CondDir dir = dirMap[rand.Next() % 2]; elements[4].type = CondExprElemntType.Dir; elements[4].meta = (int)dir; for( int i = 0 ; i < 4 ; ++i ) { elements[i].type = CondExprElemntType.WallName; elements[i].meta = (int)worldCond.wall[idx].name; idx = worldCond.getRelDirWallIndex(idx, dir); } } }
public override bool testVaild( WorldCondition worldCond) { if (IdxContent == 0) { return worldCond.checkVaild((WallName)elements[0].meta, (WallName)elements[1].meta, (CondDir)elements[2].meta); } else { CondDir dir = (CondDir)elements[4].meta; int curIdx = worldCond.getWallIndex((WallName)elements[0].meta); for (int i = 1; i < 4; ++i) { int nextIdx = worldCond.getRelDirWallIndex( curIdx , dir ); if (nextIdx != worldCond.getWallIndex((WallName)elements[0].meta)) return false; } return true; } }