//改 public void InitGame() { mapManager.InitMap(); player = GameObject.FindGameObjectWithTag("Player").GetComponent <Player>(); womanPeople = GameObject.FindGameObjectWithTag("woman").GetComponent <woman>(); if (player && GameManager.Instance.mapManager) { player.targetPos = GameManager.Instance.mapManager.getplayerBorn(3); if (isAdd) { womanPeople.transform.position = new Vector3(player.targetPos.x - 1, player.targetPos.y, 0); } } //初始化UI UpdateFoodText(); dayImage = GameObject.Find("DayImage").GetComponent <Image>(); dayText = GameObject.Find("DayText").GetComponent <Text>(); dayText.text = actName[cout++]; Invoke("HideBlack", 1); //初始化参数 isEnd = false; enemyList.Clear(); setAddButtonVisible(false); }
public static void Show() { PersonHooked personHooked = new PersonHooked() { ID = 1, Name = "roy" }; personHooked.HookIncrease += new man().sayWord; woman woman = new woman(); personHooked.HookIncrease += woman.sayWord; personHooked.FishWeight = 10; personHooked.HookIncrease -= woman.sayWord; personHooked.FishWeight = 20; personHooked.FishWeight = 5; }
//初始化地图 public void InitMap() { gameManager = this.GetComponent <GameManager>(); mapHolder = new GameObject("Map").transform; //加载策划配置 mapType.Clear(); var reader = new StringReader(configs[GameManager.Instance.level - 1].text); string[] mapArr = new string[12]; for (int i = 0; i < 12; i++) { mapArr[i] = reader.ReadLine(); } for (int i = 0; i < 11; i++) { for (int j = 0; j < 12; j++) { if (GameManager.Instance.level <= 3) { GameObject go = GameObject.Instantiate(glass_floorArray[2], new Vector3(i + 0.5f, j, 0), Quaternion.identity) as GameObject; go.transform.SetParent(mapHolder); } else { GameObject go = GameObject.Instantiate(floorArray[2], new Vector3(i + 0.5f, j, 0), Quaternion.identity) as GameObject; go.transform.SetParent(mapHolder); } } } for (int i = 0; i < 12; i++) { for (int j = 0; j < 11; j++) { if (GameManager.Instance.level <= 3) { GameObject go = GameObject.Instantiate(glass_floorArray[2], new Vector3(i, j + 0.5f, 0), Quaternion.identity) as GameObject; go.transform.SetParent(mapHolder); } else { GameObject go = GameObject.Instantiate(floorArray[2], new Vector3(i, j + 0.5f, 0), Quaternion.identity) as GameObject; go.transform.SetParent(mapHolder); } } } //string[] mapArr = File.ReadAllLines(Application.dataPath + "/Scripts/map/level" + GameManager.Instance.level + ".txt"); ////string[] mapArr = File.ReadAllLines("C:\\Users\\zzn\\Desktop\\RoguelikeProject\\Assets\\Scripts\\map\\level1.txt"); for (int x = 0; x < mapArr.Length; ++x) { string[] sArray = mapArr[x].Split(','); mapType.Add(System.Array.ConvertAll <string, int>(sArray, s => int.Parse(s))); } mapType.Reverse(); //创建地图坐标映射 rows = mapType.Count; cols = mapType[0].Length; positionList.Clear(); for (int x = 0; x < cols - 1; x++) { for (int y = 0; y < rows - 1; y++) { if (isCanGo(x, y)) { positionList.Add(new Vector2(x, y)); } } } //下面是创建围墙和地板 for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { if (isCanGo(x, y)) { if (GameManager.Instance.level <= 3) { setItemList(x, y, glass_floorArray); } else { setItemList(x, y, floorArray); } } //创建母亲 if (getMapType(x, y) == woman && !GameManager.Instance.isAdd) { woman womanPeople = GameObject.FindGameObjectWithTag("woman").GetComponent <woman>(); womanPeople.transform.position = new Vector3(x, y, 0); } if (getMapType(x, y) == iceflower) { setItem(x, y, iceFlower); } //创建不可穿越地形 if (!isCaMake(x, y)) { continue; } if (getMapType(x, y) == outwall) { setItemList(x, y, outWallArray); } else if (getMapType(x, y) == outwall_grass) { setItemList(x, y, glass_outWallArray); } else if (getMapType(x, y) == outpath) { setItem(x, y, outPathPrefab); } else if (getMapType(x, y) == outpath_grass) { setItem(x, y, glass_outPathPrefab); } } } //创建障碍物 食物 敌人 //创建障碍物 int wallCount = Random.Range(minCountWall, maxCountWall + 1);//障碍物的个数 InstantiateItems(wallCount, wallArray); //创建食物 2 - level*2 int foodCount = Random.Range(gameManager.level + 2, gameManager.level * 2 + 1); InstantiateItems(foodCount, foodArray); //创建敌人 // level/2 int enemyCount = gameManager.level; InstantiateItems(enemyCount, enemyArray); //创建出口 GameObject go4 = Instantiate(exitPrefab, getplayerBorn(exit), Quaternion.identity) as GameObject; go4.transform.SetParent(mapHolder); //创建死去祖母 GameObject go5 = Instantiate(deadPeoplePrefab, getplayerBorn(deadpeople), Quaternion.identity) as GameObject; go5.transform.SetParent(mapHolder); }