public Unit(UnitProps _unitProps, Rectangle location, Texture2D texture) : base(location, texture) { unitProps = _unitProps; unitStates = new List <UnitState>(); //ai = _ai; ChangeTextureForNormal(); way.MoveStates = new List <byte>(); effects = new List <UnitEffect>(); SetPosition(location); }
//public Unit CreateUnit(UnitProps unitProps, UnitStats unitStats) //{ // Unit unit = new Unit(unitProps, unitStats); // return unit; //} public Unit CreateUnit(ArrayList objects) { UnitProps unitProps = new UnitProps(); List <byte> commonByte = new List <byte>(); myRectangle location = new myRectangle(); Texture2D tex = null; List <UnitState> usts = new List <UnitState>(); foreach (var obj in objects) { if (obj is List <UnitState> ) { usts = obj as List <UnitState>; tex = usts[0].stateTexture; } if (obj is List <Texture2D> ) { unitProps.DistributeTexture(obj as List <Texture2D>); } if (obj is myRectangle) { location = obj as myRectangle; } if (obj is ForAsUnitStats) { unitProps.ConvertUnitStats(obj as ForAsUnitStats); } if (obj is List <byte> ) { commonByte = obj as List <byte>; } } Unit unit = new Unit(unitProps, location.rect, tex); unit.DistributeCommons(commonByte); unit.DistributeStates(usts); return(unit); }