Example #1
0
        public void AddFixture(Item item)
        {
            if (Fixtures == null)
            {
                Fixtures = new List <Item>();
            }

            Fixtures.Add(item);
        }
        //---------------------------------------------------------------------------

        public void AddPath(Vector2 start, Vector2 end)
        {
            PhysicsComponent physics = GetComponent <PhysicsComponent>();

            if (physics != null)
            {
                Fixture fixture = FixtureFactory.AttachEdge(start / Unit, end / Unit, physics.Body, Entity);
                fixture.CollisionCategories = m_CategoryMapping[CollisionCategory];
                Fixtures.Add(fixture);
                //fixture.CollidesWith = m_CategoryMapping[CollidesWith];
            }
        }
Example #3
0
        public override void CreatePhysics(World world)
        {
            var bodyDef = CreateBodyDef();

            bodyDef.FixedRotation = true;
            bodyDef.Position      = ConvertToPhysicsVector(Position);
            bodyDef.BodyType      = BodyType.DynamicBody;

            var shape = new PolygonShape();

            shape.SetAsBox(30 * ScaleFactor, 30 * ScaleFactor);
            Body = world.CreateBody(bodyDef);
            Fixtures.Add(Body.CreateFixture(shape, 1));
        }
Example #4
0
        //---------------------------------------------------------------------------

        public void Init(int radius, Vector2 offset, BodyType bodyType, float dampening)
        {
            Radius = radius;

            PhysicsComponent physics = GetComponentInAncestor <PhysicsComponent>();

            if (physics != null)
            {
                Fixture fixture = FixtureFactory.AttachCircle(radius / Unit, 0, physics.Body, offset / Unit, Entity);
                fixture.Friction      = 0.0f;
                fixture.OnCollision  += OnCollision;
                fixture.OnSeparation += OnSeparation;
                Fixtures.Add(fixture);
            }
        }
Example #5
0
        //---------------------------------------------------------------------------

        public void Init(int width, int height, Vector2 offset, BodyType bodyType, float dampening)
        {
            ClearFixtures();

            Width  = width;
            Height = height;

            PhysicsComponent physics = GetComponentInAncestor <PhysicsComponent>();

            if (physics != null)
            {
                Fixture fixture = FixtureFactory.AttachRectangle(width / Unit, height / Unit, 0, offset / Unit, physics.Body, Entity);
                fixture.OnCollision  += OnCollision;
                fixture.OnSeparation += OnSeparation;
                Fixtures.Add(fixture);
            }
        }
Example #6
0
        public override void CreatePhysics(World world)
        {
            var bodyDef = CreateBodyDef();

            bodyDef.FixedRotation = true;
            bodyDef.Position      = ConvertToPhysicsVector(Position);
            bodyDef.BodyType      = BodyType.StaticBody;

            var shape = new CircleShape {
                Radius = 600 * ScaleFactor
            };

            Body = world.CreateBody(bodyDef);
            var fixture = Body.CreateFixture(shape, 1);

            Fixtures.Add(fixture);
            fixture.IsSensor = true;
        }
Example #7
0
        public override void CreatePhysics(World world)
        {
            var bodyDef = CreateBodyDef();

            bodyDef.FixedRotation = true;
            bodyDef.Position      = ConvertToPhysicsVector(Position);
            bodyDef.BodyType      = BodyType.KinematicBody;

            var shape = new PolygonShape();

            shape.SetAsBox(30 * ScaleFactor, 40 * ScaleFactor);
            Body = world.CreateBody(bodyDef);
            var fixture = Body.CreateFixture(shape, 1);

            Fixtures.Add(fixture);
            fixture.IsSensor = true;
            Body.IsBullet    = true;
        }
Example #8
0
        //---------------------------------------------------------------------------

        public void AddRect(int x, int y, int width, int height)
        {
            PhysicsComponent physics = GetComponent <PhysicsComponent>();

            if (physics != null)
            {
                Fixture fixture = FixtureFactory.AttachRectangle(width * 64.0f / Unit, height * 64.0f / Unit, 0, new Vector2((x + width / 2.0f) * 64.0f / Unit, (y + height / 2.0f) * 64.0f / Unit), physics.Body, Entity);
                fixture.CollisionCategories = m_CategoryMapping[CollisionCategory];
                fixture.CollidesWith        = m_CategoryMapping[CollidesWith];
                fixture.IsSensor            = true;
                fixture.OnCollision        += OnCollision;
                fixture.OnSeparation       += OnSeparation;
                Fixtures.Add(fixture);

                Rects.Add(new Rectangle(x * 64, y * 64, width * 64, height * 64));

                AreaManager.Get().AddAreaRect(Entity, x, y, width, height);
            }
        }
