Ejemplo n.º 1
0
        public void test_scores()
        {
            var highCard = new HighCard();

            Assert.AreEqual(0, highCard.Score);
            var onePair = new OnePair();

            Assert.AreEqual(1, onePair.Score);
            var twoPairs = new TwoPairs();

            Assert.AreEqual(2, twoPairs.Score);
            var set = new Set();

            Assert.AreEqual(3, set.Score);
            var straight = new Straight();

            Assert.AreEqual(4, straight.Score);
            var flush = new Flush();

            Assert.AreEqual(5, flush.Score);
            var fullHouse = new FullHouse();

            Assert.AreEqual(6, fullHouse.Score);
            var quads = new Quads();

            Assert.AreEqual(7, quads.Score);
            var straightFlush = new StraightFlush();

            Assert.AreEqual(8, straightFlush.Score);
            var royalFlush = new RoyalFlush();

            Assert.AreEqual(9, royalFlush.Score);
        }
 // Token: 0x060002B6 RID: 694 RVA: 0x00022580 File Offset: 0x00020780
 public virtual void AddBokeh(RenderTexture bokehInfo, RenderTexture tempTex, RenderTexture finalTarget)
 {
     if (this.bokehMaterial)
     {
         Mesh[] meshes = Quads.GetMeshes(tempTex.width, tempTex.height);
         RenderTexture.active = tempTex;
         GL.Clear(false, true, new Color((float)0, (float)0, (float)0, (float)0));
         GL.PushMatrix();
         GL.LoadIdentity();
         bokehInfo.filterMode = FilterMode.Point;
         float num  = (float)bokehInfo.width * 1f / ((float)bokehInfo.height * 1f);
         float num2 = 2f / (1f * (float)bokehInfo.width);
         num2 += this.bokehScale * this.maxBlurSpread * DepthOfField34.BOKEH_EXTRA_BLUR * this.oneOverBaseSize;
         this.bokehMaterial.SetTexture("_Source", bokehInfo);
         this.bokehMaterial.SetTexture("_MainTex", this.bokehTexture);
         this.bokehMaterial.SetVector("_ArScale", new Vector4(num2, num2 * num, 0.5f, 0.5f * num));
         this.bokehMaterial.SetFloat("_Intensity", this.bokehIntensity);
         this.bokehMaterial.SetPass(0);
         int    i      = 0;
         Mesh[] array  = meshes;
         int    length = array.Length;
         while (i < length)
         {
             if (array[i])
             {
                 Graphics.DrawMeshNow(array[i], Matrix4x4.identity);
             }
             i++;
         }
         GL.PopMatrix();
         Graphics.Blit(tempTex, finalTarget, this.dofMaterial, 8);
         bokehInfo.filterMode = FilterMode.Bilinear;
     }
 }
Ejemplo n.º 3
0
        public void WriteToOBJ(TextWriter writer, int lodNumber, int firstVertexNumber, int firstNormalNumber, int firstCoordNumber,
                               Dictionary <string, int?> materialNames, Stream unknownData)
        {
            unknownData.Write(unknown);
            unknownData.WriteByte(unknown2);
            unknownData.WriteByte(unknown3);

            double scaleFactor = ConvertScale(Scale);

            writer.WriteLine($"g lod{lodNumber}/scale={scaleFactor}");

            writer.WriteLine("# vertices");
            Vertices.ForEach(vertex => vertex.WriteToOBJ(writer, scaleFactor));

            writer.WriteLine("# normals");
            Normals.ForEach(normal => normal.WriteToOBJ(writer));

            List <UVCoordinate> coords = GetAllUVCoords();

            writer.WriteLine("# UV coords");
            coords.ForEach(coord => coord.WriteToOBJ(writer));

            writer.WriteLine("# triangles");
            Triangles.ForEach(polygon => polygon.WriteToOBJ(writer, false, Vertices, Normals, firstVertexNumber, firstNormalNumber, materialNames));

            writer.WriteLine("# quads");
            Quads.ForEach(polygon => polygon.WriteToOBJ(writer, true, Vertices, Normals, firstVertexNumber, firstNormalNumber, materialNames));

            writer.WriteLine("# UV triangles");
            UVTriangles.ForEach(polygon => polygon.WriteToOBJ(writer, false, Vertices, Normals, firstVertexNumber, firstNormalNumber, coords, firstCoordNumber, materialNames));

            writer.WriteLine("# UV quads");
            UVQuads.ForEach(polygon => polygon.WriteToOBJ(writer, true, Vertices, Normals, firstVertexNumber, firstNormalNumber, coords, firstCoordNumber, materialNames));
        }
