Пример #1
0
        internal void OnGraphicsContextInitialized(GLControl context, WindowsFormsHost host)
        {
            m_control = context;

            m_editorCore             = new EditorCore();
            m_intervalTimer          = new System.Windows.Forms.Timer();
            m_intervalTimer.Interval = 16; // 60 FPS roughly
            m_intervalTimer.Enabled  = true;
            m_intervalTimer.Tick    += (args, o) =>
            {
                Vector2 mousePosGlobal     = new Vector2(System.Windows.Forms.Control.MousePosition.X, System.Windows.Forms.Control.MousePosition.Y);
                Vector2 glControlPosGlobal = new Vector2((float)host.PointToScreen(new Point(0, 0)).X, (float)host.PointToScreen(new Point(0, 0)).Y);

                var delta = mousePosGlobal - glControlPosGlobal;

                delta.X = MathE.Clamp(delta.X, 0, m_control.Width);
                delta.Y = MathE.Clamp(delta.Y, 0, m_control.Height);

                ((MainWindow)Application.Current.MainWindow).Tick();

                m_editorCore.GetWorldByName("main").Input.SetMousePosition(delta);
                m_editorCore.Tick();

                if (m_control != null)
                {
                    m_control.SwapBuffers();
                }
            };

            m_editorCore.PropertyChanged += OnEditorPropertyChanged;
            EntityOutliner.m_world        = m_editorCore.GetWorldByName("main");
        }
Пример #2
0
 public void Init()
 {
     GameData.instance.atTitleScreen = true;
     tutanim.SetTrigger("reset");
     cursor.SetActive(false);
     MathE.Clamp(ref selectedOption, 0, 3);
     cursor.SetPosition(8, 120 - 16 * selectedOption);
 }
Пример #3
0
 public void SetShieldRecovery(float shieldRecovery)
 {
     currentShield = MathE.Clamp(currentShield + shieldRecovery, 0, maxShield);
     if (onChangeShield != null)
     {
         onChangeShield.Invoke();
     }
     if (CurrentShield == MaxShield)
     {
         onFullShield.Invoke();
     }
 }
Пример #4
0
    // Use this for initialization

    // Update is called once per frame
    void Update()
    {
        if (deactivated && !Player.disabled)
        {
            Player.disabled = true;
        }
        buycoinstext [0].text = GameData.instance.money.ToString();
        buycoinstext [1].text = GameData.instance.coins.ToString();
        if (!finishedThePrompt)
        {
            if (Inputs.pressed("a"))
            {
                finishedThePrompt = true;
                StopAllCoroutines();
                Inputs.dialogueCheck = false;
                dialoguetext.text    = "";
                cursor.SetActive(false);
            }
            if (Inputs.pressed("b"))
            {
                switch (taskType)
                {
                case 0:
                    selectedOption = 1;
                    break;

                case 1:
                    selectedOption = 3;
                    break;
                }
                StopAllCoroutines();
                Inputs.dialogueCheck = false;
                dialoguetext.text    = "";
                cursor.SetActive(false);
                finishedThePrompt = true;
            }



            if (Inputs.pressed("down"))
            {
                selectedOption++;
                switch (taskType)
                {
                case 0:
                    MathE.Clamp(ref selectedOption, 0, 1);
                    cursor.SetPosition(120, 72 - 16 * selectedOption);
                    break;

                case 1:
                    MathE.Clamp(ref selectedOption, 0, 2);
                    cursor.SetPosition(120, 40 - 16 * selectedOption);
                    break;
                }
            }
            if (Inputs.pressed("up"))
            {
                selectedOption--;
                switch (taskType)
                {
                case 0:
                    MathE.Clamp(ref selectedOption, 0, 1);
                    cursor.SetPosition(120, 72 - 16 * selectedOption);
                    break;

                case 1:
                    MathE.Clamp(ref selectedOption, 0, 2);
                    cursor.SetPosition(120, 40 - 16 * selectedOption);
                    break;
                }
            }
        }

        if (GameData.instance.textChoice == 2)
        {
            scrollequation = 3 * 0.016f;
        }
        if (GameData.instance.textChoice == 1)
        {
            scrollequation = 2f * 0.016f;
        }
        if (GameData.instance.textChoice == 0)
        {
            scrollequation = 1f * 0.016f;
        }
    }
