Ejemplo n.º 1
0
        building FragmentShader(VertexOut vertex, Field <unit> Unit, Field <building> Building)
        {
            building building_here = Building[Here];
            unit     unit_here     = Unit[Here];

            if (Something(building_here) && IsBuilding(unit_here) && IsCenter(building_here))
            {
                if (building_here.direction >= Dir.StationaryDead)
                {
                    building_here.direction += _1;
                    return(building_here);
                }

                building
                    right      = Building[RightOne],
                    up         = Building[UpOne],
                    left       = Building[LeftOne],
                    down       = Building[DownOne],
                    up_right   = Building[UpRight],
                    up_left    = Building[UpLeft],
                    down_right = Building[DownRight],
                    down_left  = Building[DownLeft];

                // If any part of the building is dying, then the center (and consequently the whole building) should be marked as dead.
                if (right.direction == Dir.StationaryDying ||
                    up.direction == Dir.StationaryDying ||
                    left.direction == Dir.StationaryDying ||
                    down.direction == Dir.StationaryDying ||
                    up_right.direction == Dir.StationaryDying ||
                    up_left.direction == Dir.StationaryDying ||
                    down_right.direction == Dir.StationaryDying ||
                    down_left.direction == Dir.StationaryDying)
                {
                    building_here.direction = Dir.StationaryDead;
                }

                // Select this center if any part of the building is selected
                if (!selected(building_here))
                {
                    bool is_selected =
                        selected(right) ||
                        selected(up) ||
                        selected(left) ||
                        selected(down) ||
                        selected(up_right) ||
                        selected(up_left) ||
                        selected(down_right) ||
                        selected(down_left);

                    set_selected(ref building_here, is_selected);
                }
            }

            return(building_here);
        }
Ejemplo n.º 2
0
        BuildingDist FragmentShader(VertexOut vertex, Field <BuildingDist> Path, Field <data> Data, Field <unit> Unit)
        {
            BuildingDist output = BuildingDist.Nothing;

            data data_here = Data[Here];
            unit unit_here = Unit[Here];

            if (Something(data_here) && (IsBuilding(unit_here) || unit_here.type == UnitType.DragonLord || unit_here.type == UnitType.Necromancer))
            {
                float type = unit_here.type;
                if (type == UnitType.DragonLord)
                {
                    type = UnitType.DragonLordIcon;
                }
                if (type == UnitType.Necromancer)
                {
                    type = UnitType.NecromancerIcon;
                }

                set_type(ref output, type);
                set_player(ref output, unit_here.player);
                output.diff = CenterOffset;
                output.dist = _0;
            }
            else
            {
                BuildingDist
                    right = Path[RightOne],
                    up    = Path[UpOne],
                    left  = Path[LeftOne],
                    down  = Path[DownOne];

                float min_dist = _255;
                if (left.dist < min_dist)
                {
                    output.player_and_type = left.player_and_type; min_dist = left.dist;  output.diff = left.diff - vec(_1, _0);
                }
                if (down.dist < min_dist)
                {
                    output.player_and_type = down.player_and_type; min_dist = down.dist;  output.diff = down.diff - vec(_0, _1);
                }
                if (right.dist < min_dist)
                {
                    output.player_and_type = right.player_and_type; min_dist = right.dist; output.diff = right.diff + vec(_1, _0);
                }
                if (up.dist < min_dist)
                {
                    output.player_and_type = up.player_and_type; min_dist = up.dist;    output.diff = up.diff + vec(_0, _1);
                }

                output.dist = min_dist + _1;
            }

            return(output);
        }
Ejemplo n.º 3
0
        data FragmentShader(VertexOut vertex, Field <unit> Units, Field <data> Data, [Player.Vals] float player)
        {
            unit unit_here = Units[Here];
            data data_here = Data[Here];

            if (Something(data_here) && unit_here.player == player && unit_here.type == UnitType.DragonLord)
            {
                return(data.Nothing);
            }

            return(data_here);
        }
