Beispiel #1
0
        public override void Draw()
        {
            Lines.Begin(ref Camera.SimProjection, ref Camera.SimView);

            foreach (Fixture f in _obstacles.FixtureList)
            {
                Lines.DrawLine(_distanceBody[0].Position, _distanceBody[1].Position, Colors.Black);
                Lines.DrawLine(_distanceBody[2].Position, _distanceBody[3].Position, Colors.Black);
            }

            Lines.End();
            Sprites.Begin(0, null, null, null, null, null, Camera.View);

            for (int i = 0; i < 3; i++)
            {
                Sprites.Draw(_angleCube.Image, ConvertUnits.ToDisplayUnits(_angleBody[i].Position), null, Color.White, _angleBody[i].Rotation, _angleCube.Origin, 1f, SpriteEffects.None, 0f);
            }

            for (int i = 0; i < 4; i++)
            {
                Sprites.Draw(_distanceCube.Image, ConvertUnits.ToDisplayUnits(_distanceBody[i].Position), null, Color.White, _distanceBody[i].Rotation, _distanceCube.Origin, 1f, SpriteEffects.None, 0f);
            }

            Sprites.End();
            Lines.Begin(ref Camera.SimProjection, ref Camera.SimView);

            foreach (Fixture f in _obstacles.FixtureList)
            {
                Lines.DrawLineShape(f.Shape, Colors.Black);
            }

            Lines.End();

            base.Draw();
        }
    //Loops:
    private void Update()
    {
        if (!HandInput.Ready)
        {
            return;
        }

        //place:
        transform.SetPositionAndRotation(_managedHand.Skeleton.Position, _managedHand.Skeleton.Rotation);

        //hide axis if inside clip plane:
        _axisVisualizer.enabled = !_managedHand.Skeleton.InsideClipPlane;

        //wrist:
        Lines.DrawLine(Name("wrist"), GetColor(_managedHand.Skeleton.WristCenter.InsideClipPlane), GetColor(_managedHand.Skeleton.InsideClipPlane), .0005f, _managedHand.Skeleton.WristCenter.positionFiltered, _managedHand.Skeleton.Position);

        //fingers:
        DrawDigit("thumb", _managedHand.Skeleton.Thumb, GetColor(_managedHand.Skeleton.Thumb.Knuckle.InsideClipPlane), GetColor(_managedHand.Skeleton.Thumb.Tip.InsideClipPlane));
        DrawDigit("index", _managedHand.Skeleton.Index, GetColor(_managedHand.Skeleton.Index.Knuckle.InsideClipPlane), GetColor(_managedHand.Skeleton.Index.Tip.InsideClipPlane));
        DrawDigit("middle", _managedHand.Skeleton.Middle, GetColor(_managedHand.Skeleton.Middle.Knuckle.InsideClipPlane), GetColor(_managedHand.Skeleton.Middle.Tip.InsideClipPlane));
        DrawDigit("ring", _managedHand.Skeleton.Ring, GetColor(_managedHand.Skeleton.Ring.Knuckle.InsideClipPlane), GetColor(_managedHand.Skeleton.Ring.Tip.InsideClipPlane));
        DrawDigit("pinky", _managedHand.Skeleton.Pinky, GetColor(_managedHand.Skeleton.Pinky.Knuckle.InsideClipPlane), GetColor(_managedHand.Skeleton.Pinky.Tip.InsideClipPlane));

        //finger connections:
        DrawBone("thumbConnection", _managedHand.Skeleton.Position, _managedHand.Skeleton.Thumb.Knuckle, GetColor(_managedHand.Skeleton.InsideClipPlane), GetColor(_managedHand.Skeleton.Thumb.Knuckle.InsideClipPlane));
        DrawBone("indexConnection", _managedHand.Skeleton.Position, _managedHand.Skeleton.Index.Knuckle, GetColor(_managedHand.Skeleton.InsideClipPlane), GetColor(_managedHand.Skeleton.Index.Knuckle.InsideClipPlane));
        DrawBone("middleConnection", _managedHand.Skeleton.Position, _managedHand.Skeleton.Middle.Knuckle, GetColor(_managedHand.Skeleton.InsideClipPlane), GetColor(_managedHand.Skeleton.Middle.Knuckle.InsideClipPlane));
        DrawBone("ringConnection", _managedHand.Skeleton.Position, _managedHand.Skeleton.Ring.Knuckle, GetColor(_managedHand.Skeleton.InsideClipPlane), GetColor(_managedHand.Skeleton.Ring.Knuckle.InsideClipPlane));
        DrawBone("pinkyConnection", _managedHand.Skeleton.Position, _managedHand.Skeleton.Pinky.Knuckle, GetColor(_managedHand.Skeleton.InsideClipPlane), GetColor(_managedHand.Skeleton.Pinky.Knuckle.InsideClipPlane));
    }
    // draw the line between the starting and the ending circle
    private void PlaceLine()
    {
        float startingCircleY = startingCircle.transform.position.y;
        float startingCircleX = startingCircle.transform.position.x;

        float endingCircleY = endingCircle.transform.position.y;
        float endingCircleX = endingCircle.transform.position.x;

        // if the circles are aligned horizontaly, place the line accordingly
        if (startingCircleY == endingCircleY)
        {
            // if we want to draw a line from left to right, move it a bit to the right so that the center of the line
            // is not placed exactly on the startingircle, but in-between the circles;
            if (startingCircleX - endingCircleX == -1f)
            {
                //SetNeighbours(1);// 1 means endingCircle is the right neighbour of startingCircle
                MarkBiscuitsSide(startingCircleX + 0.5f, startingCircleY, false);
                lines.DrawLine(startingCircleX + 0.5f, startingCircleY, false);
            }
            // if we want to draw the line from left to right, move it a little to the left
            else
            {
                //SetNeighbours(3);// 3 means endingCircle is the left neighbour of startingCircle
                MarkBiscuitsSide(startingCircleX - 0.5f, startingCircleY, false);
                lines.DrawLine(startingCircleX - 0.5f, startingCircleY, false);
            }
        }
        // otherwise place the line verticaly( the offset 0.5f  is used to place it right in between the circles)
        else
        {
            // draw the line from bottom to top
            if (startingCircleY - endingCircleY == -1f)
            {
                //SetNeighbours(0); // 0 means endingCircle is the upper neighbour of startingCircle
                MarkBiscuitsSide(startingCircleX, startingCircleY + 0.5f, true);
                lines.DrawLine(startingCircleX, startingCircleY + 0.5f, true);
            }
            // draw the line from top to bottom
            else
            {
                //SetNeighbours(2); // 2 means endingCircle is the bottom neighbour of startingCircle
                MarkBiscuitsSide(startingCircleX, startingCircleY - 0.5f, true);
                lines.DrawLine(startingCircleX, startingCircleY - 0.5f, true);
            }
        }
    }
