Beispiel #1
0
    void Update()
    {
        if (targetPosition == null)
        {
            GameObject target = GameObject.Find(userId);
            if (target == null)
            {
                return;
            }

            targetPosition = target.GetComponent <IsometricPosition>();
            return;
        }

        // Move the camera accordingly.
        if (targetPosition.Vector() != cameraPosition.Vector())
        {
            Vector2 gridPosition = Vector2.SmoothDamp(
                cameraPosition.Vector(),
                targetPosition.Vector(),
                ref velocity,
                DampTime,
                Mathf.Infinity,
                Time.deltaTime);
            cameraPosition.Set(gridPosition.x, gridPosition.y, Offset);
        }
        else
        {
            cameraPosition.x = targetPosition.x;
            cameraPosition.y = targetPosition.y;
        }
    }
Beispiel #2
0
    private void RegisterNextPosition(float diffX, float diffY)
    {
        IsometricPosition pos = transform.gameObject.GetComponent <IsometricPosition>();
        float             x   = pos.x + diffX;
        float             y   = pos.y + diffY;

        pos.Set(x, y, -1.0f);
    }
            public PlayerControllerWrapper(float x, float y)
            {
                IsometricPosition position = context.AddComponent <IsometricPosition>();

                position.Set(x, y);

                playerController = context.AddComponent <PlayerController>();
            }
    // Move current selection.
    private static void MoveObjects(float x, float y)
    {
        GameObject[] gameObjects = Selection.gameObjects;

        foreach (GameObject gameObject in gameObjects)
        {
            IsometricPosition position = gameObject.GetComponent <IsometricPosition>();
            position.Set(position.x + x, position.y + y);
        }
    }
        public void TestIsometricDepth(
            float x,
            float y,
            float relativeDepth,
            float expectedDepth)
        {
            GameObject        empty    = new GameObject();
            IsometricPosition position = empty.AddComponent <IsometricPosition>();

            position.Set(x, y, relativeDepth);

            Assert.AreEqual(position.depth, expectedDepth);
        }
        public void TestChangingRelativeDepth(float x, float y, float depthChange)
        {
            Assert.AreNotEqual(depthChange, 0.0f);

            GameObject        empty    = new GameObject();
            IsometricPosition position = empty.AddComponent <IsometricPosition>();

            position.Set(x, y);
            Vector3 initialPosition = empty.transform.position;

            position.ChangeRelativeDepth(depthChange);
            Assert.AreNotEqual(initialPosition, empty.transform.position);

            position.ChangeRelativeDepth(0.0f);
            Assert.AreEqual(initialPosition, empty.transform.position);
        }
        public void TestIsometricCalculation(
            float isometricX,
            float isometricY,
            float realX,
            float realY,
            float realZ)
        {
            GameObject        empty    = new GameObject();
            IsometricPosition position = empty.AddComponent <IsometricPosition>();

            position.Set(isometricX, isometricY);

            Vector3 realPosition = new Vector3(realX, realY, realZ);
            float   diff         = Vector3.Distance(empty.transform.position, realPosition);

            Assert.IsTrue(diff < epsilon);
        }
Beispiel #8
0
    public void Init(float x, float y)
    {
        IsometricPosition position = transform.gameObject.AddComponent <IsometricPosition>();

        position.Set(x + 0.5f, y + 0.5f, -1.0f);
    }