Пример #1
0
    void FixedUpdate()
    {
        foreach (var girrafeLayerEventListener in mListenersToAdd)
        {
            mListeners.Add(girrafeLayerEventListener);
        }
        mListenersToAdd.Clear();

        foreach (var eventListener in mListenersToRemove)
        {
            mListeners.Remove(eventListener);
        }
        mListenersToRemove.Clear();

        int nbQuads = 0;

        foreach (var quad in mListeners)
        {
            nbQuads += quad.GetQuadCount();
        }

        mLayer.Begin(nbQuads);

        foreach (var eventListener in mListeners)
        {
            eventListener.DrawTo(mLayer);
        }

        mLayer.End();
    }
Пример #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();
    }
Пример #3
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();
    }
Пример #4
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();
    }
Пример #5
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();
    }
Пример #6
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();
    }
Пример #7
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();
    }
Пример #8
0
    private void Update()
    {
        string inputText = Input.inputString;


        if (Ui.Dirty)
        {
            Layer.Begin(Ui.NumQuads);
            Ui.Draw();
            Layer.End();
        }

        int mx       = (int)Input.mousePosition.x;
        int my       = Screen.height - (int)Input.mousePosition.y;
        int buttonId = 0;

        if (Input.GetMouseButtonUp(0))
        {
            buttonId = Ui.Test(mx / 2, my / 2);
        }

        if (buttonId == 1400)
        {
            Change(typeof(EditorSprite));
            return;
        }
        else if (buttonId == 1401)
        {
            Change(typeof(EditorTile));
            return;
        }

        if (RequesterMode == RequesterMode.None)
        {
            return;
        }

        if (RequesterMode == RequesterMode.File)
        {
            {
                if (buttonId == 6001)
                {
                    RequesterFileOldPath = RequesterFilePath;

                    System.IO.DirectoryInfo dirInfo = System.IO.Directory.GetParent(RequesterFilePath);

                    if (dirInfo != null)
                    {
                        RequesterFilePath = dirInfo.FullName;
                    }
                    else
                    {
                        RequesterFilePath = string.Empty;
                    }

                    RefreshUi();
                }
                else if (buttonId >= 100 && (buttonId - 100) < RequesterFolderListing.Count)
                {
                    PathInfo pathInfo = RequesterFolderListing[(buttonId - 100)];

                    if (pathInfo.type == 1)
                    {
                        RequesterFileOldPath = RequesterFilePath;
                        RequesterFilePath    = pathInfo.path;
                        RefreshUi();
                        return;
                    }
                    else if (pathInfo.type == 0)
                    {
                        RequesterFileOldPath = RequesterFilePath;
                        RequesterFilePath    = pathInfo.path;
                        RefreshUi();
                    }
                    else
                    {
                        if (RequesterFileIsSaving)
                        {
                            RequesterFileCallback(pathInfo.path, RequesterMode.File, true);
                            StopFileRequester();
                        }
                        else
                        {
                            RequesterFileCallback(pathInfo.path, RequesterMode.File, false);
                            StopFileRequester();
                            return;
                        }
                        return;
                    }
                }
                else if (buttonId == 6002)
                {
                    RequesterPage -= RequesterFilePageSize;
                    RefreshUi();
                }
                else if (buttonId == 6003)
                {
                    RequesterPage += RequesterFilePageSize;
                    RefreshUi();
                }
                else if (buttonId == 6004)
                {
                    RequesterSaveDirectory = RequesterFilePath;
                    StringRequester(_FileRequesterSaveName);
                }
                else if (buttonId == 6005)
                {
                    RequesterFileCallback(null, RequesterMode.File, RequesterFileIsSaving);
                    StopFileRequester();
                    return;
                }
            }
        }
        else if (RequesterMode == RequesterMode.String)
        {
            if (string.IsNullOrEmpty(inputText) == false)
            {
                Debug.Log(inputText);
                RequesterStringText += inputText;
                RefreshUi();
            }
            else if (Input.GetKeyUp(KeyCode.Backspace))
            {
                if (RequesterStringText.Length >= 0)
                {
                    if (RequesterStringText.Length > 1)
                    {
                        RequesterStringText = RequesterStringText.Substring(0, RequesterStringText.Length - 2);
                    }
                    else
                    {
                        RequesterStringText = "";
                    }
                    RefreshUi();
                    return;
                }
            }

            if (buttonId == 7002)
            {
                RequesterStringCallback(RequesterStringText, RequesterMode.String, false);
                StopStringRequester();
                return;
            }

            if (buttonId == 7003)
            {
                RequesterStringCallback(null, RequesterMode.String, false);
                StopStringRequester();
                return;
            }
        }
    }