Ejemplo n.º 4
0
 public static Mesh[] GetMeshes(int totalWidth, int totalHeight)
 {
     Mesh[] arg_99_0;
     if (Quads.HasMeshes() && Quads.currentQuads == totalWidth * totalHeight)
     {
         arg_99_0 = Quads.meshes;
     }
     else
     {
         int num  = 10833;
         int num2 = totalWidth * totalHeight;
         Quads.currentQuads = num2;
         int num3 = Mathf.CeilToInt(1f * (float)num2 / (1f * (float)num));
         Quads.meshes = new Mesh[num3];
         int num4 = 0;
         for (int i = 0; i < num2; i += num)
         {
             int triCount = Mathf.FloorToInt((float)Mathf.Clamp(num2 - i, 0, num));
             Quads.meshes[num4] = Quads.GetMesh(triCount, i, totalWidth, totalHeight);
             num4++;
         }
         arg_99_0 = Quads.meshes;
     }
     return(arg_99_0);
 }
Ejemplo n.º 5
0
        public override void Draw()
        {
            Quads.Begin();
            Quads.Render(_topLeft, _bottomRight, null, true, Colors.Black, Colors.Grey * 0.95f);
            Quads.End();

            // Draw each menu entry in turn.
            Quads.Begin();
            foreach (OptionEntry entry in _optionEntries)
            {
                Quads.Render(entry.Position - _optionEntrySize / 2f, entry.Position + _optionEntrySize / 2f, null, true, Colors.Black * TransitionAlpha, entry.TileColor * TransitionAlpha);
                Quads.Render(entry.Position - _optionEntrySize / 2f + _optionCheckOffset, entry.Position + _optionEntrySize / 2f, null, true, Colors.Black * TransitionAlpha, entry.TileColor * TransitionAlpha);
            }

            Quads.End();

            Sprites.Begin();
            foreach (OptionEntry entry in _optionEntries)
            {
                Sprites.DrawString(_font, entry.Text, entry.Position + Vector2.One + _optionTextOffset, Colors.Black * TransitionAlpha, 0f, entry.Origin, entry.Scale, SpriteEffects.None, 0f);
                Sprites.DrawString(_font, entry.Text, entry.Position + _optionTextOffset, entry.TextColor * TransitionAlpha, 0f, entry.Origin, entry.Scale, SpriteEffects.None, 0f);
                Sprites.Draw(_checkmark, entry.Position - _optionEntrySize / 2f + _optionCheckOffset, Color.White * entry.CheckedFade);
            }

            Sprites.End();
        }
