代表一个玩家的单位
Inheritance: GameDataItem, IDisposable
示例#1
0
        private void RefreshUnitCahce( Unit unit )
        {
            lock ( _unitSync )
              {

            HashSet<Unit> set;

            if ( _playerUnits.TryGetValue( unit.Owner, out set ) == false )
              _playerUnits[unit.Owner] = set = new HashSet<Unit>();

            set.Add( unit );

            if ( _placeUnits.TryGetValue( unit.Coordinate, out set ) == false )
              _placeUnits[unit.Coordinate] = set = new HashSet<Unit>();

            set.Add( unit );
              }
        }
示例#2
0
 /// <summary>
 /// 保存游戏单位对象
 /// </summary>
 /// <param name="unit"></param>
 private void Save( Unit unit )
 {
     RefreshUnitCahce( unit );
       var filepath = Path.Combine( unitsDirectory, unit.Guid + ".json" );
       File.WriteAllText( filepath, unit.SaveAsJson() );
 }
示例#3
0
 /// <summary>
 /// 获取单位可以执行的操作列表
 /// </summary>
 /// <param name="unit"></param>
 /// <returns></returns>
 public virtual ActionDescriptor[] GetActions( Unit unit )
 {
     return new ActionDescriptor[0];
 }