/// <summary>
        /// Create the board of the tic tac toe game
        /// </summary>
        /// <param name="gd"></param>
        /// <returns></returns>
        private Texture2D CreateBoard(GraphicsDevice gd)
        {
            RenderTarget2D background = new RenderTarget2D(gd, Game1.w_width, Game1.w_height);

            RenderTargetBinding[] last = gd.GetRenderTargets();
            gd.SetRenderTarget(background);
            SpriteBatch tmp = new SpriteBatch(gd);

            tmp.Begin();

            //Draw background:
            tmp.Draw(ShapeCreator.Rect(gd, Color.White, Game1.w_width, Game1.w_height), Vector2.Zero, Color.White);

            //Draw Collumns:
            float deltaX = Game1.w_width / ColNum;

            for (float i = deltaX; i < Game1.w_width; i += deltaX)
            {
                tmp.Draw(ShapeCreator.Rect(gd, Color.Black, 1, Game1.w_height), new Vector2(i, 0), Color.White);
            }

            //Draw rows:
            float deltaY = Game1.w_height / RowNum;

            for (float i = deltaY; i < Game1.w_height; i += deltaY)
            {
                tmp.Draw(ShapeCreator.Rect(gd, Color.Black, Game1.w_width, 1), new Vector2(0, i), Color.White);
            }

            tmp.End();
            gd.SetRenderTargets(last);
            return(background);
        }
Esempio n. 2
0
    private GraphNode()
    {
        this.neighbours = new List <string>();
        GameObject thePlayer = GameObject.Find("shapeCreator");

        shapeCreator = thePlayer.GetComponent <ShapeCreator>();
    }
Esempio n. 3
0
        public void AssertionFailedDialogShouldPopUpAndShapeMustBeNull()
        {
            ICreator creator = new ShapeCreator();
            IShape   shape   = creator.CreateShape(GeometryShape.NONE, 0, 0, 0, 0);

            Assert.IsTrue(shape is null);
        }
        /// <summary>
        /// Start the tic tac toe game.
        /// </summary>
        /// <param name="args">Game parameters: Number of collumns, number of rows, how many in a row is needed to win</param>
        public override void Start(GraphicsDevice gd, int[] args)
        {
            opponent   = null;
            RowNum     = args[0];
            ColNum     = args[1];
            ToWin      = args[2];
            FeatureNum = ColNum * RowNum * 3; // Every tile has three features - isplayer1? isplayer2? isnoplayer?
            ActionNum  = RowNum * ColNum;
            StateNum   = (int)Math.Pow(3, RowNum * ColNum);
            float deltaX = Game1.w_width / ColNum;
            float deltaY = Game1.w_height / RowNum;

            // Create textures for drawing
            Board  = CreateBoard(gd);
            Circle = ShapeCreator.CreateHollowCircle(gd, deltaX, deltaY, 5);
            X      = ShapeCreator.CreateX(gd, deltaX, deltaY);
            Tiles  = new Players[ColNum, RowNum];
            for (int x = 0; x < ColNum; x++)
            {
                for (int y = 0; y < RowNum; y++)
                {
                    Tiles[x, y] = Players.NoPlayer;
                }
            }

            Running  = true;
            CurrTurn = Players.Player1;
        }
Esempio n. 5
0
        public void CreatorGetsAnGeometryShapeEnumSquareAndShouldReturnSquareObject()
        {
            ICreator creator = new ShapeCreator();
            IShape   shape   = creator.CreateShape(GeometryShape.SQUARE, 10, 10, 100, 100);

            Assert.IsTrue(shape is Square);
        }
Esempio n. 6
0
        public void CreatorGetsAnGeometryShapeEnumEllipseAndShouldReturnEllipseObject()
        {
            ICreator creator = new ShapeCreator();
            IShape   shape   = creator.CreateShape(GeometryShape.ELLIPSE, 10, 10, 100, 100);

            Assert.IsTrue(shape is Ellipse);
        }
