diff --git a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide index 4bab287..73a2220 100644 Binary files a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide and b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide differ diff --git a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-shm b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-shm index e88d0ab..02bc27f 100644 Binary files a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-shm and b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-shm differ diff --git a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-wal b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-wal index a8e72e3..1342a44 100644 Binary files a/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-wal and b/.vs/Animal_shogi/v15/Server/sqlite3/storage.ide-wal differ diff --git a/Assets/Game.cs b/Assets/Game.cs index 7818a50..f446050 100644 --- a/Assets/Game.cs +++ b/Assets/Game.cs @@ -5,24 +5,45 @@ using UnityEngine.EventSystems; public class Game : MonoBehaviour { - GameObject[,] masume = new GameObject[4, 3]; + // koma : 味方の駒の頭文字を小文字で格納(zなど) 敵の駒は大文字で格納(Zなど) + char[,] koma = new char[4, 3]; GameObject[] hiyoko = new GameObject[2]; GameObject[] zou = new GameObject[2]; GameObject[] kirin = new GameObject[2]; GameObject[] lion = new GameObject[2]; public bool movemode = false; - public bool[,] ismasuclick = new bool[4, 3]; GameObject moving; - // Use this for initialization - void Start () { - for (int x = 0; x < 4; x++){ - for(int y = 0; y < 3; y++) { + // Use this for initialization + void Start() { + masuinit(); + komainit(); + } + + // Update is called once per frame + void Update() { + + } + + public void masuinit() { + for (int x = 0; x < 4; x++) { + for (int y = 0; y < 3; y++) { masume[x, y] = GameObject.Find(x + "," + y); - ismasuclick[x, y] = false; } } + } + + public void komainit() { + for (int x = 0; x < 2; x++) { + for (int y = 0; y < 3; y++) { + koma[x, y] = (char)0; + } + } + koma[2, 0] = (char)0; + koma[2, 1] = 'h'; + koma[2, 2] = (char)0; + for (int i = 0; i < 2; i++) { hiyoko[i] = GameObject.Find("hiyoko" + i); } @@ -36,25 +57,9 @@ void Start () { lion[i] = GameObject.Find("lion" + i); } } - - // Update is called once per frame - void Update () { - if (movemode == true) { - for (int x = 0; x < 4; x++) { - for (int y = 0; y < 3; y++) { - if (ismasuclick[x, y] == true) { - moving.transform.parent = masume[x, y].transform; - moving.transform.localPosition = new Vector3(0, 0); - movemode = false; - ismasuclick[x, y] = false; - } - } - } - } - } public void komaclick(string komaname) { - if (komaname.Substring(0,1) == "h") { + if (komaname.Substring(0, 1) == "h") { moving = hiyoko[int.Parse(komaname.Substring(1, 1))]; } if (komaname.Substring(0, 1) == "z") { @@ -70,14 +75,16 @@ public void komaclick(string komaname) { } public void masuclick(string mess) { - int x = int.Parse(mess.Substring(0, 1)); - int y = int.Parse(mess.Substring(1, 1)); if (movemode == true) { - ismasuclick[x, y] = true; + int x = int.Parse(mess.Substring(0, 1)); + int y = int.Parse(mess.Substring(1, 1)); + Move(x, y); } } - private void Move() { - + public void Move(int x, int y) { + moving.transform.SetParent(masume[x, y].transform); + moving.transform.localPosition = new Vector3(0, 0); + movemode = false; } } \ No newline at end of file