/* for reward
         *  private void String2String(FieldManager field,Pieces piece,int string2string)
         *  private void confirmFace(FieldManager field, int faceId, PlayerBase cp, PlayerBase player)
         */



        //investigate the targetPiece whetever it look to sameface from faceId
        //return value
        private int lookingToSameFace(int purposeFaceId, int targetFaceId)
        {
            Pieces piece = faceIdtoPieces(targetFaceId);
            int    unit  = 0;
            int    value = 1;

            if (MyTroop(piece))
            {
                unit = 1;
            }
            else
            {
                unit = -1;
            }
            if (piece.GetKind().ToString().Equals("King"))
            {
                return(0);
            }
            else if (frontFaceIdCheck(GameManager.ManagerStore.fieldManager, piece) == purposeFaceId)
            {
                Debug.Log("purposePieceId");
                Debug.Log(faceIdtoPieces(purposeFaceId).GetPieceId());
                Debug.Log("guardPiece");
                Debug.Log(piece.GetPieceId());
                return(value * unit);
            }
            else
            {
                return(0);
            }
        }
 // return whoseTroop
 private bool MyTroop(Pieces piece)
 {
     if (GameManager.ManagerStore.cp.HasPiece(piece.GetPieceId()))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
            private void AddBotton(Pieces pieces)
            {
                var piece     = pieces;//ManagerStore.piecesManager.GetPieceById(pieceId);
                var pieceKind = piece.GetKind();

                GameObject panel = default;

                GameObject button;

                //Debug.Log(pieceKind);
                switch (pieceKind)
                {
                case PieceKind.Pawn:
                    button = Instantiate(buttons[0]);
                    panel  = PawnPanel;
                    break;

                case PieceKind.King:
                    button = Instantiate(buttons[1]);
                    panel  = KingPanel;
                    break;

                case PieceKind.Queen:
                    button = Instantiate(buttons[2]);
                    panel  = QueenPanel;
                    break;

                default:
                    Debug.LogWarning("No some kind of pieces.");
                    return;
                    //break;
                }

                var piecebutton = button.GetComponent <PieceBotton>();

                piecebutton.PieceId = pieces.GetPieceId();
                piecebutton.Piece   = piece;

                pieceBottons.Add(piecebutton);

                button.transform.SetParent(panel.transform, false);

                var l = new List <int>();

                l.Add(piecebutton.PieceId);



                //ManagerStore.player.AddMyPieces(pieceKind,l);

                EnabledPiecesIdPast.Add(piece);
            }
            private void DeleteButton(Pieces pieces)
            {
                for (int i = 0; i < pieceBottons.Count(); i++)
                {
                    int crrPieceId = pieceBottons[i].PieceId;
                    //Debug.Log(pieces);

                    if (crrPieceId == pieces.GetPieceId())
                    {
                        pieceBottons[i].Delete();
                        ManagerStore.humanPlayer.DeleteMyPieces(pieceBottons[i].PieceId);

                        EnabledPiecesIdPast.Remove(pieceBottons[i].GetPiece());
                        pieceBottons.Remove(pieceBottons[i]);

                        //Debug.Log(EnabledPiecesId);
                        //Debug.Log("Deleted Piece Button!" + pieceId);

                        return;
                    }
                }
            }
Exemplo n.º 5
0
        //駒をプレイヤーのものとして登録
        public void AddMyPieces(PieceKind pieceKind, int absoluteFaceId, int forwardFaceId, bool withAnimation = true)
        {
            //Debug.Log($"addmyp kind: {pieceKind}  faceID: {absoluteFaceId}  playerkind: {playerKind}");

            GameObject piecePrefab    = piecesManager.GetPiecePrefab(pieceKind, playerKind);
            GameObject newPieceObject = Instantiate(piecePrefab, new Vector3(0, 0, 0), Quaternion.identity);
            Pieces     newPiece       = newPieceObject.GetComponent <Pieces>();

            if (withAnimation == false)
            {
                newPiece.NotCreateEffect();
            }

            fieldManager.WriteFieldInfo(PieceNum, absoluteFaceId);
            fieldManager.SetPieceAsChild(absoluteFaceId, newPieceObject);

            newPiece.Init(PieceNum, pieceKind, absoluteFaceId, forwardFaceId);

            newPieceObject.transform.LookAt(fieldManager.GetSurfaceInfoById(forwardFaceId).transform);
            fieldManager.AligmentObject(newPieceObject);

            myPieces.Add(newPiece.GetPieceId(), newPiece);
            PieceNum += 1;
        }
 // rotate selected piece
 private void rotatePiece(FieldManager field, Pieces piece, int degree)
 {
     piece.RotatePiece(degree);
     preDecision.SetMovePieceId(piece.GetPieceId());
     preDecision.SetMoveFaceId(piece.GetFaceId());
 }