public static void Run() { var casaBase = new CityHouse(); DecoratorHouse casaPiso = new PisoDecorator(casaBase); DecoratorHouse casaVentana = new VentanaDecorator(casaPiso); casaVentana.MakeHouse(); }
// Initialise une maison en donnant les paramètre // Les paramètres angle, maxWidth et maxDepth sont calculés en fonction de la route ainsi que du quartier public CityHouse InitCityHouse(List <CityHouse> houses, int maxWidth, int maxDepth, float angle) { int height, width, depth, doorPos; bool leftWall, rightWall; float Angle; if (houses.Count > 0) { CityHouse previousHouse = houses[houses.Count - 1]; // Les maisons seront créée de la gauche vers la droite if (previousHouse.hIntereface.rightWall) { leftWall = false; height = Random.Range(MIN_HEIGHT, previousHouse.hIntereface.height); depth = Random.Range(MIN_DEPTH, previousHouse.hIntereface.depth); } else { height = Random.Range(MIN_HEIGHT, MAX_HEIGHT); depth = Random.Range(MIN_DEPTH, maxDepth); leftWall = (height > previousHouse.hIntereface.height || depth > previousHouse.hIntereface.depth); } } else { height = Random.Range(MIN_HEIGHT, MAX_HEIGHT); depth = Random.Range(MIN_DEPTH, maxDepth); leftWall = true; } rightWall = (Random.value > 0.5f); width = Random.Range(MIN_WIDTH, maxWidth); doorPos = Random.Range(0, width); // La position varie entre 0 et width - 1 (on commence à compter à partir de 0) return(DefCityHouse(height, width, depth, doorPos, leftWall, rightWall, angle)); }