-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layer.cs
115 lines (95 loc) · 2.74 KB
/
Layer.cs
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*-----------------------------------------
* Layer.cs
* Arthur Ward Jr
* Quantum Box
* Version 0.1
*
* Defines a drawable object layer
* This class stores helps to organize objects into seperate layers for drawing and collision purposes
*
-----------------------------------------*/
#region Using
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Rain.Objects;
#endregion
namespace Rain
{
class Layer
{
private float scrollRateX;
private float scrollRateY;
private List<GameObject> objects;
private Boolean visible;
private int layerZOrder;
public Layer(float scrollX, float scrollY, int zorder = 0, Boolean vis = true)
{
scrollRateX = scrollX;
scrollRateY = scrollY;
visible = vis;
objects = new List<GameObject>();
layerZOrder = zorder;
}
//Adds a game object to this layer
public void add(GameObject obj)
{
objects.Add(obj);
}
//Removes a game object from this layer
public Boolean remove(GameObject obj)
{
return objects.Remove(obj);
}
public void update(GameTime gameTime)
{
for (int i = 0; i < objects.Count; i++)
if (objects[i].Remove)
{
objects.Remove(objects[i]);
}
else
{
objects[i].AnimationTable.CurrentAnimation.incFrame(gameTime);
objects[i].update(gameTime);
}
}
//Change/Retreive the current scroll rates: Used for parallax scrolling
public float ScrollRateX
{
get { return scrollRateX; }
set { scrollRateX = value; }
}
public float ScrollRateY
{
get { return scrollRateY; }
set { scrollRateY = value; }
}
//Get/Set Visibility
public Boolean Visible
{
get { return visible; }
set { visible = value; }
}
//Get/Set Zorder
public int ZOrder
{
get { return layerZOrder; }
set { layerZOrder = value; }
}
//Retrieve the game objects contained within this Layer.
public List<GameObject> Objects
{
get { return objects; }
}
}
}