Beispiel #1
0
    protected virtual void Update()
    {
        Debug.DrawRay(transform.position, transform.forward * 2, Color.red);

        if (useInputProvider)
        {
            if (inputProvider.SpecialKey1)
            {
                if (magnet != null)
                {
                    magnet.Attract();
                }
            }

            if (rotation != null)
            {
                rotation.CancelRotationByCollisionHit();
                rotation.Rotate(inputProvider.PitchValue, inputProvider.YawValue);
            }

            if (movement != null)
            {
                movement.Move();
            }
        }
        Animation();
    }
Beispiel #2
0
        public void ValueTypes()
        {
            var args = new string[] {
                "--string-value", $"{v1}",
                "--char-value", $"{v2}",
                "--integer-value", $"{v3}",
                "--long-value", $"{v4}",
                "--boolean-value", "true",
                "--float-value", $"{v5}",
                "--double-value", $"{v6}",
                "--decimal-value", $"{v7}"
            };

            var obj = new TypeObject();

            Magnet.Attract(obj, args);

            Assert.Equal(v1, obj.StringValue);
            Assert.Equal(v2, obj.CharValue);
            Assert.Equal(v3, obj.IntegerValue);
            Assert.Equal(v4, obj.LongValue);
            Assert.True(obj.BooleanValue);
            Assert.Equal(v5, obj.FloatValue);
            Assert.Equal(v6, obj.DoubleValue);
            Assert.Equal(v7, obj.DecimalValue);
        }
Beispiel #3
0
        public void IfPresentExceptionPass()
        {
            var args = new string[] {
                "--present-value",
                "--raise-ex"
            };

            var obj = new PresentPassObject();

            Magnet.Attract(obj, args);

            Assert.True(obj.PresentValue);
        }
Beispiel #4
0
        public void IfNotPresent()
        {
            var args = new string[] {
                "--required-value", "HelloWorld",
                "--default-value", "50"
            };

            var obj = new ComplexObject();

            Magnet.Attract(obj, args);

            Assert.False(obj.PresentValue);
        }
Beispiel #5
0
        public void ParseValue()
        {
            var args = new string[] {
                "--custom-point", "[-10,15]"
            };

            var obj = new CustomObject();

            Magnet.Attract(obj, args);

            Assert.Equal(-10, obj.Point.X);
            Assert.Equal(15, obj.Point.Y);
        }
Beispiel #6
0
        public void DefaultValue()
        {
            var args = new string[] {
                "--required-value", "HelloWorld",
                "--present-value"
            };

            var obj = new ComplexObject();

            Magnet.Attract(obj, args);

            Assert.Equal(25, obj.DefaultValue);
        }
Beispiel #7
0
        public void IsRequired()
        {
            var args = new string[] {
                "--required-value", "HelloWorld",
                "--present-value",
                "--default-value", "50"
            };

            var obj = new ComplexObject();

            Magnet.Attract(obj, args);

            Assert.Equal("HelloWorld", obj.RequiredValue);
        }
Beispiel #8
0
        public void OptionSet()
        {
            var args = new string[] {
                "--present-value",
                "--raise-ex",
                "--custom-point", "[-10,15]"
            };

            var obj = new OptionSetObject();

            Magnet.Attract(obj, args);

            Assert.True(obj.PObject.PresentValue);
            Assert.Equal(15, obj.CObject.Point.Y);
        }
Beispiel #9
0
        public void ParseValueException()
        {
            var args = new string[] {
                "--custom-point", "{-10,15}"
            };

            var obj = new CustomObject();

            Magnet.Attract(obj, args);

            Assert.Throws <FormatException>(delegate()
            {
                foreach (var ex in obj.Exceptions)
                {
                    throw ex;
                }
            });
        }
Beispiel #10
0
        public void IfPresentException()
        {
            var args = new string[] {
                "--present-value",
                "--raise-ex"
            };

            var obj = new PresentObject();

            Magnet.Attract(obj, args);

            Assert.Throws <IfPresentException>(delegate()
            {
                foreach (var ex in obj.Exceptions)
                {
                    throw ex;
                }
            });
        }
Beispiel #11
0
        public void IsRequiredException()
        {
            var args = new string[] {
                "--present-value",
                "--default-value", "50"
            };

            var obj = new ComplexObject();

            Magnet.Attract(obj, args);

            Assert.Throws <IsRequiredException>(delegate()
            {
                foreach (var ex in obj.Exceptions)
                {
                    throw ex;
                }
            });
        }