Inheritance: MonoBehaviour
        public GameView(GraphicsDevice gd, ContentManager c, model.GameModel model)
        {
            renderer = new LineDrawer (gd);
            shuttle = c.Load<Texture2D> ("shuttle.png");
            spriteBatch = new SpriteBatch(gd);
            this.model = model;
            camera = new Camera (gd.Viewport.Bounds, model.map.getLevelWidth());

            effect = c.Load<SoundEffect> ("fire.wav");
        }
Beispiel #2
0
 /// <summary>
 /// Constructs a new line.
 /// </summary>
 /// <param name="colorA">Initial color of the first vertex of the line.</param>
 /// <param name="colorB">Initial color of the second vertex of the line.</param>
 /// <param name="drawer">System responsible for drawing this line.</param>
 public Line(Color colorA, Color colorB, LineDrawer drawer)
 {
     this.drawer = drawer;
     drawer.GetNewLineIndex(out IndexA);
     IndexB = IndexA + 1;
     drawer.vertices[IndexA].Position = Vector3.Zero;
     drawer.vertices[IndexA].Color = colorA;
     drawer.vertices[IndexB].Position = Vector3.Zero;
     drawer.vertices[IndexB].Color = colorB;
 }
Beispiel #3
0
 public bool Process(Command command)
 {
     switch (command)
     {
         case Command.DrawLine:
             _drawer = LineDrawer.WaitBeginPoint;
             return true;
         default:
             throw new InvalidCommandException(command + " is not recognized.");
     }
 }
Beispiel #4
0
        public void Setup(AgentController owner)
        {
            Debug.Assert(_longTerm != null);
            Debug.Assert(_normal != null);
            Debug.Assert(_immediate != null);

            _owner = owner;
            TrackObject(_owner.transform);

            RefreshText();

            _drawer = Camera.main.GetComponent <LineDrawer>();
        }
Beispiel #5
0
    void Start()
    {
        shipElements = GetComponent <GravityElements>();
        encounters   = GetComponent <Encounters>();

        spriteRenderer = GetComponentInChildren <SpriteRenderer>(true);
        lineDrawer     = GetComponentInChildren <LineDrawer>();

        perigeeIcons = new List <GameObject>();
        apogeeIcons  = new List <GameObject>();

        updateEncounters();
    }
    private void Update()
    {
        mousePosition   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        mousePosition.z = 0;

        if (Input.GetMouseButtonDown(0))
        {
            objSelected = Physics2D.OverlapCircle(mousePosition, 0.05f);
            if (objSelected != null)
            {
                if (objSelected.tag == "Paper" && currentColor != nullColor)
                {
                    drawing = Instantiate(prefab_trail, mousePosition, Quaternion.Euler(0.0f, 0.0f, 0.0f), paper).GetComponent <LineDrawer>();
                    drawing.line.startColor = currentColor;
                    drawing.line.endColor   = currentColor;
                }
                else if (objSelected.tag == "Color")
                {
                    if (currentColor != nullColor)
                    {
                        currentColor = (objSelected.GetComponent <SpriteRenderer>().color + currentColor) / 2;
                    }
                    else
                    {
                        currentColor = objSelected.GetComponent <SpriteRenderer>().color;
                    }
                    audio.Play();
                    cursorSprite_paintColor.enabled = true;
                    cursorSprite_paintColor.color   = currentColor;
                    objSelected = null;
                }
            }
        }
        else if (objSelected != null && objSelected.tag == "Paper" && currentColor != nullColor)
        {
            if (Input.GetMouseButton(0))
            {
                drawing.line.positionCount++;
                drawing.line.SetPosition(drawing.line.positionCount - 1, mousePosition);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                if (drawing.simplifyLine)
                {
                    drawing.line.Simplify(drawing.simplifyTolerance);
                }
                drawing.enabled = false;
            }
        }
    }
Beispiel #7
0
        private void RouteLine(LineDrawer drawLine, float x1, float y1, float x2, float y2)
        {
            UmlPortSide startSide = DataSource.StartPortSide;
            UmlPortSide endSide   = DataSource.EndPortSide;

            if (Math.Abs(x2 - x1) > Math.Abs(y2 - y1))
            {
                DrawHorizontal(drawLine, x1, y1, x2, y2);
            }
            else
            {
                DrawVertical(drawLine, x1, y1, x2, y2);
            }
        }
