コード例 #1
0
 public Unit(UnitDataSet dataSet)
 {
     _name      = dataSet.Name;
     _unitView  = dataSet.UnitView;
     _anchor    = dataSet.Anchor;
     _radius    = dataSet.Radius;
     _hitpoint  = new NumberSink(dataSet.HitPoint);
     _moveSpeed = dataSet.MoveSpeed;
     _commands  = dataSet.Commands;
     _weapon    = new Weapon(dataSet.Weapon);
 }
コード例 #2
0
        public UnitFactory()
        {
            var unitXmlData = unitXmlDatas.Descendants("Unit");

            foreach (var unitElement in unitXmlData)
            {
                UnitDataSet dataSet          = new UnitDataSet();
                var         anchorElement    = unitElement.Element("Anchor");
                var         radiusElement    = unitElement.Element("Radius");
                var         moveSpeedElement = unitElement.Element("MoveSpeed");
                var         hitpointElement  = unitElement.Element("HitPoint");
                string      width            = anchorElement.Attribute("width").Value;
                string      height           = anchorElement.Attribute("height").Value;
                dataSet.Name      = unitElement.Attribute("name").Value;
                dataSet.Anchor    = new Size(int.Parse(width), int.Parse(height));
                dataSet.Radius    = int.Parse(radiusElement.Attribute("value").Value);
                dataSet.HitPoint  = int.Parse(hitpointElement.Attribute("value").Value);
                dataSet.MoveSpeed = int.Parse(moveSpeedElement.Attribute("value").Value);
                dataSet.Weapon    = new WeaponDataSet(new Effects.Damage(1), 300, 60);
                dataSet.CreateUnitView();
                dataSet.Commands = _commandFactory.CreateBasicCommands();
                _units.Add(dataSet);
            }
        }