Exemplo n.º 1
0
        public void Move(UnitBase unit, int y, int x)
        {
            var key = unit.GetPositionKey();

            _units.Remove(key);

            unit.Move(y, x);

            key = unit.GetPositionKey();

            _units[key] = unit;
        }
Exemplo n.º 2
0
        public void Add(UnitBase unit)
        {
            var key = unit.GetPositionKey();

            if (_units.ContainsKey(key))
            {
                return;
            }

            _units.Add(key, unit);
        }
Exemplo n.º 3
0
        public IUnit GetUnit(int y, int x)
        {
            var key = UnitBase.GetPositionKey(y, x);

            if (_units.TryGetValue(key, out var unit))
            {
                return(unit);
            }

            return(null);
        }
Exemplo n.º 4
0
 public Army(params IUnit[] units)
 {
     _units = units.ToDictionary(o => UnitBase.GetPositionKey(o.Y, o.X));
 }
Exemplo n.º 5
0
        public void Remove(IUnit unit)
        {
            var key = UnitBase.GetPositionKey(unit.Y, unit.X);

            _units.Remove(key);
        }