Beispiel #8
0
    Vector3 OffsetPursue(GameObject offsetPursueTarget)
    {
        Vector3 targetPos = offsetPursueTarget.transform.TransformPoint(offset);

        Vector3 toTarget = targetPos - transform.position;
        float   distance = toTarget.magnitude;
        float   time     = distance / maxSpeed;
        Vector3 target   = targetPos
                           + offsetPursueTarget.GetComponent <Boid>().velocity *time;

        LineDrawer.DrawTarget(target, Color.gray);

        return(Arrive(target));
    }
        public void Draw3DLines(Camera camera, Matrix world, Vector3[] lines, Color color)
        {
            LineDrawer.Begin();
            List <Vector2> trans = new List <Vector2>();

            foreach (var v in lines)
            {
                var p = Vector3.Project(v, Viewport.X, Viewport.Y, Viewport.Width, Viewport.Height, Viewport.MinZ, Viewport.MaxZ, world * camera.ViewProjection);
                trans.Add(Common.Math.ToVector2(p));
            }
            LineDrawer.Draw(trans.ToArray(), color);
            //LineDrawer.DrawTransformed(lines, world * camera.View * camera.Projection, color);
            LineDrawer.End();
        }
Beispiel #10
0
        public void TestAddShapeDrawer()
        {
            Assert.ThrowsException <ArgumentNullException>(() => _canvasShapeDrawersHelper.AddShapeDrawer(null));
            var lineDrawer = new LineDrawer(new Point(), new Point());

            _canvasShapeDrawersHelper.AddShapeDrawer(lineDrawer);
            Assert.AreEqual(_shapeDrawers.Count, 1);
            Assert.AreSame(_shapeDrawers[0], lineDrawer);
            var rectangleDrawer = new RectangleDrawer(new Point(), new Point());

            _canvasShapeDrawersHelper.AddShapeDrawer(rectangleDrawer);
            Assert.AreEqual(_shapeDrawers.Count, 2);
            Assert.AreSame(_shapeDrawers[1], rectangleDrawer);
        }
    // Use this for initialization
    void Start()
    {
        renderer = GetComponent <Renderer>();
        Debug.Log("Grid started");
        Texture2D tex = new Texture2D(texSize, texSize);

        //LineDrawer.DrawLine(tex, 0, 0, 64, 64, Color.black);
        LineDrawer.DrawGrid(tex, 7);
        tex.Apply();
        Debug.Log("Grid finished");
        Debug.Log(renderer.material.mainTexture);
        renderer.material.mainTexture = tex;
        Debug.Log(renderer.material.mainTexture);
    }
Beispiel #12
0
        protected override void Initialize()
        {
            ModelDrawer = new InstancedModelDrawer(this);

            ConstraintDrawer = new LineDrawer(this);
            ConstraintDrawer.DisplayTypes.Add(typeof(GrabSpring), typeof(DisplayGrabSpring));
            ConstraintDrawer.DisplayTypes.Add(typeof(MotorizedGrabSpring), typeof(DisplayMotorizedGrabSpring));

            ContactDrawer          = new ContactDrawer(this);
            BoundingBoxDrawer      = new BoundingBoxDrawer(this);
            SimulationIslandDrawer = new SimulationIslandDrawer(this);

            base.Initialize();
        }
Beispiel #13
0
    // Use this for initialization
    public virtual void Start()
    {
        lineDrawer = SceneUtils.FindObject <LineDrawer>();
        if (!lineDrawer)
        {
            Debug.Log("[WARN] lineDrawComponent needs LineDrawer!");
        }

        lineFollowComponent = this.GetComponent <LineFollowComponent>();
        lineFollowComponent.AddEventListener(this.gameObject);
        this.AddEventListener(lineFollowComponent.gameObject);

        this.canBeDragged = false;
    }
Beispiel #14
0
    private void Awake()
    {
        instance = this;

        lines = new SpriteRenderer[QUANTITY_IN_POOL];
        for (int i = 0; i < QUANTITY_IN_POOL; i++)
        {
            GameObject lineObject = Instantiate(linePrefab);
            lineObject.transform.parent = transform;
            lineObject.transform.localPosition = Vector3.zero;
            lineObject.SetActive(false);
            lines[i] = lineObject.GetComponent<SpriteRenderer>();
        }
    }
