Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        //Target not assigned through the inspector
        if (Target == null)
        {
            //Search Target with Tag
            //Target = GameObject.FindGameObjectWithTag("Target");

            //Search Target with GameObject Name
            //This method should be avoided
            //Target = GameObject.Find("Target");

            //Search Target GameObject with associated class
            //Finding GameObject with associated scripts is the most robust and secure way

            SimpleTarget simpleTarget = GameObject.FindObjectOfType <SimpleTarget>();
            if (simpleTarget != null)
            {
                Target = simpleTarget.gameObject;
            }
        }

        //Snap to target is only for demonstration purposes: SnapToTarget should ALWAYS be false
        if (SnapToTarget && Target != null)
        {
            gameObject.transform.position = Target.transform.position;
        }
    }
Exemplo n.º 2
0
        public static Target BeginTarget(this Mobile m, int range, bool allowGround, TargetFlags flags, TargetCallback callback)
        {
            Target t = new SimpleTarget(range, flags, allowGround, callback);

            m.Target = t;

            return(t);
        }
        public void default_values_with_a_simple_type()
        {
            var target      = new SimpleTarget();
            var description = Description.For(target);

            description.BulletLists.Any().ShouldBeFalse();
            description.LongDescription.ShouldBeNull();
            description.Title.ShouldEqual(typeof(SimpleTarget).Name);
            description.ShortDescription.ShouldEqual(target.ToString());
        }
        public void WithConstructor()
        {
            var mockCtor = new Mock <Func <SimpleTarget> >(MockBehavior.Strict);
            var target   = new SimpleTarget();

            mockCtor.Setup(x => x()).Returns(target);

            var mapper = FluentMapper
                         .ThatMaps <SimpleTarget>().From <SimpleSource>()
                         .WithConstructor(mockCtor.Object)
                         .Create();

            var result = mapper.Map(new SimpleSource());

            mockCtor.Verify(x => x(), Times.Once());
        }
Exemplo n.º 5
0
        public void sets_the_properties()
        {
            var target = new SimpleTarget {
                Key = "test", Value = "value"
            };
            var writer = ObjectBlockWriter.Basic();

            var block = writer.BlockFor(target);

            Action <string, string> assert = (name, value) =>
            {
                var result = block.FindProperty(name);
                result.ShouldNotBeNull();
                result.Name.ShouldEqual(name.FirstLetterLowercase());
                result.Value.ShouldEqual(value);
            };

            assert("Key", "test");
            assert("Value", "value");
        }
Exemplo n.º 6
0
        public Target BeginTarget( int range, bool allowGround, TargetFlags flags, TargetCallback callback )
        {
            Target t = new SimpleTarget( range, flags, allowGround, callback );

            this.Target = t;

            return t;
        }
Exemplo n.º 7
0
        public void default_values_with_a_simple_type()
        {
            var target = new SimpleTarget();
            var description = Description.For(target);

            description.BulletLists.Any().ShouldBeFalse();
            description.LongDescription.ShouldBeNull();
            description.Title.ShouldEqual(typeof (SimpleTarget).Name);
            description.ShortDescription.ShouldEqual(target.ToString());
        }
        public void WithConstructor()
        {
            var mockCtor = new Mock<Func<SimpleTarget>>(MockBehavior.Strict);
            var target = new SimpleTarget();
            mockCtor.Setup(x => x()).Returns(target);

            var mapper = FluentMapper
                .ThatMaps<SimpleTarget>().From<SimpleSource>()
                .WithConstructor(mockCtor.Object)
                .Create();

            var result = mapper.Map(new SimpleSource());

            mockCtor.Verify(x => x(), Times.Once());
        }