Esempio n. 1
0
        public override Vector2 GetSpeed(Emitter emitter, Particle particle)
        {
            //Get direction
            Vector2 direction = new Vector2(emitter.Position.X - particle.Position.X, emitter.Position.Y - particle.Position.Y);
            //Calculate speed
            float speed = MathHelper.Lerp(minSpeed, maxSpeed, (float)random.NextDouble());

            //Calculate final vector
            return direction / direction.Length() * speed;
        }
Esempio n. 2
0
        public World(Rectangle rect, int offset, ControlMode controlMode, bool muteShape = true)
        {
            this.rect = rect;
            this.borderOffset = offset;
            this.controlMode = controlMode;
            this.mute = muteShape;

            this.currentShape = new Shape(this, controlMode);

            //Combo emitters
            List<ParticleModifier> p = new List<ParticleModifier>();
            p.Add(new GravityModifier(new Vector2(0, -0.5f)));
            p.Add(new RandomSpeedModifier(new Vector2(0.1f, 0.1f)));
            this.comboEmitter = new Emitter(rect.Width / 100f, 0f, Color.Orange * 0.6f, Color.Red, 20, 1, new RandomSpawnSpeed(Vector2.Zero, Vector2.Zero), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, rect.Height), p);
            this.comboEmitter.Position = new Vector2(rect.Center.X, rect.Center.Y);

            List<ParticleModifier> cp = new List<ParticleModifier>();
            cp.Add(new GravityModifier(new Vector2(0, -0.5f)));
            cp.Add(new RandomSpeedModifier(new Vector2(1f, 1f)));
            this.epicComboEmitter = new Emitter(rect.Width / 90f, 0f, Color.Orange * 0.5f, Color.Blue, 20, 1.5f, new RandomSpawnSpeed(Vector2.Zero), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, rect.Height), cp);
            this.epicComboEmitter.Position = new Vector2(rect.Center.X, rect.Center.Y);

            //Get rect of one block for size
            Rectangle blockRect = CalculateBlockRectangle(0,0);
            List<ParticleModifier> ep = new List<ParticleModifier>();
            ep.Add(new GravityModifier(new Vector2(0, 0.3f)));
            explosionEmitter = new Emitter(
                (float)blockRect.Width / (float)Assets.Textures.Block.Width,
                (float)blockRect.Width / (float)Assets.Textures.Block.Width,
                Color.Red,
                Color.Red,
                1,
                2f,
                new RandomSpawnSpeed(new Vector2(12, -rect.Width / 30), new Vector2(-12, -rect.Width / 50)),
                Assets.Textures.Block,
                new RectangleSpawnShape(0, 0),
                ep
            );
            stats = new Stats(Assets.Fonts.BasicFont, Color.White, rect);

            //Tetris emitter
            tetrisEmitter = new Emitter(rect.Width / 100f, 0f, Color.Red * 0.4f, Color.Blue, 100, 0.5f, new RandomSpawnSpeed(new Vector2(-30,-9), new Vector2(30,-4)), Assets.Textures.Particle, new RectangleSpawnShape(rect.Width, 0), new List<ParticleModifier>());
            tetrisEmitter.Position = new Vector2(rect.Center.X, rect.Bottom);
        }
Esempio n. 3
0
 public override Vector2 GetSpeed(Emitter emitter, Particle particle)
 {
     return new Vector2(MathHelper.Lerp(minSpeed.X, maxSpeed.X, (float)random.NextDouble()), MathHelper.Lerp(minSpeed.Y, maxSpeed.Y, (float)random.NextDouble()));
 }
Esempio n. 4
0
 public abstract Vector2 GetSpeed(Emitter emitter, Particle particle);
Esempio n. 5
0
 static void BuildMenu(Action quit)
 {
     mainMenu = new Menu(new List<Button>() {
     new Button(new Rectangle(180, 330, 140, 50), Color.Transparent, Color.White * 0.3f, "Endless", Assets.Fonts.BasicFont, Color.White, StartSP),
     new Button(new Rectangle(330, 330, 140, 50), Color.Transparent, Color.White * 0.3f, "Battle mode", Assets.Fonts.BasicFont, Color.White, StartMP),
     new Button(new Rectangle(490, 330, 140, 50), Color.Transparent, Color.White * 0.3f, "Exit game", Assets.Fonts.BasicFont, Color.White, quit),
     new Button(new Rectangle(320, 400, 160, 50), Color.Transparent, Color.White * 0.3f, "Achievements", Assets.Fonts.BasicFont, Color.White, ToAchievements)
     });
     pausedMenu = new Menu(new List<Button>() {
     new Button(new Rectangle(60, 80, 195, 50), Color.Black * 0.5f, Color.White * 0.3f, "Continue", Assets.Fonts.BasicFont, Color.White, Continue),
     new Button(new Rectangle(60, 150, 195, 50), Color.Black * 0.5f, Color.White * 0.3f, "Back to main menu", Assets.Fonts.BasicFont, Color.White, ToMenu)
     });
     gameOverMenu = new Menu(new List<Button>() {
     new Button(new Rectangle(60, 150, 195, 50), Color.Black * 0.5f, Color.White * 0.3f, "Back to main menu", Assets.Fonts.BasicFont, Color.White, ToMenu)
     });
     mpGameOverMenu = new Menu(new List<Button>() {
     new Button(new Rectangle(300, 330, 200, 50), Color.Transparent, Color.White * 0.3f, "Back to main menu", Assets.Fonts.BasicFont, Color.White, ToMenu)
     });
     achievementsMenu = new Menu(new List<Button>() {
     new Button(new Rectangle(590, 10, 200, 50), Color.Transparent, Color.White * 0.3f, "Back to main menu", Assets.Fonts.BasicFont, Color.White, ToMenu),
     new Button(new Rectangle(0, 440, 80, 40), Assets.Textures.ArrowLeft, ScrollRight),
     new Button(new Rectangle(720, 440, 80, 40), Assets.Textures.ArrowRight, ScrollLeft)
     });
     //Create the menu emitter
     List<ParticleModifier> p = new List<ParticleModifier>();
     p.Add(new GravityModifier(new Vector2(0, -0.07f)));
     p.Add(new RandomSpeedModifier(new Vector2(0.1f, 0.1f)));
     menuEmitter = new Emitter(2, 0.5f, Color.Orange * 0.6f, Color.Red * 0.7f, 20, 1, new RandomSpawnSpeed(Vector2.Zero, Vector2.Zero), Assets.Textures.Particle, new RectangleSpawnShape(800, 0), p);
     menuEmitter.ForcePosition(new Vector2(400, 500));
 }