예제 #1
0
        public void JsonPassiveNode_Convert(float _x, float _y, float zoomLevel, int orbitRadiiIndex, float[] orbitRadii, int skillsPerOrbitIndex, float[] skillsPerOrbit)
        {
            var group = new JsonPassiveNodeGroup
            {
                OriginalX = _x,
                OriginalY = _y,
                ZoomLevel = zoomLevel,
            };

            var node = new JsonPassiveNode
            {
                PassiveNodeGroup    = group,
                OrbitRadiiIndex     = orbitRadiiIndex,
                OrbitRadii          = orbitRadii,
                SkillsPerOrbitIndex = skillsPerOrbitIndex,
                SkillsPerOrbit      = skillsPerOrbit,
                ZoomLevel           = zoomLevel,
            };

            var nodeDefinition = PassiveNodeDefinition.Convert(node);
            var nodePosition   = node.PositionAtZoomLevel(1f);

            Assert.AreEqual(nodePosition.X, nodeDefinition.Position.X);
            Assert.AreEqual(nodePosition.Y, nodeDefinition.Position.Y);
        }
예제 #2
0
        public void JsonPassiveNode_ClearPosition(float x, float y, float zoomLevel, int orbitRadiiIndex, float[] orbitRadii, int skillsPerOrbitIndex, float[] skillsPerOrbit)
        {
            var group = new JsonPassiveNodeGroup
            {
                OriginalX = x,
                OriginalY = y,
                ZoomLevel = zoomLevel,
            };

            var node = new JsonPassiveNode
            {
                PassiveNodeGroup    = group,
                OrbitRadiiIndex     = orbitRadiiIndex,
                OrbitRadii          = orbitRadii,
                SkillsPerOrbitIndex = skillsPerOrbitIndex,
                SkillsPerOrbit      = skillsPerOrbit,
                ZoomLevel           = zoomLevel,
            };

            Assert.AreEqual(group.Position.X - orbitRadii[orbitRadiiIndex] * zoomLevel * (float)Math.Sin(-2 * Math.PI * skillsPerOrbitIndex / skillsPerOrbit[skillsPerOrbitIndex]), node.Position.X);
            Assert.AreEqual(group.Position.Y - orbitRadii[orbitRadiiIndex] * zoomLevel * (float)Math.Cos(-2 * Math.PI * skillsPerOrbitIndex / skillsPerOrbit[skillsPerOrbitIndex]), node.Position.Y);

            var newGroup = new JsonPassiveNodeGroup
            {
                OriginalX = x * 10,
                OriginalY = y * 10,
                ZoomLevel = zoomLevel,
            };

            node.PassiveNodeGroup = newGroup;
            node.ClearPositionCache();

            Assert.AreEqual(newGroup.Position.X - orbitRadii[orbitRadiiIndex] * zoomLevel * (float)Math.Sin(-2 * Math.PI * skillsPerOrbitIndex / skillsPerOrbit[skillsPerOrbitIndex]), node.Position.X);
            Assert.AreEqual(newGroup.Position.Y - orbitRadii[orbitRadiiIndex] * zoomLevel * (float)Math.Cos(-2 * Math.PI * skillsPerOrbitIndex / skillsPerOrbit[skillsPerOrbitIndex]), node.Position.Y);
        }
예제 #3
0
        public void JsonPassiveNodeGroup_Position(float x, float y, float zoomLevel)
        {
            var group = new JsonPassiveNodeGroup()
            {
                OriginalX = x,
                OriginalY = y,
                ZoomLevel = zoomLevel,
            };

            Assert.AreEqual(x * zoomLevel, group.Position.X);
            Assert.AreEqual(y * zoomLevel, group.Position.Y);
        }