/// <summary> /// 吸收来自其他单元的属性 /// </summary> /// <param name="fromCell">来源及cell</param> public void Absorb([NotNull] TheFiveCellBase fromCell) { additionProperties.Plus(fromCell.Export()); fromCell.ClearProperties(); }
/// <summary> /// 创建单位 /// </summary> /// <param name="unitType">单位类型</param> /// <param name="dataId">数据ID</param> /// <returns>地图单元类</returns> public T CreateUnit <T>(UnitType unitType, int dataId) where T : MapCellBase { // 地图单元与障碍物使用相同单元替换Image的方式进行服用, 来解决创建单位过多问题 MapCellBase result = null; switch (unitType) { // ---------------------------加载数据进行替换模式---------------------------- case UnitType.MapCell: // 地图单元 { result = new MapCell(null, dataId, MapManager.MapBaseLayer); } break; case UnitType.Obstacle: // 障碍物 { var go = GetGameObject(MapCellTableName, dataId, MapDrawer.Single.ItemParentList[MapManager.MapObstacleLayer]); result = new Obstacle(go, dataId, MapManager.MapObstacleLayer); go.name = result.MapCellId.ToString(); go.SetActive(true); } break; // ---------------------------------加载预设模式--------------------------------- case UnitType.FightUnit: // 战斗单位 { var go = GetGameObject(MapCellTableName, dataId, MapDrawer.Single.ItemParentList[MapManager.MapPlayerLayer]); result = new FightUnit(go, dataId, MapManager.MapPlayerLayer); go.name = result.MapCellId.ToString(); go.SetActive(true); } break; case UnitType.NPC: // NPC { var go = GetGameObject(MapCellTableName, dataId, MapDrawer.Single.ItemParentList[MapManager.MapNpcLayer]); // TODO 区分出兵点入兵点 switch (dataId) { case 301: // 出兵点 result = new OutMonsterPoint(go, dataId, MapManager.MapObstacleLayer); break; case 302: // 入兵点 result = new InMonsterPoint(go, dataId, MapManager.MapObstacleLayer); break; case 401: // 塔基 result = new TowerPoint(go, dataId, MapManager.MapObstacleLayer); break; default: result = new Npc(go, dataId, MapManager.MapNpcLayer); break; } go.name = result.MapCellId.ToString(); go.SetActive(true); } break; case UnitType.Tower: { // 创建塔 var go = GetGameObject(MapCellTableName, dataId, MapDrawer.Single.ItemParentList[MapManager.MapNpcLayer]); result = new Tower(go, dataId, MapManager.MapPlayerLayer); // 设置数据 go.name = result.MapCellId.ToString(); go.SetActive(true); } break; case UnitType.TowerCell: { // 创建塔单元 var go = GetGameObject(MapCellTableName, dataId, MapDrawer.Single.ItemParentList[MapManager.MapPlayerLayer]); result = new TheFiveCellBase(go, dataId, MapManager.MapPlayerLayer); // 设置数据 go.name = result.MapCellId.ToString(); go.SetActive(true); } break; } return((T)result); }