public InnResBean(long id, Vector3 startPosition, List <Vector3> listPosition, Direction2DEnum direction2D) { this.id = id; this.startPosition = new Vector3Bean(startPosition);; if (listPosition != null) { this.listPosition = TypeConversionUtil.ListV3ToListV3Bean(listPosition); } this.direction = (int)direction2D; }
/// <summary> /// 自定义位置转为系统位置 /// </summary> /// <param name="vector3Bean"></param> /// <returns></returns> public static Vector3 Vector3BeanToVector3(Vector3Bean vector3Bean) { Vector3 vector3 = new Vector3(vector3Bean.x, vector3Bean.y, vector3Bean.z); return(vector3); }
/// <summary> /// 初始化墙壁 /// </summary> public void InitWall(List <InnResBean> listWall, int layer, List <InnResBean> listDoor) { GetInnSize(layer, out int innInitWidth, out int innInitHeight, out int offsetH); //建造墙壁 for (int i = 0; i < innInitWidth; i++) { for (int f = 0; f < innInitWidth; f++) { bool isBuild = false; if (i == 0 || i == innInitWidth - 1) { isBuild = true; } else { if (f == 0 || f == innInitHeight - 1) { isBuild = true; } } if (isBuild) { bool hasData = false; foreach (InnResBean itemWall in listWall) { Vector3 startPosition = itemWall.GetStartPosition(); if (startPosition.x == i && startPosition.y == f + offsetH) { hasData = true; break; } } if (!hasData) { InnResBean itemData = new InnResBean(); itemData.startPosition = new Vector3Bean(i, f + offsetH); itemData.id = 20001; listWall.Add(itemData); } } } } if (listDoor != null) { ///移除门所占墙壁 for (int i = 0; i < listDoor.Count; i++) { InnResBean itemData = listDoor[i]; for (int f = 0; f < itemData.listPosition.Count; f++) { Vector3Bean doorPositon = itemData.listPosition[f]; for (int h = 0; h < listWall.Count; h++) { Vector3Bean wallPostion = listWall[h].startPosition; if (doorPositon.x == wallPostion.x + 1 && doorPositon.y == wallPostion.y) { listWall.Remove(listWall[h]); h--; } } } } } }
public void SetBuildPosition(Vector3 vector3) { buildPosition = new Vector3Bean(vector3); }
/// <summary> /// 获取位置 /// </summary> /// <param name="worldType"></param> /// <param name="position"></param> public void GetWorldPosition(out WorldTypeEnum worldType, out Vector3 position) { worldType = (WorldTypeEnum)this.worldType; position = this.position.GetVector3(); }
public void SetPosition(Vector3 position) { this.position = new Vector3Bean(position); }
/// <summary> /// Vector3 转化为 Vector3Bean /// </summary> /// <param name="vector3"></param> /// <returns></returns> public static Vector3Bean ToVector3Bean(this Vector3 vector3) { Vector3Bean vector3Bean = new Vector3Bean(vector3); return(vector3Bean); }