Пример #1
0
        private void DrawCellAndToken(Graphics g)
        {
            SceneObject possessCell  = null;
            SceneObject selectTarget = null;

            foreach (SceneObject obj in sceneItems)
            {
                if (obj.Id == cellTar)
                {
                    selectTarget = obj;
                }
                else
                {//先绘制非目标
                    obj.Draw(g, false);
                }

                if (obj.Id == UserProfile.Profile.InfoBasic.Position)
                {
                    possessCell = obj;
                }
            }

            if (selectTarget != null)
            {
                selectTarget.Draw(g, true);
            }


            if (possessCell != null)
            {
                Image token      = PicLoader.Read("Map", "Token.PNG");
                int   drawWidth  = token.Width * possessCell.Width / GameConstants.SceneTileStandardWidth;
                int   drawHeight = token.Height * possessCell.Height / GameConstants.SceneTileStandardHeight;
                if (movingData.Time <= 0)
                {
                    g.DrawImage(token, possessCell.X - drawWidth / 2 + possessCell.Width / 8,
                                possessCell.Y - drawHeight + possessCell.Height / 3, drawWidth, drawHeight);
                }
                else
                {
                    int realX = (int)(movingData.Source.X * (movingData.Time) / ChessMoveAnimTime +
                                      movingData.Dest.X * (ChessMoveAnimTime - movingData.Time) / ChessMoveAnimTime);
                    int yOff = (int)(Math.Pow(realX - (movingData.Source.X + movingData.Dest.X) / 2, 2) * (4 * 80) /
                                     Math.Pow(movingData.Source.X - movingData.Dest.X, 2) - 80);
                    var pos = new Point(realX, yOff + (int)(movingData.Source.Y * (movingData.Time) / ChessMoveAnimTime +
                                                            movingData.Dest.Y * (ChessMoveAnimTime - movingData.Time) / ChessMoveAnimTime));
                    g.DrawImage(token, pos.X, pos.Y, drawWidth, drawHeight);
                }
                token.Dispose();
            }
        }
Пример #2
0
            /// <summary>
            /// This is the main function of the class, it'll create a triangulated polygon
            /// from and SceneObject.
            /// </summary>
            /// <param name="sourceObject">The object to convert.</param>
            /// <param name="guarenteedView">A camera that can see the whole object.</param>
            /// <returns>A polygon created from 'sourceObject'.</returns>
            public Polygon CreatePolygon(OpenGL gl, SceneObject sourceObject, Cameras.Camera guarenteedView)
            {
                //	Save the current camera data.
                gl.MatrixMode(OpenGL.PROJECTION);
                gl.PushMatrix();

                //	Look through the camera that can see the object.
                guarenteedView.Project(gl);

                //	Start triangulation.
                Begin(gl);

                //	Draw the object.
                sourceObject.Draw(gl);

                //	End triangulation.
                End(gl);

                Polygon newPoly = Triangle;

                newPoly.Name = sourceObject.Name + " (Triangulated Poly)";
                return(newPoly);
            }
Пример #3
0
            /// <summary>
            /// This is the main function of the class, it'll create a triangulated polygon
            /// from and SceneObject.
            /// </summary>
            /// <param name="sourceObject">The object to convert.</param>
            /// <param name="guarenteedView">A camera that can see the whole object.</param>
            /// <returns>A polygon created from 'sourceObject'.</returns>
            public Polygon CreatePolygon(OpenGL gl, SceneObject sourceObject, Cameras.Camera guarenteedView)
            {
                //	Save the current camera data.
                gl.MatrixMode(OpenGL.PROJECTION);
                gl.PushMatrix();

                //	Look through the camera that can see the object.
                guarenteedView.Project(gl);

                //	Start triangulation.
                Begin(gl);

                //	Draw the object.
                sourceObject.Draw(gl);

                //	End triangulation.
                End(gl);

                Polygon newPoly = Triangle;
                newPoly.Name = sourceObject.Name + " (Triangulated Poly)";
                return newPoly;
            }