Example #1
0
    void DrawHitbox(Hitbox hb, bool isChecked = false)
    {
        Layer.SetColour(new Color32(0xFF, 0xFF, 0xFF, 0xFF));
        Layer.Add(hb.x0 + 1, hb.y0, hb.w - 2, 13, Button_Up);

        Layer.SetColour(new Color32(0xFF, 0xFF, 0xFF, 0xFF));
        Layer.Add(hb.x0, hb.y0, 1, 13, Button_Light);

        Layer.SetColour(new Color32(0xFF, 0xFF, 0xFF, 0xFF));
        Layer.Add(hb.x0 + hb.w - 1, hb.y0, 1, 13, Button_Dark);

        Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
        Font.AddTo(Layer, hb.tx, hb.ty, hb.text);

        if (hb.gadget == Gadget.Check)
        {
            if (isChecked)
            {
                Layer.Add(hb.x0 + 1, hb.y0 + 1, 11, 11, Checkbox);
            }
            else
            {
                Layer.Add(-10, -10, 0, 0, Checkbox);
            }
        }
    }
Example #2
0
    void FixedUpdate()
    {
        // Calculate the top left coordinates.
        sizeX   = victoriaBold.lineHeight * cols;
        sizeY   = victoriaBold.lineHeight * rows;
        originX = (Screen.width / 2 / mLayer.scale) - sizeX / 2;
        originY = (Screen.height / 2 / mLayer.scale) - sizeY / 2;

        // Figure out how many quads the background, two lines of text and the flashing cursor will use.
        int quadLength = 0;

        quadLength += victoriaBold.Estimate(line1);
        quadLength += victoriaBold.Estimate(line2);
        quadLength += 2; // 1 for the background and 1 for the cursor.

        mLayer.Begin(quadLength + 2);

        // Draw the Background in the background colour
        mLayer.SetColour(backgroundColour);
        mLayer.Add(originX, originY, sizeX, sizeY, mWhite);

        // Draw both lines Lines of text colour
        mLayer.SetColour(textColour); // Note: We only need to change the colour when necessary, not every quad or line of text.
        victoriaBold.AddTo(mLayer, originX, originY + victoriaBold.lineHeight, line1);
        victoriaBold.AddTo(mLayer, originX, originY + victoriaBold.lineHeight * 2, line2);

        // Draw the flashing Cursor, but alternative colours every other second.
        mLayer.SetColour(((int)Time.time % 2 == 0) ? textColour : backgroundColour);
        mLayer.Add(originX, originY + victoriaBold.lineHeight * 3, victoriaBold.lineHeight, victoriaBold.lineHeight, mWhite);

        mLayer.End();
    }
 public void DrawTo(GiraffeLayer layer)
 {
     if (visible)
     {
         layer.Add(mTransform2D, mSprite);
     }
 }
Example #4
0
    void Start()
    {
        mLayer = GetComponent <GiraffeLayer>();
        mAtlas = mLayer.atlas;

        mBoxes    = new GiraffeSprite[4];
        mBoxes[0] = mAtlas.GetSprite("Box");
        mBoxes[1] = mAtlas.GetSprite("Box2");
        mBoxes[2] = mAtlas.GetSprite("Box3");
        mBoxes[3] = mAtlas.GetSprite("Box4");

        int count = 50 + UnityEngine.Random.Range(1, 20);

        mLayer.Begin(count);

        for (int i = 0; i < count; i++)
        {
            int x = UnityEngine.Random.Range(0, Screen.width);
            int y = UnityEngine.Random.Range(0, Screen.height);
            int b = UnityEngine.Random.Range(0, mBoxes.Length);
            mLayer.Add(x, y, mBoxes[b]);
        }

        mLayer.End();
    }
