コード例 #1
0
 public void Dispose()
 {
     PointSampler.Dispose();
     LinearSampler.Dispose();
     Aniso4xSampler.Dispose();
     PlatformDispose();
 }
コード例 #2
0
ファイル: DrawTiles.cs プロジェクト: JordanFisher/WAL
        protected color Sprite(tile c, vec2 pos, PointSampler Texture, bool solid_blend_flag, float solid_blend)
        {
            color clr = color.TransparentBlack;

            if (pos.x > 1 || pos.y > 1 || pos.x < 0 || pos.y < 0)
            {
                return(clr);
            }

            pos = pos * .98f + vec(.01f, .01f);

            pos.x += Float(c.i);
            pos.y += Float(c.j);
            pos   *= TileSpriteSheet.SpriteSize;

            clr = Texture[pos];

            if (solid_blend_flag)
            {
                color solid_clr = FarColor[Int(c.type), 6 + (int)(c.type)];
                clr = solid_blend * clr + (1 - solid_blend) * solid_clr;
            }

            return(clr);
        }
コード例 #3
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <dirward> Dirward, PointSampler Texture)
        {
            color output = color.TransparentBlack;

            dirward here = Dirward[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Dirward.Size);

            if (ValidDirward(here))
            {
                // Draw guid coloring
                vec2 guid = fmod(here.geo_id * 1293.4184145f, 1.0f);
                output.r   += guid.x;
                output.g   += guid.y;
                output.a    = 1f;
                output.rgb *= output.a;
            }

            // Draw polarity only
            if (ValidDirward(here))
            {
                return((color)(here.polarity > .5 ? vec(1, 0, 0, 1) : vec(0, 1, 0, 1)));
            }

            return(output);
        }
コード例 #4
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <geo> Geo, PointSampler Texture)
        {
            color output = color.TransparentBlack;

            geo here = Geo[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Geo.Size);

            if (here.dir > _0)
            {
                // Draw arrow
                //output += DrawDebugInfoTile(here.dir, 0, subcell_pos, Texture);

                // Draw bad cell info
                //if (here.bad == _true) output.r = 1;

                // Draw guid coloring
                vec2 guid = fmod(here.geo_id * 1293.4184145f, 1.0f);
                output.r   += guid.x;
                output.g   += guid.y;
                output.a    = 1f;
                output.rgb *= output.a;

                // Draw arrow over
                output *= DrawDebugArrow(here.dir, subcell_pos, Texture);
            }

            return(output);
        }
コード例 #5
0
 public void Dispose()
 {
     DefaultBlendState?.Dispose();
     AlphaBlendState?.Dispose();
     AlphaDarkenState?.Dispose();
     LinearSampler?.Dispose();
     PointSampler?.Dispose();
     Checkers?.Dispose();
 }
コード例 #6
0
ファイル: BasicDraw.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, PointSampler Texture)
        {
            color output;

            output      = Texture[vertex.TexCoords];
            output     *= vertex.Color;
            output.rgb *= vertex.Color.a;

            return(output);
        }
コード例 #7
0
        protected color ExplosionSprite(building u, unit d, vec2 pos, float frame, PointSampler Texture)
        {
            if (pos.x > 1 || pos.y > 1 || pos.x < 0 || pos.y < 0)
            {
                return(color.TransparentBlack);
            }

            pos   += 255 * vec(u.part_x, u.part_y);
            pos.x += floor(frame) * ExplosionSpriteSheet.DimX;
            pos   *= ExplosionSpriteSheet.SpriteSize;

            return(Texture[pos]);
        }
コード例 #8
0
ファイル: DrawCorpses.cs プロジェクト: JordanFisher/WAL
        protected color Sprite(corpse c, vec2 pos, PointSampler Texture)
        {
            if (pos.x > 1 || pos.y > 1 || pos.x < 0 || pos.y < 0)
            {
                return(color.TransparentBlack);
            }

            pos.x += Float(Anim.Dead);
            pos.y += Float(c.direction) - 1;
            pos   *= UnitSpriteSheet.SpriteSize;

            var clr = Texture[pos];

            return(clr);
        }
