예제 #1
0
 public MeshBatcher(GraphicsDevice graphicsDevice)
 {
     this.GraphicsDevice  = graphicsDevice;
     this.alphaBlendState = StateEx.NonPremultipled_Hidef();
     this.maskState       = StateEx.SrcAlphaMask();
     this.meshPool        = new Stack <MeshItem>();
 }
예제 #2
0
 public MeshBatcher(GraphicsDevice graphicsDevice)
 {
     this.GraphicsDevice  = graphicsDevice;
     this.sprite          = new SpriteBatchEx(graphicsDevice);
     this.spineRender     = new SkeletonMeshRenderer(graphicsDevice);
     this.alphaBlendState = StateEx.NonPremultipled_Hidef();
 }
예제 #3
0
 public BvrRepeat(bool restartOnEnter, int repeatCount, StateEx stateEx, GSM_State state, Func <bool> isDone)
 {
     this.restartOnEnter = restartOnEnter;
     this.repeatCount    = repeatCount;
     this.curRepeatCount = 0;
     this.stateEx        = stateEx ?? new StateEx();
     this.state          = state;
     this.isDone         = isDone;
 }
예제 #4
0
        public void Draw(RenderEnv env, GameTime gameTime)
        {
            //计算UI偏移
            Matrix trans = Matrix.CreateTranslation(this.Position.X, this.Position.Y, 0);

            //绘制外框
            env.GraphicsDevice.ScissorRectangle = new Rectangle((int)this.Position.X, (int)this.Position.Y, (int)this.Size.X, (int)this.Size.Y);
            env.GraphicsDevice.RasterizerState  = StateEx.Scissor();

            env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
            env.Sprite.FillRectangle(this.MinimapRectangle, new Color(Color.Black, 0.7f));
            UIGraphics.DrawNineForm(env, this.resource, Vector2.Zero, this.Size);
            env.Sprite.End();

            env.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;

            //绘制标题
            if (this.MapNameFont != null)
            {
                env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                if (this.StreetName != null)
                {
                    env.Sprite.DrawStringEx(this.MapNameFont, this.StreetName, this.streetNameOrigin, Color.White);
                }
                if (this.MapName != null)
                {
                    env.Sprite.DrawStringEx(this.MapNameFont, this.MapName, this.mapNameOrigin, Color.White);
                }
                env.Sprite.End();
            }

            //绘制小地图
            if (this.MiniMap != null)
            {
                //绘制小地图标记
                env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                if (MapMarkVisible && this.MiniMap.MapMark != null)
                {
                    env.Sprite.Draw(this.MiniMap.MapMark, mapMarkOrigin, Color.White);
                }
                env.Sprite.End();

                if (this.MiniMap.Canvas != null)
                {
                    //计算世界地图到小地图的偏移
                    Texture2D canvas = this.MiniMap.Canvas;
                    Rectangle fromRect;
                    if (this.MiniMap.Width > 0 && this.MiniMap.Height > 0)
                    {
                        fromRect = new Rectangle(-this.MiniMap.CenterX, -this.MiniMap.CenterY, this.MiniMap.Width, this.MiniMap.Height);
                    }
                    else
                    {
                        fromRect = env.Camera.WorldRect;
                    }
                    Rectangle toRect         = new Rectangle(0, 0, canvas.Width, canvas.Height);
                    Matrix    worldToMinimap = Matrix.CreateTranslation(-fromRect.X, -fromRect.Y, 0)
                                               * Matrix.CreateScale(1f / fromRect.Width * toRect.Width, 1f / fromRect.Height * toRect.Height, 0)
                                               * Matrix.CreateTranslation(toRect.X, toRect.Y, 0);

                    //计算小地图区域的二次偏移
                    Rectangle rect   = this.MinimapRectangle;
                    Vector2   offset = new Vector2((rect.Width - canvas.Width) / 2, (rect.Height - canvas.Height) / 2);
                    worldToMinimap *= Matrix.CreateTranslation(offset.X, offset.Y, 0);

                    //设置剪裁区域
                    env.GraphicsDevice.ScissorRectangle = new Rectangle(
                        (int)this.Position.X + rect.X, (int)this.Position.Y + rect.Y, rect.Width, rect.Height);
                    env.GraphicsDevice.RasterizerState = StateEx.Scissor();

                    //绘制小地图本体
                    env.Sprite.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, transformMatrix: trans);
                    env.Sprite.Draw(this.MiniMap.Canvas, miniMapOrigin + offset, Color.White);

                    if (this.ResourceLoaded)
                    {
                        Vector2 iconOrigin = new Vector2(0, 5);
                        //绘制一般传送门
                        if (this.Portals.Count > 0 && this.texPortal != null)
                        {
                            Vector2 origin = new Vector2(this.texPortal.Width / 2, this.texPortal.Height / 2);
                            foreach (var portal in this.Portals)
                            {
                                Vector2 position = Vector2.Transform(portal, worldToMinimap);
                                position = miniMapOrigin + position - origin - iconOrigin;
                                position = MathHelper2.Round(position);
                                env.Sprite.Draw(this.texPortal, position, Color.White);
                            }
                        }

                        //绘制地图内传送门
                        if (this.Transports.Count > 0 && this.texTransport != null)
                        {
                            Vector2 origin = new Vector2(this.texTransport.Width / 2, this.texTransport.Height / 2);
                            foreach (var portal in this.Transports)
                            {
                                Vector2 position = Vector2.Transform(portal, worldToMinimap);
                                position = miniMapOrigin + position - origin - iconOrigin;
                                position = MathHelper2.Round(position);
                                env.Sprite.Draw(this.texTransport, position, Color.White);
                            }
                        }
                    }

                    //绘制摄像机区域框
                    Rectangle cameraRect = MathHelper2.Transform(env.Camera.ClipRect, worldToMinimap);
                    cameraRect.X += (int)miniMapOrigin.X;
                    cameraRect.Y += (int)miniMapOrigin.Y;
                    env.Sprite.DrawRectangle(cameraRect, Color.Yellow);
                    env.Sprite.End();
                    env.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
                }
            }
        }
예제 #5
0
 public static extern uint XInputGetStateEx(uint dwUserIndex, ref StateEx pState);
예제 #6
0
 public void Draw(GameTime gameTime, RenderEnv renderEnv)
 {
     renderEnv.Sprite.Begin(SpriteSortMode.Deferred, StateEx.NonPremultipled_Hidef());
     DrawNode(Base, gameTime, renderEnv);
     renderEnv.Sprite.End();
 }
예제 #7
0
 public BvrSingle(StateEx stateEx, GSM_State state, Func <bool> isDone)
 {
     this.stateEx = stateEx ?? new StateEx();
     this.state   = state;
     this.isDone  = isDone;
 }