コード例 #1
0
ファイル: Triangle3D.cs プロジェクト: CedricHanebaum/Dame
 public Triangle3D(Vector3D v1, Vector3D v2, Vector3D v3, Color color)
 {
     this.v1 = v1;
     this.v2 = v2;
     this.v3 = v3;
     this.color = color;
 }
コード例 #2
0
ファイル: Triangle3D.cs プロジェクト: CedricHanebaum/Dame
 public static Triangle3D operator +(Triangle3D t, Vector3D v)
 {
     Vector3D v1, v2, v3;
     v1 = t.getV1() + v;
     v2 = t.getV2() + v;
     v3 = t.getV3() + v;
     return new Triangle3D(v1, v2, v3, t.getColor());
 }
コード例 #3
0
ファイル: Vector3D.cs プロジェクト: CedricHanebaum/Dame
        public static Point Vector3DToISO(Vector3D v)
        {
            int x = 0, y = 0;

            x = (int)(1 * v.getX() + -1 * v.getY() + 0 * v.getZ());
            y = (int)(0.5 * v.getX() + 0.5 * v.getY() + -1 * v.getZ());

            return new Point(x, y);
        }
コード例 #4
0
ファイル: Board3D.cs プロジェクト: CedricHanebaum/Dame
        // kaputt
        public int getFieldX(Vector3D v)
        {
            if (!this.isInside(v)) throw new ArgumentException();

            for (int i = 0; i < size; ++i) {
                for (int j = 0; j < size; ++j) {
                    if (this.isInsideField(i, j, v)) return i;
                }
            }

            return -1;
        }
コード例 #5
0
ファイル: Board3D.cs プロジェクト: CedricHanebaum/Dame
        public Board3D(Vector3D basePoint, int size)
            : base(basePoint)
        {
            if (!(size == 8 || size == 10)) throw new ArgumentException();
            this.size = size;

            for (int i = 0; i < size; i++) {
                for (int j = 0; j < size; j++) {
                    Color color = (i + j) % 2 == 0 ? COLOR_WHITE: COLOR_BLACK;

                    Triangle3D[] rect = this.getRect(i * RECTSIZE, j * RECTSIZE, color);

                    this.addTriangle(rect[0]);
                    this.addTriangle(rect[1]);
                }
            }

            Vector3D v01 = new Vector3D(0, 0, 0);
            Vector3D v02 = new Vector3D(RECTSIZE * size, 0, 0);
            Vector3D v03 = new Vector3D(0, RECTSIZE * size, 0);
            Vector3D v04 = new Vector3D(RECTSIZE * size, RECTSIZE * size, 0);

            Vector3D v05 = v01 + new Vector3D(-EDGEWIDTH, -EDGEWIDTH, 0);
            Vector3D v06 = v02 + new Vector3D(EDGEWIDTH, -EDGEWIDTH, 0);
            Vector3D v07 = v03 + new Vector3D(-EDGEWIDTH, EDGEWIDTH, 0);
            Vector3D v08 = v04 + new Vector3D(EDGEWIDTH, EDGEWIDTH, 0);

            Vector3D v09 = v01 + new Vector3D(-EDGEWIDTH, 0, 0);
            Vector3D v10 = v02 + new Vector3D(0, -EDGEWIDTH, 0);
            Vector3D v11 = v03 + new Vector3D(0, EDGEWIDTH, 0);
            Vector3D v12 = v04 + new Vector3D(EDGEWIDTH, 0, 0);

            Triangle3D t1 = new Triangle3D(v05, v09, v02, EDGE_COLOR);
            Triangle3D t2 = new Triangle3D(v05, v02, v10, EDGE_COLOR);

            Triangle3D t3 = new Triangle3D(v10, v06, v04, EDGE_COLOR);
            Triangle3D t4 = new Triangle3D(v12, v06, v04, EDGE_COLOR);

            Triangle3D t5 = new Triangle3D(v12, v03, v08, EDGE_COLOR);
            Triangle3D t6 = new Triangle3D(v07, v03, v08, EDGE_COLOR);

            Triangle3D t7 = new Triangle3D(v11, v07, v09, EDGE_COLOR);
            Triangle3D t8 = new Triangle3D(v11, v01, v09, EDGE_COLOR);

            this.addTriangle(t1);
            this.addTriangle(t2);
            this.addTriangle(t3);
            this.addTriangle(t4);
            this.addTriangle(t5);
            this.addTriangle(t6);
            this.addTriangle(t7);
            this.addTriangle(t8);
        }
