-
Notifications
You must be signed in to change notification settings - Fork 2
/
Juego.cs
138 lines (116 loc) · 3.06 KB
/
Juego.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
using System.IO;
using Items;
using Items.Modifiers;
using Maps;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Moggle.Textures;
using Units;
namespace AoM
{
/// <summary>
/// The game engine
/// </summary>
public class Juego : Moggle.Game
{
#region Texturas definidas
/// <summary>
/// Gets the set of predefined run-time-generated <see cref="Texture"/>
/// </summary>
/// <value>The textures.</value>
public static Textures Textures { get; private set; }
#endregion
/// <summary>
/// Gets the item modification database
/// </summary>
public ItemModifierDatabase ItemMods { get; private set; }
/// <summary>
/// The database for item types
/// </summary>
/// <value>The items.</value>
public ItemDatabase Items { get; private set; }
/// <summary>
/// Gets the class and race manager
/// </summary>
public UnitClassRaceManager ClassRaceManager { get; private set; }
/// <summary>
/// Gets the collection of skills
/// </summary>
public SkillCollection SkillList { get; private set; }
/// <summary>
/// Attribute database
/// </summary>
public DamageAttributesManager DamageAttrs { get; private set; }
/// <summary>
/// Carga el contenido del juego, incluyendo los controles universales.
/// </summary>
protected override void LoadContent ()
{
try
{
base.LoadContent ();
}
catch (System.Exception ex)
{
System.Console.WriteLine ("Critical error: cannot load content");
throw ex;
}
Textures = new Textures (GraphicsDevice);
}
/// <summary>
/// </summary>
protected override void Initialize ()
{
SimpleTextureGenerator = new SimpleTextures (GraphicsDevice);
// Load files
LoadDBContent ();
base.Initialize ();
}
void LoadDBContent ()
{
var file = File.OpenText (FileNames.ItemModifiers);
var jsonStr = file.ReadToEnd ();
file.Close ();
ItemMods = Newtonsoft.Json.JsonConvert.DeserializeObject<ItemModifierDatabase> (
jsonStr,
Map.JsonSets);
Items = ItemDatabase.FromFile ();
ClassRaceManager = UnitClassRaceManager.FromFile ();
SkillList = SkillCollection.FromFile ();
DamageAttrs = DamageAttributesManager.FromFile ();
}
/// <summary>
/// Initializes a new instance of the <see cref="AoM.Juego"/> class.
/// </summary>
public Juego ()
{
Content.RootDirectory = @"Content/Content";
Graphics.IsFullScreen = true;
}
/// <summary>
/// Commor generator for simple definible textures
/// </summary>
public SimpleTextures SimpleTextureGenerator { get; private set; }
}
/// <summary>
/// Set of easy definable textures
/// </summary>
public class Textures
{
/// <summary>
/// Solid white color texture
/// </summary>
public readonly Texture2D SolidTexture;
/// <summary>
/// Initializes a new instance of the <see cref="AoM.Textures"/> class.
/// </summary>
/// <param name="gd">Gd.</param>
internal Textures (GraphicsDevice gd)
{
SolidTexture = new Texture2D (gd, 1, 1);
var data = new Color[1];
data [0] = Color.White;
SolidTexture.SetData (data);
}
}
}