Beispiel #15
0
    private void CreateLevelUiGrid()
    {
        foreach (var item in uiGrids)
        {
            ClearTestChilds(item.transform);
        }

        cellItems  = new CellItem[LevelSize, LevelSize];
        laserItems = new LaserItem[4, LevelSize];
        laserLines = new LineDrawer[4, LevelSize];

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < LevelSize; j++)
            {
                LaserItem laserItem = Instantiate(laserPrefab).GetComponent <LaserItem>();
                laserItem.transform.SetParent(laserGrids[i].transform, false);

                laserItems[i, j] = laserItem;
                laserLines[i, j] = new LineDrawer(i * LevelSize + j, lineMaterial, laserItem.gameObject);

                int                iCopy   = i;
                int                jCopy   = j;
                EventTrigger       trigger = laserItem.GetComponent <EventTrigger>();
                EventTrigger.Entry entry   = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerDown;
                entry.callback.AddListener((eventData) => { OnLaserDown(iCopy, jCopy); });
                trigger.triggers.Add(entry);

                entry         = new EventTrigger.Entry();
                entry.eventID = EventTriggerType.PointerUp;
                entry.callback.AddListener((eventData) => { OnLaserUp(iCopy, jCopy); });
                trigger.triggers.Add(entry);
            }
        }

        for (int i = 0; i < LevelSize; i++)
        {
            for (int j = 0; j < LevelSize; j++)
            {
                CellItem cellItem = Instantiate(slotPrefab).GetComponent <Slot>();
                cellItem.transform.SetParent(gridPanel.transform, false);

                cellItems[i, j] = cellItem;
            }
        }

        FitGridToScreen();
    }
Beispiel #16
0
    public void CreateDestroyerLine(Vector3?begin, Vector3?end)
    {
        if (begin == null || end == null)
        {
            Debug.Log("LineDestroyer missing vector!");
            return;
        }

        LineDrawer drawer     = new LineDrawer(null);
        GameObject lineParent = drawer.DrawInGameLine(begin.Value, end.Value, Color.blue, 0.5f, new GameObject("Parent").transform);
        GameObject line       = lineParent.transform.Find("line").gameObject;

        line.GetComponent <CapsuleCollider>().isTrigger = true;
        line.AddComponent <LineDestroyerBehaviour>();
    }
Beispiel #17
0
        protected override void Initialize()
        {
            LoadIcons();
            basicFont = Content.Load <SpriteFont>("basicFont");

            windowWidth  = GraphicsDevice.PresentationParameters.BackBufferWidth;
            windowHeight = GraphicsDevice.PresentationParameters.BackBufferHeight;

            TileCache.Boot();
            Camera     = new Camera();
            MapManager = new MapManager();
            Line       = new LineDrawer();

            base.Initialize();
        }
Beispiel #18
0
    /*!
     * \brief Add a white line with a specific thickness in the middle of a texture.
     * \param[in] thickness The thickness of the line
     * \param[in] tex The texture.
     * \return void
     */
    public static void AddWhiteLineToTexture(float thickness, Texture2D tex)
    {
        var colors = tex.GetPixels();

        int middle = (tex.width / 2) - 1;
        var start  = new int[] { middle, 0 };
        var end    = new int[] { middle, tex.height - 1 };

        LineDrawer.plotThickLineAA(start[0], start[1], end[0], end[1], thickness, delegate(int x, int y, float i) {
            colors[y * tex.width + (tex.width - 1 - x)] = new Color(i, i, i);
        });

        tex.SetPixels(colors);
        tex.Apply();
    }
    // Use this for initialization
    void Start()
    {
        node          = null;
        shipElements  = GetComponent <GravityElements>();
        ship          = GetComponent <ShipGravityBehavior>();
        lineDrawer    = GetComponentInChildren <LineDrawer>();
        patchedConics = GetComponent <ShipPatchedConics>();

        currentMassiveBody = shipElements.massiveBody;

        hoverDistanceTolerance = 1f;
        hovering        = false;
        lastTrueAnomaly = shipElements.TrueAnomaly;
        thrustVector    = new Vector2(0, 0);
    }
