81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using NBC;
|
|
using NBC.Entitas;
|
|
|
|
namespace NBF.Fishing2
|
|
{
|
|
public class Map : Entity
|
|
{
|
|
public int MapId;
|
|
|
|
public string RoomCode;
|
|
|
|
/// <summary>
|
|
/// 好友房地图
|
|
/// </summary>
|
|
public bool IsRoomMap => !string.IsNullOrEmpty(RoomCode);
|
|
|
|
/// <summary>
|
|
/// 地图中的单位
|
|
/// </summary>
|
|
public Dictionary<long, MapUnit> Units = new Dictionary<long, MapUnit>();
|
|
|
|
|
|
/// <summary>
|
|
/// 创建地图单位
|
|
/// </summary>
|
|
public void CreteMapUnit()
|
|
{
|
|
// //创建自己
|
|
// var role = Scene.GetComponent<Role>();
|
|
// var mapUnitInfo = role.GetMapUnitInfo();
|
|
// CreteMapUnit(mapUnitInfo);
|
|
//
|
|
// //创建其他玩家
|
|
}
|
|
|
|
|
|
public MapUnit CreateMapUnit(MapUnitInfo unitInfo)
|
|
{
|
|
var mapUnit = Entity.Create<MapUnit>(Scene, unitInfo.Id, true, true);
|
|
mapUnit.SetUnitInfo(unitInfo);
|
|
Add(mapUnit);
|
|
return mapUnit;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取一个单位
|
|
/// </summary>
|
|
/// <param name="self"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public MapUnit GetUnit(long id)
|
|
{
|
|
return Units.GetValueOrDefault(id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入地图
|
|
/// </summary>
|
|
/// <param name="map"></param>
|
|
/// <param name="unit"></param>
|
|
/// <returns></returns>
|
|
public bool Add(MapUnit unit)
|
|
{
|
|
Units.Add(unit.Id, unit);
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 离开地图
|
|
/// </summary>
|
|
/// <param name="self"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool Remove(long id)
|
|
{
|
|
return Units.Remove(id);
|
|
}
|
|
}
|
|
} |