Skip to content

Commit

Permalink
駒を動かす動作を関数化
Browse files Browse the repository at this point in the history
  • Loading branch information
tokyosuperch committed Nov 16, 2018
1 parent 1d5d782 commit 2b5d22c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
Binary file modified .vs/Animal_shogi/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file modified .vs/Animal_shogi/v15/Server/sqlite3/storage.ide-shm
Binary file not shown.
Binary file modified .vs/Animal_shogi/v15/Server/sqlite3/storage.ide-wal
Binary file not shown.
65 changes: 36 additions & 29 deletions Assets/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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") {
Expand All @@ -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;
}
}

0 comments on commit 2b5d22c

Please sign in to comment.