-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameElement.cs
82 lines (68 loc) · 2.47 KB
/
GameElement.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
using System;
using Mogre;
namespace Game
{
class GameElement
{
/// <summary>
/// This abstract class is the basis of each element in the game. It contains the SceneNode, Enitity
/// and PhysObj necessary to build the game elements. It implements the Dispose method necessary to
/// destroy a GameElement at the end of its life in the game, and a method to position the GameElement
/// in the reference system of the game node's parent.
/// The Enitity, the SceneNode and the PhysObj are to be initialized in the classes derived from this one.
/// </summary>
protected SceneManager mSceneMgr;
protected Entity gameEntity;
/// <summary>
/// Read/Write. This property allows to read and write the game entity
/// </summary>
public Entity GameEntity
{
get { return gameEntity; }
set { gameEntity = value; }
}
protected SceneNode gameNode;
/// <summary>
/// Read/Write. This property allows to read and write the game node
/// </summary>
public SceneNode GameNode
{
get { return gameNode; }
set { gameNode = value; }
}
protected bool isMovable;
/// <summary>
/// Read/Write. This property allows to read and write whether this game element is movable
/// </summary>
public bool IsMovable
{
get { return isMovable; }
set { IsMovable = value; }
}
/// <summary>
/// This method is detaches from the scene graph and derstroies the game node and the game entity
/// </summary>
public virtual void Dispose()
{
if(gameNode.Parent != null)
{
gameNode.DetachAllObjects();
gameNode.RemoveAndDestroyAllChildren();
gameNode.Parent.RemoveChild(gameNode.Name);
}
gameNode.Dispose();
if (gameEntity != null)
{
gameEntity.Dispose();
}
}
/// <summary>
/// This virtual method allows to set the game element in the reference system of game node's parent
/// </summary>
/// <param name="position">The position in which to put the game element</param>
virtual public void SetPosition(Vector3 position)
{
gameNode.Position = position;
}
}
}