コード例 #9
0
    // Start is called before the first frame update
    void Start()
    {
        bp           = BaseParameters.Instance;
        IDs          = new Dictionary <int, Node>();
        Nodes        = new List <Node>();
        null_parents = new List <Node>();
        sampler      = PointSampler.Instance;
        eh           = EventHandler.Instance;

        eh.Sub(Event.EventType.CorruptNode, this);
        eh.Sub(Event.EventType.NodeDestroyed, this);
        eh.Sub(Event.EventType.NodeChannel, this);
        eh.Sub(Event.EventType.UpdatePowerUps, this);
        DisplayMaterial.SetFloat("_Channeling", 0.0f);
    }
コード例 #10
0
        color FragmentShader(VertexOut vertex, PointSampler data_texture, [Player.Vals] float player)
        {
            unit d = unit.Nothing;

            if (data_texture[Here].a > 0)
            {
                d.type   = UnitType.Footman;
                d.player = player;

                // Note: Unlike other data and simulation shaders, we do need to set the alpha component for this channel.
                // The reason is that we will be drawing multiple mouse datas onto the same render target, with potential overlap.
                d.a = 1;
            }

            return((color)d);
        }
コード例 #11
0
ファイル: DrawCorpses.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <corpse> Corpses, PointSampler Texture, float blend)
        {
            color output = color.TransparentBlack;

            corpse here = Corpses[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Corpses.Size);

            if (CorpsePresent(here))
            {
                output += Sprite(here, subcell_pos, Texture);
                output *= blend;
            }

            return(output);
        }
コード例 #12
0
ファイル: DrawTiles.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <tile> Tiles, PointSampler Texture,
                             [Vals.Bool] bool solid_blend_flag, float solid_blend)
        {
            color output = color.TransparentBlack;

            vec2 subcell_pos = get_subcell_pos(vertex, Tiles.Size);

            tile here = tile.Nothing;

            here.i    = _0;
            here.j    = _25;
            here.type = TileType.Trees;

            output += Sprite(here, subcell_pos, Texture, solid_blend_flag, solid_blend);

            return(output);
        }
コード例 #13
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
        protected color DrawDebugInfoTile(float index_x, float index_y, vec2 pos, PointSampler Texture, vec2 SpriteSize)
        {
            color clr = color.TransparentBlack;

            if (pos.x > 1 || pos.y > 1 || pos.x < 0 || pos.y < 0)
            {
                return(clr);
            }

            pos = pos * .98f + vec(.01f, .01f);

            pos.x += index_x;
            pos.y += index_y;
            pos   *= SpriteSize;

            clr += Texture[pos];

            return(clr);
        }
コード例 #14
0
ファイル: DrawTiles.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <tile> Tiles, PointSampler Texture, [Vals.Bool] bool draw_grid,
                             [Vals.Bool] bool solid_blend_flag, float solid_blend)
        {
            color output = color.TransparentBlack;

            tile here = Tiles[Here];

            vec2 subcell_pos = get_subcell_pos(vertex, Tiles.Size);

            if (here.type > _0)
            {
                output += Sprite(here, subcell_pos, Texture, solid_blend_flag, solid_blend);

                if (draw_grid)
                {
                    output += GridLines(subcell_pos);
                }
            }

            return(output);
        }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        PointSampler script = (PointSampler)target;

        if (GUILayout.Button("SamplePoints"))
        {
            var points = script.SamplePoints();
            var holder = GameObject.Find("NodeHolder").transform;

            for (int i = 0; i < points.Count; i++)
            {
                var obj = GameObject.Instantiate(script.DebugObject);

                var p = points[i];
                obj.transform.parent   = holder;
                obj.transform.position = new Vector3(p.x, p.y, obj.transform.position.z);
            }
        }
    }
