Ejemplo n.º 1
0
        public Bullet(Vector2 position, World world) : base(world) {

            trail = ParticleEmitter.SpawnBulletTrail(ConvertUnits.ToDisplayUnits(position));

            body = BodyFactory.CreateCircle(world, ConvertUnits.ToSimUnits(0.5f), 1, position);
            body.BodyType = BodyType.Dynamic;
            body.CollidesWith = Category.Cat4;
            body.CollisionCategories = Category.Cat5;
            body.Restitution = 1.0f;
            body.Friction = 0.0f;
            body.OnCollision += OnCollision;
            body.LinearVelocity = new Vector2(0, -25);

            body.UserData = this;

        }
Ejemplo n.º 2
0
        public Ball(Player player, Vector2 position, float radius, float maxY, World world) : base(world) {
            this.player = player;
            this.radius = ConvertUnits.ToSimUnits(player.BallRadius);
            this.maxY = maxY;

            switch (player.Index)
            {
                case PlayerIndex.One:
                    trail = ParticleEmitter.SpawnGenericProjectileEmitterRed(ConvertUnits.ToDisplayUnits(position));
                    break;
                case PlayerIndex.Two:
                    trail = ParticleEmitter.SpawnGenericProjectileEmitterBlue(ConvertUnits.ToDisplayUnits(position));
                    break;
                default:
                    trail = ParticleEmitter.SpawnGenericProjectileEmitterRed(ConvertUnits.ToDisplayUnits(position));
                    break;
            }

            trail.startScale = 0.5f * ConvertUnits.ToDisplayUnits(this.radius) / 10.0f;
            trail.endScale = 0.05f * ConvertUnits.ToDisplayUnits(this.radius) / 10.0f;


            body = BodyFactory.CreateCircle(world, this.radius, 1, position);
            body.BodyType = BodyType.Dynamic;
            body.CollidesWith = Category.Cat2 | Category.Cat4;
            body.CollisionCategories = Category.Cat1;
            body.Restitution = 1.0f;
            body.Friction = 0.0f;
            body.OnCollision += OnCollision;

            //body.ApplyLinearImpulse(new Vector2(-0.2f, -1f)*0.8f);
            body.UserData = this;

            speed = Owner.BallSpeed;
            //body.LinearVelocity = Vector2.Normalize(new Vector2(-1f, -1f))*10f;
        }
 //Factory methods for making a few different emitter types
 public static ParticleEmitter SpawnSmokeEmitter(Texture2D tex, Vector2 position) {
     ParticleEmitter pe = new ParticleEmitter(tex, position);
     pe.spawnDelay = 0.001f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMax = 120;
     pe.angleMin = 60;
     pe.speedMin = 90;
     pe.speedMax = 150;
     pe.lifetimeMin = 0.6f;
     pe.lifetimeMax = 1.2f;
     pe.startColor = Color.White;
     pe.endColor = Color.Black;
     //pe.endColor.A = 120;
     pe.startScale = 0.6f;
     pe.endScale = 2.0f;
     pe.acceleration = new Vector2(0, 600);
     return pe;
 }
 public static ParticleEmitter SpawnToxicEmitter(Texture2D tex, Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(tex, position);
     pe.spawnDelay = 0.05f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = 0;
     pe.angleMax = 360;
     pe.speedMin = 50;
     pe.speedMax = 100;
     pe.lifetimeMin = 3f;
     pe.lifetimeMax = 5f;
     pe.startColor = Color.LimeGreen;
     pe.endColor = Color.Teal;
     //pe.endColor.A = 120;
     pe.startScale = 3f;
     pe.endScale = 5f;
     return pe;
 }
 public static ParticleEmitter SpawnShowerEmitter(Texture2D tex, Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(tex, position);
     pe.spawnDelay = 0.0005f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = -135;
     pe.angleMax = -45;
     pe.speedMin = 500;
     pe.speedMax = 800;
     pe.lifetimeMin = 0.1f;
     pe.lifetimeMax = 0.3f;
     pe.startColor = Color.White;
     pe.endColor = Color.Blue;
     //pe.endColor.A = 120;
     pe.startScale  = 0.15f;
     pe.endScale = 0.08f;
     return pe;
 }
 public static ParticleEmitter SpawnExplosionEmitter(Texture2D tex, Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(tex, position);
     pe.spawnDelay = 0.001f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = 0;
     pe.angleMax = 360;
     pe.speedMin = 300;
     pe.speedMax = 900;
     pe.lifetimeMin = 0.2f;
     pe.lifetimeMax = 0.5f;
     pe.startColor = Color.Yellow;
     pe.endColor = Color.Red;
     pe.endColor.A = 120;
     pe.startScale = 2.5f;
     pe.endScale = 0.3f;
     return pe;
 }
 public static ParticleEmitter SpawnFireEmitter(Texture2D tex, Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(tex, position);
     pe.spawnDelay = 0.002f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = 70;
     pe.angleMax = 110;
     pe.speedMin = 150;
     pe.speedMax = 250;
     pe.lifetimeMin = 0.3f;
     pe.lifetimeMax = 0.9f;
     pe.startColor = Color.Yellow;
     pe.endColor = Color.Red;
     pe.endColor.A = 50;
     pe.startScale = 2.5f;
     pe.endScale = 0.3f;
     return pe;
 }
 public static ParticleEmitter SpawnBulletTrail(Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(AssetManager.GetTexture("softparticle"), position);
     pe.spawnDelay = 0.0001f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = 250;
     pe.angleMax = 290;
     pe.speedMin = 60;
     pe.speedMax = 100;
     pe.lifetimeMin = 0.05f;
     pe.lifetimeMax = 0.2f;
     pe.startColor = Color.White;
     pe.endColor = Color.Yellow;
     pe.endColor.A = 200;
     pe.startScale = 0.6f;
     pe.endScale = 0.03f;
     return pe;
 }
 public static ParticleEmitter SpawnGenericProjectileEmitterRed(Vector2 position)
 {
     ParticleEmitter pe = new ParticleEmitter(AssetManager.GetTexture("softparticle"), position);
     pe.spawnDelay = 0.002f;
     pe.spawnTimer = pe.spawnDelay;
     pe.angleMin = 0;
     pe.angleMax = 360;
     pe.speedMin = 80;
     pe.speedMax = 150;
     pe.lifetimeMin = 0.05f;
     pe.lifetimeMax = 0.2f;
     pe.startColor = Color.Crimson;
     pe.endColor = Color.Yellow;
     pe.endColor.A = 200;
     pe.startScale = 0.5f;
     pe.endScale = 0.05f;
     return pe;
 }