Ejemplo n.º 4
0
        building FragmentShader(VertexOut vertex, Field <unit> Units, Field <building> Building, [Player.Vals] float player)
        {
            unit     unit_here     = Units[Here];
            building building_here = Building[Here];

            if (Something(building_here) && IsBuilding(unit_here) && unit_here.player == player)
            {
                building_here.direction = Dir.StationaryDead;
            }

            return(building_here);
        }
Ejemplo n.º 5
0
        data FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Unit, float action, [Player.Vals] float player)
        {
            data data_here = Data[Here];
            unit unit_here = Unit[Here];

            if (unit_here.player == player && Something(data_here) && IsUnit(unit_here) && selected(data_here) && action < UnitAction.NoChange)
            {
                data_here.action = action;
            }

            return(data_here);
        }
Ejemplo n.º 6
0
        data FragmentShader(VertexOut vertex, Field <unit> Unit, Field <data> Data)
        {
            data data_here = Data[Here];
            unit unit_here = Unit[Here];

            if (Something(data_here) && (data_here.action == UnitAction.Spawning || data_here.action == UnitAction.Raising))
            {
                data_here.action = UnitAction.Attacking;
            }

            return(data_here);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 8
0
        vec4 FragmentShader(VertexOut vertex, Field <unit> Unit, Field <building> Building, Field <vec4> TargetData)
        {
            building building_here = Building[Here];
            unit     unit_here     = Unit[Here];
            vec4     target        = TargetData[Here];

            if (Something(building_here) && IsBuilding(unit_here))
            {
                target = TargetData[center_dir(building_here)];
            }

            return(target);
        }
Ejemplo n.º 9
0
        extra FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Unit, Field <extra> Extra, vec2 Destination, [Player.Vals] float player, [SelectionFilter.Vals] float filter)
        {
            data  data_here  = Data[Here];
            unit  unit_here  = Unit[Here];
            extra extra_here = Extra[Here];

            if (player == unit_here.player && selected(data_here) && SelectionFilter.FilterHasUnit(filter, unit_here.type))
            {
                extra_here = extra.Nothing;
            }

            return(extra_here);
        }
Ejemplo n.º 10
0
        vec4 FragmentShader(VertexOut vertex, Field <unit> CurrentUnits, [Player.Vals] float player)
        {
            vec2 uv   = vertex.TexCoords * CurrentUnits.Size + vec(.5f, .5f);
            unit here = CurrentUnits[Here];

            if (here.player == player && here.type == UnitType.DragonLord)
            {
                return(pack_vec2_corrected(uv));
            }
            else
            {
                return(vec4.Zero);
            }
        }
Ejemplo n.º 11
0
        unit FragmentShader(VertexOut vertex, Field <unit> Units, Field <data> Data, PlayerTuple Teams)
        {
            unit unit_here = Units[Here];
            data data_here = Data[Here];

            if (!Something(data_here) && unit_here.player == Player.None)
            {
                return(unit_here);
            }

            unit_here.team = GetPlayerVal(Teams, unit_here.player);

            return(unit_here);
        }
Ejemplo n.º 12
0
        vec4 FragmentShader(VertexOut vertex, Field <unit> CurrentUnits)
        {
            vec2 uv   = vertex.TexCoords * CurrentUnits.Size;
            unit here = CurrentUnits[Here];

            if (here.anim == Anim.Die && here.type == UnitType.DragonLord)
            {
                return(pack_vec2(uv));
            }
            else
            {
                return(vec4.Zero);
            }
        }
