Esempio n. 1
0
    public IEnumerator MoveEnd()
    {
        if (isMove)
        {
            yield break;
        }

        isMoveEnd = true;
        CMove.SetNowpos(nowPos[0], nowPos[1]);

        if (selectPos.Count >= 0)
        {
            //移動パスを配列に変更
            int[,] moveTo = new int[selectPos.Count, 2];
            for (int i = 0; i < selectPos.Count; i++)
            {
                moveTo [i, 0] = selectPos [i] [0];
                moveTo [i, 1] = selectPos [i] [1];
            }
            //移動していたら移動関数呼び出し
            if (moveTo.GetLength(0) > 0)
            {
                yield return(StartCoroutine(CMove.MoveTo(moveTo)));
            }
            selectPos.Clear();
            selectMove = 0;
        }
        GameController.Gcon.SetGamePhase(Phase.MenuAtMoveEnd);
        yield return(StartCoroutine(MoveCost(nowPos[0], nowPos[1])));

        isMoved = false;

        isMoveEnd = false;
    }
    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;
        }
    }