summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/BoxProfile.cs
blob: 7d31984c569e7c57af03fc4939359dfd0931cbb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using Microsoft.Xna.Framework;

namespace MonoGame.Extended.Particles.Profiles
{
    public class BoxProfile : Profile
    {
        public float Width { get; set; }
        public float Height { get; set; }

        public override void GetOffsetAndHeading(out Vector2 offset, out Vector2 heading)
        {
            switch (Random.Next(3))
            {
                case 0: // Left
                    offset = new Vector2(Width*-0.5f, Random.NextSingle(Height*-0.5f, Height*0.5f));
                    break;
                case 1: // Top
                    offset = new Vector2(Random.NextSingle(Width*-0.5f, Width*0.5f), Height*-0.5f);
                    break;
                case 2: // Right
                    offset = new Vector2(Width*0.5f, Random.NextSingle(Height*-0.5f, Height*0.5f));
                    break;
                default: // Bottom
                    offset = new Vector2(Random.NextSingle(Width*-0.5f, Width*0.5f), Height*0.5f);
                    break;
            }

            Random.NextUnitVector(out heading);
        }
    }
}