コード例 #1
0
ファイル: NPCCollection.cs プロジェクト: kayorga/3DSP
        public void draw(Camera camera, SpriteBatch spriteBatch, SpriteFont font)
        {
            //TODO

            graphicsDevice.DepthStencilState = DepthStencilState.DepthRead;
            graphicsDevice.BlendState        = BlendState.Additive;
            billboardEngine.Draw(graphicsDevice, camera);
            graphicsDevice.BlendState        = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;

            foreach (NPC npc in _content)
            {
                npc.draw(camera, queue);
            }

            while (queue.Count > 0)
            {
                DmgNumber num   = queue.Dequeue();
                Color     color = (num.crit) ? Color.Gold : Color.White;

                spriteBatch.Begin();
                spriteBatch.DrawString(font, num.dmg.ToString(), num.position, color);
                spriteBatch.End();
            }

            graphicsDevice.BlendState        = BlendState.Opaque;
            graphicsDevice.DepthStencilState = DepthStencilState.Default;
            graphicsDevice.SamplerStates[0]  = SamplerState.LinearWrap;
            graphicsDevice.RasterizerState   = RasterizerState.CullCounterClockwise;
        }
コード例 #2
0
        public override void draw(Camera camera, Queue <DmgNumber> queue)
        {
            draw(camera);

            //crit number position calculation
            for (int i = 0; i < dmgNumbers.Count; i++)
            {
                DmgNumber dmgNum = dmgNumbers[i];
                if (!dmgNum.update())
                {
                    dmgNumbers.Remove(dmgNum);
                    i--;
                    continue;
                }

                Vector3 dmgNumPos3 = graphicsDevice.Viewport.Project(Vector3.Zero,
                                                                     camera.ProjectionMatrix,
                                                                     camera.ViewMatrix,
                                                                     Matrix.CreateTranslation(position + new Vector3(0, 2, 0)));

                dmgNum.setPos(dmgNumPos3.X, dmgNumPos3.Y);

                queue.Enqueue(dmgNum);
            }
        }