Esempio n. 7
0
    void Initialize()
    {
        Controller = GameObject.FindGameObjectWithTag("Magic");
        CO         = Controller.GetComponent <ColorizeObjects> ();
        SC         = Controller.GetComponent <ShapeCreator> ();

        rectTrans     = gameObject.GetComponent <RectTransform> ();
        startPosition = rectTrans.localPosition;

        startParent = GameObject.FindGameObjectWithTag("Canvas");
        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);

        if (gameObject.name == "Circle")
        {
            shapeNR = 0;
        }
        else if (gameObject.name == "Triangle")
        {
            shapeNR = 1;
        }
        else
        {
            shapeNR = 2;
        }
    }
Esempio n. 8
0
        /// <summary>
        /// Creates a four in a row board object
        /// </summary>
        /// <param name="gd">Graphics device to use</param>
        /// <param name="background">Color of the board</param>
        /// <param name="width">Board width</param>
        /// <param name="height">Board height</param>
        public Board(GraphicsDevice gd, Color background, int width, int height, int colNum, int rowNum)
        {
            RowNum      = rowNum;
            ColNum      = colNum;
            this.width  = width;
            this.height = height;
            // The length of each tile, on the X and Y axis
            float deltaX = width / ColNum;
            float deltaY = height / RowNum;

            // Calculate the raius of circles on the board, it is set to be 4/10 of the length of the tile (on the shorter axis)
            circleRadius = (int)((4 * MathHelper.Min(deltaX, deltaY)) / 10);

            // Create the board texture manually (not a loaded image to allow various sizes of the window)
            boardTexture = new RenderTarget2D(gd, width, height);
            // Save the current target of the GraphicsDevice (Probably the window screen)
            RenderTargetBinding[] last = gd.GetRenderTargets();
            // Start drawing on the created board texture
            gd.SetRenderTarget(boardTexture);
            SpriteBatch sb = new SpriteBatch(gd);

            sb.Begin();
            // Fill the background with a white color
            sb.Draw(ShapeCreator.Rect(gd, Color.White, width, height), Vector2.Zero, Color.White);
            // Draw the to-be board
            sb.Draw(ShapeCreator.Rect(gd, background, width, height), new Vector2(0, deltaY), Color.White);
            DrawHoles(gd, sb);
            sb.End();
            // Make the white pixels transperent in order to create layering
            ShapeCreator.Transper(boardTexture, Color.White);

            // Return the graphics device to its previous state
            gd.SetRenderTargets(last);
        }
Esempio n. 9
0
        /// <summary>
        /// Create a textbox
        /// </summary>
        /// <param name="maxLength">The max length of text inside it</param>
        public TextBox(GraphicsDevice gd, Rectangle bounds, string initText, Color color, Color TextColor, int id, bool IsVisible, int maxLength) : base(id, IsVisible)
        {
            // Initialize text box variables
            BackgroundColor = color;
            this.TextColor  = TextColor;
            Capital         = false;
            MaxLength       = maxLength;

            Bounds = bounds;
            Text   = initText;

            Texture = new RenderTarget2D(gd, bounds.Width, bounds.Height);
            // Draw the button rectangle
            RenderTargetBinding[] last = gd.GetRenderTargets();
            gd.SetRenderTarget(Texture);
            SpriteBatch sb = new SpriteBatch(gd);

            sb.Begin();
            sb.Draw(ShapeCreator.Rect(gd, color, bounds.Width, bounds.Height), Vector2.Zero, Color.White);
            sb.Draw(ShapeCreator.Rect(gd, Color.White, bounds.Width - 2, bounds.Height - 2), Vector2.One, Color.White);
            // Draw the text
            sb.End();
            gd.SetRenderTargets(last);

            IsAlive = true;
        }
Esempio n. 10
0
    void OnEnable()
    {
        //shapeCreator = target as ShapeCreator;
        GameObject thePlayer = GameObject.Find("shapeCreator");

        this.shapeCreator = thePlayer.GetComponent <ShapeCreator>();
    }
