using System;
using System.Collections.Generic;
using UnityEngine;
namespace Thousandto.Launcher.ExternalLibs
{
///
/// 场景地图区域块
///
[Serializable]
public class RegionPart
{
#region//私有变量
private int _index = 0;
private float _wide = 0f;
private float _high = 0f;
private List _descriptList = new List();
#endregion
#region//公共变量
//编号
//中心点
private Vector3 Center;
//最小点
private Vector3 Min;
//最大点
private Vector3 Max;
//包围Bounds
private Bounds Bounds;
//是否还原
public bool IsRePlace = false;
//当前区域是可用
public bool IsAvailable = true;
//地图区域块资源描述
public SceneAssetDescript[] Descripts = null;
private List _nodesList = new List();
#endregion
#region//构造函数
public RegionPart(int index, int part, float celWide, float celHigh, Vector2 min)
{
int rl = index % part; //列
int cl = index / part; //行
_index = index;
Min = Vector3.zero;
Max = Vector3.zero;
Center = Vector3.zero;
Min.x = min.x + celWide * rl;
Min.z = min.y + celHigh * cl;
Max.x = Min.x + celWide;
Max.z = Min.z + celWide;
_wide = celWide;
_high = celHigh;
Center.x = Max.x - celWide / 2;
Center.z = Max.z - celHigh / 2;
var size = new Vector3(celWide, 400, celHigh);
Bounds = new Bounds(Center, size);
Bounds.min = new Vector3(Min.x, -200, Min.z);
Bounds.max = new Vector3(Max.x, 200, Max.z);
}
public int GetIndex()
{
return _index;
}
public Vector3 GetMin()
{
return Min;
}
public Vector3 GetMax()
{
return Max;
}
public Bounds GetBounds()
{
return Bounds;
}
public void AddDescriptList(SceneAssetDescript des)
{
_descriptList.Add(des);
}
public bool Intersects(Bounds b)
{
return Bounds.Intersects(b);
}
public List GetNodes()
{
return _nodesList;
}
public void SetNodes(List list)
{
_nodesList.Clear();
for (int i = 0; i < list.Count; i++)
{
_nodesList.Add(list[i]);
}
}
public void AddNode(SceneNodeCommpent node)
{
if(node != null)
_nodesList.Add(node);
}
#endregion
}
}