Ejemplo n.º 6
0
    public void AddBokeh(RenderTexture bokehInfo, RenderTexture tempTex, RenderTexture finalTarget)
    {
        if (!bokehMaterial)
        {
            return;
        }
        Mesh[] meshes = Quads.GetMeshes(tempTex.width, tempTex.height);
        RenderTexture.active = tempTex;
        GL.Clear(clearDepth: false, clearColor: true, new Color(0f, 0f, 0f, 0f));
        GL.PushMatrix();
        GL.LoadIdentity();
        bokehInfo.filterMode = FilterMode.Point;
        float num  = (float)bokehInfo.width * 1f / ((float)bokehInfo.height * 1f);
        float num2 = 2f / (1f * (float)bokehInfo.width);

        num2 += bokehScale * maxBlurSpread * BOKEH_EXTRA_BLUR * oneOverBaseSize;
        bokehMaterial.SetTexture("_Source", bokehInfo);
        bokehMaterial.SetTexture("_MainTex", bokehTexture);
        bokehMaterial.SetVector("_ArScale", new Vector4(num2, num2 * num, 0.5f, 0.5f * num));
        bokehMaterial.SetFloat("_Intensity", bokehIntensity);
        bokehMaterial.SetPass(0);
        int i = 0;

        Mesh[] array = meshes;
        for (int length = array.Length; i < length; i++)
        {
            if ((bool)array[i])
            {
                Graphics.DrawMeshNow(array[i], Matrix4x4.identity);
            }
        }
        GL.PopMatrix();
        Graphics.Blit(tempTex, finalTarget, dofMaterial, 8);
        bokehInfo.filterMode = FilterMode.Bilinear;
    }
Ejemplo n.º 7
0
        public Quad CreateQuad(Effect effect)
        {
            Quad quad = Quads.New();

            quad.Effect = effect;
            Quads.Sort(Quad.QuadComparer);
            return(quad);
        }
Ejemplo n.º 8
0
        public Quad CreateQuad(Effect effect, Texture2D texture)
        {
            Quad quad = Quads.New();

            quad.Effect = effect;
            quad.SetTexture(texture);
            Quads.Sort(Quad.QuadComparer);
            return(quad);
        }
Ejemplo n.º 9
0
    private List <IRenderable> CreateMeshes(List <Chunk> chunks)
    {
        float uvWidth = 2048.0f / 16.0f;
        float uvCell  = uvWidth / 2048.0f;

        float   xUv          = uvCell * 2.0f;
        float   yUv          = uvCell * 15.0f;
        Vector2 uvCoordinate = new Vector2(xUv, yUv);
        Vector2 uvOffset     = new Vector2(uvCell, uvCell);

        var blockPos = new Vector3();
        var list     = new List <IRenderable>();

        foreach (var chunk in chunks)
        {
            for (uint x = 0; x < Chunk.Width; ++x)
            {
                for (uint y = 0; y < Chunk.Height; ++y)
                {
                    for (uint z = 0; z < Chunk.Depth; ++z)
                    {
                        blockPos.X = x;
                        blockPos.Y = y;
                        blockPos.Z = z;

                        var block = chunk.At(x, y, z);

                        if (block.BlockType != BlockType.Air)
                        {
                            foreach (Side side in Sides.All)
                            {
                                // Chunk borders TBD
                                if (Chunk.IsChunkBorder(x, y, z))
                                {
                                    _pool.AddFace(Quads.QuadFor(side), block.World, uvCoordinate, uvOffset);
                                    continue;
                                }

                                // Check block next to current block in direction of the side.
                                //  - If neighbor exists and not air block, don't draw
                                var dir = Directions.DirectionFor(side);
                                if (chunk.At(blockPos + dir).BlockType == BlockType.Air)
                                {
                                    _pool.AddFace(Quads.QuadFor(side), block.World, uvCoordinate, uvOffset);
                                }
                            }
                        }
                    }
                }
            }
            list.Add(new ChunkMesh(chunk, _pool.ToMesh(_program)));
            _pool.Reset();
        }

        return(list);
    }
Ejemplo n.º 10
0
 public void Draw(Matrix view, Matrix projection)
 {
     foreach (Quad quad in Quads)
     {
         if (quad.Active)
         {
             quad.Draw(view, projection, Light);
         }
     }
     Quads.CleanUp();
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Draws the message box.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            Quads.Begin();
            Quads.Render(_topLeft, _bottomRight, null, true, ContentWrapper.Black, ContentWrapper.Grey * 0.65f);
            Quads.End();

            SpriteBatch.Begin();
            // Draw the message box text.
            SpriteBatch.DrawString(_font, _message, _textPosition + Vector2.One, ContentWrapper.Black);
            SpriteBatch.DrawString(_font, _message, _textPosition, ContentWrapper.Beige);
            SpriteBatch.End();
        }