Beispiel #4
0
    public void CloseSideOnDirection(int direction)
    {
        // 0 - top, 1 - right, 2 - bottom, 3 - left
        int top    = 0;
        int right  = 1;
        int bottom = 2;
        int left   = 3;

        UnityEngine.Vector3 position = this.gameObject.transform.position;

        switch (direction)
        {
        case 0:
        {
            sides[0] = true;
            lines.DrawLine(position, false, top);
            break;
        }

        case 1:
        {
            sides[1] = true;
            lines.DrawLine(position, true, right);
            break;
        }

        case 2:
        {
            sides[2] = true;
            lines.DrawLine(position, false, bottom);
            break;
        }

        case 3:
        {
            sides[3] = true;
            lines.DrawLine(position, true, left);
            break;
        }
        }
    }
    private void DrawDigit(string fingerName, ManagedFinger finger, Color colorA, Color colorB)
    {
        fingerName = Name(fingerName);
        Lines.DrawLine(fingerName, colorA, colorB, .0005f, finger.PointLocationsFiltered);

        if (_managedHand.Visible && finger.Visible)
        {
            Lines.SetVisibility(fingerName, true);
        }
        else
        {
            Lines.SetVisibility(fingerName, false);
        }
    }
    private void DrawBone(string fingerName, Vector3 from, ManagedKeypoint to, Color colorA, Color colorB)
    {
        fingerName = Name(fingerName);
        Lines.DrawLine(fingerName, colorA, colorB, .0005f, from, to.positionFiltered);

        if (_managedHand.Visible && to.Visible)
        {
            Lines.SetVisibility(fingerName, true);
        }
        else
        {
            Lines.SetVisibility(fingerName, false);
        }
    }
    void Start()
    {
        rect = GetComponent <RectTransform>();
        Lines.DrawLine(rect, Vector2.zero, Vector2.zero, Color.clear);
        //tex = Lines.GetRawImageTexture(rect);
        //pixels = tex.GetPixels32();
        RawImage rimg = GetComponent <RawImage>();

        rimg.raycastTarget = false;
        KeyInput ki = GetComponent <KeyInput>();

        if (ki == null)
        {
            ki = gameObject.AddComponent <KeyInput>();
        }
        ki.AddListener(new KBind(key, "draw selection rectangle",
                                 pressFunc: new EventBind(this, nameof(StartPress)),
                                 holdFunc: new EventBind(this, nameof(ContinuePress)),
                                 releaseFunc: new EventBind(this, nameof(ReleasePress))
                                 ));
    }
 /**
  * Handle the opponent move.
  */
 private void MoveReceived(float x, float y, bool direction, int turn, float squareX, float squareY, int player1Score, int player2Score)
 {
     lines.DrawLine(x, y, direction);
     MarkBiscuit(squareX, squareY, player1Score, player2Score, turn);
     SwitchTurns(turn);
 }