Exemplo n.º 1
0
    public override String ToString()
    {
        String r = "";

        if (CurrentChunkHead != null)
        {
            for (int j = MaxHeight - 1; j >= 0; j--)
            {
                r += $"{j,6:000000}: ";
                for (GeneColumn iterator = CurrentChunkHead; iterator != CurrentChunkTail; iterator = iterator.Next)
                {
                    r += $"{iterator.CellAtY(j)}";
                }
                r += "\n";
            }
            int Width          = CurrentChunkTail.GlobalX - CurrentChunkHead.GlobalX + 1;
            int digitosLargura = (Width - 1).ToString().Length;
            for (int digito = 0; digito < digitosLargura; digito++)
            {
                r += "        ";
                for (int x = 0; x < Width; x++)
                {
                    var xs = x.ToString();
                    r += xs.Length > digito ? $"{xs[digito]}" : "0";
                }
                r += "\n";
            }
        }
        return(r);
    }
Exemplo n.º 2
0
    public void UpdateWorldAroundX(int x)
    {
        var newLeftChunkLimit = x - (int)(renderChunkWidth / 2);

        trimCells(newLeftChunkLimit);
        leftChunkLimit = newLeftChunkLimit;
        mMapGenerator.SetCurrentChunkHead(leftChunkLimit);
        mMapGenerator.SetCurrentChunkTail(rightChunkLimit);

        for (int i = 0; i < 2; i++)
        {
            /*
             *  This external for is a "workaround" for the weird ground block being
             *  placed in lieu of a few clock items.
             *  The second pass seems to fix it.
             */
            for (GeneColumn iterator = mMapGenerator.CurrentChunkHead;
                 iterator != mMapGenerator.CurrentChunkTail.Next;
                 iterator = iterator.Next)
            {
                for (int j = 0; j > -mMapGenerator.MaxHeight; j--)  // Height is inverted
                {
                    char cellCode = iterator.CellAtY(j);
                    if (cellCode == 'C')
                    {
                        ClockItem clock = (ClockItem)clockScene.Instance();
                        clock.GlobalPosition   = MapToWorld(new Vector2(iterator.GlobalX, j)) + (new Vector2(32F, 32F));
                        clock.ExtraTime        = iterator.ClockExtraTime;
                        clock.SourceGeneColumn = iterator;
                        AddChild(clock);
                        iterator.ClockPlaced = true;
                        break; // Not necessary to proceed
                    }
                    else
                    {
                        SetCell(iterator.GlobalX, j, tileFromCode(cellCode));
                    }
                }
                if (iterator.GlobalX % 10 == 0 && !placedXLabels.Contains(iterator.GlobalX))
                {
                    // Place a Global X Label
                    CellXLabel xlabel = (CellXLabel)cellXLabelScene.Instance();
                    xlabel.GlobalX        = iterator.GlobalX;
                    xlabel.GlobalPosition = MapToWorld(new Vector2(iterator.GlobalX, -9)) + (new Vector2(32F, 32F));
                    AddChild(xlabel);
                }
            }
        }
    }
Exemplo n.º 3
0
    public String ToRichTextString()
    {
        String r = "";

        // Actual tiles
        for (int j = MaxHeight - 1; j >= 0; j--)
        {
            r += $"{j,6:000000}: ";
            for (GeneColumn iterator = CurrentChunkHead; iterator != CurrentChunkTail.Next; iterator = iterator.Next)
            {
                switch (iterator.CellAtY(j))
                {
                case 'G':
                    r += "[color=gray]";
                    break;

                case 'S':
                    r += "[color=red]";
                    break;

                case 'N':
                    r += "[color=purple]";
                    break;

                case 'C':
                case 'c':
                    r += "[color=yellow]";
                    break;

                default:
                    r += "[color=cyan]";
                    break;
                }
                r += $"{iterator.CellAtY(j)}";
                r += "[/color]";
            }
            r += "\n";
        }

        // Global X coordinates
        int digitosLargura = 4;
        int playerX        = Global.MappedPlayerX;

        for (int digito = 0; digito < digitosLargura; digito++)
        {
            r += "        ";
            for (GeneColumn iterator = CurrentChunkHead; iterator != CurrentChunkTail.Next; iterator = iterator.Next)
            {
                var    gX = iterator.GlobalX;
                string color;
                if (gX == playerX)
                {
                    color = "yellow";
                }
                else if (gX < 0)
                {
                    color = "purple";
                }
                else
                {
                    color = "lime";
                }
                var xs = $"{Mathf.Abs(gX),4:0000}";
                r += $"[color={color}]";
                r += xs[digito];
                r += "[/color]";
            }
            r += "\n";
        }
        return(r);
    }