示例#1
0
        public void Assignment_X_ModifiesScale_AndNotOriginal()
        {
            float originalX = 10;
            float originalY = 20;
            float scaleX    = 30;
            float scaleY    = 40;
            float newScaleX = 50;
            float expected  = originalX * newScaleX;
            var   original  = Vector.Create(originalX, originalY);
            var   scale     = Vector.Create(scaleX, scaleY);
            var   source    = new ScalingVector(original, scale);

            source.X = newScaleX;

            Assert.AreEqual(source.Scale.X, newScaleX);
            Assert.AreEqual(source.X, expected);
            Assert.AreEqual(source.Base.X, originalX);
        }
示例#2
0
        public void ScalingVector_NestedOriginal()
        {
            float originalX = 10;
            float originalY = 20;
            float scaleX    = 30;
            float scaleY    = 40;
            float expectedX = originalX * scaleX * scaleX;
            float expectedY = originalY * scaleY * scaleY;

            var original = Vector.Create(originalX, originalY);
            var scale    = Vector.Create(scaleX, scaleY);

            ScalingVector nestedOriginal = new ScalingVector(original, scale);
            ScalingVector source         = new ScalingVector(nestedOriginal, scale);

            Assert.AreEqual(source.X, expectedX);
            Assert.AreEqual(source.Y, expectedY);
        }
示例#3
0
        public void Constructor_SharedVector_Float_Float()
        {
            float originalX = 10;
            float originalY = 20;
            float scaleX    = 30;
            float scaleY    = 40;
            float expectedX = originalX * scaleX;
            float expectedY = originalY * scaleY;
            var   original  = Vector.Create(originalX, originalY);
            var   source    = new ScalingVector(original, scaleX, scaleY);

            Assert.AreEqual(source.Scale.X, scaleX);
            Assert.AreEqual(source.Scale.Y, scaleY);
            Assert.AreEqual(source.Base.X, originalX);
            Assert.AreEqual(source.Base.Y, originalY);
            Assert.AreEqual(source.X, expectedX);
            Assert.AreEqual(source.Y, expectedY);
        }
示例#4
0
        public void CameraFocus(Player player)
        {
            var   v     = player.Position;
            float count = 1;

            for (int i = 0; i < this.players.Length; i++)
            {
                if (i == player._joystickID)
                {
                    continue;
                }

                if (this.players[i] == null)
                {
                    continue;
                }
                v = new OffsetVector(v, this.players[i].Position);
                count++;
            }
            v = new ScalingVector(v, 1 / count, 1 / count);
            GameWindow.Singleton.Canvas.GetCamera().Follow(v);
        }