Ejemplo n.º 1
0
    IEnumerator MainUpdate()
    {
        numberOfItems = ItemMode == 2 ? Items.instance.items.Count : Items.instance.pcItems.Count;
        if (currentBagPosition == 0)
        {
            offscreenindexup   = -1;
            offscreenindexdown = 3;
        }

        if (currentMenu == quantitymenu)
        {
            if (Inputs.pressed("down"))
            {
                amountToTask--;
                MathE.Wrap(ref amountToTask, 1, maximumItem);
                UpdateQuantityScreen();
            }
            if (Inputs.pressed("up"))
            {
                amountToTask++;
                MathE.Wrap(ref amountToTask, 1, maximumItem);
                UpdateQuantityScreen();
            }
        }
        if (currentMenu == itemwindow)
        {
            if (Inputs.pressed("down"))
            {
                currentBagPosition++;

                if (currentBagPosition == offscreenindexdown && currentBagPosition <= numberOfItems && numberOfItems > 3)
                {
                    offscreenindexup++;
                    offscreenindexdown++;
                }
                MathE.Clamp(ref currentBagPosition, 0, numberOfItems);
                UpdateBagScreen();
            }
            if (Inputs.pressed("up"))
            {
                currentBagPosition--;

                if (currentBagPosition == offscreenindexup && offscreenindexup > -1)
                {
                    offscreenindexup--;
                    offscreenindexdown--;
                }
                MathE.Clamp(ref currentBagPosition, 0, numberOfItems);
                UpdateBagScreen();
            }
        }

        if (currentMenu == mainwindow)
        {
            if (Inputs.pressed("down"))
            {
                selectedOption++;
                MathE.Clamp(ref selectedOption, 0, 3);
                UpdateMainScreen();
            }
            if (Inputs.pressed("up"))
            {
                selectedOption--;
                MathE.Clamp(ref selectedOption, 0, 3);
                UpdateMainScreen();
            }
        }

        if (Inputs.pressed("select"))
        {
            if (currentMenu == itemwindow)
            {
                if (!switching)
                {
                    switching = true;
                    selectCursor.gameObject.SetActive(true);
                    selectBag = currentBagPosition;
                    UpdateBagScreen();
                }
                else if (currentBagPosition != numberOfItems)
                {
                    //our bag
                    if (ItemMode == 2)
                    {
                        selectCursor.gameObject.SetActive(false);
                        Item item = Items.instance.items[selectBag];
                        Items.instance.items[selectBag]          = Items.instance.items[currentBagPosition];
                        Items.instance.items[currentBagPosition] = item;
                        switching = false;
                    }


                    if (ItemMode == 1 || ItemMode == 3)
                    {
                        Item item = Items.instance.pcItems[selectBag];
                        Items.instance.pcItems[selectBag]          = Items.instance.pcItems[currentBagPosition];
                        Items.instance.pcItems[currentBagPosition] = item;

                        switching = false;
                    }

                    UpdateBagScreen();
                }
            }
        }

        if (Inputs.pressed("a"))
        {
            SoundManager.instance.PlayABSound();
            if (currentMenu == itemwindow)
            {
                if (currentBagPosition == numberOfItems)
                {
                    Dialogue.instance.Deactivate();
                    Dialogue.instance.fastText = true;
                    switching = false;
                    selectCursor.gameObject.SetActive(false);
                    Dialogue.instance.keepTextOnScreen = true;
                    Dialogue.instance.needButtonPress  = false;
                    yield return(Dialogue.instance.text("What do you want\\lto do?"));

                    currentMenu = mainwindow;
                    UpdateMainScreen();
                }
                else
                {
                    if (!itemSlots[currentBagPosition - offscreenindexup - 1].isKeyItem && ItemMode != 3)
                    {
                        amountToTask = 1;
                        Dialogue.instance.Deactivate();
                        Dialogue.instance.fastText         = true;
                        Dialogue.instance.keepTextOnScreen = true;
                        Dialogue.instance.needButtonPress  = false;
                        yield return(Dialogue.instance.text("How much?"));

                        currentMenu = quantitymenu;
                        UpdateQuantityScreen();
                    }
                    else if (itemSlots[currentBagPosition - offscreenindexup - 1].isKeyItem)
                    {
                        switch (ItemMode)
                        {
                        case 1:
                            StartCoroutine(WithdrawItem());
                            break;

                        case 2:
                            StartCoroutine(DepositItem());
                            break;
                        }
                    }
                    else if (ItemMode == 3)
                    {
                        amountToTask = 1;
                        Dialogue.instance.Deactivate();
                        Dialogue.instance.fastText         = true;
                        Dialogue.instance.keepTextOnScreen = true;
                        Dialogue.instance.needButtonPress  = false;
                        yield return(Dialogue.instance.text("How much?"));

                        currentMenu = quantitymenu;
                        UpdateQuantityScreen();
                    }
                }
                if (currentBagPosition != numberOfItems && itemSlots[currentBagPosition - offscreenindexup - 1].isKeyItem && ItemMode == 3)
                {
                    StartCoroutine(TooImportantToToss());
                }
            }

            else if (currentMenu == mainwindow)
            {
                if (selectedOption == 0)
                {
                    UpdateBagScreen();
                    StartCoroutine(ItemMode1());
                }
                if (selectedOption == 1)
                {
                    UpdateBagScreen();
                    StartCoroutine(ItemMode2());
                }
                if (selectedOption == 2)
                {
                    UpdateBagScreen();
                    StartCoroutine(ItemMode3());
                }
                if (selectedOption == 3)
                {
                    Close();
                }
            }
            else if (currentMenu == quantitymenu)
            {
                if (ItemMode == 3)
                {
                    if (!itemSlots[currentBagPosition - offscreenindexup - 1].isKeyItem)
                    {
                        StartCoroutine(TossItem());
                    }
                }
                if (ItemMode == 1)
                {
                    StartCoroutine(WithdrawItem());
                }

                if (ItemMode == 2)
                {
                    StartCoroutine(DepositItem());
                }
            }
        }


        if (Inputs.pressed("b"))
        {
            SoundManager.instance.PlayABSound();
            if (currentMenu == mainwindow)
            {
                Close();
            }
            else if (currentMenu == itemwindow)
            {
                switching = false;
                selectCursor.gameObject.SetActive(false);
                StartCoroutine(WhatDoText());

                currentMenu = mainwindow;
                UpdateMainScreen();
            }
            else if (currentMenu == quantitymenu)
            {
                if (ItemMode == 1)
                {
                    currentBagPosition = 0;
                    selectBag          = -1;
                    StartCoroutine(WhatWithdrawText());
                    currentMenu = itemwindow;
                }
                if (ItemMode == 2)
                {
                    currentBagPosition = 0;
                    selectBag          = -1;
                    StartCoroutine(WhatDepositText());
                    currentMenu = itemwindow;
                }
                if (ItemMode == 3)
                {
                    currentBagPosition = 0;
                    selectBag          = -1;
                    StartCoroutine(WhatTossText());
                    currentMenu = itemwindow;
                }
            }
        }

        foreach (GameObject menu in allMenus)
        {
            if (menu != currentMenu)
            {
                menu.SetActive(false);
            }
            else
            {
                menu.SetActive(true);
            }
            if (menu == mainwindow && (currentMenu == itemwindow || currentMenu == quantitymenu))
            {
                menu.SetActive(true);
            }
            if (menu == quantitymenu && (currentMenu == itemwindow || currentMenu == mainwindow))
            {
                menu.SetActive(false);
            }
            if (menu == itemwindow && currentMenu == quantitymenu)
            {
                menu.SetActive(true);
            }
        }
        yield return(0);
    }
    // Use this for initialization

    // Update is called once per frame
    void Update()
    {
        if (isLowerCase)
        {
            nameselectscreen.sprite = lowercase;
        }
        else
        {
            nameselectscreen.sprite = uppercase;
        }
        displaytext.text = futureName;
        if (BeginHandler.instance.givingRedAName || BeginHandler.instance.givingGaryAName)
        {
            maxNameSize = 7;
        }
        else
        {
            maxNameSize = 10;
        }
        if (currentYselection == 5)
        {
            currentXselection = 0;
        }

        cursor.SetPosition(8 + 16 * currentXselection, 96 - 16 * currentYselection);
        if (Inputs.pressed("right"))
        {
            if (currentYselection != 5)
            {
                currentXselection++;
            }
        }
        if (Inputs.pressed("left"))
        {
            if (currentYselection != 5)
            {
                currentXselection--;
            }
        }
        if (Inputs.pressed("up"))
        {
            currentYselection--;
        }
        if (Inputs.pressed("down"))
        {
            currentYselection++;
        }
        MathE.Wrap(ref currentXselection, 0, 8);
        MathE.Wrap(ref currentYselection, 0, 5);

        if (Inputs.pressed("b"))
        {
            if (futureName.Length > 0)
            {
                futureName = futureName.Remove(futureName.Length - 1);
            }
        }
        if (Inputs.pressed("start"))
        {
            if (futureName.Length != 0)
            {
                if (BeginHandler.instance.givingRedAName)
                {
                    GameData.instance.playerName = futureName;
                    BeginHandler.instance.tutanim.SetTrigger("transition");
                    Dialogue.instance.enabled            = true;
                    BeginHandler.instance.givingRedAName = false;
                    this.gameObject.SetActive(false);
                }
                if (BeginHandler.instance.givingGaryAName)
                {
                    GameData.instance.rivalName = futureName;
                    BeginHandler.instance.tutanim.SetTrigger("transition");
                    Dialogue.instance.enabled             = true;
                    BeginHandler.instance.givingGaryAName = false;
                    this.gameObject.SetActive(false);
                }

                BeginHandler.instance.currentmenu = null;
            }
        }
        if (Inputs.pressed("a"))
        {
            if (currentXselection == 8 && currentYselection == 4)
            {
                if (futureName.Length != 0)
                {
                    if (BeginHandler.instance.givingRedAName)
                    {
                        GameData.instance.playerName = futureName;
                        BeginHandler.instance.tutanim.SetTrigger("transition");
                        Dialogue.instance.enabled            = true;
                        BeginHandler.instance.givingRedAName = false;
                        cursor.SetActive(false);
                        this.gameObject.SetActive(false);
                    }
                    if (BeginHandler.instance.givingGaryAName)
                    {
                        GameData.instance.rivalName = futureName;
                        BeginHandler.instance.tutanim.SetTrigger("transition");
                        Dialogue.instance.enabled             = true;
                        BeginHandler.instance.givingGaryAName = false;
                        cursor.SetActive(false);
                        this.gameObject.SetActive(false);
                    }

                    BeginHandler.instance.currentmenu = null;
                }
            }
            else
            {
                if (currentXselection == 0 && currentYselection == 5)
                {
                    isLowerCase = !isLowerCase;
                }
                else if (futureName.Length == maxNameSize)
                {
                    return;
                }
                else
                {
                    futureName += currentYselection < 3 && isLowerCase ? characters[currentYselection, currentXselection].ToLower() : characters[currentYselection, currentXselection];
                }
            }
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        pricetext.text = "$" + fullPrice.ToString();
        moneytext.text = "$" + GameData.instance.money.ToString();

        if (currentMenu == quantitymenu)
        {
            if (ItemMode == 1)
            {
                itemPrice   = ItemsToBuy[currentBagPosition - offscreenindexup - 1].intPrice;
                maximumItem = 99;
            }
            if (ItemMode == 2)
            {
                //Set the selling price of the selected item.
                itemPrice   = PokemonData.itemPrices[Items.instance.items[currentBagPosition].name] / 2;
                maximumItem = Items.instance.items[currentBagPosition].quantity;
            }
        }
        if (Dialogue.instance.finishedText)
        {
            if (currentMenu == quantitymenu)
            {
                fullPrice = amountToTask * itemPrice;
                if (Inputs.pressed("down"))
                {
                    amountToTask--;
                    MathE.Wrap(ref amountToTask, 1, maximumItem);
                    UpdateQuantityScreen();
                }
                if (Inputs.pressed("up"))
                {
                    amountToTask++;
                    MathE.Wrap(ref amountToTask, 1, maximumItem);
                    UpdateQuantityScreen();
                }
            }
            if (currentMenu == martwindow)
            {
                if (Inputs.pressed("down"))
                {
                    currentBagPosition++;
                    if (currentBagPosition == offscreenindexdown && offscreenindexdown != martlist.Count + 1)
                    {
                        offscreenindexup++;
                        offscreenindexdown++;
                    }
                    MathE.Clamp(ref currentBagPosition, 0, martlist.Count);
                    UpdateBuyScreen();
                }
                if (Inputs.pressed("up"))
                {
                    currentBagPosition--;
                    if (currentBagPosition == offscreenindexup && offscreenindexup > -1)
                    {
                        offscreenindexup--;
                        offscreenindexdown--;
                    }
                    MathE.Clamp(ref currentBagPosition, 0, martlist.Count);
                    UpdateBuyScreen();
                }
            }
            if (currentMenu == itemwindow)
            {
                if (Inputs.pressed("down"))
                {
                    currentBagPosition++;
                    if (currentBagPosition == offscreenindexdown && offscreenindexdown != Items.instance.items.Count + 1)
                    {
                        offscreenindexup++;
                        offscreenindexdown++;
                    }
                    MathE.Clamp(ref currentBagPosition, 0, Items.instance.items.Count);
                    UpdateSellScreen();
                }
                if (Inputs.pressed("up"))
                {
                    currentBagPosition--;
                    if (currentBagPosition == offscreenindexup && offscreenindexup > -1)
                    {
                        offscreenindexup--;
                        offscreenindexdown--;
                    }
                    MathE.Clamp(ref currentBagPosition, 0, Items.instance.items.Count);
                    UpdateSellScreen();
                }



                if (currentBagPosition != Items.instance.items.Count)
                {
                    maximumItem = Items.instance.items[currentBagPosition].quantity;
                }
                else
                {
                    maximumItem = 0;
                }
            }

            if (currentMenu == buysellwindow)
            {
                cursor.SetPosition(8, 128 - 16 * selectedOption);

                cursor.SetActive(true);

                if (Inputs.pressed("down"))
                {
                    selectedOption++;
                    MathE.Clamp(ref selectedOption, 0, 2);
                }
                if (Inputs.pressed("up"))
                {
                    selectedOption--;
                    MathE.Clamp(ref selectedOption, 0, 2);
                }
                if (Inputs.pressed("b"))
                {
                    play.menuActive = false;
                    cursor.SetActive(false);
                    Inputs.Enable("start");
                    this.gameObject.SetActive(false);
                }
            }


            if (Inputs.pressed("select"))
            {
                if (currentMenu == itemwindow)
                {
                    if (!switching)
                    {
                        switching = true;
                        selectBag = currentBagPosition;
                    }
                    else if (currentBagPosition != Items.instance.items.Count)
                    {
                        //our Bag
                        Item item = Items.instance.items[selectBag];
                        Items.instance.items[selectBag]          = Items.instance.items[currentBagPosition];
                        Items.instance.items[currentBagPosition] = item;
                        switching = false;
                        selectCursor.gameObject.SetActive(false);

                        UpdateSellScreen();
                    }
                }
            }


            if (Inputs.pressed("a"))
            {
                SoundManager.instance.PlayABSound();
                if (currentMenu == buysellwindow)
                {
                    if (selectedOption == 0)
                    {
                        currentBagPosition = 0;
                        currentMenu        = martwindow;
                        UpdateBuyScreen();
                    }
                    if (selectedOption == 1)
                    {
                        currentBagPosition = 0;
                        currentMenu        = itemwindow;
                        UpdateSellScreen();
                    }
                    if (selectedOption == 2)
                    {
                        play.menuActive = false;
                        Inputs.Enable("start");
                        cursor.SetActive(false);
                        this.gameObject.SetActive(false);
                        return;
                    }
                }
                else if (currentMenu == martwindow)
                {
                    if (currentBagPosition == martlist.Count)
                    {
                        UpdateBuySellScreen();
                        currentMenu = buysellwindow;
                    }
                    else
                    {
                        amountToTask = 1;
                        UpdateQuantityScreen();
                        cursor.SetActive(false);
                        currentMenu = quantitymenu;
                        ItemMode1();
                    }
                }
                else if (currentMenu == itemwindow)
                {
                    if (currentBagPosition == Items.instance.items.Count)
                    {
                        UpdateBuySellScreen();
                        switching = false;
                        selectCursor.gameObject.SetActive(false);
                        currentMenu = buysellwindow;
                    }
                    else
                    {
                        if (!Items.instance.items[currentBagPosition].isKeyItem && PokemonData.itemPrices[Items.instance.items[currentBagPosition].name] > 0)
                        {
                            amountToTask = 1;
                            UpdateQuantityScreen();
                            cursor.SetActive(false);
                            currentMenu = quantitymenu;
                            ItemMode2();
                        }
                        else
                        {
                            switching = false;
                            StartCoroutine(UnsellableItem());
                        }
                    }
                }


                else if (currentMenu == quantitymenu)
                {
                    if (ItemMode == 2)
                    {
                        if (!Items.instance.items[currentBagPosition].isKeyItem)
                        {
                            GameData.instance.money += fullPrice;
                            Items.instance.RemoveItem(amountToTask, currentBagPosition);
                            currentMenu = itemwindow;
                            cursor.SetActive(true);
                            selectCursor.gameObject.SetActive(false);
                            UpdateSellScreen();
                        }
                    }

                    if (ItemMode == 1)
                    {
                        if (GameData.instance.money >= fullPrice)
                        {
                            GameData.instance.money -= fullPrice;
                            Items.instance.AddItem(martlist[currentBagPosition], amountToTask);
                            currentMenu = martwindow;
                            cursor.SetActive(true);
                            selectCursor.gameObject.SetActive(false);
                            UpdateBuyScreen();
                        }
                        else
                        {
                            StartCoroutine(NotEnoughMoney());
                        }
                    }
                }
            }

            if (Inputs.pressed("b"))
            {
                SoundManager.instance.PlayABSound();
                if (currentMenu == martwindow)
                {
                    UpdateBuySellScreen();
                    currentMenu = buysellwindow;
                }
                else if (currentMenu == itemwindow)
                {
                    switching = false;
                    UpdateBuySellScreen();
                    selectCursor.gameObject.SetActive(false);
                    currentMenu = buysellwindow;
                }
                else if (currentMenu == quantitymenu)
                {
                    if (ItemMode == 1)
                    {
                        selectBag = -1;
                        cursor.SetActive(true);
                        selectCursor.gameObject.SetActive(false);
                        currentMenu = martwindow;
                    }
                    if (ItemMode == 2)
                    {
                        selectBag = -1;
                        cursor.SetActive(true);
                        selectCursor.gameObject.SetActive(false);
                        currentMenu = itemwindow;
                    }
                }
            }
        }



        foreach (GameObject menu in allMenus)
        {
            if (menu != currentMenu)
            {
                menu.SetActive(false);
            }
            else
            {
                menu.SetActive(true);
            }
            if (menu == martwindow && (currentMenu == quantitymenu && ItemMode == 1))
            {
                menu.SetActive(true);
            }
            if (menu == itemwindow && (currentMenu == quantitymenu && ItemMode == 2))
            {
                menu.SetActive(true);
            }

            if (menu == quantitymenu && (currentMenu == itemwindow || currentMenu == martwindow))
            {
                menu.SetActive(false);
            }
            if (menu == buysellwindow && (currentMenu == quantitymenu || currentMenu == itemwindow || currentMenu == martwindow))
            {
                menu.SetActive(true);
            }
        }
    }