Пример #5
0
    IEnumerator  MainUpdate()
    {
        if (currentBagPosition == 0)
        {
            offscreenindexup   = -1;
            offscreenindexdown = 3;
        }


        amountText.text = amountToTask.ToString();
        if (currentMenu == quantitymenu && Dialogue.instance.finishedText)
        {
            if (Inputs.pressed("down"))
            {
                amountToTask--;
            }
            if (Inputs.pressed("up"))
            {
                amountToTask++;
            }
            if (amountToTask < 1)
            {
                amountToTask = maximumItem;
            }
            if (amountToTask > maximumItem)
            {
                amountToTask = 1;
            }
        }
        if (currentMenu == itemwindow && Dialogue.instance.finishedText)
        {
            if (Inputs.pressed("down"))
            {
                currentBagPosition++;

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

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


            if (currentBagPosition != Items.instance.items.Count)
            {
                maximumItem = Items.instance.items [currentBagPosition].quantity;
            }
            else
            {
                maximumItem = 0;
            }
        }
        if (currentMenu == null && (currentMenu != quantitymenu || currentMenu != itemwindow))
        {
        }
        else
        {
            if (currentMenu == usetossmenu && Dialogue.instance.finishedText)
            {
                if (Inputs.pressed("down"))
                {
                    selectedOption++;
                    MathE.Clamp(ref selectedOption, 0, 1);
                    UpdateUseTossScreen();
                }
                if (Inputs.pressed("up"))
                {
                    selectedOption--;
                    MathE.Clamp(ref selectedOption, 0, 1);
                    UpdateUseTossScreen();
                }
            }
        }
        if (Inputs.pressed("select") && Dialogue.instance.finishedText && currentBagPosition != Items.instance.items.Count)
        {
            if (!switching)
            {
                switching = true;
                selectCursor.gameObject.SetActive(true);
                selectBag = currentBagPosition;
                UpdateBagScreen();
            }
            else
            {
                //our Bag
                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;
                UpdateBagScreen();
            }
        }
        if (Dialogue.instance.finishedText)
        {
            if (Inputs.pressed("a"))
            {
                SoundManager.instance.PlayABSound();
                if (currentMenu == itemwindow)
                {
                    if (currentBagPosition == Items.instance.items.Count)
                    {
                        MainMenu.instance.selectedOption = 0;
                        MainMenu.instance.currentmenu    = MainMenu.instance.thismenu;
                        this.gameObject.SetActive(false);
                    }
                    else
                    {
                        amountToTask = 1;
                        usetossmenu.SetActive(true);
                        UpdateUseTossScreen();
                        switching = false;
                        selectCursor.gameObject.SetActive(true);
                        cursor.SetActive(true);
                        currentMenu = usetossmenu;
                    }
                }

                else if (currentMenu == usetossmenu)
                {
                    if (selectedOption == 0)
                    {
                        if (Items.instance.items.Count > 0)
                        {
                            ItemMode1();
                            Player.instance.UseItem(Items.instance.items [currentBagPosition].name);
                        }
                    }
                    if (selectedOption == 1)
                    {
                        if (Items.instance.items.Count > 0)
                        {
                            ItemMode2();
                            quantitymenu.SetActive(true);
                            currentMenu = quantitymenu;
                        }
                    }
                }
                else if (currentMenu == quantitymenu)
                {
                    if (ItemMode == 1)
                    {
                        //use item
                    }

                    if (ItemMode == 2)
                    {
                        if (!Items.instance.items[currentBagPosition].isKeyItem)
                        {
                            yield return(Dialogue.instance.text("Is it OK to toss \\l" + Items.instance.items[currentBagPosition].name + "?"));

                            yield return(StartCoroutine(Dialogue.instance.prompt()));

                            if (Dialogue.instance.selectedOption == 0)
                            {
                                yield return(Dialogue.instance.text("Threw away " + Items.instance.items[currentBagPosition].name + "."));

                                StartCoroutine(TossItem());
                            }
                            else
                            {
                                Dialogue.instance.Deactivate();
                                UpdateBagScreen();
                                cursor.SetActive(true);
                                currentMenu = itemwindow;
                            }
                        }
                        else
                        {
                            StartCoroutine(TooImportantToToss());
                        }
                    }
                }
            }
            if (Inputs.pressed("b"))
            {
                SoundManager.instance.PlayABSound();
                if (currentMenu == itemwindow)
                {
                    switching = false;
                    selectCursor.gameObject.SetActive(false);
                    MainMenu.instance.currentmenu = MainMenu.instance.thismenu;
                    Inputs.Enable("start");
                    this.gameObject.SetActive(false);
                }
                else if (currentMenu == usetossmenu)
                {
                    currentMenu = itemwindow;
                    selectCursor.gameObject.SetActive(false);
                    UpdateBagScreen();
                }
                else if (currentMenu == quantitymenu)
                {
                    if (ItemMode == 2)
                    {
                        selectCursor.gameObject.SetActive(false);
                        UpdateBagScreen();
                        currentMenu = itemwindow;
                    }
                }
            }



            foreach (GameObject menu in allMenus)
            {
                if (menu != currentMenu)
                {
                    menu.SetActive(false);
                }
                else
                {
                    menu.SetActive(true);
                }
                if (menu == usetossmenu && (currentMenu == quantitymenu))
                {
                    menu.SetActive(true);
                }

                if (menu == quantitymenu && (currentMenu == itemwindow))
                {
                    menu.SetActive(false);
                }
                if (menu == itemwindow && (currentMenu == quantitymenu || currentMenu == usetossmenu))
                {
                    menu.SetActive(true);
                }
                if (currentMenu == null)
                {
                    indicator.SetActive(false);
                }
            }
        }
    }
Пример #6
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);
    }