Esempio n. 11
0
    void Start()
    {
        Controller = GameObject.FindGameObjectWithTag("Magic");
        CO         = Controller.GetComponent <ColorizeObjects> ();
        SC         = Controller.GetComponent <ShapeCreator> ();
        grid       = Controller.GetComponent <SnapToGrid> ();

        rectTrans     = gameObject.GetComponent <RectTransform> ();
        startPosition = rectTrans.localPosition;

        // No need for a position shift since .position is used with screen- overlay
//		startParent = GameObject.FindGameObjectWithTag ("Canvas");
//		Rect parentRect = startParent.GetComponent<RectTransform> ().rect;
//
//		shiftPos = new Vector3 (-parentRect.width / 2, -parentRect.height / 2, 0);

        if (gameObject.GetComponent <Shape>().GetType() == typeof(Circle))
        {
            shapeNR = 0;
        }
        else if (gameObject.GetComponent <Shape>().GetType() == typeof(Triangle))
        {
            shapeNR = 1;
        }
        else
        {
            shapeNR = 2;
        }
    }
Esempio n. 12
0
        private void PnlDrawingArea_MouseUp(object sender, MouseEventArgs e)
        {
            if (IsSelecting)
            {
                string shapeName = ShowDialog(Lang.ShapeNameMessage, "");

                if (shapeName != null)
                {
                    UserShapeCreators.Add(new UserShapeCreator(Shapes, FirstPoint, new Point(e.X, e.Y), shapeName));
                    ButtonsUserShapes();
                }
                IsSelecting = false;
                DoDrawing(Shapes);
            }
            if (UserShapeCreator != null)
            {
                UserShape userShape = UserShapeCreator.GetUserShape();
                userShape.CopyToListShapes(Shapes, FirstPoint, new Point(e.X, e.Y));
                DoDrawing(Shapes);
            }

            if (ShapeCreator != null)
            {
                IShape currShape = ShapeCreator.GetShape();
                currShape.Point1 = FirstPoint;
                currShape.Point2 = new Point(e.X, e.Y);
                Shapes.Add(currShape);
                TempShape = null;
                DoDrawing(Shapes);
            }
        }
Esempio n. 13
0
    public MoveNodePoly()
    {
        GameObject go = GameObject.Find("shapeCreator");

        this.shapeCreator = go.GetComponent <ShapeCreator>();
        shapeCreator      = go.GetComponent <ShapeCreator>();
    }
Esempio n. 14
0
 //Начало рисования фигуры
 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);
 }
Esempio n. 15
0
 private void OnEnable()
 {
     needsRepaint            = true;
     shapeCreator            = (ShapeCreator)target;
     selectionInfo           = new SelectionInfo();
     Undo.undoRedoPerformed += onUndo;
     Tools.hidden            = true;
 }
Esempio n. 16
0
 void OnEnable()
 {
     shapeChangedSinceLastRepaint = true;
     shapeCreator            = target as ShapeCreator;
     selectionInfo           = new SelectionInfo();
     Undo.undoRedoPerformed += OnUndoOrRedo;
     Tools.hidden            = true;
 }
Esempio n. 17
0
    public GraphPolygon4()
    {
        vertices = new float[0];
        GameObject thePlayer = GameObject.Find("shapeCreator");

        shapeCreator  = thePlayer.GetComponent <ShapeCreator>();
        pointsOnEdges = new List <string>();
        drawStat      = DrawStat.NORMAL;
    }
Esempio n. 18
0
    void Start()
    {
        GameObject canvas = GameObject.FindGameObjectWithTag("Canvas");

        screenview   = canvas.GetComponent <RectTransform> ().rect;
        shiftPos     = new Vector3(-screenview.width / 2, -screenview.height / 2, 0);
        SC           = gameObject.GetComponent <ShapeCreator> ();
        gridCellSize = gridCellSize / 100 * UIScaler.baseUnit;
    }
Esempio n. 19
0
        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);
        }