Ejemplo n.º 13
0
        color FragmentShader(VertexOut vertex, Field <BuildingDist> BuildingDistances, Field <building> Data, Field <unit> Unit, float blend, float radius, [Player.Vals] float player)
        {
            BuildingDist info = BuildingDistances[Here];

            if (info.dist > _15)
            {
                return(color.TransparentBlack);
            }

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

            // Get the building data by following the offset
            vec2     offset = Float(info.diff - Pathfinding_ToSpecial.CenterOffset);
            var      index  = new RelativeIndex(offset.x, offset.y);
            building b      = Data[index];
            unit     u      = Unit[index];

            // Get the distance from here to the building center
            float l = length(255 * (info.diff - Pathfinding_ToSpecial.CenterOffset) - (subcell_pos - vec(.5f, .5f)));

            // Draw pixel
            if (fake_selected(b) && u.player == player)
            {
                if (l > .8f * radius && l < radius * 1.15f)
                {
                    color clr = SelectedUnitColor.Get(get_player(info)) * .75f;
                    clr.a = 1;
                    return(clr * blend);
                }

                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info)) * 1f;
                    clr.a = 1;
                    return(clr * blend);
                }
            }
            else
            {
                if (l < radius)
                {
                    color clr = BuildingMarkerColors.Get(get_player(info), get_type(info));
                    return(clr * blend);
                }
            }

            return(color.TransparentBlack);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
0
        building FragmentShader(VertexOut vertex, Field <building> Data, Field <unit> Units)
        {
            building here      = Data[Here];
            unit     unit_here = Units[Here];

            if (IsBuilding(unit_here) && !IsCenter(here) &&
                !IsCenter(Data[RightOne]) && !IsCenter(Data[LeftOne]) && !IsCenter(Data[UpOne]) && !IsCenter(Data[DownOne]) &&
                !IsCenter(Data[UpRight]) && !IsCenter(Data[UpLeft]) && !IsCenter(Data[DownRight]) && !IsCenter(Data[DownLeft]))
            {
                return(building.Nothing);
            }
            else
            {
                return(here);
            }
        }
Ejemplo n.º 16
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Units, [Player.Vals] float player, [Vals.Bool] bool only_selected)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            if (player != Player.None && unit_here.player != player || only_selected && !fake_selected(data_here))
            {
                return(vec4.Zero);
            }

            return(vec(
                       unit_here.type == UnitType.Footman ? 1f : 0,
                       unit_here.type == UnitType.DragonLord ? 1f : 0,
                       unit_here.type == UnitType.Necromancer ? 1f : 0,
                       unit_here.type == UnitType.Skeleton ? 1f : 0
                       ));
        }
Ejemplo n.º 17
0
        data FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Unit,
                            vec2 bl, vec2 tr,
                            [Player.Vals] float player,
                            bool deselect,
                            [Vals.Bool] bool fake)
        {
            unit unit_here = Unit[Here];
            data data_here = Data[Here];

            if (unit_here.player != player || BlockingTileHere(unit_here))
            {
                return(data_here);
            }

            vec2 pos    = vertex.TexCoords * Data.Size;
            bool select = bl < pos && pos < tr;

            // If the player unit here matches the specified player.
            if (select)
            {
                if (fake)
                {
                    set_selected_fake(ref data_here, true);
                }
                else
                {
                    set_selected(ref data_here, true);
                }
            }
            else
            {
                if (deselect)
                {
                    if (fake)
                    {
                        set_selected_fake(ref data_here, false);
                    }
                    else
                    {
                        set_selected(ref data_here, false);
                    }
                }
            }

            return(data_here);
        }
Ejemplo n.º 18
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]);
        }
Ejemplo n.º 19
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Units, [Player.Vals] float player, [Vals.Bool] bool only_selected)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            if (player != Player.None && unit_here.player != player || only_selected && !fake_selected(data_here))
            {
                return(vec4.Zero);
            }

            return(vec(
                       unit_here.type == UnitType.ClaySoldier ? 1f : 0,
                       unit_here.type == UnitType.Barracks ? 1f : 0,
                       unit_here.type == UnitType.GoldMine ? 1f : 0,
                       unit_here.type == UnitType.JadeMine ? 1f : 0
                       ));
        }