Beispiel #20
0
    public bool enableScript           = true;      //is the script enabled ?


    // Start is called before the first frame update
    void Start()
    {
        //We initialize our lists
        impacts = new List <collisionForce>();
        lines   = new List <LineDrawer>();

        //We fill our lineDrawer list (=> ready to draw lines)
        for (int j = 0; j < maxNumberLine; j++)
        {
            var lineDrawer = new LineDrawer(lineRadiusCoeff);
            lineDrawer.lineRenderer.startWidth = lineRadiusCoeff;
            lineDrawer.lineRenderer.endWidth   = lineRadiusCoeff;
            lines.Add(lineDrawer);
        }
    }
Beispiel #21
0
 // initialize objects
 void OnEnable()
 {
     // get hand
     hand = this.GetComponent <Hand>();
     // create line
     l = new LineDrawer();
     // get actions
     PlayAction.AddOnChangeListener(onPlay, hand.handType);
     PullAction.AddOnChangeListener(onPull, hand.handType);
     GrabAction.AddOnChangeListener(onGrab, hand.handType);
     RotationAction.AddOnChangeListener(onRotate, hand.handType);
     // set default color
     currColor = Color.blue;
     showLine  = true;
 }
        public void TestDrawSelectionCorners()
        {
            const string MEMBER_FUNCTION_NAME_DRAW_SELECTION_CORNERS = "DrawSelectionCorners";
            var          arguments = new object[] { null };
            TargetInvocationException expectedException = Assert.ThrowsException <TargetInvocationException>(() => _target.Invoke(MEMBER_FUNCTION_NAME_DRAW_SELECTION_CORNERS, arguments));

            Assert.IsInstanceOfType(expectedException.InnerException, typeof(ArgumentNullException));
            var lineDrawer = new LineDrawer(new Point(), new Point());
            var target     = new PrivateObject(lineDrawer);
            var graphics   = new GraphicsMock();

            arguments = new object[] { graphics };
            target.Invoke(MEMBER_FUNCTION_NAME_DRAW_SELECTION_CORNERS, arguments);
            Assert.IsTrue(graphics.IsCalledDrawSelectionCorner);
        }
        public void TestDrawSelectionHint()
        {
            var lineDrawer = new LineDrawer(new Point(), new Point());
            var graphics   = new GraphicsMock();

            lineDrawer.DrawSelectionHint(graphics);
            Assert.IsTrue(graphics.IsCalledDrawSelectionCorner);
            Assert.IsTrue(graphics.IsCalledDrawSelectionBorderLine);
            var rectangleDrawer = new RectangleDrawer(new Point(), new Point());

            graphics = new GraphicsMock();
            rectangleDrawer.DrawSelectionHint(graphics);
            Assert.IsTrue(graphics.IsCalledDrawSelectionCorner);
            Assert.IsTrue(graphics.IsCalledDrawSelectionBorderRectangle);
        }
Beispiel #24
0
    Vector3 Arrive(Vector3 arriveTarget)
    {
        Vector3 toTarget = arriveTarget - transform.position;

        float distance = toTarget.magnitude;

        float slowingDistance = 10;

        LineDrawer.DrawSphere(arriveTarget, slowingDistance, 10, Color.yellow);

        float   ramped  = (distance / slowingDistance) * maxSpeed;
        float   clamped = Mathf.Min(ramped, maxSpeed);
        Vector3 desired = (toTarget / distance) * clamped;

        return(desired - velocity);
    }
Beispiel #25
0
        private void InitEditorGizmos()
        {
            _lineDrawer0 = new LineDrawer(_pluginFreeController.linkLineMaterial);
            _lineDrawer1 = new LineDrawer(_pluginFreeController.linkLineMaterial);

            _zoneMaterial = new Material(_pluginFreeController.linkLineMaterial);
            Color zoneColor = Color.magenta;

            zoneColor.a = 0.1f;
            _zoneMaterial.SetColor("_Color", zoneColor);

            _targetPosMaterial = new Material(_pluginFreeController.linkLineMaterial);
            Color posColor = Color.green;

            posColor.a = 0.1f;
            _targetPosMaterial.SetColor("_Color", posColor);
        }
Beispiel #26
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Initalizing previous states with valid information
            keyboardPrevious = Keyboard.GetState();
            mousePrevious    = Mouse.GetState();
            gamePadsCurrrent = new List <GamePadState>();
            gamePadsPrevious = new List <GamePadState>();
            for (int i = 0; i < MaxGamePads; i++)
            {
                gamePadsPrevious.Add(GamePad.GetState(i));
            }

            // Initalizing the spritebatch for drawing
            LineDrawer.InitateLineDrawer(GraphicsDevice);
            spriteBatch = new SpriteBatch(GraphicsDevice);
            base.Initialize();
        }
