1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using Microsoft.Xna.Framework; |
---|
5 | using Microsoft.Xna.Framework.Audio; |
---|
6 | using Microsoft.Xna.Framework.Content; |
---|
7 | using Microsoft.Xna.Framework.GamerServices; |
---|
8 | using Microsoft.Xna.Framework.Graphics; |
---|
9 | using Microsoft.Xna.Framework.Input; |
---|
10 | using Microsoft.Xna.Framework.Media; |
---|
11 | using Microsoft.Xna.Framework.Net; |
---|
12 | using Microsoft.Xna.Framework.Storage; |
---|
13 | |
---|
14 | namespace Effects |
---|
15 | { |
---|
16 | public class Particle |
---|
17 | { |
---|
18 | |
---|
19 | #region Variables, getters and setters |
---|
20 | |
---|
21 | private Vector2 position; |
---|
22 | public Vector2 Position |
---|
23 | { |
---|
24 | get { return position; } |
---|
25 | set { position = value; } |
---|
26 | } |
---|
27 | |
---|
28 | private Texture2D texture; |
---|
29 | public Texture2D Texture |
---|
30 | { |
---|
31 | get { return texture; } |
---|
32 | set { texture = value; } |
---|
33 | } |
---|
34 | |
---|
35 | private float scale; |
---|
36 | public float Scale |
---|
37 | { |
---|
38 | get { return scale; } |
---|
39 | set { scale = value; } |
---|
40 | } |
---|
41 | |
---|
42 | private float rotation; |
---|
43 | public float Rotation |
---|
44 | { |
---|
45 | get { return rotation; } |
---|
46 | set { rotation = value; } |
---|
47 | } |
---|
48 | |
---|
49 | private Vector2 origin; |
---|
50 | public Vector2 Origin |
---|
51 | { |
---|
52 | get { return origin; } |
---|
53 | set { origin = value; } |
---|
54 | } |
---|
55 | |
---|
56 | private Vector2 velocity; |
---|
57 | public Vector2 Velocity |
---|
58 | { |
---|
59 | get { return velocity; } |
---|
60 | set { velocity = value; } |
---|
61 | } |
---|
62 | |
---|
63 | private bool alive; |
---|
64 | public bool Alive |
---|
65 | { |
---|
66 | get { return alive; } |
---|
67 | set { alive = value; } |
---|
68 | } |
---|
69 | |
---|
70 | private float lifetime; |
---|
71 | public float Lifetime |
---|
72 | { |
---|
73 | get { return lifetime; } |
---|
74 | set { lifetime = value; } |
---|
75 | } |
---|
76 | |
---|
77 | private float currentTime; |
---|
78 | public float CurrentTime |
---|
79 | { |
---|
80 | get { return currentTime; } |
---|
81 | set { currentTime = value; } |
---|
82 | } |
---|
83 | |
---|
84 | #endregion |
---|
85 | |
---|
86 | public void Initialize(Vector2 position, float scale, float rotation, Vector2 velocity, float lifetime) |
---|
87 | { |
---|
88 | this.alive = true; |
---|
89 | this.position = position; |
---|
90 | this.scale = scale; |
---|
91 | this.lifetime = lifetime; |
---|
92 | this.rotation = rotation; |
---|
93 | this.origin = new Vector2(texture.Width / 2, texture.Height / 2); |
---|
94 | |
---|
95 | this.currentTime = 0.0f; |
---|
96 | } |
---|
97 | |
---|
98 | /// <summary> |
---|
99 | /// Updates particles position |
---|
100 | /// TODO: |
---|
101 | /// - Update for rotation, velocity etc. |
---|
102 | /// </summary> |
---|
103 | /// <param name="time"></param> |
---|
104 | public void Update(float time) |
---|
105 | { |
---|
106 | this.position = velocity * time; |
---|
107 | this.currentTime += time; |
---|
108 | } |
---|
109 | } |
---|
110 | } |
---|