示例#1
0
        //駒をrotate辺回転する ex)rotateが-1で10角形なら-36度
        public void RotatePiece(int pieceId, int rotate)
        {
            Pieces piece = GetPieceById(pieceId);

            int        rotationAmount = (360 / piece.GetShape()) * rotate;
            Quaternion rot            = Quaternion.AngleAxis(rotationAmount, Vector3.up);
            Quaternion q = piece.transform.rotation;

            piece.transform.rotation = q * rot;

            int forwardFaceId = fieldManager.ConvertRelative2AbsId(piece.GetFaceId(), 0, piece.GetForwardDirection());

            piece.SetForwardFaceId(forwardFaceId);
        }
        // return circle faceId
        private List <int> circleFaceIdCheck(FieldManager field, Pieces piece)
        {
            //何角形のますにいるかをint型で返す
            int        faceShape         = piece.GetShape();
            List <int> circleFaceIdCheck = new List <int>();
            //辞書型配列で受け取る
            Dictionary <int, List <int> > MovableRange = GameManager.ManagerStore.piecesManager.GetMoveRange(piece.GetKind());
            //辞書型配列で受け取った稼働範囲からforeachでそれぞれ検証
            List <int> movableFaces = MovableRange[faceShape];

            foreach (int movableFace in movableFaces)
            {
                //候補の面の相対idを絶対idに変換
                circleFaceIdCheck.Add(field.ConvertRelative2AbsId(piece.GetFaceId(), movableFace, piece.GetForwardDirection()));
            }
            return(circleFaceIdCheck);
        }
        //kingフラフラストラテギー
        private void TestStrategy(PlayerBase cp, FieldManager field)
        {
            int count = 0;
            //pieceリストから先頭を取得
            List <Pieces> CpList = cp.GetMyPieces();

            foreach (Pieces candidate in CpList)
            {
                //何角形のますにいるかをint型で返す
                int faceShape = candidate.GetShape();

                //辞書型配列で受け取る
                Dictionary <int, List <int> > MovableRange = GameManager.ManagerStore.piecesManager.GetMoveRange(candidate.GetKind());

                //辞書型配列で受け取った稼働範囲からforeachでそれぞれ検証
                List <int> movableFaces = MovableRange[faceShape];

                foreach (int movableFace in movableFaces)
                {
                    //候補の面の相対idを絶対idに変換
                    int candidateFace = field.ConvertRelative2AbsId(candidate.GetFaceId(), movableFace, candidate.GetForwardDirection());
                    check = field.IsPieceOnFace(candidateFace);
                    if (check == -1)
                    {
                        //       Debug.Log("敵艦見ゆ?");
                        preDecision.SetMovePieceId(candidate.GetPieceId()); //移動する駒のid
                        preDecision.SetMoveFaceId(candidateFace);           //移動先の絶対id
                        count++;
                        break;
                    }
                    if (candidate.GetKind().ToString().Equals("Pawn"))
                    {
                        break;
                    }
                }
                if (count != 0)
                {
                    break;
                }
            }
        }