Пример #1
0
    // Instantiates a moving gameobject
    GameObject InstantiateGameObject()
    {
        GameObject gameObj = new GameObject();

        gameObj.AddComponent <GraphicalObject>();
        gameObj.AddComponent <IGB283Transform>();
        gameObj.AddComponent <ColourLerp>();

        GraphicalObject gra = gameObj.GetComponent <GraphicalObject>();

        gra.xSize = Random.Range(minVerts, maxVerts);
        gra.ySize = Random.Range(minVerts, maxVerts);

        IGB283Transform trans  = gameObj.GetComponent <IGB283Transform>();
        Vector3         newPos = new Vector3(Random.Range(-posRange, posRange), Random.Range(-posRange, posRange), 0);

        trans.initialPosition = newPos;
        trans.initialScale    = new Vector3(Random.Range(minSize, maxSize), Random.Range(minSize, maxSize), 1);
        trans.xSpeed          = Random.Range(minMovSpeed, maxMovSpeed);
        trans.rotSpeed        = Random.Range(minRotSpeed, maxRotSpeed);

        ColourLerp col = gameObj.GetComponent <ColourLerp>();

        col.colour00 = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255));
        col.colour01 = new Color32((byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255), (byte)Random.Range(0, 255));

        return(gameObj);
    }
Пример #2
0
        private void DrawMulticoloredPixels(MainViewModel context)
        {
            double sizeX = (DrawCanvas.Width / _numberOfColumns);
            double sizeY = (DrawCanvas.Height / _numberOfRows);

            for (int i = 0; i < context.GraphicalObjects.Count; i++)
            {
                GraphicalObject obj = context.GraphicalObjects[i];
                for (int j = 0; j < obj.ObjectModel.Width; j++)
                {
                    for (int k = 0; k < obj.ObjectModel.Height; k++)
                    {
                        if (obj.ObjectModel[j, k].Value > 0)
                        {
                            Draw(
                                DrawCanvas,
                                (obj.Position.X + j) * sizeX - 1,
                                (obj.Position.Y + k) * sizeY - 1,
                                new LinearGradientBrush(
                                    Color.FromRgb(
                                        (byte)obj.ObjectColor.Red,
                                        (byte)obj.ObjectColor.Green,
                                        (byte)obj.ObjectColor.Blue),
                                    Darken(obj.ObjectColor),
                                    45.0));
                        }
                    }
                }

                DrawLabels(context, sizeX, sizeY);
            }
        }
Пример #3
0
        //Load everything and set position.
        public void LoadContent(ContentManager content)
        {
            cursor = new GraphicalObject("Player", new Vector2(190, 0));

            play = new TextLine("Font", "Play Game", Color.White, new Vector2(240, 200));
            score = new TextLine("Font", "High Scores", Color.White, new Vector2(240, 250));
            end = new TextLine("Font", "End Game", Color.White, new Vector2(240, 300));

            title = new GraphicalObject("Title", new Vector2(0, 0));
            title.X = width / 2 - title.width / 2;
            title.Y = 25;
        }
Пример #4
0
    // Instantiates the object that controls the moving objects vertical height
    GameObject InstantiateControlObject(GameObject parent, Vector3 startPos)
    {
        GameObject controlObj = new GameObject();

        controlObj.AddComponent <GraphicalObject>();
        controlObj.AddComponent <Moveable>();

        GraphicalObject gra = controlObj.GetComponent <GraphicalObject>();

        gra.xSize = 3;
        gra.ySize = 3;

        controlObj.GetComponent <Moveable>().movingObject = parent;

        controlObj.transform.position   = startPos;
        controlObj.transform.localScale = new Vector3(0.1f, 0.1f, 1);

        return(controlObj);
    }