Esempio n. 20
0
 /// <summary>
 /// Constructor specifying graph information.
 /// </summary>
 /// <param name="graph">The graph whose edges are being routed.</param>
 /// <param name="padding">The minimum padding from an obstacle's curve to its enclosing polyline.</param>
 /// <param name="cornerFitRadius">The radius of the arc inscribed into path corners</param>
 /// <param name="useSparseVisibilityGraph">If true, use a sparse visibility graph, which saves memory for large graphs
 /// but may select suboptimal paths</param>
 /// <param name="useObstacleRectangles">If true, use obstacle bounding boxes in visibility graph</param>
 public RectilinearEdgeRouter(GeometryGraph graph, double padding, double cornerFitRadius,
                              bool useSparseVisibilityGraph, bool useObstacleRectangles)
     : this(ShapeCreator.GetShapes(graph), padding, cornerFitRadius, useSparseVisibilityGraph, useObstacleRectangles)
 {
     ValidateArg.IsNotNull(graph, "graph");
     foreach (var edge in graph.Edges)
     {
         this.AddEdgeGeometryToRoute(edge.EdgeGeometry);
     }
 }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
    public GraphPointOnEdge(string poly, int parentEdge, float k)
    {
        GameObject thePlayer = GameObject.Find("shapeCreator");

        shapeCreator      = thePlayer.GetComponent <ShapeCreator>();
        this.parentEdge   = parentEdge;
        this.position     = new Vector2();
        this.edgePosition = k;
        this.parentPoly   = poly;
    }
Esempio n. 23
0
    void Start()
    {
        flowMap     = GameObject.FindObjectOfType <FlowMap> ();
        pathCreator = GameObject.FindObjectOfType <ShapeCreator> ();

        if (pathCreator != null)
        {
            path = new Path(pathCreator.points.ToArray(), criticalDstToSeekNextTarget, isCyclic);
        }
    }
        protected static void CreateScene()
        {
            m_SceneManager = mRoot.CreateSceneManager(SceneType.ST_GENERIC);

            m_Camera = m_SceneManager.CreateCamera("myCamera1");
            m_Camera.ProjectionType = ProjectionType.PT_ORTHOGRAPHIC;
            m_Camera.SetPosition(-1, 2000, 0);
            m_Camera.NearClipDistance = 5;
            m_Camera.FarClipDistance  = 2501;
            m_Camera.LookAt(Vector3.ZERO);

            Viewport viewport = mRenderWindow.AddViewport(m_Camera);

            viewport.BackgroundColour = ColourValue.Black;
            m_Camera.AspectRatio      = viewport.ActualWidth / viewport.ActualHeight;


            var context  = ZmqContext.Create();
            var receiver = new MessageReceiver(context);

            receiver.Listen();
            m_Bus = new MessageBus(new MessageSender(context), receiver);

            var creator = new ShapeCreator(m_SceneManager);

            creator.CreateUnitTrianlge();
            creator.CreateStar();

            //m_Object = new GameObject(m_SceneManager);
            //m_Path = new Path(4, new CircularMotion(0, 50, new Angle(0), new Angle(Math.PI / 10), 20, Vector.Zero), m_Bus);
            //m_Circle = path.CreatePathTo(new Vector2(100, -100), new Vector2(0, 10), Vector2.ZERO);
            //m_Circle = new CircularMotion(0, 50, new Angle(0), new Angle(Math.PI/2),2);
            m_Linear = new LinearMotion(0, new Vector(10, 0), Vector.Zero);

            m_SceneManager.AmbientLight = new ColourValue(1, 1, 1);

            mNinjaEntity = m_SceneManager.CreateEntity("Ninja", "triangle");

            mNinjaNode = m_SceneManager.RootSceneNode.CreateChildSceneNode("NinjaNode");
            mNinjaNode.AttachObject(mNinjaEntity);
            mNinjaNode.SetPosition(500, 0, -500);

            m_ClickStar = m_SceneManager.CreateEntity("Star", "star");
            m_ClickNode = m_SceneManager.RootSceneNode.CreateChildSceneNode("ClickNode");
            m_ClickNode.AttachObject(m_ClickStar);

            mLight                = m_SceneManager.CreateLight("pointLight");
            mLight.Type           = Light.LightTypes.LT_POINT;
            mLight.Position       = new Vector3(250, 150, 250);
            mLight.DiffuseColour  = ColourValue.White;
            mLight.SpecularColour = ColourValue.White;
        }
Esempio n. 25
0
//        Строитель(Builder) - шаблон проектирования, который инкапсулирует создание объекта и позволяет разделить его на различные этапы.

//Когда использовать паттерн Строитель?
//Когда процесс создания нового объекта не должен зависеть от того,
//      из каких частей этот объект состоит и как эти части связаны между собой

