Make an emitter if you want a continous stream of particles from some location (which can move) If you just want one spew of particles, use the method World.MakeParticles. This will probably be overwritten eventually
Пример #1
0
        public Player(Texture2D texture, Vector2 position, Character character, LinkedListNode<Vector2> checkpoint)
            : base(texture, position, new Vector2(GameData.PLAYER_WIDTH, GameData.PLAYER_HEIGHT))
        {
            Color = character.Color;
            CurrentCharacter = character;
            SpawnedPlatform = null;
            ClonedPlayer = null;
            Score = 0;
            Checkpoints = 0;
            Progress = 0;
            Place = 0;
            Node = checkpoint;
            MaxVelocity = GameData.MAX_VELOCITY;

            ResetValues();

            int[] animationFrames = { 4, 4, 2, 4, 2, 1, 1 };
            Origin = new Vector2(Origin.X / animationFrames.Max(), Origin.Y / animationFrames.Length);
            float textureScale = GameData.PLAYER_HEIGHT / Origin.Y / 2f * (20f / 18f);
            Sprite = new AnimatedSprite(texture, this, animationFrames, textureScale);

            SlideEmitter = new ParticleEmitter(GameData.SLIDE_TEXTURES, Position, 75f);
            SlideEmitter.Red = SlideEmitter.Blue = SlideEmitter.Green = 1f;
            SlideEmitter.RedVar = SlideEmitter.BlueVar = SlideEmitter.GreenVar = 0f;
            SlideEmitter.AngVelVar = 0.001f;
            SlideEmitter.LiveTime = 5f;
            SlideEmitter.VelVarX = SlideEmitter.VelVarY = 0.5f;

            JetpackEmitter = new ParticleEmitter(GameData.JETPACK_TEXTURES, Position, 140f);
            JetpackEmitter.Size = 1.5f;
            JetpackEmitter.Red = 0.62f;
            JetpackEmitter.Blue = 0.16f;
            JetpackEmitter.Green = 0.1f;
            JetpackEmitter.RedVar = JetpackEmitter.BlueVar = JetpackEmitter.GreenVar = 0f;
        }
Пример #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Content.RootDirectory = "Content";
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO figure out why multiple songs do not work well with muting
            // Load the songs
            //songs = new List<Song>();
            //songs.Add(Content.Load<Song>("Music/Air Skate"));
            //songs.Add(Content.Load<Song>("Music/Main Menu"));
            //songs.Add(Content.Load<Song>("Music/Character Select"));
            Song song = Content.Load<Song>("Music/Air Skate");
            MediaPlayer.Play(song);
            MediaPlayer.IsRepeating = true;
            MediaPlayer.Volume = GameData.VOLUME;
            MediaPlayer.IsMuted = GameData.MUTED;

            // Set up user interface
            SpriteFont font = Content.Load<SpriteFont>("Fonts/Segoe_UI_15_Bold");
            FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(font);
            viewModel = new BasicUIViewModel();
            FontManager.Instance.LoadFonts(Content, "Fonts");

            StringBuilder builder = new StringBuilder();
            for (int i = 0; i < playerControls.Count; i++)
            {
                builder.Append("Player ").AppendLine((i + 1).ToString())
                    .AppendLine(playerControls[i].ToString());
            }
            viewModel.ControlsText = builder.ToString();
            Console.WriteLine(builder.ToString());
            //viewModel.ControlsText = "Hello!\nWhoo!!";

            viewModel.MaxPlayers = GameData.MAX_PLAYERS;
            viewModel.LevelValue = GameData.LEVEL_FILE;
            viewModel.PlayerValue = GameData.DEFAULT_PLAYERS;

            LoadUI(Menu.Main);

            //InitializePlayers();

            // Use this to draw any rectangles
            whiteRect = new Texture2D(GraphicsDevice, 1, 1);
            whiteRect.SetData(new[] { Color.White });

            smear = Content.Load<Texture2D>("Art/smear");

            // Load assets in the Content Manager
            //background = Content.Load<Texture2D>("Art/skyscrapers");
            LoadBackground(2);
            fontSmall = Content.Load<SpriteFont>("Fonts/Score");
            fontBig = Content.Load<SpriteFont>("Fonts/ScoreBig");

            // Create objects
            platforms = new List<Platform>();
            particles = new List<Particle>();
            obstacles = new List<Obstacle>();
            drops = new List<Drop>();
            world = new World(this);

            // Initialize camera
            int width = graphics.GraphicsDevice.Viewport.Width;
            int height = graphics.GraphicsDevice.Viewport.Height;
            cameraBounds = new Rectangle((int)(width * GameData.SCREEN_LEFT), (int)(height * GameData.SCREEN_TOP),
                (int)(width * (GameData.SCREEN_RIGHT - GameData.SCREEN_LEFT)), (int)(height * (1 - 2 * GameData.SCREEN_TOP)));
            screenCenter = cameraBounds.Center.ToVector2();

            // Define particles
            List<Texture2D> particleTextures = new List<Texture2D>();
            particleTextures.Add(Content.Load<Texture2D>("Particles/circle"));
            particleTextures.Add(Content.Load<Texture2D>("Particles/star"));
            particleTextures.Add(Content.Load<Texture2D>("Particles/diamond"));

            particleEmitter = new ParticleEmitter(particleTextures, GameData.PLAYER_START, 1f);
            particleEmitter.VelVarX = particleEmitter.VelVarY = 5f;
            particleEmitter.LiveTime = 8f;

            GameData.SLIDE_TEXTURES = new List<Texture2D>();
            GameData.SLIDE_TEXTURES.Add(Content.Load<Texture2D>("Particles/smoke"));

            GameData.JETPACK_TEXTURES = new List<Texture2D>();
            GameData.JETPACK_TEXTURES.Add(Content.Load<Texture2D>("Particles/gradient"));

            GameData.ROCKET_TEXTURES = new List<Texture2D>();
            GameData.ROCKET_TEXTURES.Add(Content.Load<Texture2D>("Particles/gradient"));
        }