Пример #5
0
        /// <summary>
        /// Handles the MouseUp event of the tabFunclet control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// Created by SMK at  2:19 PM on 27/11/11 
        private void tabFunclet_MouseUp(object sender, MouseEventArgs e)
        {
            ptMouse_Up = e.Location;
            double dist = Auxi_Geometry.Distance(ptMouse_Down, e.Location);
            //ContextMenuStrip = cmenuFunc;
            tabFunclet.ContextMenuStrip = null;
            int iWasCaught, iNode;
            NodeShape shape;
            if (moverOnTab.Release(out iWasCaught, out iNode, out shape))
            {
                GraphicalObject grobj = moverOnTab[iWasCaught].Source;
                if (e.Button == MouseButtons.Left)
                {
                    if (grobj is Function)
                    {

                        if (((Function)grobj).LeftClick(e.Location) == true)
                        {
                            UpdateFormGraphic();
                        }
                    }

                    if (grobj is Port)
                    {
                        var endPort = FindPortCandidate(ptMouse_Up);
                        if (endPort != null && portLinkStart != null
                            && endPort.PortType == PortType.Input
                            && portLinkStart.PortType == PortType.Output)
                        {
                            var ld = new LinkDot(portLinkStart, endPort, penLinks, 4);
                            lstFuncsLink.Add(ld);
                            UpdateFormGraphic();
                            portLinkStart = null;
                            var parentS = endPort.ParentFunlet;
                            if (parentS is Function)
                            {
                                var obj = lnkNdDesign.FuncList.FindAll(t => t.ListPort.Exists(u => u.ID == grobj.ID));
                                if (obj != null)
                                {
                                    endPort.ParentFunlet.InputFunclets.AddRange(obj);
                                }
                            }
                            endPort.MarkPortConnected(endPort);

                            BuildXSLInDesign();
                        }
                    }

                    if (grobj is LinkDot)
                    {
                        if (currentLinkDot != null)
                        {
                            var objLink = lstFuncsLink.Find(t => t.StartPort == currentLinkDot.StartPort);
                            var endPort = FindPortCandidate(ptMouse_Up);
                            if (objLink != null && endPort != null)
                            {
                                objLink.EndPort.MarkPortConnected(objLink.EndPort.ID, false);
                                lstFuncsLink.Remove(currentLinkDot);
                                var ld = new LinkDot(currentLinkDot.StartPort, endPort, penLinks, 4);
                                lstFuncsLink.Add(ld);
                                UpdateFormGraphic();
                                portLinkStart = null;
                                var parentS = endPort.ParentFunlet;
                                if (parentS is Function)
                                {
                                    var obj = lnkNdDesign.FuncList.Find(t => t.ListPort.Exists(u => u.ID == grobj.ID)) as GraphNode;
                                    if (obj != null)
                                        endPort.ParentFunlet.InputFunclets.Add(obj);
                                }
                                endPort.MarkPortConnected(endPort);
                                BuildXSLInDesign();
                            }
                        }
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (grobj is Function)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    if (grobj is Port)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    if (grobj is GraphConcat)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    else
                    {
                        tabFunclet.ContextMenuStrip = null;
                    }
                }
            }

            isOnMovingHeadOfLine = false;
            isOnMovingTailOfLine = false;
            this.tabFunclet.ContextMenuStrip = ctxFunlet;
            MustPaint();
        }
Пример #6
0
        /// <summary>
        /// Handles the MouseUp event of the tabFunclet control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
        /// Created by SMK at  2:19 PM on 27/11/11 
        private void tabFunclet_MouseUp(object sender, MouseEventArgs e)
        {
            ptMouse_Up = e.Location;
            double dist = Auxi_Geometry.Distance(ptMouse_Down, e.Location);
            //ContextMenuStrip = cmenuFunc;
            tabFunclet.ContextMenuStrip = null;
            int iWasCaught, iNode;
            NodeShape shape;
            if (moverOnTab.Release(out iWasCaught, out iNode, out shape))
            {
                GraphicalObject grobj = moverOnTab[iWasCaught].Source;
                if (e.Button == MouseButtons.Left)
                {
                    if (grobj is Function)
                    {

                        if (((Function)grobj).LeftClick(e.Location) == true)
                        {
                            UpdateFormGraphic();
                        }
                    }

                    if (grobj is Port)
                    {

                        if (((Port)grobj).LeftClick(e.Location) == true)
                        {
                            UpdateFormGraphic();
                        }
                    }

                    if (grobj is GraphConcat)
                    {

                        if (((GraphConcat)grobj).LeftClick(e.Location) == true)
                        {
                            UpdateFormGraphic();
                        }
                    }

                    if (grobj is LinkDot)
                    {
                        LinkDot link = grobj as LinkDot;
                        int iOffset = lstFuncsLink.IndexOf(link);
                        Point ptHead = link.Points[link.Points.Count - 1];
                        Point ptBegin = link.Points[0];
                        Point ptRightSideOfHead = new Point(ptHead.X + 4, ptHead.Y);
                        Point ptLeftSideOfBegin = new Point(ptBegin.X - 4, ptBegin.Y);
                        Funclet fncHead = null;
                        Funclet fncTail = null;
                        GraphicalObject grobjHead = null;
                        GraphicalObject grobjTail = null;

                        moverOnTab.Catch(ptRightSideOfHead);
                        grobjHead = moverOnTab.CaughtSource;
                        moverOnTab.ReleaseMover();

                        moverOnTab.Catch(ptLeftSideOfBegin);
                        grobjTail = moverOnTab.CaughtSource;
                        moverOnTab.ReleaseMover();

                        if (grobjHead is Funclet)
                        {
                            fncHead = grobjHead as Funclet;
                        }

                        if (grobjTail is Funclet)
                        {
                            fncTail = grobjTail as Funclet;
                        }

                        if (isOnMovingHeadOfLine == true)
                        {
                            if (fncHead != null)
                            {
                                int iLine = fncHead.LineByPoint(ptRightSideOfHead);
                                link.MoveEndDot(fncHead.InConnectionPoints[iLine]);
                                fncHead.InConnectionOrder(iLine, iOffset);
                                tabFunclet.Invalidate();
                            }
                        }

                        if (isOnMovingTailOfLine == true)
                        {
                            if (fncTail != null)
                            {
                                int iLine = fncTail.LineByPoint(ptLeftSideOfBegin);
                                link.MoveDot(0, fncTail.OutConnectionPoints[iLine]);
                                fncTail.OutConnectionOrder(iLine, iOffset);
                                tabFunclet.Invalidate();
                            }
                        }
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    if (grobj is Function)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    if (grobj is Port)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    if (grobj is GraphConcat)
                    {
                        OnMouseUpObject = grobj;
                        PointAtMouseUp = e.Location;
                    }
                    else
                    {
                        tabFunclet.ContextMenuStrip = null;
                    }
                }
            }

            isOnMovingHeadOfLine = false;
            isOnMovingTailOfLine = false;
        }