Пример #7
0
    void Update()
    {
        if (currentMenu == switchstats)
        {
            if (Inputs.pressed("down"))
            {
                selectedOption++;
                MathE.Clamp(ref selectedOption, 0, 2 + switchMenuOffset);
                UpdateSwitch();
            }
            if (Inputs.pressed("up"))
            {
                selectedOption--;
                MathE.Clamp(ref selectedOption, 0, 2 + switchMenuOffset);
                UpdateSwitch();
            }
        }
        if (currentMenu == mainwindow)
        {
            highlightedmon  = GameData.instance.party[selectedOption];
            partyAnimTimer += 1;
            float hpratio      = (float)highlightedmon.currentHP / (float)highlightedmon.maxHP;
            float animLoopTime = hpratio > .5f ? 10 : hpratio > .21f ? 32 : 64; //the animation takes 10,32, or 64 frames
            if (partyAnimTimer == animLoopTime)
            {
                partyAnimTimer = 0;
            }

            foreach (Pokemon pokemon in GameData.instance.party)
            {
                Transform slottransform = partyslots[GameData.instance.party.IndexOf(pokemon)].transform;
                if (GameData.instance.party.IndexOf(pokemon) != selectedOption)
                {
                    slottransform.GetChild(0).GetComponent <Image>().sprite = partyanims[PokemonData.PokemonPartySprite[pokemon.name]].anim[0];
                }
                else
                {
                    slottransform.GetChild(0).GetComponent <Image>().sprite = partyanims[PokemonData.PokemonPartySprite[pokemon.name]].anim[Mathf.FloorToInt(2f * partyAnimTimer / animLoopTime)];
                }
            }


            cursor.SetPosition(0, 128 - 16 * selectedOption);


            if (Dialogue.instance.finishedText || selectingPokemon)
            {
                if (Inputs.pressed("down"))
                {
                    selectedOption++;
                    MathE.Clamp(ref selectedOption, 0, numberofPokemon - 1);
                }
                if (Inputs.pressed("up"))
                {
                    selectedOption--;
                    MathE.Clamp(ref selectedOption, 0, numberofPokemon - 1);
                }
            }
        }

        if (Inputs.pressed("b") && Dialogue.instance.finishedText)
        {
            SoundManager.instance.PlayABSound();
            if (currentMenu == mainwindow)
            {
                Inputs.instance.DisableForSeconds("b", 0.2f);
                Dialogue.instance.fastText = false;
                Dialogue.instance.Deactivate();
                Inputs.Enable("start");
                moon.currentmenu = moon.thismenu;
                this.gameObject.SetActive(false);
            }
            else if (currentMenu == switchstats)
            {
                selectedOption = selectedMon;
                currentMenu    = mainwindow;
                UpdateMainMenu();
            }
        }
        if (Inputs.pressed("a") && Dialogue.instance.finishedText)
        {
            SoundManager.instance.PlayABSound();
            if (currentMenu == mainwindow)
            {
                if (!switching)
                {
                    int textOffsetLength = 4;
                    switchMenuOffsetX = 0;
                    switchMenuOffset  = 0;
                    int numberOfFieldMoves = 0;
                    int selectedMenu       = 0;
                    selectedMon = selectedOption;
                    Pokemon selectedPokemon = GameData.instance.party[selectedMon];
                    for (int i = 0; i < 4; i++)
                    {
                        fieldMoveNames[i] = "";
                        fieldMoveObj[i].SetActive(false);
                    }
                    for (int i = 0; i < 4; i++)
                    {
                        if (selectedPokemon.slotHasMove(i))
                        {
                            Move move = selectedPokemon.moves[i];
                            if (isFieldMove(move))
                            {
                                numberOfFieldMoves++;
                                if (move.name.Length > 6 && selectedMenu != 8)
                                {
                                    selectedMenu     = 4;
                                    textOffsetLength = 2;
                                }
                                if (move.name.Length > 8)
                                {
                                    selectedMenu     = 8;
                                    textOffsetLength = 0;
                                }
                                fieldMoveNames[switchMenuOffset] = move.name;
                                fieldMoveObj[3 - switchMenuOffset].SetActive(true);
                                for (int j = 0; j < textOffsetLength; j++)
                                {
                                    fieldMoveText[3 - switchMenuOffset].text += " ";
                                }

                                switchMenuOffset++;
                            }
                        }
                    }
                    for (int i = 0; i < numberOfFieldMoves; i++)
                    {
                        fieldMoveText[(4 - switchMenuOffset) + i].text += fieldMoveNames[i].ToUpper();
                    }
                    switchMenuOffsetX      = selectedMenu / 4;
                    selectedMenu          += switchMenuOffset;
                    switchMenuImage.sprite = switchMenuSprites[selectedMenu];

                    selectedOption = 0;
                    currentMenu    = switchstats;
                    UpdateSwitch();
                }
                else
                {
                    Dialogue.instance.Deactivate();
                    StartCoroutine(Switch());
                    UpdateScreen();
                    StartCoroutine(Dialogue.instance.text("Choose a POKéMON."));
                    Dialogue.instance.finishedText = true;
                    switching = false;
                }
            }
            else if (currentMenu == switchstats)
            {
                if (selectedOption < switchMenuOffset)
                {
                    StartCoroutine(UseFieldMove(fieldMoveNames[selectedOption]));
                }
                if (selectedOption == switchMenuOffset)
                {
                    SoundManager.instance.SetMusicLow();
                    SoundManager.instance.PlayCry(PokemonData.MonToID(GameData.instance.party[selectedMon].name) - 1);
                    Dialogue.instance.Deactivate();
                    currentMenu = stats1;
                    UpdateStats1();
                }
                else if (selectedOption == switchMenuOffset + 1)
                {
                    switching      = true;
                    selectedOption = selectedMon;
                    currentMenu    = mainwindow;
                    StartCoroutine(Dialogue.instance.text("Move #MON\\lwhere?"));
                    Dialogue.instance.finishedText = true;
                    UpdateMainMenu();
                }
                else if (selectedOption == switchMenuOffset + 2)
                {
                    selectedOption = selectedMon;
                    currentMenu    = mainwindow;
                    UpdateMainMenu();
                }
            }
            else if (currentMenu == stats1)
            {
                currentMenu = stats2;
                UpdateStats2();
            }
            else if (currentMenu == stats2)
            {
                SoundManager.instance.SetMusicNormal();
                Dialogue.instance.Deactivate();
                Dialogue.instance.fastText         = true;
                Dialogue.instance.keepTextOnScreen = true;
                Dialogue.instance.needButtonPress  = false;
                StartCoroutine(Dialogue.instance.text("Choose a POKéMON."));
                Dialogue.instance.finishedText = true;
                selectedOption = selectedMon;
                currentMenu    = mainwindow;
                UpdateMainMenu();
            }
        }
    }