Example #5
0
    void Start()
    {
        mLayer = GetComponent <GiraffeLayer>();
        mAtlas = mLayer.atlas;

        ReadTileMap();


        int area          = mapWidth * mapHeight;
        int x             = 0;
        int y             = 0;
        int screenOriginX = Screen.width / 2 - (mapWidth * tileWidth) / 2;
        int screenOriginY = Screen.height / 2 - (mapHeight * tileHeight) / 2;

        mLayer.Begin(area);
        for (int i = 0; i < area; i++)
        {
            mLayer.Add(screenOriginX + x * tileWidth, screenOriginY + y * tileHeight, mAtlas.GetSpriteAt(map[i]));

            x++;
            if (x >= mapWidth)
            {
                x = 0;
                y++;
            }
        }
        mLayer.End();
    }
Example #6
0
    void Draw()
    {
        int sw = Screen.width / mLayer.scale;
        int sh = Screen.height / mLayer.scale;

        int cols = (sw / mSpriteWidth) + 2;
        int rows = (sh / mSpriteHeight) + 1;


        int scrollY = Mathf.FloorToInt(mScrollY);
        int offset  = (int)mScrollY % mSpriteWidth;

        mLayer.Begin(cols * rows);

        int worldI = 0;
        int biome  = 0;

        for (int i = 0; i < cols; i++)
        {
            worldI = scrollY + i;
            biome  = (worldI / 231);

            uint u = hash((uint)worldI);

            for (int j = 0; j < rows; j++)
            {
                uint h = hash((uint)(worldI ^ j));
                if (h % 13 == j)
                {
                    mLayer.Add(i * mSpriteWidth - (int)offset, j * mSpriteHeight, mSprites[(biome + h) % 4]);
                }
                else
                {
                    mLayer.Add(i * mSpriteWidth - (int)offset, j * mSpriteHeight, mSprites[0]);
                }
            }
        }

        mLayer.End();
    }
Example #7
0
    void Draw3d()
    {
        int numQuads = 1;

        numQuads += Font.Estimate(Caption);

        if (IsAccessing)
        {
            numQuads++;
        }

        if (IsKeyState)
        {
            numQuads++;
        }

        int kScale = Layer.scale;

        Layer.Begin(numQuads);

        Font.AddTo(Layer, 25, 25, Caption);

        Layer.Add(Screen.width / 2 / kScale - Crosshair.width / 2, Screen.height / 2 / kScale - Crosshair.height / 2, Crosshair);

        if (IsAccessing)
        {
            Layer.Add(2, Screen.height / kScale - 2 - Floppy.height, Floppy);
        }

        if (IsKeyState)
        {
            Layer.Add(Screen.width / kScale - KeyboardMode.width - 2, Screen.height / kScale - 2 - KeyboardMode.height, KeyboardMode);
        }

        Layer.End();
    }
Example #8
0
    void FixedUpdate()
    {
        mLayer.Begin(mCount);

        for (int i = 0; i < mCount; i++)
        {
            GiraffeSprite sprite = mBoxes[i % 2];
            mRotations[i] += Time.fixedDeltaTime;
            mScales[i]     = new Vector2(sprite.width, sprite.height) * Mathf.Sin(mRotations[i]) * 8.0f;
            Matrix2D transform = Matrix2D.TRS(mTranslations[i], mRotations[i], mScales[i]);
            mLayer.Add(transform, sprite);
        }

        mLayer.End();
    }
Example #9
0
    public void AddTo(GiraffeLayer layer, int x, int y, String text)
    {
        int length = text.Length;

        int p = x;

        for (int i = 0; i < length; i++)
        {
            char c = text[i];
            if (c >= characterRangeMin && c <= characterRangeMax && characters.ContainsKey(c))
            {
                GiraffeFontGlyph glyph = characters[c];
                layer.Add(p + glyph.xOffset, y + glyph.yOffset, glyph.sprite);
                p += glyph.xAdvance;
            }
            else if (c == ' ')
            {
                p += spaceAdvance;
            }
        }
    }