Ejemplo n.º 1
0
    void Update()
    {
        if (!Input.GetKeyDown(KeyCode.Escape))
        {
            return;
        }

        if (!hudEnabled)
        {
            return;
        }

        if (Game.game.tapjoyPromotionWindow != null)
        {
            return;
        }

        if (Game.game.currentDialog != null)
        {
            return;
        }

        Game.GameStates currentState = Game.game.currentState;

        if (currentState == Game.GameStates.InTutorial ||
            (currentState == Game.GameStates.InGame || currentState == Game.GameStates.Town) &&
            inventoryVisible == false)
        {
            bool inTown            = Game.game.InTown();
            bool townButtonEnabled = TownGui.townButtonsEnabled();

            if (Game.game.pauseButtonEnabled)
            {
                if (!inTown || (inTown && townButtonEnabled))
                {
                    inventoryActive(null);
                }
            }
        }
        else if (inventoryVisible)
        {
            HudInventory hudInventory = GetComponent <HudInventory>();
            hudInventory.returnToGame(null);
        }
    }
Ejemplo n.º 2
0
    public void showInGameHud()
    {
        Game game = Game.game;

        Game.GameStates currentState = Game.game.currentState;

        if (currentState == Game.GameStates.Town || currentState == Game.GameStates.InTutorialTown)
        {
            if (Screen.height >= 480)
            {
                healthStatBar.fillRect.y     = 0.085f;
                magicStatBar.fillRect.y      = 0.13f;
                experienceStatBar.fillRect.y = 0.176f;
                levelRect.y = 0.235f;

                portraitRect.y = 0.05f;
                infoBarRect.y  = 0.05f;
            }
            else
            {
                healthStatBar.fillRect.y     = 0.13f;
                magicStatBar.fillRect.y      = 0.18f;
                experienceStatBar.fillRect.y = 0.227f;
                levelRect.y = 0.27f;

                portraitRect.y = 0.1f;
                infoBarRect.y  = 0.1f;
            }
        }

        //level of the player
        Rect lvlRect = new Rect(levelRect);

        float h      = (float)Screen.height;
        float w      = (float)Screen.width;
        float aspect = w / h;

        if (aspect > (16.0f / 9.0f))
        {
            float pw = (w - h * 16.0f / 9.0f) * 0.5f;
            lvlRect.x += pw / Screen.width;
        }

        string fontInResolution = textFont("[F ButtonFontBigXL]", "[F ButtonFontBig28]", "[F ButtonFontBig32]", "[F FontSize72]");

        if (lastlvl != game.getPlayerLevel())
        {
            lastlvl  = game.getPlayerLevel();
            lvlLabel = null;
        }

        showLabelFormat(ref lvlLabel, lvlRect, fontInResolution + "[c FFFFFFFF]" + lvlNoCapsString.text + " : " + game.getPlayerLevel().ToString() + fontInResolution,
                        new string[] { "ButtonFontBigXL", "ButtonFontBig28", "ButtonFontBig32", "FontSize72" });
        //health bar
        healthStatBar.fillRect.x      = infoBarRect.x + (originalHealthFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        healthStatBar.getCurrentValue = game.getPlayerHealth;
        healthStatBar.getMaximumValue = game.getPlayerMaxHealth;
        healthStatBar.draw();

        //magic bar
        magicStatBar.fillRect.x      = infoBarRect.x + (originalMagicFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        magicStatBar.getCurrentValue = game.getPlayerMagic;
        magicStatBar.getMaximumValue = game.getPlayerMaxMagic;
        magicStatBar.draw();

        //exp bar
        experienceStatBar.fillRect.x      = infoBarRect.x + (originalExperienceFillRect.x - infoBarRect.x) * 1.5f * ((float)Screen.height / (float)Screen.width);
        experienceStatBar.getCurrentValue = delegate()
        {
            if (Game.game.gameStats.level < Game.levelCap)
            {
                return(game.getPlayerExperience() - game.getExperienceForCurrentLevel());
            }
            else
            {
                return(1);
            }
        };
        experienceStatBar.getMaximumValue = delegate()
        {
            if (Game.game.gameStats.level < Game.levelCap)
            {
                return(game.getExperienceNeededForNextLevel() - game.getExperienceForCurrentLevel());
            }
            else
            {
                return(1);
            }
        };
        experienceStatBar.draw();

        //hero's icon
        showImage(portrait, portraitRect);

        //hud layout
        showImage(infoBarHero, infoBarRect);

        // Pause Button

        bool inTown            = Game.game.InTown();
        bool townButtonEnabled = TownGui.townButtonsEnabled();

        if (Game.game.pauseButtonEnabled)
        {
            if (!inTown || (inTown && townButtonEnabled))
            {
                showHudButton(pauseButton, true, inventoryActive);
            }
        }

        ButtonDelegate btHealDelegate  = delegate(Object o){};
        ButtonDelegate btMagicDelegate = delegate(Object o){};

        bool canUseHealingPotion = true;
        bool canUseMagicPotion   = true;

        TutSkillAndMagic skillAndMagic = Game.game.GetComponent <TutSkillAndMagic>();

        if (skillAndMagic != null && skillAndMagic.runningTutorial)
        {
            canUseHealingPotion = false;
        }

        if (Game.game.playableCharacter != null)
        {
            if (Game.game.playableCharacter.isAlive())
            {
                //use healing potion
                btHealDelegate = delegate(Object o)
                {
                    if (!inventoryVisible && canUseHealingPotion)
                    {
                        Inventory.inventory.consume(healingPotionItem, 1);
                        Game.game.healingPotionButton = true;
                        if (audioHud != null)
                        {
                            Game.game.playSound(audioHud.audioPool[0]);
                        }
                    }
                };

                //use magic potion
                btMagicDelegate = delegate(Object o)
                {
                    if (!inventoryVisible && canUseMagicPotion)
                    {
                        Inventory.inventory.consume(manaPotionItem, 1);
                        if (audioHud != null)
                        {
                            Game.game.playSound(audioHud.audioPool[1]);
                        }
                    }
                };
            }
        }

        if (!Game.game.InTown())
        {
            //show current buffs
            showBuffStack();

            //enemy life bar
            enemyLifeBar.draw();

            if (Game.game.currentDialog == null)
            {
                itemPotionEnabled  = Inventory.inventory.getItemAmmount(healingPotionItem) > 0;
                magicPotionEnabled = Inventory.inventory.getItemAmmount(manaPotionItem) > 0;
                chestPotionEnabled = true;

                //life potion button
                if (Game.game.healingPotionEnabled)
                {
                    showHudButton(healingPotion, itemPotionEnabled, btHealDelegate);

                    if (Inventory.inventory.getItemAmmount(healingPotionItem) > 0)
                    {
                        potionUseStyle.font = styleInResolution(potionFontStyle, buttonSmall, buttonMidle, buttonBig, buttonBigXXL, 0f);
                        showLabel(healingPotionNRect, Inventory.inventory.getItemAmmount(healingPotionItem).ToString(), potionUseStyle);
                    }
                }
                // if potions > 1


                //magic potion button
                if (Game.game.magicPotionEnabled)
                {
                    showHudButton(magicPotion, magicPotionEnabled, btMagicDelegate);

                    if (Inventory.inventory.getItemAmmount(manaPotionItem) > 0)
                    {
                        potionUseStyle.font = styleInResolution(potionFontStyle, buttonSmall, buttonMidle, buttonBig, buttonBigXXL, 0f);
                        showLabel(manaPotionNRect, Inventory.inventory.getItemAmmount(manaPotionItem).ToString(), potionUseStyle);
                    }
                }

                //open chest button
                if (Game.game.quickChestEnabled)
                {
                    showHudButton(chest, chestPotionEnabled, delegate(Object o)
                    {
                        if (!inventoryVisible)
                        {
                            toogleQuickPotions(null);
                        }
                    }
                                  );
                }

                //skill images
                Texture2D[] currentSkillImages         = new Texture2D[4];
                Texture2D[] currentDisabledSkillImages = new Texture2D[4];

                TexturePool tpool = (Resources.Load("TexturePools/Skills") as GameObject).GetComponent <TexturePool>();

                for (int i = 0; i < 4; i++)
                {
                    if (Game.game.currentSkills[i] != -1)
                    {
                        Texture2D image  = tpool.getFromList(Game.skillData[(int)Game.game.currentSkills[i]].enabled);
                        Texture2D dimage = tpool.getFromList(Game.skillData[(int)Game.game.currentSkills[i]].disabled);

                        currentSkillImages[i]         = image;
                        currentDisabledSkillImages[i] = dimage;
                    }
                }

                skill1.enabled = currentSkillImages[0]; skill1.disabled = currentDisabledSkillImages[0];
                skill2.enabled = currentSkillImages[1]; skill2.disabled = currentDisabledSkillImages[1];
                skill3.enabled = currentSkillImages[2]; skill3.disabled = currentDisabledSkillImages[2];
                skill4.enabled = currentSkillImages[3]; skill4.disabled = currentDisabledSkillImages[3];

                bool canUseSkillButtons = true;

                if (skillAndMagic != null && skillAndMagic.runningTutorial && Game.game.magicPotionEnabled)
                {
                    canUseSkillButtons = false;
                }

                //skills buttons
                showHudButton(skill1, Game.game.canUseSkill((int)Game.game.currentSkills[0]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[0]);
                    }
                });
                showHudButton(skill2, Game.game.canUseSkill((int)Game.game.currentSkills[1]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[1]);
                    }
                });
                showHudButton(skill3, Game.game.canUseSkill((int)Game.game.currentSkills[2]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[2]);
                    }
                });
                showHudButton(skill4, Game.game.canUseSkill((int)Game.game.currentSkills[3]), delegate(Object o)
                {
                    if (canUseSkillButtons)
                    {
                        Game.game.useSkill((int)Game.game.currentSkills[3]);
                    }
                });
            }
        }
    }