Exemplo n.º 1
0
Arquivo: GridTest.cs Projeto: zon/cell
    void Update()
    {
        follower.shape.transform.localPosition = camera.ScreenToWorldPoint(Input.mousePosition).XY().ToCell();
        follower.shape.transform.localRotation = rotation;
        follower.shape.radius = Mathf.Max(scale.x, scale.y) / 2;

        Behavior.CoreUpdate();

        var collisions = grid.GetCollisions(follower.shape);
        var bodies     = collisions.Select(c => c.shape);

        for (var o = 0; o < obstacles.Length; o++)
        {
            var ob = obstacles[o];
            grid.DrawCells(ob.shape, Color.blue);
            if (bodies.Contains(ob.shape))
            {
                ob.renderer.material.color = Color.red;
            }
            else
            {
                ob.renderer.material.color = Color.yellow;
            }
        }

        grid.DrawCells(follower.shape, Color.magenta);
        // follower.shape.mesh.DebugDraw(Color.green);
    }
Exemplo n.º 2
0
    void Update()
    {
        a.transform.localRotation += aRotationRate * Vec2.deg2rad * Time.deltaTime;
        a.transform.localScale     = aScale.ToCell();

        b.transform.localPosition  = camera.ScreenToWorldPoint(Input.mousePosition).XY().ToCell();
        b.transform.localRotation += bRotationRate * Vec2.deg2rad * Time.deltaTime;
        b.transform.localScale     = bScale.ToCell();

        Behavior.CoreUpdate();

        var collision = b.CheckCollision(a);

        if (collision != null)
        {
            b.transform.localPosition += collision.overlap;
            b.transform.Update();
            b.Update();

            a.mesh.DebugDraw(Color.red);
        }
        else
        {
            a.mesh.DebugDraw(Color.yellow);
        }

        b.mesh.DebugDraw(Color.blue);
    }
Exemplo n.º 3
0
    void FixedUpdate()
    {
        follower.speed        = speed;
        follower.acceleration = acceleration;

        Behavior.CoreUpdate();
    }
Exemplo n.º 4
0
    void Update()
    {
        var t = (Time.time % translationDuration) / translationDuration;

        body.transform.localPosition  = Vector2.Lerp(minPosition, maxPosition, t).ToCell();
        body.transform.localRotation += (rotationRate / translationDuration) * Vec2.deg2rad * Time.deltaTime;
        body.transform.localScale     = Vector2.Lerp(minScale, maxScale, t).ToCell();

        Behavior.CoreUpdate();

        body.mesh.DebugDraw(Color.white);
    }
Exemplo n.º 5
0
    void FixedUpdate()
    {
        parent.localPosition = parentArgs.position.ToCell();
        parent.localRotation = parentArgs.rotation;
        parent.localScale    = parentArgs.scale.ToCell();

        for (var c = 0; c < children.Length; c++)
        {
            var child = children[c];
            var args  = childArgs[c];
            child.localPosition = args.position.ToCell();
            child.localRotation = args.rotation;
            child.localScale    = args.scale.ToCell();
        }

        Behavior.CoreUpdate();

        // Log(parent);
        // if (children.Length > 0)
        //  Log(children[0]);
    }
Exemplo n.º 6
0
 void FixedUpdate()
 {
     Behavior.CoreUpdate();
 }