Пример #8
0
        public static void UpdateFrequency(object sender, ImageType imageType, FrequencyType frequencyType, ref ThemeOptions ThemeOptions)
        {
            double  input         = 0;
            TextBox sourceTextBox = sender as TextBox;

            // Process the Input
            try
            {
                string inputText = sourceTextBox.Text;
                if (inputText.Contains('%'))
                {
                    inputText = inputText.Substring(0, inputText.IndexOf('%'));                          // removes % from input if it was left
                }
                if (frequencyType == FrequencyType.Relative)
                {
                    input = Math.Max(0, double.Parse(inputText));
                }
                else if (frequencyType == FrequencyType.Exact)
                {
                    input = MathE.Clamp(double.Parse(inputText), 0, 100);
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
                // incorrect value entered, end update and reset text (reset externally)
                return;
            }

            // Update a Frequency
            if (frequencyType == FrequencyType.Relative) // set the relative chance & recalculate exact chances to represent said change
            {
                Debug.WriteLine("Relative");

                if (input == 0)
                {
                    int zeroCount = 0;
                    if (ThemeOptions.RelativeFrequency[ImageType.Static] == 0)
                    {
                        zeroCount++;
                    }
                    if (ThemeOptions.RelativeFrequency[ImageType.GIF] == 0)
                    {
                        zeroCount++;
                    }
                    if (ThemeOptions.RelativeFrequency[ImageType.Video] == 0)
                    {
                        zeroCount++;
                    }

                    if (zeroCount >= 2) // attempted to make all frequencies 0%, cancel this change
                    {
                        Debug.WriteLine("Cannot have 0% probability across all entries. Change cancelled");
                        return;
                    }
                }

                ThemeOptions.RelativeFrequency[imageType] = input / 100; // the actual value is a percentage

                RecalculateExactFrequency(ref ThemeOptions);
            }
            else if (frequencyType == FrequencyType.Exact) // set a new exact chance, recalculating the remaining exact chances & also the relative chances to represent this change
            {
                Debug.WriteLine("Exact");
                ThemeOptions.ExactFrequency[imageType] = input / 100; // the actual value is a percentage

                if (input < 100 && input > 0)
                {
                    CalculateExactFrequency(imageType, ref ThemeOptions);
                    RecalculateRelativeFrequency(imageType, false, ref ThemeOptions);
                }
                else if (input >= 100) // exact chance of 1, set everything else to 0
                {
                    if (imageType != ImageType.Static)
                    {
                        ThemeOptions.ExactFrequency[ImageType.Static] = 0;
                    }
                    if (imageType != ImageType.GIF)
                    {
                        ThemeOptions.ExactFrequency[ImageType.GIF] = 0;
                    }
                    if (imageType != ImageType.Video)
                    {
                        ThemeOptions.ExactFrequency[ImageType.Video] = 0;
                    }
                    RecalculateRelativeFrequency(imageType, true, ref ThemeOptions);
                }
                else if (input <= 0) // exact chance of 0, set everything else to 0.5
                {
                    if (imageType != ImageType.Static)
                    {
                        ThemeOptions.ExactFrequency[ImageType.Static] = 0.5;
                    }
                    if (imageType != ImageType.GIF)
                    {
                        ThemeOptions.ExactFrequency[ImageType.GIF] = 0.5;
                    }
                    if (imageType != ImageType.Video)
                    {
                        ThemeOptions.ExactFrequency[ImageType.Video] = 0.5;
                    }
                    RecalculateRelativeFrequency(imageType, true, ref ThemeOptions);
                }
            }
        }
Пример #9
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);
            }
        }
    }