Ejemplo n.º 12
0
        /// <summary>Draws the message box.</summary>
        public override void Draw()
        {
            Quads.Begin();
            Quads.Render(_topLeft, _bottomRight, null, true, Colors.Black, Colors.Grey * 0.65f);
            Quads.End();

            Sprites.Begin();

            // Draw the message box text.
            Sprites.DrawString(_font, _message, _textPosition + Vector2.One, Colors.Black);
            Sprites.DrawString(_font, _message, _textPosition, Colors.Beige);
            Sprites.End();
        }
Ejemplo n.º 13
0
        public void quads_yes()
        {
            var set   = new Quads();
            var cards = Cards.New()
                        .Ace(Suit.GetAll().ToArray())
                        .SpadesTen()
                        .SpadesKing()
                        .ClubsFive();

            set.SetCards(cards);
            var result = set.IsPresent();

            Assert.IsTrue(result);
        }
Ejemplo n.º 14
0
        public static void UpdateCache()
        {
            System.Collections.Generic.List <QuadHold> rem = new System.Collections.Generic.List <QuadHold>();
            int time = Environment.TickCount;

            foreach (var q in Quads)
            {
                if ((q.LastUsed + 500) < time)
                {
                    rem.Add(q);
                }
            }
            foreach (var rq in rem)
            {
                Quads.Remove(rq);
            }
        }
Ejemplo n.º 15
0
        public void quads_no()
        {
            var set   = new Quads();
            var cards = new List <Card>
            {
                new Card(Suit.Clubs, Rank.Ace),
                new Card(Suit.Diamonds, Rank.Ace),
                new Card(Suit.Spades, Rank.Ace),
                new Card(Suit.Hearts, Rank.King),
                new Card(Suit.Spades, Rank.Ten),
                new Card(Suit.Spades, Rank.King)
            };

            set.SetCards(cards);
            var result = set.IsPresent();

            Assert.IsFalse(result);
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            Vector2 transitionOffset = new Vector2(0f, (float)Math.Pow(TransitionPosition, 2) * 90f);

            // Draw each menu entry in turn.
            Quads.Begin();
            foreach (MenuEntry entry in _menuEntries)
            {
                Quads.Render(entry.Position - _menuEntrySize / 2f, entry.Position + _menuEntrySize / 2f, null, true,
                             ContentWrapper.Grey * entry.Alpha * TransitionAlpha, entry.TileColor * entry.Alpha * TransitionAlpha);
            }

            Quads.Render(_menuSlider.Position - new Vector2(_menuEntrySize.Y / 2f),
                         _menuSlider.Position + new Vector2(_menuEntrySize.Y / 2f), null, true,
                         ContentWrapper.Grey * TransitionAlpha, _menuSlider.TileColor * TransitionAlpha);

            Quads.End();

            Sprites.Begin();
            foreach (MenuEntry entry in _menuEntries)
            {
                Sprites.DrawString(_font, entry.Text, entry.Position + Vector2.One, ContentWrapper.Black * entry.Alpha * entry.Alpha * TransitionAlpha,
                                   0f, entry.Origin, entry.Scale, SpriteEffects.None, 0f);
                Sprites.DrawString(_font, entry.Text, entry.Position, entry.TextColor * entry.Alpha * TransitionAlpha,
                                   0f, entry.Origin, entry.Scale, SpriteEffects.None, 0f);

                if (entry.Fade > 0f)
                {
                    Sprites.Draw(entry.Preview, PreviewPosition, null, Color.White * Math.Max((TransitionAlpha - 0.8f) / 0.2f, 0f) * entry.Fade, 0f, _previewOrigin, 1f, SpriteEffects.None, 0f);
                }
            }
            Sprites.End();

            Quads.Begin();
            Quads.Render(Vector2.Zero, new Vector2(Framework.GraphicsDevice.Viewport.Width, TitleBarHeight), null, ContentWrapper.Grey * 0.7f * TransitionAlpha);
            Quads.End();

            // Make the menu slide into place during transitions, using a
            // power curve to make things look more interesting (this makes
            // the movement slow down as it nears the end).
            Sprites.Begin();
            Sprites.Draw(_samplesLogo, _titlePosition - transitionOffset, null, Color.White, 0f, _titleOrigin, 1f, SpriteEffects.None, 0f);
            Sprites.End();
        }
