/// <summary> /// 召唤 /// </summary> /// <param name="type"></param> /// <param name="point"></param> private void OnSummon(int type, Vector2 point) { int color = type / 10; int newType = type % 10; string pieceName = ""; if (color == (int)Config.PieceColor.BLACK) { pieceName = "Black_"; } else { pieceName = "White_"; } switch ((Config.PieceType)newType) { case Config.PieceType.P: pieceName = pieceName + "P"; break; case Config.PieceType.N: pieceName = pieceName + "N"; break; case Config.PieceType.B: pieceName = pieceName + "B"; break; case Config.PieceType.R: pieceName = pieceName + "R"; break; case Config.PieceType.Q: pieceName = pieceName + "Q"; break; case Config.PieceType.K: pieceName = pieceName + "K"; break; } GameObject temp = GameObject.Instantiate(m_piece); temp.name = point.x + "_" + point.y; temp.transform.parent = m_qizi.transform; temp.SetActive(true); PieceItem02 pieceItem = temp.AddComponent <PieceItem02>(); summonIndex++; pieceItem.InitView(temp, new Piece((Config.PieceColor)color, (Config.PieceType)newType, (int)point.x, (int)point.y), summonIndex, false); pieceItem.canMove = false; if (isTurn == true) { canNext = false; m_modelDrag.isTurn = canNext; } App.ObjectPoolManager.RegisteObject(pieceName, "FX/" + pieceName, 0, 30, -1); App.ObjectPoolManager.Instantiate(pieceName, (GameObject obj) => { if (color == (int)Config.PieceColor.BLACK) { obj.transform.localRotation = Quaternion.Euler(0, 180, 0); } obj.SetActive(true); obj.transform.parent = temp.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f); pieceItem.pieceModel = obj; var effectPlayer = App.EffectManager.LoadEffect(obj, "summon_normal"); effectPlayer.enabled = true; effectPlayer.IsOnce = true; App.SoundManager.PlaySoundClip(Config.Sound.SummonSuccess); App.UIManager.StartCoroutine(_SendPaintEnd(newType)); }); }
/// <summary> /// 初始化棋盘 /// </summary> private void InitChessBoard() { for (int y = 0; y < Config.Board.MaxY; y++) { for (int x = 0; x < Config.Board.MaxX; x++) { int piece = App.ChessLogic02.GetPiece(x, y); if (piece >= 0) { int color = piece / 10; int type = piece % 10; string pieceName = ""; if (color == (int)Config.PieceColor.BLACK) { pieceName = "Black_"; } else { pieceName = "White_"; } switch ((Config.PieceType)type) { case Config.PieceType.P: pieceName = pieceName + "P"; break; case Config.PieceType.N: pieceName = pieceName + "N"; break; case Config.PieceType.B: pieceName = pieceName + "B"; break; case Config.PieceType.R: pieceName = pieceName + "R"; break; case Config.PieceType.Q: pieceName = pieceName + "Q"; break; case Config.PieceType.K: pieceName = pieceName + "K"; break; } GameObject temp = GameObject.Instantiate(m_piece); temp.transform.parent = m_qizi.transform; temp.SetActive(true); PieceItem02 pieceItem = temp.AddComponent <PieceItem02>(); summonIndex++; pieceItem.InitView(temp, new Piece((Config.PieceColor)color, (Config.PieceType)type, x + 1, y + 1), summonIndex, false); App.ObjectPoolManager.RegisteObject(pieceName, "FX/" + pieceName, 0, 30, -1); App.ObjectPoolManager.Instantiate(pieceName, (GameObject obj) => { if (selfColor == Config.PieceColor.WHITE) { obj.transform.localRotation = Quaternion.Euler(0, 180, 0); } obj.SetActive(true); obj.transform.parent = temp.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f); pieceItem.pieceModel = obj; }); } } } }