コード例 #6
0
ファイル: Token3D.cs プロジェクト: CedricHanebaum/Dame
        public Token3D(Vector3D basePoint, PlayerColor color)
            : base(basePoint)
        {
            switch (color) {
                case PlayerColor.Black:
                    firstColor = Color.Blue;
                    secondColor = Color.DarkBlue;
                    break;
                case PlayerColor.White:
                    firstColor = Color.Red;
                    secondColor = Color.DarkRed;
                    break;
            }

            List<Vector3D> up = new List<Vector3D>();
            List<Vector3D> down = new List<Vector3D>();

            for (int i = 0; i <= 16; ++i) {
                int gegenkathete = (int) (Math.Sin((Math.PI / (RESOLUTION / 2)) * i) * RADIUS);
                int ankathete = (int)(Math.Cos((Math.PI / (RESOLUTION / 2)) * i) * RADIUS);

                up.Add(new Vector3D(ankathete, gegenkathete, HEIGHT));
                down.Add(new Vector3D(ankathete, gegenkathete, 0));
            }

            // Circle down
            for (int i = 0; i < down.Count - 1; ++i) {
                this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), down[i], down[i + 1], firstColor));
            }
            this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), down[down.Count - 1], down[0], firstColor));

            // Side Triangle up, up, down
            for (int i = 0; i < up.Count - 1; ++i) {
                this.addTriangle(new Triangle3D(up[i], up[i + 1], down[i], secondColor));
            }
            this.addTriangle(new Triangle3D(up[up.Count - 1], up[1], down[down.Count - 1], secondColor));

            // Side Triangle down, down, up
            for (int i = 0; i < down.Count - 1; ++i) {
                this.addTriangle(new Triangle3D(down[i], down[i + 1], up[i + 1], secondColor));
            }
            this.addTriangle(new Triangle3D(down[down.Count - 1], down[1], up[1], secondColor));

            // Circle Up
            for (int i = 0; i < up.Count - 1; ++i) {
                this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), up[i], up[i + 1], firstColor));
            }
            this.addTriangle(new Triangle3D(new Vector3D(0, 0, 10), up[up.Count - 1], up[0], firstColor));
        }
コード例 #7
0
ファイル: GhostToken3D.cs プロジェクト: CedricHanebaum/Dame
        public GhostToken3D(Vector3D basePoint, PlayerColor playerColor)
            : base(basePoint)
        {
            switch (playerColor) {
                case PlayerColor.Black:
                    color = colorBlack;
                    break;
                case PlayerColor.White:
                    color = colorWhite;
                    break;
            }

            List<Vector3D> up = new List<Vector3D>();
            List<Vector3D> down = new List<Vector3D>();

            for (int i = 0; i <= 16; ++i) {
                int gegenkathete = (int)(Math.Sin((Math.PI / (RESOLUTION / 2)) * i) * RADIUS);
                int ankathete = (int)(Math.Cos((Math.PI / (RESOLUTION / 2)) * i) * RADIUS);

                up.Add(new Vector3D(ankathete, gegenkathete, HEIGHT));
                down.Add(new Vector3D(ankathete, gegenkathete, 0));
            }

            // Circle down
            for (int i = 0; i < down.Count - 1; ++i) {
                this.addLine(new Line3D(down[i], down[i + 1], color));
            }
            this.addLine(new Line3D(down[down.Count -1], down[0], color));

            // Side Triangle up, up, down
            for (int i = 0; i < up.Count; ++i) {
                this.addLine(new Line3D(up[i], down[i], color));
            }

            // Circle Up
            for (int i = 0; i < up.Count - 1; ++i) {
                this.addLine(new Line3D(up[i], up[i + 1], color));
            }
            this.addLine(new Line3D(up[up.Count - 1], up[0], color));
        }
コード例 #8
0
ファイル: Diamond3D.cs プロジェクト: CedricHanebaum/Dame
        public Diamond3D(Vector3D basePoint)
            : base(basePoint)
        {
            Vector3D v1 = new Vector3D(5, 5, 0);
            Vector3D v2 = new Vector3D(-5, 5, 0);
            Vector3D v3 = new Vector3D(5, -5, 0);
            Vector3D v4 = new Vector3D(-5, -5, 0);

            Vector3D v5 = new Vector3D(0, 0, 8);
            Vector3D v6 = new Vector3D(0, 0, -8);

            Triangle3D t1 = new Triangle3D(v5, v1, v2, Color.Green);
            Triangle3D t2 = new Triangle3D(v6, v1, v2, Color.Green);

            Triangle3D t3 = new Triangle3D(v5, v1, v3, Color.DarkGreen);
            Triangle3D t4 = new Triangle3D(v6, v1, v3, Color.DarkGreen);

            this.addTriangle(t1);
            this.addTriangle(t2);
            this.addTriangle(t3);
            this.addTriangle(t4);
        }
コード例 #9
0
ファイル: Board3D.cs プロジェクト: CedricHanebaum/Dame
        private bool isInsideField(int x, int y, Vector3D v)
        {
            if (x < 0 || x > size) throw new ArgumentException();
            if (y < 0 || y > size) throw new ArgumentException();
            bool ret = false;

            Vector3D basePoint = this.getBasePoint();

            // up left
            Vector3D field1 = new Vector3D(x * RECTSIZE, y * RECTSIZE, 0);
            // down right
            Vector3D field2 = new Vector3D(x * RECTSIZE + RECTSIZE, y * RECTSIZE + RECTSIZE, 0);

            if (v.getX() >= (basePoint + field1).getX() && v.getX() <= (basePoint + field1).getX() + RECTSIZE) {
                if (v.getY() >= (basePoint + field1).getY() && v.getY() <= (basePoint + field1).getY() + RECTSIZE) {
                    if (v.getZ() == (basePoint + field1).getZ()) {
                        return ret = true;
                    }
                }
            }

            return ret;
        }
