public void CreateShapes() { int currentLevel = gameController.GetDifficultyLevel(); // Сколько всего фигур генеритсяя на текущем уровне int currentLevelShapeCount = props.GetCurrentLevelShapesCount(currentLevel); int currentShapeTypesByLevel = props.GetCurrentLevelShapeTypesCount(currentLevel); if (currentShapeTypesByLevel == 2) { int firstTypeCount = Random.Range(props.minShapeCount, currentLevelShapeCount - 1); int secondTypeCount = currentLevelShapeCount - firstTypeCount; for (int i = 0; i < firstTypeCount; i++) { GameObject shape = shapeCreator.CreateShape(spherePrefab); shape.transform.position = CreateRandomPosition(); shapes.Add(shape); } for (int i = 0; i < secondTypeCount; i++) { GameObject shape = shapeCreator.CreateShape(cubePrefab); shape.transform.position = CreateRandomPosition(); shapes.Add(shape); } } if (currentShapeTypesByLevel == 3) { int firstTypeCount = Random.Range(props.minShapeCount, currentLevelShapeCount - 3); int secondTypeCount = Random.Range(props.minShapeCount, currentLevelShapeCount - firstTypeCount); int thirdTypeCount = Random.Range(props.minShapeCount, currentLevelShapeCount - secondTypeCount); Debug.LogError(firstTypeCount); Debug.LogError(secondTypeCount); Debug.LogError(thirdTypeCount); for (int i = 0; i < firstTypeCount; i++) { GameObject shape = shapeCreator.CreateShape(spherePrefab); shape.transform.position = CreateRandomPosition(); shapes.Add(shape); } for (int i = 0; i < secondTypeCount; i++) { GameObject shape = shapeCreator.CreateShape(cubePrefab); shape.transform.position = CreateRandomPosition(); shapes.Add(shape); } for (int i = 0; i < thirdTypeCount; i++) { GameObject shape = shapeCreator.CreateShape(cylinderPrefab); shape.transform.position = CreateRandomPosition(); shapes.Add(shape); } } }
public void AssertionFailedDialogShouldPopUpAndShapeMustBeNull() { ICreator creator = new ShapeCreator(); IShape shape = creator.CreateShape(GeometryShape.NONE, 0, 0, 0, 0); Assert.IsTrue(shape is null); }
public void CreatorGetsAnGeometryShapeEnumEllipseAndShouldReturnEllipseObject() { ICreator creator = new ShapeCreator(); IShape shape = creator.CreateShape(GeometryShape.ELLIPSE, 10, 10, 100, 100); Assert.IsTrue(shape is Ellipse); }
public void CreatorGetsAnGeometryShapeEnumSquareAndShouldReturnSquareObject() { ICreator creator = new ShapeCreator(); IShape shape = creator.CreateShape(GeometryShape.SQUARE, 10, 10, 100, 100); Assert.IsTrue(shape is Square); }
//Начало рисования фигуры private void canvas1_MouseDown(object sender, MouseEventArgs e) { shape = ShapeCreator.CreateShape(currentShape); shape.Pen = new Pen(this.btnStrokeColor.BackColor, float.Parse(cmbThickness.Text)); shape.Brush = cbIsTransparent.Checked ? new SolidBrush(Color.Transparent) : new SolidBrush(btnFillColor.BackColor); shape.StartDraw(e.Location, this.canvas1); }
public void CreateSquareX70Y100Width150Height70WithSquareCreatorFactoryMethod() { ICreator shapeCreator = new ShapeCreator(); IShape square = shapeCreator.CreateShape(GeometryShape.SQUARE, 70, 100, 150, 70); Assert.AreEqual(70, ((Square)square).rectangle.X); Assert.AreEqual(30, ((Square)square).rectangle.Y); Assert.AreEqual(150, ((Square)square).rectangle.Width); Assert.AreEqual(70, ((Square)square).rectangle.Height); }
public void CreateEllipseX100Y40Width10Height50WithSquareCreatorFactoryMethod() { ICreator shapeCreator = new ShapeCreator(); IShape ellipse = shapeCreator.CreateShape(GeometryShape.ELLIPSE, 100, 40, 10, 50); Assert.AreEqual(100, ((Ellipse)ellipse).rectangle.X); Assert.AreEqual(40, ((Ellipse)ellipse).rectangle.Y); Assert.AreEqual(10, ((Ellipse)ellipse).rectangle.Width); Assert.AreEqual(50, ((Ellipse)ellipse).rectangle.Height); }
void spawnShape(float x, float y) { if (spawnErasers) { int ID = SC.CreateEraser(shapeNR, x, y); string name = "shape" + ID; } else { int ID = SC.CreateShape(shapeNR, x, y); string name = "shape" + ID; CO.ColorizeShape(name); } }
private void Canvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { try { canvas = sender as Canvas; if (_currentAddShapeType != null && canvas != null) { // get the point where you clicked on the canvas var position = e.GetPosition(canvas); // create and add shape var shape = _shapeCreator.CreateShape(_currentAddShapeType.Value, position); _shapes.Add(shape); } } catch (Exception ex) { MessageBox.Show(ex.Message, "An error has occured", MessageBoxButton.OK, MessageBoxImage.Error); } }
static void Main(string[] args) { List <IShape> entities = new List <IShape>(); IFactoryShape shapeCreator = new ShapeCreator(); entities.Add(shapeCreator.CreateShape(EShape.POINT)); entities.Add(shapeCreator.CreateShape(EShape.LINE)); entities.Add(shapeCreator.CreateShape(EShape.CIRCLE)); entities.Add(shapeCreator.CreateShape(EShape.ARC)); entities.Add(shapeCreator.CreateShape(EShape.ELLIPSE)); entities.Add(shapeCreator.CreateShape(EShape.NURB)); Console.WriteLine("Factory Method."); Console.ReadKey(); }