public UnitData(UnitLayout _layout, int _x, int _y, bool _rotated) { x = _x; y = _y; layout = _layout; rotated = _rotated; positions = new List <int>(); int offsetX = 0, offsetY = 0; if (!_rotated) { for (int i = 0; i < _layout.layout.Length; i++) { if (_layout.layout[i] == '+') { positions.Add(x + offsetX); positions.Add(y + offsetY); offsetX++; } } } else { for (int i = 0; i < _layout.layout.Length; i++) { if (_layout.layout[i] == '+') { positions.Add(x + offsetX); positions.Add(y + offsetY); offsetY++; } } } }
public UnitLayout GetLayout(string name) { UnitLayout ret; if (!cache.TryGetValue(name, out ret)) { ret = new UnitLayout(name); cache.Add(name, ret); } return(ret); }