Пример #9
0
    void Draw()
    {
        int numQuads = 1;

        switch (Mode)
        {
        case PauseMode.Welcome:  numQuads += kAboutSize + welcomeHitboxes_Size; break;

        case PauseMode.About:    numQuads += kAboutSize + tabHitboxes_Size; break;

        case PauseMode.Controls: numQuads += kControlsSize + tabHitboxes_Size; break;

        case PauseMode.Disks:
        {
            if (DX8.FloppySensor.IsEmpty == true)
            {
                foreach (var floppy in DX8.Floppys)
                {
                    numQuads += 3;
                    numQuads += Font.Estimate(floppy.Title);
                }
            }
            else
            {
                numQuads += kNotEmptyDriveSize;
            }
            numQuads += tabHitboxes_Size;
        }
        break;

        case PauseMode.Options:
        {
            numQuads += optionBoxes_Size + tabHitboxes_Size;

            if (DX8.FloppySensor.Floppy == null)
            {
                numQuads++;
            }
        }
        break;
        }

        Layer.Begin(numQuads);

        Layer.SetColour(new Color32(0xb3, 0xb2, 0xac, 0xFF));
        Layer.Add(WindowX, WindowY, WindowW, WindowH, White);

        if (Mode == PauseMode.Welcome)
        {
            Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
            for (int i = 0; i < Strings.kAbout.Length; i++)
            {
                Font.AddTo(Layer, WindowX + 4, WindowY + 4 + (9 * i), Strings.kAbout[i]);
            }

            for (int i = 0; i < welcomeHitboxes.Count; i++)
            {
                DrawHitbox(welcomeHitboxes[i]);
            }
        }
        else
        {
            for (int i = 0; i < tabHitBoxes.Count; i++)
            {
                DrawHitbox(tabHitBoxes[i]);
            }

            if (Mode == PauseMode.About)
            {
                Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
                for (int i = 0; i < Strings.kAbout.Length; i++)
                {
                    Font.AddTo(Layer, WindowX + 4, WindowY + 15 + (9 * i), Strings.kAbout[i]);
                }
            }
            else if (Mode == PauseMode.Controls)
            {
                Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
                for (int i = 0; i < Strings.kControls.Length; i++)
                {
                    Font.AddTo(Layer, WindowX, WindowY + 15 + (9 * i), Strings.kControls[i]);
                }
            }
            else if (Mode == PauseMode.Options)
            {
                for (int i = 0; i < optionBoxes.Count; i++)
                {
                    Hitbox hb = optionBoxes[i];
                    switch (hb.id)
                    {
                    default:
                        DrawHitbox(hb);
                        break;

                    case kOptions_3D:
                    {
                        DrawHitbox(hb, !DX8.Is2dState);
                    }
                    break;

                    case kOptions_Heavy:
                    {
                        DrawHitbox(hb, DX8.Character.CanPickUpHeavy);
                    }
                    break;

                    case kOptions_KeyboardCapture:
                    {
                        DrawHitbox(hb, DX8.IsKeyState);
                    }
                    break;

                    case kOptions_Mute:
                    {
                        DrawHitbox(hb, DX8.Mute);
                    }
                    break;

                    case kOptions_Eject:
                    {
                        DrawHitbox(hb, false);
                        if (DX8.FloppySensor.Floppy == null)
                        {
                            Layer.Add(hb.x0, hb.y0, 150, 13, Ghost150);
                        }
                    }
                    break;

                    case kOptions_ShowOptionsOnStart:
                    {
                        DrawHitbox(hb, DX8.ShowOptionsOnStart);
                    }
                    break;
                    }
                }
            }
            else if (Mode == PauseMode.Disks)
            {
                if (DX8.FloppySensor.IsEmpty == true)
                {
                    int x = WindowX;
                    int y = WindowY + 15;
                    int w = 75;

                    foreach (var floppy in DX8.Floppys)
                    {
                        Layer.SetColour(new Color32(0xFF, 0xFF, 0xFF, 0xFF));

                        y += 13;

                        if (y >= WindowY + WindowH - 13)
                        {
                            x += 75;
                            y  = WindowY + 15;
                        }

                        Layer.Add(x, y, Button_Light);
                        Layer.Add(x + 1, y, w, 13, Button_Up);
                        Layer.Add(x + 1 + w, y, Button_Dark);

                        Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
                        Font.AddTo(Layer, x + 1, y + 2, floppy.Title);

                        floppy.UI_X0 = x;
                        floppy.UI_Y0 = y;
                        floppy.UI_X1 = x + w;
                        floppy.UI_Y1 = y + 13;
                    }
                }
                else
                {
                    Layer.SetColour(new Color32(0x29, 0x2c, 0x2e, 0xFF));
                    Font.AddTo(Layer, WindowX + WindowW / 2 - (Strings.kNotEmptyDrive.Length * 9) / 2, WindowY + 45, Strings.kNotEmptyDrive);
                }
            }
        }

        Layer.End();
    }