IEnumerator PromotionCoroutine(Piece get) { //Vector2 pos = this.Tile; PromotionWindow window = PromotionWindow.Show(); window.Init(this); while (PromotionWindow.IsShowing) { yield return(null); } //yield return null; //if (Tile != pos) { // Move(pos, false); //} ShogiNetwork.Instance.UpdatePieces(this, get); History history = History.Instance; List <Piece> eq = PieceController.Instance.FindMyEqualPieces(this); //bool isExistPieceMoveableSamePlace = false; List <Piece> same = null; if (eq != null) { foreach (Piece p in eq) { if (p.IsMoveable(this.Tile)) { //isExistPieceMoveableSamePlace = true; if (same == null) { same = new List <Piece>(); } same.Add(p); } } } history.Add(this, same); Owner.Act(); }
public void PutDown(Vector2 at) { Debug.Log("Put down! " + at); UserInfo me = GameLogic.Instance.GetMe(); SetOwner(me); SetTilePosition(at); Init(); //SetActive (true); Transform canvas = GameObject.Find("Canvas").transform; string uiname = "MyUI"; UIController controller = canvas.FindChild(uiname).GetComponent <UIController>(); int value = me.GetHolds(Kind); controller.UpdateUI(Kind, value - 1); ShogiNetwork.Instance.UpdatePieces(this, null); History history = History.Instance; List <Piece> eq = PieceController.Instance.FindMyEqualPieces(this); //bool isExistPieceMoveableSamePlace = false; List <Piece> same = null; if (eq != null) { foreach (Piece p in eq) { if (p.IsMoveable(this.Tile)) { //isExistPieceMoveableSamePlace = true; if (same == null) { same = new List <Piece>(); } same.Add(p); } } } history.Add(this, same); Owner.Act(); }
public void Move(Vector2 at, bool flag = true) { if (!this.OnBoard) { return; } RectTransform rect = GetComponent <RectTransform> (); Vector2 rend = GetRenderPosition(at); if (rect.anchoredPosition == rend) { return; } CloseGuideArea(); rect.anchoredPosition = rend; bool isPutDowned = (GameBoard.Instance.GetPiece(this.Tile) == null); Vector2 tmp = Tile; GameBoard.Instance.SetPiece(this.Tile, null); tile = at; Piece get = GameBoard.Instance.SetPiece(this); if (get != null) { //Debug.Log("Piece got!!"); get.CloseGuideArea(); get.SetTilePosition(Vector2.zero); get.SetActive(false); this.owner.GetPiece(get); //get.transform.localPosition = new Vector3(1000, 1000, 1000); //get.gameObject.SetActive(false); } if ((!owner.IsFirst && (Tile.y >= 7 && Tile.y <= 9)) || (owner.IsFirst && (Tile.y >= 1 && Tile.y <= 3)) || (!owner.IsFirst && (tmp.y >= 7 && tmp.y <= 9)) || (owner.IsFirst && (tmp.y >= 1 && tmp.y <= 3))) { if (!IsPromoted && canPromote && !isPutDowned) { UserInfo me = GameLogic.Instance.GetMe(); if (owner == me) { if (get != null) { if (get.Owner != me) { AskPromotion(get); return; } } else { AskPromotion(null); return; } } } } if (!flag) { return; } ShogiNetwork.Instance.UpdatePieces(this, get); History history = History.Instance; List <Piece> eq = PieceController.Instance.FindMyEqualPieces(this); //bool isExistPieceMoveableSamePlace = false; List <Piece> same = null; if (eq != null) { foreach (Piece p in eq) { if (p.IsMoveable(this.Tile)) { //isExistPieceMoveableSamePlace = true; if (same == null) { same = new List <Piece>(); } same.Add(p); } } } history.Add(this, same); Owner.Act(); }