-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExampleGameAssetLoader.cs
More file actions
84 lines (82 loc) · 3.13 KB
/
Copy pathExampleGameAssetLoader.cs
File metadata and controls
84 lines (82 loc) · 3.13 KB
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
using System;
using System.Collections.Generic;
using FEEngine;
using FEEngine.Classes;
using FEEngine.GameLoader;
[assembly: AssemblyAssetLoader(typeof(ExampleGame.ExampleGameAssetLoader))]
namespace ExampleGame
{
public class ExampleGameAssetLoader : AssetLoader
{
protected override void LoadContent(Game game)
{
Vector2 size = (25, 15);
var units = new List<int>();
units.AddRange(AddUnits(Unit.UnitAffiliation.Player, size.Y - 5, size.X, game));
units.AddRange(AddUnits(Unit.UnitAffiliation.Enemy, size.Y - 2, size.X, game));
var map = new Map(size.X, size.Y);
var unitRegister = game.Registry.GetRegister<Unit>();
foreach (int index in units)
{
map.AddUnit(unitRegister[index]);
}
game.Registry.GetRegister<Map>().Add(map);
}
private static List<int> AddUnits(Unit.UnitAffiliation affiliation, int y, int mapWidth, Game game)
{
var stats = Unit.CreateStats(hp: 15, str: 9, mag: 1, dex: 7, spd: 5, lck: 8, def: 7, res: 5, cha: 10, mv: 5);
var indices = new List<int>();
Register<Unit> unitRegister = game.Registry.GetRegister<Unit>();
Register<Item> itemRegister = game.Registry.GetRegister<Item>();
Register<Battalion> battalionRegister = game.Registry.GetRegister<Battalion>();
for (int x = 0; x < mapWidth; x++)
{
int unitY = y + (x % 2);
var unit = new Unit((x, unitY), affiliation, stats)
{
Class = new Soldier(),
};
indices.Add(unitRegister.Count);
unitRegister.Add(unit);
unit.AddSkill<HawkeyePlus>();
int lanceIndex = CreateLance(itemRegister);
unit.Inventory.Add(lanceIndex);
unit.EquippedWeapon = itemRegister[lanceIndex];
unit.Battalion = CreateBattalion(battalionRegister, unit);
}
return indices;
}
private static int CreateLance(Register<Item> itemRegister)
{
var stats = new WeaponStats
{
Attack = 5,
HitRate = 80,
CritRate = 0,
Type = WeaponType.Lance,
Range = (1, 1),
Weight = 1,
Durability = 25
};
var lance = new Item(false, weaponStats: stats, name: "C#ium Lance");
int index = itemRegister.Count;
itemRegister.Add(lance);
return index;
}
private static Battalion CreateBattalion(Register<Battalion> battalionRegister, Unit unit)
{
var battalion = new Battalion
{
Name = "Test Battalion",
Parent = unit,
StatBoosts = new BattalionStatBoosts
{
CharmBoost = 5
}
};
battalion.SetGambit<TestGambit>();
battalionRegister.Add(battalion);
return battalion;
}
}
}