Ejemplo n.º 20
0
        TeamTuple FragmentShader(VertexOut vertex, Field <TeamTuple> Path, Field <data> Data, Field <unit> Units)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            TeamTuple
                right = Path[RightOne],
                up    = Path[UpOne],
                left  = Path[LeftOne],
                down  = Path[DownOne];

            TeamTuple dist_to_enemy_of = min(right, up, left, down) + vec(_1, _1, _1, _1);

            if (Something(data_here))
            {
                if (BlockingTileHere(unit_here) || unit_here.player == Player.None)
                {
                    dist_to_enemy_of += 100 * TeamTuple(_1, _1, _1, _1);
                }
                else
                {
                    dist_to_enemy_of += 3 * TeamTuple(_1, _1, _1, _1);

                    if (unit_here.team != Team.One)
                    {
                        dist_to_enemy_of.TeamOne = _0;
                    }
                    if (unit_here.team != Team.Two)
                    {
                        dist_to_enemy_of.TeamTwo = _0;
                    }
                    if (unit_here.team != Team.Three)
                    {
                        dist_to_enemy_of.TeamThree = _0;
                    }
                    if (unit_here.team != Team.Four)
                    {
                        dist_to_enemy_of.TeamFour = _0;
                    }
                }
            }

            return(dist_to_enemy_of);
        }
Ejemplo n.º 21
0
        data FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Unit, Field <unit> Select,
                            [Player.Vals] float player,
                            bool deselect,
                            [Vals.Bool] bool fake)
        {
            unit unit_here = Unit[Here];
            data data_here = Data[Here];

            if (unit_here.player != player)
            {
                return(data_here);
            }

            unit select = Select[Here];

            // If the player unit here matches the specified player.
            if (select.type > 0 && (select.player == Player.None || unit_here.player == select.player) && !BlockingTileHere(unit_here))
            {
                if (fake)
                {
                    set_selected_fake(ref data_here, true);
                }
                else
                {
                    set_selected(ref data_here, true);
                }
            }
            else
            {
                if (deselect)
                {
                    if (fake)
                    {
                        set_selected_fake(ref data_here, false);
                    }
                    else
                    {
                        set_selected(ref data_here, false);
                    }
                }
            }

            return(data_here);
        }
Ejemplo n.º 22
0
        building FragmentShader(VertexOut vertex, Field <unit> Unit, Field <building> Building)
        {
            building building_here = Building[Here];
            unit     unit_here     = Unit[Here];

            if (Something(building_here) && IsBuilding(unit_here))
            {
                building center = Building[center_dir(building_here)];

                if (!Something(center))
                {
                    return(building.Nothing);
                }

                set_selected_fake(ref building_here, fake_selected(center));
            }

            return(building_here);
        }
Ejemplo n.º 23
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Unit, Field <data> TargetData, vec2 Destination, [Player.Vals] float player, [SelectionFilter.Vals] float filter)
        {
            data data_here = Data[Here];
            unit unit_here = Unit[Here];
            vec4 target    = vec4.Zero;

            if (player == unit_here.player && selected(data_here) && SelectionFilter.FilterHasUnit(filter, unit_here.type))
            {
                vec2 dest = Destination;

                target = pack_vec2(dest);
            }
            else
            {
                target = (vec4)TargetData[Here];
            }

            return(target);
        }
Ejemplo n.º 24
0
        unit FragmentShader(VertexOut vertex, Field <unit> Units, [SymmetryType.Vals] float type, bool convert_dragonlords)
        {
            unit info = Units[Here];
            vec2 pos  = vertex.TexCoords * Units.Size;

            if (DoNothing(Units, pos, type))
            {
                return(info);
            }

            unit copy = Units[Here - QuadMirrorShift(Units, pos, type)];

            if (copy.player == Player.None)
            {
                return(copy);
            }

            if (pos.x > Units.Size.x / 2)
            {
                copy.player += _1; copy.team += _1;
            }
            if (pos.y > Units.Size.y / 2)
            {
                copy.player += _2; copy.team += _2;
            }

            if (copy.player > Player.Four)
            {
                copy.player -= Player.Four;
            }
            if (copy.team > Team.Four)
            {
                copy.team -= Team.Four;
            }

            if (convert_dragonlords && copy.type == UnitType.DragonLord)
            {
                copy.type = UnitType.Footman;
            }

            return(copy);
        }