Example #9
0
    public void PlaceFixture(string objType, Tile tile)
    {
        //TODO: This function assumes 1x1 no rotation objects

        if (!FixturePrototypes.ContainsKey(objType))
        {
            Debug.LogError("FixtureProtoypes does not contain a definition for: " + objType);
            return;
        }

        Fixture obj = Fixture.PlaceInstance(FixturePrototypes [objType], tile);

        if (obj == null)
        {
            Debug.LogError("World:PlaceInstance returned a null object");
            return;
        }
        Fixtures.Add(obj);
        InvalidateTileGraph();
        if (cbFixtureCreated != null)
        {
            cbFixtureCreated(obj);
        }
    }
Example #10
0
        private bool AddInternal(Type type)
        {
            var typeInfo = type.GetTypeInfo();

            if (TestHelper.HasTests(typeInfo) == false)
            {
                return(false);                                         // does not contain any tests, skip it
            }
            var attrs = TestHelper.GetTestFixtureAttributes(typeInfo); // maybe there is no TestFixture attribute

            if (attrs.Count() == 0)
            {
                Fixtures.Add(new TestFixture(typeInfo, null)); // no TestFixture attribute on the class
            }
            else
            {
                foreach (var testFixtureAttribute in attrs)
                {
                    Fixtures.Add(new TestFixture(typeInfo, testFixtureAttribute));
                }
            }

            return(true);
        }
Example #11
0
        /// <summary>
        /// Sets up the form
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //setup for testing
            CoreExtensions.Host.InitializeService();
            //get the test suite
            TestSuite suite = TestUtility.GetTestSuite(Constants.DefaultWebTestAssembly);

            //get dictionaries for forms and querying
            foreach (TestMethod tm in suite.GetMethods())
            {
                Methods.Add(tm.TestName.FullName, tm);
            }
            foreach (TestFixture tf in suite.GetFixtures())
            {
                Fixtures.Add(tf.ClassName, tf);
            }
            foreach (TestEnvironment t in EnvironmentProvider.GetEnvironments().OrderBy(a => a.Name))
            {
                Environments.Add(t.ID, t);
            }
            foreach (TestSystem tsys in SystemProvider.GetSystems().OrderBy(a => a.Name))
            {
                Systems.Add(tsys.ID, tsys);
            }
            foreach (TestSite ts in SiteProvider.GetEnabledSites().OrderBy(a => a.SystemID).ThenBy(a => a.Name))
            {
                try {
                    Sites.Add(ts.ID, ts);
                } catch (ArgumentException aex) {
                    throw new ArgumentException(string.Format("This key has already been added: {0}-{1}", ts.SystemID, ts.Name));
                }
            }

            ltlResults.Text = string.Empty;             //reset output
            ltlError.Text   = string.Empty;
            ltlLog.Text     = string.Empty;

            if (!IsPostBack)               //setup form
            {
                foreach (KeyValuePair <string, TestFixture> kvp in Fixtures)
                {
                    ListItem li = new ListItem(TestUtility.GetClassName(kvp.Value.ClassName), kvp.Value.TestName.FullName);
                    cblTests.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestEnvironment> ekvp in Environments)
                {
                    ListItem li = new ListItem(ekvp.Value.Name, ekvp.Key.ToString());
                    cblEnv.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSystem> sykvp in Systems)
                {
                    ListItem li = new ListItem(sykvp.Value.Name, sykvp.Value.Name);
                    cblSystems.Items.Add(li);
                }
                foreach (KeyValuePair <int, TestSite> skvp in Sites)
                {
                    ListItem li = new ListItem(string.Format("{1}<span class='systemName'>{0}</span>", Systems[skvp.Value.SystemID].Name, skvp.Value.Name), skvp.Key.ToString());
                    li.Attributes.Add("class", Systems[skvp.Value.SystemID].Name);
                    cblSites.Items.Add(li);
                }
            }
            else
            {
                foreach (ListItem li in cblSites.Items)                   //css classes get lost on postback
                {
                    li.Attributes.Add("class", Systems[Sites[int.Parse(li.Value)].SystemID].Name);
                }
            }
        }
Example #12
0
        public void AddFixture(Item item)
        {
            Fixtures ??= new List <Item>();

            Fixtures.Add(item);
        }