コード例 #16
0
ファイル: PointSampler.cs プロジェクト: R-N/Skid
 void Awake()
 {
     singleton = this;
 }
コード例 #17
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
        color FragmentShader(VertexOut vertex, Field <geo> Geo, Field <vec4> PolarDistance, PointSampler Texture)
        {
            color output = color.TransparentBlack;

            geo   here = Geo[Here];
            float dist = 0;

            vec2 subcell_pos = get_subcell_pos(vertex, Geo.Size);

            if (here.dir > _0)
            {
                if (subcell_pos > vec(.5f, .5f))
                {
                    vec2 subcell_pos_1 = get_subcell_pos(vertex, Geo.Size * 2);
                    output += DrawDebugNum(unpack_val(PolarDistance[Here].xy), subcell_pos_1, Texture) * rgb(0xFF8080);
                }

                if (subcell_pos < vec(.5f, .5f))
                {
                    vec2 subcell_pos_2 = get_subcell_pos(vertex, Geo.Size * 2);
                    output += DrawDebugNum(unpack_val(PolarDistance[Here].zw), subcell_pos_2, Texture) * rgb(0xFF8080);
                }

                return(output);
            }



            if (subcell_pos.y > .5)
            {
                dist = unpack_val(PolarDistance[Here].xy);
            }
            else
            {
                dist = unpack_val(PolarDistance[Here].zw);
            }

            if (here.dir > _0)
            {
                dist   = dist / 1024.0f;
                output = (color)vec(dist, dist, dist, 1.0f);
            }

            return(output);
        }
コード例 #18
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
 protected color DrawDebugArrow(float dir, vec2 pos, PointSampler Texture)
 {
     return(DrawDebugInfoTile(_0, Float(dir - _1), pos, Texture, DebugArrowsSpriteSheet.SpriteSize));
 }
コード例 #19
0
ファイル: DrawDebugInfo.cs プロジェクト: JordanFisher/WAL
 protected color DrawDebugNum(float num, vec2 pos, PointSampler Texture)
 {
     return(DrawDebugInfoTile(num, _0, pos, Texture, DebugNumSpriteSheet.SpriteSize));
 }
コード例 #20
0
        color FragmentShader(VertexOut vertex, Field <building> Buildings, Field <unit> Units, PointSampler Texture, PointSampler Explosion,
                             [Player.Vals] float player,
                             float s)
        {
            color output = color.TransparentBlack;

            building building_here = Buildings[Here];
            unit     unit_here     = Units[Here];

            if (!IsBuilding(unit_here))
            {
                return(output);
            }

            vec2 subcell_pos = get_subcell_pos(vertex, Buildings.Size);

            if (Something(building_here))
            {
                if (building_here.direction >= Dir.StationaryDead)
                {
                    float frame = ExplosionSpriteSheet.ExplosionFrame(s, building_here);
                    if (frame < ExplosionSpriteSheet.AnimLength)
                    {
                        output += ExplosionSprite(building_here, unit_here, subcell_pos, frame, Explosion);
                    }
                }
                else
                {
                    float frame = 0;
                    output += Sprite(player, building_here, unit_here, subcell_pos, frame, Texture);
                }
            }

            return(output);
        }
コード例 #21
0
        protected color Sprite(float player, building b, unit u, vec2 pos, float frame, PointSampler Texture)
        {
            if (pos.x > 1 || pos.y > 1 || pos.x < 0 || pos.y < 0)
            {
                return(color.TransparentBlack);
            }

            bool  draw_selected   = u.player == player && fake_selected(b);
            float selected_offset = draw_selected ? 3 : 0;

            pos   += Float(vec(b.part_x, b.part_y));
            pos.x += Float(u.player) * BuildingSpriteSheet.BuildingDimX;
            pos.y += selected_offset + BuildingSpriteSheet.SubsheetDimY * Float(UnitType.BuildingIndex(u.type));
            pos   *= BuildingSpriteSheet.SpriteSize;

            return(Texture[pos]);
        }