Ejemplo n.º 25
0
        PlayerTuple FragmentShader(VertexOut vertex, Field <PlayerTuple> Path, Field <data> Data, Field <unit> Units)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            PlayerTuple
                right = Path[RightOne],
                up    = Path[UpOne],
                left  = Path[LeftOne],
                down  = Path[DownOne];

            PlayerTuple distance_to = min(right, up, left, down) + vec(_1, _1, _1, _1);

            if (Something(data_here))
            {
                SetPlayerVal(ref distance_to, unit_here.player, _0);
            }

            return(distance_to);
        }
Ejemplo n.º 26
0
        building FragmentShader(VertexOut vertex, Field <unit> Unit, Field <building> Building)
        {
            building building_here = Building[Here];
            unit     unit_here     = Unit[Here];

            if (Something(building_here) && IsBuilding(unit_here))
            {
                building center = Building[center_dir(building_here)];

                if (!Something(center))
                {
                    return(building.Nothing);
                }

                building_here.prior_direction_and_select = center.prior_direction_and_select;
                building_here.direction = center.direction;
            }

            return(building_here);
        }
Ejemplo n.º 27
0
        PlayerTuple FragmentShader(VertexOut vertex, Field <PlayerTuple> Necromancy, Field <data> Data, Field <unit> Units)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            PlayerTuple
                right = Necromancy[RightOne],
                up    = Necromancy[UpOne],
                left  = Necromancy[LeftOne],
                down  = Necromancy[DownOne];

            PlayerTuple necromancy = max(right, up, left, down) - vec(_1, _1, _1, _1);

            if (unit_here.type == UnitType.Necromancer)
            {
                SetPlayerVal(ref necromancy, unit_here.player, NecromancyRange);
            }

            return(necromancy);
        }
Ejemplo n.º 28
0
        TeamTuple FragmentShader(VertexOut vertex, Field <TeamTuple> AntiMagic, Field <data> Data, Field <unit> Units)
        {
            data data_here = Data[Here];
            unit unit_here = Units[Here];

            TeamTuple
                right = AntiMagic[RightOne],
                up    = AntiMagic[UpOne],
                left  = AntiMagic[LeftOne],
                down  = AntiMagic[DownOne];

            TeamTuple antimagic = max(right, up, left, down) - vec(_1, _1, _1, _1);

            if (unit_here.type == UnitType.DragonLord)
            {
                SetTeamVal(ref antimagic, unit_here.team, AntiMagicRange);
            }

            return(antimagic);
        }
Ejemplo n.º 29
0
        vec4 FragmentShader(VertexOut vertex, Field <data> Data, Field <unit> Units, [Player.Vals] float player, bool only_selected)
        {
            data data_here = Data[Here];

            vec4 output = vec4.Zero;

            if (Something(data_here))
            {
                unit unit_here = Units[Here];

                bool valid = (player == Player.None || unit_here.player == player) && (!only_selected || fake_selected(data_here));

                if ((IsUnit(unit_here) || IsBuilding(unit_here) && IsCenter(to_building(data_here))) && valid)
                {
                    output.xyz = pack_coord_3byte(1);
                }
            }

            return(output);
        }
Ejemplo n.º 30
0
        unit FragmentShader(VertexOut vertex, Field <unit> Units)
        {
            unit unit_here = Units[Here];

            if (unit_here.type == _2)
            {
                unit_here.type = _6;
            }

            if (unit_here.type == _3)
            {
                unit_here.type = _7;
            }

            if (unit_here.type == _4)
            {
                unit_here.type = _8;
            }

            return(unit_here);
        }