Beispiel #27
0
    void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }

        instance     = this;
        lineRenderer = gameObject.GetComponent <LineRenderer>();
        if (lineRenderer == null)
        {
            lineRenderer = gameObject.AddComponent <LineRenderer>();
        }

        DontDestroyOnLoad(gameObject);
    }
    void Start()
    {
        System.Diagnostics.Debug.WriteLine(this.name + " Starting ObjectController script...");

        // the coordinates display canvas attached to this GameObject
        myText = this.GetComponentInChildren <Text>();

        /* demonstrates how to access code from another object
         * GameObject ethan = GameObject.Find("Ethan2");
         * c = (ThirdPersonCharacter)ethan.GetComponent(typeof(ThirdPersonCharacter));
         * anim = (Animator)ethan.GetComponent(typeof(Animator));
         */

        ld = new LineDrawer(0.01f);
        // This should enable destroy of the child LineRenderer when object is destroyed
        ld.lineRenderer.transform.SetParent(transform);
    }
Beispiel #29
0
        protected override void Initialize()
        {
            if (GraphicsDevice.GraphicsProfile == GraphicsProfile.HiDef)
                ModelDrawer = new InstancedModelDrawer(this);
            else
                ModelDrawer = new BruteModelDrawer(this);

            ConstraintDrawer = new LineDrawer(this);
            ConstraintDrawer.DisplayTypes.Add(typeof(GrabSpring), typeof(DisplayGrabSpring));
            ConstraintDrawer.DisplayTypes.Add(typeof(MotorizedGrabSpring), typeof(DisplayMotorizedGrabSpring));

            ContactDrawer = new ContactDrawer(this);
            BoundingBoxDrawer = new BoundingBoxDrawer(this);
            SimulationIslandDrawer = new SimulationIslandDrawer(this);

            base.Initialize();
        }
Beispiel #30
0
    public void Start()
    {
        d = anchor2.localPosition - anchor1.localPosition;
        TransferFunction.dt = Time.fixedDeltaTime;
        Queue <Unit> queue          = new Queue <Unit>();
        List <Unit>  unitsForUpdate = new List <Unit>();

        for (int i = 0; i < inputs.Count; i++)
        {
            queue.Enqueue(inputs[i]);
        }
        Unit current;

        while (queue.Count > 0)
        {
            current = queue.Dequeue();
            if (current.AddParentsToEvent(ref queue))
            {
                unitsForUpdate.Add(current);
            }
        }
        unitsForUpdate.Reverse();
        for (int i = 0; i < unitsForUpdate.Count; i++)
        {
            Step += unitsForUpdate[i].Tick;
        }
        Indicator[] uns = FindObjectsOfType <Indicator>();
        for (int i = 0; i < uns.Length; i++)
        {
            Step += uns[i].Tick;
        }
        ControlLaw.dt = Time.fixedDeltaTime;
        for (int i = 0; i < inputs.Count; i++)
        {
            LineDrawer drawer = Instantiate(prefabDraver, container);
            drawer.input  = inputs[i];
            drawer.color  = colors[i];
            drawer.parent = this;
            drawer.maxY   = max;
            drawer.minY   = min;
            drawers.Add(drawer);
            Step += drawer.Tick;
        }
        StartCoroutine(Cycle());
    }
Beispiel #31
0
 private void ResetGame(bool withTuto)
 {
     cursor.GetComponent <CursorManager>().Init();
     gameManager.GetComponent <OrganSettlementManager>().Init();
     gameManager.GetComponent <GameManager>().Reset();
     gameManager.GetComponent <PauseManager>().Init();
     if (withTuto)
     {
         gameManager.GetComponent <GameScenario>().Init();
     }
     else
     {
         gameManager.GetComponent <GameScenario>().SkipTutorial();
     }
     LineDrawer.ClearRelations();
     Camera.main.GetComponent <MoveCamera>().Init();
     organContainer.GetComponentInChildren <MainOrgan>().UpdateNextTurnLabel();
 }
