Beispiel #1
0
        //---------------------------------------------------------------------------

        public Bullet(string name, Guid parent) : base(name, parent)
        {
            AddComponent <TransformComponent>();
            AddComponent <BulletPhysicsComponent>();
            AddComponent <SpriteComponent>().Init(AssetManager.Get().Find <Texture2D>(ESpriteAssets.RedOrb));
            AddComponent <LightingComponent>().Init(AssetManager.Get().Find <Texture2D>(ESpriteAssets.RedOrb), Vector2.Zero, Vector2.One * 2, Color.White, 0.5f);

            CircleColliderComponent collider = AddComponent <CircleColliderComponent>();

            collider.Init(4, BodyType.Dynamic);
            collider.SetSensor(true);
            collider.SetCollisionCategory(ECollisionCategory.Bullet);
            collider.SetCollidesWith(ECollisionCategory.Stage);
            collider.Enter += OnHit;

            AddComponent <DespawnComponent>();
        }
Beispiel #2
0
        //---------------------------------------------------------------------------

        private static Pickup Create(string name, Vector3 location, Vector3 force)
        {
            Pickup pickup = EntityFactory.Create <Pickup>(string.Format("{0}Pickup", name));

            pickup.AddComponent <TransformComponent>().Init(location);

            PhysicsComponent physics = pickup.AddComponent <PhysicsComponent>();

            physics.Init(BodyType.Dynamic, 0.97f, 2.0f);

            CircleColliderComponent collider = pickup.AddComponent <CircleColliderComponent>();

            collider.Init(25, BodyType.Dynamic);
            collider.SetCollidesWith(ECollisionCategory.Stage);
            collider.SetCollisionCategory(ECollisionCategory.Pickup);
            collider.SetRestitution(0.3f);
            //collider.SetSensor(true);

            physics.ApplyForce(force, true);

            pickup.AddComponent <DespawnComponent>();
            return(pickup);
        }