/// <summary> /// 创建一条路径 /// </summary> public bool CreateRoute() { pointList.Clear(); pointIndex = 1; currentIndex = 0; pointList.Add(Player.transform.localPosition); // Vector3 axis = new Vector3(0, 0, 1); int dir = Random.Range(0, 2) == 0 ? 1 : -1; Vector3 ov = this.player.Direction * moveDis; Vector3 v1 = ov; Vector3 v3 = Quaternion.AngleAxis(90 * dir, axis) * v1; Vector3 v2 = v1 + v3; pointList.Add(Player.transform.localPosition + v1); pointList.Add(Player.transform.localPosition + v2); pointList.Add(Player.transform.localPosition + v3); GameObject go = Resources.Load <GameObject>(AssetPathUtil.GetPlayerPath(0)); for (int i = 1; i < pointList.Count; i++) { //GameObject o = GameObject.Instantiate<GameObject>(go); //o.transform.localPosition = pointList[i]; //o.transform.SetParent(LayerManager.mapLayer, false); } isRandomDir = false; foreach (var item in pointList) { if (MapManager.GetGridByPos(item) == null || MapManager.IsNearSideByPos(item)) { return(false); } } _isCreateRoute = true; return(true); }
public Player() { tree = AIManager.GetTree(this); mineList = new List <MapGrid>(); GameObject go = Resources.Load <GameObject>(AssetPathUtil.GetPlayerPath(0)); obj = GameObject.Instantiate <GameObject>(go); spRender = obj.GetComponent <SpriteRenderer>(); spRender.sortingLayerName = LayerUtil.SORTING_LAYER_PLAYER; Color = new Color(156 / 255F, 255 / 255f, 137 / 255f); checkGrid = new CheckGrid(this); //_direction = new Vector3(-0.3f, -1, 0).normalized; }