Пример #10
0
    // Update is called once per frame
    void Update()
    {
        if (Inputs.pressed("a"))
        {
            if (Title.instance.gameObject.activeSelf)
            {
                if (selectedOption == 3)
                {
                    SoundManager.instance.PlayABSound();
                    Inputs.instance.DisableForSeconds("a", 0.2f);
                    Title.instance.currentMenu = Title.instance.HasData ? Title.instance.datamenu : Title.instance.nodatamenu;
                    this.gameObject.SetActive(false);
                }
            }
            else if (MainMenu.instance.currentmenu == MainMenu.instance.optionsmenu)
            {
                if (selectedOption == 3)
                {
                    SoundManager.instance.PlayABSound();
                    Inputs.Enable("start");
                    MainMenu.instance.currentmenu = MainMenu.instance.thismenu;
                    this.gameObject.SetActive(false);
                }
            }
        }
        if (Inputs.pressed("b"))
        {
            if (Title.instance.gameObject.activeSelf)
            {
                SoundManager.instance.PlayABSound();
                this.gameObject.SetActive(false);
            }
            else if (MainMenu.instance.currentmenu == MainMenu.instance.optionsmenu)
            {
                SoundManager.instance.PlayABSound();
                Inputs.Enable("start");
                MainMenu.instance.currentmenu = MainMenu.instance.thismenu;
                this.gameObject.SetActive(false);
            }
        }

        if (Inputs.pressed("left"))
        {
            if (selectedOption == 0)
            {
                GameData.instance.textChoice--;
                MathE.Clamp(ref GameData.instance.textChoice, 0, 2);
                UpdateCursorPosition();
            }
            if (selectedOption == 1)
            {
                GameData.instance.animationChoice--;
                MathE.Clamp(ref GameData.instance.animationChoice, 0, 1);
                UpdateCursorPosition();
            }
            if (selectedOption == 2)
            {
                GameData.instance.battleChoice--;
                MathE.Clamp(ref GameData.instance.battleChoice, 0, 1);
                UpdateCursorPosition();
            }
        }

        if (Inputs.pressed("right"))
        {
            if (selectedOption == 0)
            {
                GameData.instance.textChoice++;
                MathE.Clamp(ref GameData.instance.textChoice, 0, 2);
                UpdateCursorPosition();
            }
            if (selectedOption == 1)
            {
                GameData.instance.animationChoice++;
                MathE.Clamp(ref GameData.instance.animationChoice, 0, 1);
                UpdateCursorPosition();
            }
            if (selectedOption == 2)
            {
                GameData.instance.battleChoice++;
                MathE.Clamp(ref GameData.instance.battleChoice, 0, 1);
                UpdateCursorPosition();
            }
        }

        if (Inputs.pressed("down"))
        {
            selectedOption++;
            MathE.Clamp(ref selectedOption, 0, 3);
            UpdateCursorPosition();
        }
        if (Inputs.pressed("up"))
        {
            selectedOption--;
            MathE.Clamp(ref selectedOption, 0, 3);
            UpdateCursorPosition();
        }
    }