Ejemplo n.º 17
0
    void AddBokeh(RenderTexture bokehInfo, RenderTexture tempTex, RenderTexture finalTarget)
    {
        if (bokehMaterial)
        {
            Mesh[] meshes = Quads.GetMeshes(tempTex.width, tempTex.height);

            RenderTexture.active = tempTex;
            GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));

            GL.PushMatrix();
            GL.LoadIdentity();

            // important, otherwise we get bokeh shape & size artefacts
            bokehInfo.filterMode = FilterMode.Point;

            float arW = (bokehInfo.width * 1.0f) / (bokehInfo.height * 1.0f);
            //float sc = BOKEH_EXTRA_BLUR / bokehInfo.height + bokehScale * maxBlurSpread * BOKEH_EXTRA_BLUR * oneOverBaseSize;

            float sc = 2.0f / (1.0f * bokehInfo.width);
            sc += bokehScale * maxBlurSpread * BOKEH_EXTRA_BLUR * oneOverBaseSize;

            bokehMaterial.SetTexture("_Source", bokehInfo);
            bokehMaterial.SetTexture("_MainTex", bokehTexture);
            bokehMaterial.SetVector("_ArScale", new Vector4(sc, sc * arW, 0.5f, 0.5f * arW));
            bokehMaterial.SetFloat("_Intensity", bokehIntensity);
            bokehMaterial.SetPass(0);

            foreach (Mesh m in meshes)
            {
                if (m)
                {
                    Graphics.DrawMeshNow(m, Matrix4x4.identity);
                }
            }

            GL.PopMatrix();

            Graphics.Blit(tempTex, finalTarget, dofMaterial, 8);

            // important to set back as we sample from this later on
            bokehInfo.filterMode = FilterMode.Bilinear;
        }
    }
Ejemplo n.º 18
0
 // Removes a quad at a given index number.
 // The capacity remains the same, but the total number of quads to be drawn is reduced in 1
 public void RemoveQuadAtIndex(int index)
 {
     Debug.Assert(index < Quads.Count, "removeQuadAtIndex: Invalid index");
     Quads.RemoveAt(index);
     Dirty = true;
 }
Ejemplo n.º 19
0
 public override void OnDisable()
 {
     Quads.Cleanup();
 }