コード例 #10
0
ファイル: Board3D.cs プロジェクト: CedricHanebaum/Dame
        private Triangle3D[] getRect(int x, int y, Color color)
        {
            Triangle3D[] ret = new Triangle3D[2];

            Vector3D v1 = new Vector3D(x, y, 0);
            Vector3D v2 = new Vector3D(x + RECTSIZE, y, 0);
            Vector3D v3 = new Vector3D(x, y + RECTSIZE, 0);
            Vector3D v4 = new Vector3D(x + RECTSIZE, y + RECTSIZE, 0);

            ret[0] = new Triangle3D(v1, v2, v3, color);
            ret[1] = new Triangle3D(v4, v2, v3, color);

            return ret;
        }
コード例 #11
0
ファイル: Board3D.cs プロジェクト: CedricHanebaum/Dame
        public bool isInside(Vector3D v)
        {
            Vector3D basePoint = this.getBasePoint();
            int length = RECTSIZE * size;

            if (v.getX() >= basePoint.getX() && v.getX() <= basePoint.getX() + length) {
                if (v.getY() >= basePoint.getY() && v.getY() <= basePoint.getY() + length) {
                    if (v.getZ() == basePoint.getZ()) {
                        return true;
                    }
                }
            }

            return false;
        }
コード例 #12
0
ファイル: World.cs プロジェクト: CedricHanebaum/Dame
        public override void draw(Graphics g)
        {
            if (visible) {
                board.draw(g);

                for (int i = 0; i < tokens.GetLength(0); ++i) {
                    for (int j = 0; j < tokens.GetLength(1); ++j) {

                        Token3D token1;
                        Token3D token2;

                        GhostToken3D gToken1;
                        GhostToken3D gToken2;

                        Vector3D v1 = new Vector3D(0, 0, 10);

                        Vector3D tokenPosRel = new Vector3D(48 * i, 48 * j, 0);
                        Vector3D tokenPosAbs = tokenBase + tokenPosRel;

                        switch (tokens[i, j]) {
                            case Token.Black:
                                token1 = new Token3D(tokenPosAbs, Token3D.PlayerColor.Black);
                                token1.draw(g);
                                break;
                            case Token.White:
                                token1 = new Token3D(tokenPosAbs, Token3D.PlayerColor.White);
                                token1.draw(g);
                                break;
                            case Token.BlackDraugth:
                                token1 = new Token3D(tokenPosAbs, Token3D.PlayerColor.Black);
                                token2 = new Token3D(tokenPosAbs + v1, Token3D.PlayerColor.Black);

                                token1.draw(g);
                                token2.draw(g);

                                break;
                            case Token.WhiteDraugth:
                                token1 = new Token3D(tokenPosAbs, Token3D.PlayerColor.White);
                                token2 = new Token3D(tokenPosAbs + v1, Token3D.PlayerColor.White);

                                token1.draw(g);
                                token2.draw(g);

                                break;
                            case Token.BlackGhost:
                                gToken1 = new GhostToken3D(tokenPosAbs, GhostToken3D.PlayerColor.Black);
                                gToken1.draw(g);
                                break;
                            case Token.WhiteGhost:
                                gToken1 = new GhostToken3D(tokenPosAbs, GhostToken3D.PlayerColor.White);
                                gToken1.draw(g);
                                break;
                            case Token.BlackDraugthGhost:
                                gToken1 = new GhostToken3D(tokenPosAbs, GhostToken3D.PlayerColor.Black);
                                gToken2 = new GhostToken3D(tokenPosAbs + v1, GhostToken3D.PlayerColor.Black);

                                gToken1.draw(g);
                                gToken2.draw(g);
                                break;
                            case Token.WhiteDraugthGhost:
                                gToken1 = new GhostToken3D(tokenPosAbs, GhostToken3D.PlayerColor.White);
                                gToken2 = new GhostToken3D(tokenPosAbs + v1, GhostToken3D.PlayerColor.White);

                                gToken1.draw(g);
                                gToken2.draw(g);
                                break;
                            case Token.empty:
                                break;
                        }

                    }
                }
            }
        }
コード例 #13
0
ファイル: Line3D.cs プロジェクト: CedricHanebaum/Dame
 public Line3D(Vector3D v1, Vector3D v2, Color color)
 {
     this.v1 = v1;
     this.v2 = v2;
     this.color = color;
 }
コード例 #14
0
ファイル: Shape.cs プロジェクト: CedricHanebaum/Dame
 protected FilledShape(Vector3D basePoint)
 {
     this.basePoint = basePoint;
 }
コード例 #15
0
ファイル: GhostShape.cs プロジェクト: CedricHanebaum/Dame
 protected GhostShape(Vector3D basePoint)
 {
     this.basePoint = basePoint;
 }