コード例 #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;
        }
    }
コード例 #2
0
        public void TestCreatingMapFeatureAddsComponents()
        {
            var wrapper           = new MapFeatureManagerWrapper("id3");
            var mapFeatureManager = wrapper.mapFeatureManager;

            Assert.IsTrue(mapFeatureManager.Create(wrapper.id, mapFeatureData));
            GameObject go = GameObject.Find(wrapper.id);

            Assert.IsNotNull(go.GetComponent <IsometricPosition>());
            Assert.AreEqual(
                go.transform.rotation,
                Quaternion.Euler(0.0f, 0.0f, 0.0f));

            IsometricPosition component = go.GetComponent <IsometricPosition>();
            Vector2           position  = new Vector2(1.0f, 2.0f);

            Assert.AreEqual(component.Vector(), position);
        }
コード例 #3
0
            public Vector2 GetPosition()
            {
                IsometricPosition position = context.GetComponent <IsometricPosition>();

                return(position.Vector());
            }