Ejemplo n.º 20
0
 //Add quad to the list
 public void AddQuad(Quad quad)
 {
     Quads.Add(quad);
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Draws the background screen.
 /// </summary>
 public override void Draw(GameTime gameTime)
 {
     Quads.Begin();
     Quads.Render(Vector2.Zero, _viewportSize, null, ContentWrapper.Cyan, ContentWrapper.Ocean, ContentWrapper.Cyan, ContentWrapper.Sky);
     Quads.End();
 }
Ejemplo n.º 22
0
 //Remove a quad
 public void RemoveQuad(Quad quad)
 {
     Quads.Remove(quad);
 }
Ejemplo n.º 23
0
 //Make enumerable instead
 #region Implementation of IEnumerable
 public IEnumerator <Quad> GetEnumerator()
 {
     return(Quads.GetEnumerator());
 }
Ejemplo n.º 24
0
 /// <summary>Draws the background screen.</summary>
 public override void Draw()
 {
     Quads.Begin();
     Quads.Render(Vector2.Zero, _viewportSize, null, Colors.Cyan, Colors.Ocean, Colors.Cyan, Colors.Sky);
     Quads.End();
 }
Ejemplo n.º 25
0
 public void InsertQuad(ref CCV3F_C4B_T2F_Quad quad, int index)
 {
     Debug.Assert(index < Quads.Capacity, "insertQuadWithTexture: Invalid index");
     Quads.Insert(index, quad);
     Dirty = true;
 }
Ejemplo n.º 26
0
        private void ReadObjFile(string pathObjFile)
        {
            using (var myStream = new FileStream(pathObjFile, FileMode.Open))
            {
                var myReader = new StreamReader(myStream);
                var coord    = new double[3];
                var tri      = new int[3];
                var tex      = new int[4];
                var quad     = new int[4];

                string line;
                while ((line = myReader.ReadLine()) != null)
                {
                    if (line != "")
                    {
                        line = line.Trim(' ');

                        string[] array;
                        switch (line[0])
                        {
                        case 'v':
                        {
                            if (line[1] != 't' && line[1] != 'n')
                            {
                                line  = line.Trim('v', ' ');
                                array = line.Split(' ');
                                for (var i = 0; i < 3; i++)
                                {
                                    coord[i] = double.Parse(array[i], CultureInfo.InvariantCulture);
                                }

                                var v = new Vertex(coord[0], coord[1], coord[2]);
                                Vertices.Add(v);
                            }
                            else
                            {
                                if (line[1] == 't')
                                {
                                    line  = line.Trim('t', 'v', ' ');
                                    array = line.Split(' ');
                                    for (var i = 0; i < 2; i++)
                                    {
                                        coord[i] = double.Parse(array[i], CultureInfo.InvariantCulture);
                                    }

                                    var v = new Vertex2D(coord[0], coord[1]);
                                    TextureCoordinates.Add(v);
                                }
                            }

                            break;
                        }

                        case 'f':
                        {
                            line  = line.Trim('f', ' ');
                            array = line.Split(new[] { ' ', '/' },
                                               StringSplitOptions.RemoveEmptyEntries);
                            if (array.Length == 9)
                            {
                                for (int i = 0, j = 0; i < 3 && j < array.Length; i++, j += 3)
                                {
                                    tri[i] = int.Parse(array[j]);
                                    tex[i] = int.Parse(array[j + 1]);
                                }

                                var t = new Triangle(Vertices[tri[0] - 1], Vertices[tri[1] - 1],
                                                     Vertices[tri[2] - 1], TextureCoordinates[tex[0] - 1],
                                                     TextureCoordinates[tex[1] - 1], TextureCoordinates[tex[2] - 1]);
                                Triangles.Add(t);
                            }

                            if (array.Length == 12)
                            {
                                for (int i = 0, j = 0; i < 4 && j < array.Length; i++, j += 3)
                                {
                                    quad[i] = int.Parse(array[j]);
                                    tex[i]  = int.Parse(array[j + 1]);
                                }

                                var q = new Quad(Vertices[quad[0] - 1], Vertices[quad[1] - 1],
                                                 Vertices[quad[2] - 1],
                                                 Vertices[quad[3] - 1], TextureCoordinates[tex[0] - 1],
                                                 TextureCoordinates[tex[1] - 1], TextureCoordinates[tex[2] - 1],
                                                 TextureCoordinates[tex[3] - 1]);
                                Quads.Add(q);
                            }
                        }
                        break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 27
0
 void OnDisable()
 {
     Quads.Cleanup();
 }
Ejemplo n.º 28
0
 public void RemoveAllQuads()
 {
     Quads.Clear();
     Dirty = true;
 }
 // Token: 0x060002AC RID: 684 RVA: 0x00021A60 File Offset: 0x0001FC60
 public virtual void OnDisable()
 {
     Quads.Cleanup();
 }
Ejemplo n.º 30
0
 public void RemoveQuadsAtIndex(int index, int amount)
 {
     Debug.Assert(index + amount <= Quads.Count, "removeQuadAtIndex: Invalid index");
     Quads.RemoveAt(index, amount);
     Dirty = true;
 }