//Когда необходимо обеспечить получение различных вариаций объекта в процессе его создания

        // pattern Builder;
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ShapeCreator creator = new ShapeCreator();
            ShapeBuilder builder = null;



            Brush br = Brushes.Red;

            switch (((TextBlock)comboBoxColor.SelectedItem).Text)
            {
            case "Red": br = Brushes.Red; break;

            case "Green": br = Brushes.Green; break;

            case "Blue": br = Brushes.Blue; break;
            }

            double X = rand.Next(0, 300);
            double Y = rand.Next(0, 300);


            string f1 = ((TextBlock)comboBoxMain.SelectedItem).Text;
            string f2 = ((TextBlock)comboBoxSecond.SelectedItem).Text;

            if (f1 == "Эллипс" && f2 == "Круг")
            {
                builder = new MainInnerShapeBuilder1();
            }
            else if (f1 == "Эллипс" && f2 == "Треугольник")
            {
                builder = new MainInnerShapeBuilder2();
            }
            else if (f1 == "Прямоугольник" && f2 == "Круг")
            {
                builder = new MainInnerShapeBuilder3();
            }
            else if (f1 == "Прямоугольник" && f2 == "Треугольник")
            {
                builder = new MainInnerShapeBuilder4();
            }

            CompositeShape compositeShape = creator.Create(builder);

            compositeShape.MainShape.sh.Fill     = br; // заливка
            compositeShape.MainShape.sh.Stroke   = br; // обводка
            compositeShape.MainShape.sh.Margin   = new Thickness(X, Y, 0, 0);
            compositeShape.InnerShape.sh2.Margin = new Thickness(X, Y, 0, 0);

            grid3.Children.Add(compositeShape.MainShape.sh);
            grid3.Children.Add(compositeShape.InnerShape.sh2);
        }
Esempio n. 26
0
    void Initialize()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO          = Controller.GetComponent <ColorizeObjects> ();
        SC          = Controller.GetComponent <ShapeCreator> ();
        rectTrans   = gameObject.GetComponent <RectTransform> ();
        startParent = GameObject.FindGameObjectWithTag("Canvas");

        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);
    }
Esempio n. 27
0
 public BaseMeshBuilder(ShapeCreator shapeCreator,
                        Func <float, float, float, T> GetColorAt,
                        Func <int> XSize,
                        Func <int> ZSize,
                        Func <int, int, Vector3> GetCurrentVertexPosition, bool shadeFlat = true)
 {
     this.shapeCreator             = shapeCreator;
     this.XSize                    = XSize;
     this.ZSize                    = ZSize;
     this.GetColorAt               = GetColorAt;
     this.GetCurrentVertexPosition = GetCurrentVertexPosition;
     this.useFlatShading           = shadeFlat;
 }
Esempio n. 28
0
    void Start()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO        = Controller.GetComponent <ColorizeObjects> ();
        SC        = Controller.GetComponent <ShapeCreator> ();
        grid      = Controller.GetComponent <SnapToGrid> ();
        OS        = Controller.GetComponent <ObjectSelector> ();
        rectTrans = gameObject.GetComponent <RectTransform> ();

        // No need for a position shift since .position is used with screen- overlay
        startParent = GameObject.FindGameObjectWithTag("Canvas");
        Rect parentRect = startParent.GetComponent <RectTransform> ().rect;

        shiftPos = new Vector3(-parentRect.width / 2, -parentRect.height / 2, 0);
    }
Esempio n. 29
0
        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();
        }
Esempio n. 30
0
    void Start()
    {
        GameObject Controller = GameObject.FindGameObjectWithTag("Magic");

        CO       = Controller.GetComponent <ColorizeObjects> ();
        SC       = Controller.GetComponent <ShapeCreator> ();
        grid     = Controller.GetComponent <SnapToGrid> ();
        OS       = Controller.GetComponent <ObjectSelector> ();
        material = Background.GetComponent <Shape> ().material;
        width    = Background.GetComponent <RectTransform> ().rect.width;
        height   = Background.GetComponent <RectTransform> ().rect.height;
        Debug.Log(Background.GetComponent <RectTransform> ().rect.width);
        material.SetFloat("_Width", width);
        material.SetFloat("_Height", height);
//		material.SetFloat ("_XPosition", t);
//		material.SetFloat ("_YPosition", t);
    }