// 駒移動処理 public void MoveKomaObj(string name, int x, int y) { bool motigomaFlag = false; // 持ち駒の場合 if (name.IndexOf(KomaConst.motigoma) > -1) { name = name.Replace(KomaConst.motigoma, ""); MotigomaManager motigomaManager = MotigomaManager.Instance; motigomaManager.Minus(name); if (KomaFunction.isSelfKoma(name)) { GameObject obj = transform.Find("../Motigoma1").gameObject; MotigomaScript mSc = obj.GetComponent <MotigomaScript> (); mSc.RefreshKoma(); } else { GameObject obj = transform.Find("../Motigoma2").gameObject; MotigomaScript mSc = obj.GetComponent <MotigomaScript> (); mSc.RefreshKoma(); } name = CreateKomaObj(name, x, y); MasuManager manager = MasuManager.Instance; manager.SetMasu(x, y, KomaFunction.GetKomaNameByObjName(name)); manager.UpdMasuObjNameByXAndY(name, x, y); motigomaFlag = true; } GameObject gameObj = GameObject.Find(name); KomaScript sc = gameObj.GetComponent <KomaScript> (); gameObj.transform.position = new Vector3(basex - per1x * x, basey - per1y * y, 2); // 持ち駒でない場合 if (!motigomaFlag) { Debug.Log("motigomadenai " + name); execCheckGetEnemyKoma(name, x, y); execCheckNarigoma(name, x, y); // 移動前のマスを初期化 MasuManager manager = MasuManager.Instance; manager.EmptyMasu(sc.x, sc.y); sc.x = x; sc.y = y; manager.SetMasu(x, y, KomaFunction.GetKomaNameByObjName(name)); manager.UpdMasuObjNameByXAndY(name, x, y); } }
// 相手の駒を取ったか確認&実行時 void execCheckGetEnemyKoma(string objName, int x, int y) { GameObject gameObj = GameObject.Find(objName); KomaScript sc = gameObj.GetComponent <KomaScript>(); MasuManager manager = MasuManager.Instance; MasuInit masu = manager.GetMasu(x, y); MotigomaManager mManager = MotigomaManager.Instance; if (sc.selfFlag && masu.enemyFlag) { if (masu.komaName.Equals(KomaConst.komaOu2) || masu.komaName.Equals(KomaConst.komaGy2)) { mManager.Plus(KomaConst.komaOu); } else if (masu.komaName.Equals(KomaConst.komaHi2) || masu.komaName.Equals(KomaConst.komaRy2)) { mManager.Plus(KomaConst.komaHi); } else if (masu.komaName.Equals(KomaConst.komaKa2) || masu.komaName.Equals(KomaConst.komaUm2)) { mManager.Plus(KomaConst.komaKa); } else if (masu.komaName.Equals(KomaConst.komaKi2)) { mManager.Plus(KomaConst.komaKi); } else if (masu.komaName.Equals(KomaConst.komaGi2) || masu.komaName.Equals(KomaConst.komaNg2)) { mManager.Plus(KomaConst.komaGi); } else if (masu.komaName.Equals(KomaConst.komaKe2) || masu.komaName.Equals(KomaConst.komaNk2)) { mManager.Plus(KomaConst.komaKe); } else if (masu.komaName.Equals(KomaConst.komaKy2) || masu.komaName.Equals(KomaConst.komaNy2)) { mManager.Plus(KomaConst.komaKy); } else if (masu.komaName.Equals(KomaConst.komaFu2) || masu.komaName.Equals(KomaConst.komaTo2)) { mManager.Plus(KomaConst.komaFu); } GameObject obj = transform.Find("../Motigoma1").gameObject; MotigomaScript mSc = obj.GetComponent <MotigomaScript>(); mSc.RefreshKoma(); DestroyKomaObj(masu.objName); } else if (sc.enemyFlag && masu.selfFlag) { if (masu.komaName.Equals(KomaConst.komaOu) || masu.komaName.Equals(KomaConst.komaGy)) { mManager.Plus(KomaConst.komaOu2); } else if (masu.komaName.Equals(KomaConst.komaHi) || masu.komaName.Equals(KomaConst.komaRy)) { mManager.Plus(KomaConst.komaHi2); } else if (masu.komaName.Equals(KomaConst.komaKa) || masu.komaName.Equals(KomaConst.komaUm)) { mManager.Plus(KomaConst.komaKa2); } else if (masu.komaName.Equals(KomaConst.komaKi)) { mManager.Plus(KomaConst.komaKi2); } else if (masu.komaName.Equals(KomaConst.komaGi) || masu.komaName.Equals(KomaConst.komaNg)) { mManager.Plus(KomaConst.komaGi2); } else if (masu.komaName.Equals(KomaConst.komaKe) || masu.komaName.Equals(KomaConst.komaNk)) { mManager.Plus(KomaConst.komaKe2); } else if (masu.komaName.Equals(KomaConst.komaKy) || masu.komaName.Equals(KomaConst.komaNy)) { mManager.Plus(KomaConst.komaKy2); } else if (masu.komaName.Equals(KomaConst.komaFu) || masu.komaName.Equals(KomaConst.komaTo)) { mManager.Plus(KomaConst.komaFu2); } GameObject obj = transform.Find("../Motigoma2").gameObject; MotigomaScript mSc = obj.GetComponent <MotigomaScript>(); mSc.RefreshKoma(); DestroyKomaObj(masu.objName); } }