Beispiel #32
0
    void Awake()
    {
        _cameraController = FindObjectOfType <CameraController>();
        _cameraController.Initialize(Navmesh.Size, .5f);
        _lineDrawer = GetComponent <LineDrawer>();
        _camera     = Camera.main;
        Help.gameObject.SetActive(!Application.isEditor);
        _agent = FindObjectOfType <DotsNavAgent>();
        var tr = _agent.transform;

        _start = tr.Find("Start");
        _goal  = tr.Find("Goal");
        var size = _start.localScale.x;
        var s    = new Vector3(size, size, size);

        _goal.localScale = s;
        _agent.Radius    = size / 2;
    }
Beispiel #33
0
    public GameController(GameObject container, WindowController linkedWindow)
    {
        /*
         * Create a new game with the given sizes
         */

        playerContainer  = container;
        windowController = linkedWindow;
        lines            = new List <Line>();
        corners          = new Dictionary <Vector3, Corner>();

        /* Create the lineDrawer for this game */
        lineDrawer = new LineDrawer(this);

        /* run setup functions for the game */
        SetupPlayers();
        SetupGameArea();
    }
        public void TestIsCloseToPoint()
        {
            var rectangleDrawer = new RectangleDrawer(new Point(1.0, 5.0), new Point(-1.0, 2.0));

            Assert.IsTrue(rectangleDrawer.IsCloseToPoint(new Point(0.5, 3.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(rectangleDrawer.IsCloseToPoint(new Point(-1.1, 2.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(rectangleDrawer.IsCloseToPoint(new Point(1.1, 2.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(rectangleDrawer.IsCloseToPoint(new Point(-1.0, 1.9), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(rectangleDrawer.IsCloseToPoint(new Point(-1.0, 5.1), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            var lineDrawer = new LineDrawer(new Point(1.0, 5.0), new Point(-1.0, 2.0));

            Assert.IsTrue(lineDrawer.IsCloseToPoint(new Point(0.0, 3.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsTrue(lineDrawer.IsCloseToPoint(new Point(0.5, 3.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(lineDrawer.IsCloseToPoint(new Point(-2.0, 2.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsTrue(lineDrawer.IsCloseToPoint(new Point(0.0, 2.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsFalse(lineDrawer.IsCloseToPoint(new Point(1.0, 6.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
            Assert.IsTrue(lineDrawer.IsCloseToPoint(new Point(1.0, 4.0), Definitions.MOUSE_POSITION_TO_SELECTION_SHAPE_MAXIMUM_DISTANCE_SQUARED));
        }
Beispiel #35
0
        public void OnMouseClick(Point location)
        {
            switch (_drawer)
            {
                case LineDrawer.WaitBeginPoint:
                    _begin = location;
                    _drawer = LineDrawer.WaitEndPoint;
                    break;

                case LineDrawer.WaitEndPoint:
                    _end = location;
                    _drawer = LineDrawer.WaitBeginPoint;
                    DrawPad.Add(new Line(_begin, _end));
                    break;

                default:
                    throw new InvalidCommandException("Draw line");
            }
        }
    void Start()
    {
        /*linePoints[0]=new Vector3(0,0,0);
        linePoints[1]=new Vector3(2,2,2);
        theMat = new Material(Shader.Find("Self-Illumin/VertexLit"));
        line=new VectorLine("line",linePoints,theMat,2);
        Vector.DrawLine3D(line);

        Debug.Log("vector.drawLine");*/
        linePoints[0]=new Vector3(-1.0f,2.0f,1.0f);
        linePoints[1]=new Vector3(4.0f,2.0f,4.0f);
        a=new LineDrawer ();
        //a.DrawArcLine(new Vector3(2.828f,2,0),new Vector3(-2.828f,2,0),new Vector3(0,2,0),3.14f,2.828f,2,40,2,Color.yellow,null);
        a.DrawArcLine(new Vector3(2.828f,2,0),new Vector3(0,2,-2.828f),new Vector3(0,2,0),1.57f,2.828f,2,100,0.02f,Color.red,null);
        //a.DrawArcLine(new Vector3(2.828f,0,2),new Vector3(2f,2,2),new Vector3(0,0,2),0.785f,2.828f,1,40,16,Color.black,null);
        //a.DrawArcLine(new Vector3(2.828f,0,2),new Vector3(0,2.828f,2),new Vector3(0,0,2),1.57f,2.828f,1,80,2,Color.red,null);
        //a.DrawArcLine(new Vector3(2.828f,0,2),new Vector3(0,-2.828f,2),new Vector3(0,0,2),1.57f,2.828f,1,40,16,Color.black,null);
         a.DrawStraightLine(linePoints[0],linePoints[1],0.02f,Color.yellow,null);
        //a.DrawArcLine(new Vector3(2,2.828f,0),new Vector3(2,0,-2.828f),new Vector3(2,0,0),1.57f,2.828f,3,40,8,Color.black,null);
        //a.DrawArcLine(new Vector3(2,2.828f,0),new Vector3(2,0,-2.828f),new Vector3(2,0,0),4.71f,2.828f,3,40,16,Color.yellow,null);
        nowtime=Time.time;
    }
    // Use this for initialization
    void Start()
    {
        Instance = this;

        lineRenderers = new LineRenderer[SceneManager.Instance.gridX * SceneManager.Instance.gridY];

        for (int i = 0; i < lineRenderers.Length; i++)
        {
            var go = new GameObject();
            go.name = "LineRenderer " + i;
            go.transform.parent = this.transform;
            go.AddComponent<LineRenderer>();
            lineRenderers[i] = go.GetComponent<LineRenderer>();
            lineRenderers[i].SetWidth(0.1f, 0.01f);
            lineRenderers[i].material = lineColor;
        }

        float x = Screen.width / SceneManager.Instance.gridY / 2;
        float y = Screen.height / SceneManager.Instance.gridX / 2;
        int index = 0;
        for (int i = 0; i < SceneManager.Instance.gridX; i++)
        {
            for (int j = 0; j < SceneManager.Instance.gridY; j++)
            {
                SceneManager.Instance.vectorStart[index] = new Vector2(x, y);
                if (drawLines)
                {
                    LineDrawer.Instance.lineRenderers[index].SetPosition(0, Camera.main.ScreenToWorldPoint(new Vector3(x, Screen.height - y, 10f)));
                    LineDrawer.Instance.lineRenderers[index].SetPosition(1, Camera.main.ScreenToWorldPoint(new Vector3(SceneManager.Instance.vectorfield[index].x, Screen.height - SceneManager.Instance.vectorfield[index].y, 10)));
                }
                x += Screen.width / SceneManager.Instance.gridY;
                index++;
            }

            x = Screen.width / SceneManager.Instance.gridY / 2;
            y += Screen.height / SceneManager.Instance.gridX;
        }
    }
 public override void createMinion(Minion minion)
 {
     base.createMinion(minion);
     lineDrawer = minionObject.GetComponentInChildren<LineDrawer>() as LineDrawer;
     roboHookMinion = (RoboHookMinion)minion;    // parent tutuyor aslinda minionu, ama ben surekli RoboHookMinon a cast etmek istemiyorum. hazir cast edilmisini elimde tutacagim.
 }
 protected LineDisplayObjectBase(LineDrawer drawer)
 {
     Drawer = drawer;
     myLinesReadOnly = new ReadOnlyCollection<Line>(myLines);
 }
        private static void DrawHorizontal(LineDrawer drawLine, float x1, float y1, float x2, float y2)
        {
            float x3 = (x1 + x2)/2;

            drawLine(x1, y1, x3, y1);
            drawLine(x2, y2, x3, y2);
            drawLine(x3, y1, x3, y2);
        }
        private static void DrawVertical(LineDrawer drawLine, float x1, float y1, float x2, float y2)
        {
            float y3 = (y1 + y2)/2;

            drawLine(x1, y1, x1, y3);
            drawLine(x2, y2, x2, y3);
            drawLine(x1, y3, x2, y3);
        }
        private void RouteLine(LineDrawer drawLine, float x1, float y1, float x2, float y2)
        {
            UmlPortSide startSide = DataSource.StartPortSide;
            UmlPortSide endSide = DataSource.EndPortSide;

            if (Math.Abs(x2 - x1) > Math.Abs(y2 - y1))
            {
                DrawHorizontal(drawLine, x1, y1, x2, y2);
            }
            else
            {
                DrawVertical(drawLine, x1, y1, x2, y2);
            }
        }
Beispiel #43
0
 private static void RouteLine(LineDrawer drawLine, float x1, float y1, float x2, float y2)
 {
     drawLine(x1, y1, x2, y2);
 }