/// <summary> /// 设置格子动画 /// </summary> /// <param name="startGrid">动画开始的格子</param> private void SetGridAnimation(LevelGrid startGrid, float waitTime, float totalTime, Vector3 offset, AnimationCurve curve) { startGrid.animation.Initialize(0, totalTime, offset, curve); List <LevelGrid> list = new List <LevelGrid>(); list.Add(startGrid); SetGridAnimation(list, 1, waitTime, totalTime, offset, curve); }
/// <summary> /// 获取目标格子周围的格子 /// </summary> /// <param name="startGrid">动画开始的格子</param> private LevelGrid[] GetAroundGrids(LevelGrid tg) { LevelGrid[] arounds = new LevelGrid[4]; arounds[0] = GetGrid(tg.adjacentPx); arounds[1] = GetGrid(tg.adjacentNx); arounds[2] = GetGrid(tg.adjacentPz); arounds[3] = GetGrid(tg.adjacentNz); return(arounds); }
/// <summary> /// 获取格子 /// </summary> /// <param name="position"></param> public LevelGrid GetGrid(Vector3 position) { string id = LevelGrid.GetId(position); LevelGrid grid = null; if (m_map.TryGetValue(id, out grid)) { return(grid); } return(null); }
/// <summary> /// 获取格子 /// </summary> /// <param name="id">格子id</param> public LevelGrid GetGrid(string id) { if (string.IsNullOrEmpty(id)) { return(null); } LevelGrid grid = null; if (m_map.TryGetValue(id, out grid)) { return(grid); } return(null); }
public void Initialize(LevelArea _area, SecurityElement _xml) { m_xml = _xml; m_area = _area; GameObject go = new GameObject(); go.name = "gird"; go.transform.parent = transform; m_grid = go.AddComponent <LevelGrid>(); m_grid.assetName = m_xml.Attribute("asset_name"); m_grid.bundleName = m_xml.Attribute("bundle_name"); m_grid.position = new Vector3(int.Parse(m_xml.Attribute("pos_x")), int.Parse(m_xml.Attribute("pos_y")), int.Parse(m_xml.Attribute("pos_z"))); m_grid.rotationAngle = new Vector3(int.Parse(m_xml.Attribute("angle_x")), int.Parse(m_xml.Attribute("angle_y")), int.Parse(m_xml.Attribute("angle_z"))); m_grid.function = LevelFunctionType.Door; }
// <summary> /// 检查 hero 是否在此区域内 /// </summary> public bool CheckHeroInArea() { if (m_heroTransform != null) { var hp = m_heroTransform.position; m_heroPosition.x = (int)hp.x; m_heroPosition.y = (int)hp.y; m_heroPosition.z = (int)hp.z; m_heroInGrid = ground.GetGrid(m_heroPosition); } else { m_heroInGrid = null; } return(m_heroInGrid != null); }