Пример #11
0
    // Update is called once per frame
    void Update()
    {
        if ((currentmenu == rednamemenu || currentmenu == garynamemenu) && currentmenu != nameselectionmenu)
        {
            if (Inputs.pressed("down"))
            {
                selectedOption++;
                MathE.Clamp(ref selectedOption, 0, 3);
                cursor.SetPosition(8, 120 - 16 * selectedOption);
            }
            if (Inputs.pressed("up"))
            {
                selectedOption--;
                MathE.Clamp(ref selectedOption, 0, 3);
                cursor.SetPosition(8, 120 - 16 * selectedOption);
            }
        }
        foreach (GameObject menu in allmenus)
        {
            if (menu != currentmenu)
            {
                menu.SetActive(false);
            }
            else
            {
                menu.SetActive(true);
            }
        }

        if (Inputs.pressed("a"))
        {
            if (currentmenu == rednamemenu)
            {
                if (selectedOption == 0)
                {
                    currentmenu = nameselectionmenu;
                    nameselectionmenu.SetActive(true);
                    names.futureName = "";
                }
                else
                {
                    currentmenu = null;
                    switch (VersionManager.instance.version)
                    {
                    case Version.Red:
                        switch (selectedOption)
                        {
                        case 1:
                            GameData.instance.playerName = "RED";
                            break;

                        case 2:
                            GameData.instance.playerName = "ASH";
                            break;

                        case 3:
                            GameData.instance.playerName = "JACK";
                            break;
                        }
                        break;

                    case Version.Blue:
                        switch (selectedOption)
                        {
                        case 1:
                            GameData.instance.playerName = "BLUE";
                            break;

                        case 2:
                            GameData.instance.playerName = "GARY";
                            break;

                        case 3:
                            GameData.instance.playerName = "JOHN";
                            break;
                        }
                        break;
                    }
                    tutanim.SetTrigger("transition");
                    Dialogue.instance.enabled = true;
                    givingRedAName            = false;
                    cursor.SetActive(false);
                }
            }

            if (currentmenu == garynamemenu)
            {
                if (selectedOption == 0)
                {
                    currentmenu = nameselectionmenu;
                    nameselectionmenu.SetActive(true);
                    names.futureName = "";
                }
                else
                {
                    currentmenu = null;
                    switch (GameData.instance.version)
                    {
                    case Version.Blue:
                        switch (selectedOption)
                        {
                        case 1:
                            GameData.instance.rivalName = "RED";
                            break;

                        case 2:
                            GameData.instance.rivalName = "ASH";
                            break;

                        case 3:
                            GameData.instance.rivalName = "JACK";
                            break;
                        }
                        break;

                    case Version.Red:
                        switch (selectedOption)
                        {
                        case 1:
                            GameData.instance.rivalName = "BLUE";
                            break;

                        case 2:
                            GameData.instance.rivalName = "GARY";
                            break;

                        case 3:
                            GameData.instance.rivalName = "JOHN";
                            break;
                        }
                        break;
                    }
                    tutanim.SetTrigger("transition");
                    Dialogue.instance.enabled = true;
                    givingRedAName            = false;
                    cursor.SetActive(false);
                }
            }
        }
    }