public void InitCharacters() { if (!CharsInited) { //0 prefab名 //1 陣営 //2 マスx //3 マスy //4 職業 //5 名前 //6 ID GameObject characters = new GameObject(); characters.name = "characters"; for (int i = 0; i < CSVReader.GetLength(mapData); i++) { string[] charData = CSVReader.ReadLine(mapData, i + 1); //Debug.Log(charData[0]); string prefabPath = "prefabs/characters_map/" + charData[0]; //Debug.Log(prefabPath); GameObject chara = (GameObject)Instantiate(Resources.Load(prefabPath), Vector3.zero, this.transform.rotation); chara.name = charData [0]; // Debug.Log(charData[3]); GameObject go = chara; go.transform.parent = characters.transform; /* * chara.GetComponent<playerMove>().NowPos = int.Parse(charData[3]); */ //GameObject square = GameObject.Find(i % 5 + ":" + i % 2); //chara.transform.position = square.transform.position/* + new Vector3(0.0f, 0.5f, 0.0f)*/; // chara.GetComponent<Character>().SetLevel(int.Parse(charData[5])); if (charData[1] == "1") { playerList.Add(chara); } else if (charData[1] == "2") { enemyList.Add(chara); } else { Debug.Log("Error, is character player or enemy?"); } _characters.Add(chara); //Debug.Log("================"); int x = int.Parse(charData [2]); int y = int.Parse(charData [3]); //侵入不可領域のキャラクターの配置位置をランダムに変更 while (true) { if (MapCreateScript.mapChips [x, y] == null) { x = Random.Range(0, MapCreateScript.mapChips.GetLength(0)); y = Random.Range(0, MapCreateScript.mapChips.GetLength(1)); } else { break; } } CharacterMove CMove = chara.GetComponent <CharacterMove> (); if (CMove != null) { //Debug.Log (x + ";" + y); CMove.SetNowpos(x, y); CMove.PosInit(); } Character c = chara.GetComponent <Character>(); if (charData[5] != "") { c.SetName(charData[5]); } if (charData[6] != "") { c.SetID(int.Parse(charData[6])); } } /* * MapMoveScript.MMS.UpdateAllChars(); */ CharsInited = true; } }