Пример #1
0
    //when this object is created, load a monster in to it and then display all of the information
    public void DisplayMonster(Monster m)
    {
        Monster = m;

        var data     = GameManager.Instance.monstersData.monstersAllDict;
        var equips   = GameManager.Instance.items.allEquipsDict;
        var statuses = GameManager.Instance.GetComponent <AllStatusEffects>().allStatusDict;
        var colors   = GameManager.Instance.typeColorDictionary;

        Color type1Color = colors[m.info.type1];

        Color atk1Color = colors[m.info.attack1.type];
        Color atk2Color = colors[m.info.attack2.type];

        GetComponent <SpriteRenderer>().color = type1Color;

        levelText.text  = m.info.level.ToString();
        attackText.text = Mathf.Round(m.info.Attack.Value).ToString();
        koText.text     = m.currentMapKOs.ToString();
        nameText.text   = m.info.name;

        monsterIcon.GetComponent <SpriteRenderer>().sprite = m.frontModel.GetComponent <SpriteRenderer>().sprite;

        //show the equipment if this monster has any
        if (equips.ContainsKey(m.info.equip1Name))
        {
            EquipmentScript e = equips[m.info.equip1Name];
            equip1.GetComponent <SpriteRenderer>().sprite = e.sprite;
            e.ActivateItem(e, equip1);
        }
        else
        {
            equip1.GetComponent <SpriteRenderer>().sprite = null;
        }

        if (equips.ContainsKey(m.info.equip2Name))
        {
            EquipmentScript e = equips[m.info.equip2Name];
            equip2.GetComponent <SpriteRenderer>().sprite = e.sprite;
            e.ActivateItem(e, equip2);
        }
        else
        {
            equip2.GetComponent <SpriteRenderer>().sprite = null;
        }

        //if there are no statuses, don't show anything in the status sprites
        if (m.statuses.Count == 0)
        {
            for (int s = 0; s < statusSprites.Length; s++)
            {
                statusSprites[s].sprite = null;
            }
        }
        else
        {
            for (int i = 0; i < m.statuses.Count; i++)
            {
                statusSprites[i].sprite = m.statuses[0].statusSprite;
            }
        }

        //show the rank this monster is with rank stars equal to its rank
        for (int r = 0; r < m.info.monsterRank; r++)
        {
            rankSprites[r].SetActive(true);
        }

        //set the attack graphics

        atk1Text.text = m.info.attack1Name;
        atk1Bg.GetComponent <SpriteRenderer>().color = atk1Color;
        atk2Bg.GetComponent <SpriteRenderer>().color = atk2Color;
        atk2Text.text = m.info.attack2Name;

        if (m.GetComponent <Tower>().attackNumber == 1)
        {
            atk1Outline.GetComponent <GoldFX>().enabled = true;
            atk2Outline.GetComponent <GoldFX>().enabled = false;
        }
        else
        {
            atk1Outline.GetComponent <GoldFX>().enabled = false;
            atk2Outline.GetComponent <GoldFX>().enabled = true;
        }


        //set the ability graphics
        abilityAmmoText.text = (m.info.specialAbility.castingAmmo - m.info.specialAbility.castingCount).ToString();
        //lowerbound value for this fill is .23 while the upperbound is .86, thus these numbers
        staminaProgress.fillAmount = .23f + (.63f * m.GetComponent <Tower>().staminaBar.BarProgress);

        if (staminaProgress.fillAmount >= .86f)
        {
            stamFX._Color = Color.green;
        }
        else if (staminaProgress.fillAmount >= .73f)
        {
            stamFX._Color = Color.yellow;
        }
        else if (staminaProgress.fillAmount >= .63f)
        {
            stamFX._Color = Color.magenta;
        }
        else if (staminaProgress.fillAmount >= .49f)
        {
            stamFX._Color = Color.red;
        }
        else if (staminaProgress.fillAmount >= .39f)
        {
            stamFX._Color = Color.cyan;
        }
        else if (staminaProgress.fillAmount >= .28f)
        {
            stamFX._Color = Color.blue;
        }
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            var     equips     = GameManager.Instance.items.allEquipsDict;
            Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);

            RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero);

            //if this tower is clicked on, it can be placed
            if (hit.collider != null)
            {
                if (hit.collider.gameObject.tag == "Tower")
                {
                    //GameManager.Instance.OverworldMenuControl();
                    //GameManager.Instance.overworldMenu.GetComponentInChildren<OverworldInfoMenu>().activeMonster = hit.collider.gameObject.GetComponent<Monster>();

                    infoMenu.SetActive(true);
                    if (enemyInfoMenu)
                    {
                        enemyInfoMenu.SetActive(false);
                    }
                    activeMonster = hit.collider.gameObject.GetComponent <Monster>();

                    //checks the monster's equipment and displays the matching sprites if there is equipment on the monster
                    if (equips.ContainsKey(activeMonster.info.equip1Name))
                    {
                        e1.DeactivateItem(e1, equip1);
                        e1 = equips[activeMonster.info.equip1Name];
                        //equip1.GetComponent<Image>().color = Color.white;
                        equip1.name = activeMonster.info.equip1Name;
                        equip1.GetComponent <SpriteRenderer>().sprite = equips[activeMonster.info.equip1Name].sprite;

                        e1.ActivateItem(e1, equip1);
                    }
                    else
                    {
                        equip1.GetComponent <SpriteRenderer>().sprite = null;
                        //equip1.GetComponent<Image>().color = Color.clear;
                        equip1.name = "Equip1";
                        e1.DeactivateItem(e1, equip1);
                        //e1 = null;
                    }

                    if (equips.ContainsKey(activeMonster.info.equip2Name))
                    {
                        e2.DeactivateItem(e2, equip2);
                        e2 = equips[activeMonster.info.equip2Name];
                        //equip2.GetComponent<Image>().color = Color.white;
                        equip2.name = activeMonster.info.equip2Name;
                        equip2.GetComponent <SpriteRenderer>().sprite = equips[activeMonster.info.equip2Name].sprite;
                        e2.ActivateItem(e2, equip2);
                    }
                    else
                    {
                        equip2.GetComponent <SpriteRenderer>().sprite = null;
                        equip2.name = "Equip2";
                        e2.DeactivateItem(e2, equip2);
                        //e2 = null;
                        //equip2.GetComponent<Image>().color = Color.clear;
                    }
                }
            }
        }


        CheckMonster();

        if (activeMonster)
        {
            type1.GetComponent <Image>();
            type2.GetComponent <Image>();


            var types  = GameManager.Instance.monstersData.typeChartDict;
            var equips = GameManager.Instance.items.allEquipsDict;

            //monsterName.text = activeMonster.info.name;
            //attack1BtnText.text = activeMonster.info.attack1Name;
            //atk1Power.text = activeMonster.info.attack1.Power.Value.ToString();
            //atk1Range.text = activeMonster.info.attack1.Range.Value.ToString();
            //atk1TypeSp.sprite = types[activeMonster.info.attack1.type].typeSprite;

            //attack2BtnText.text = activeMonster.info.attack2Name;
            //atk2Power.text = activeMonster.info.attack2.Power.Value.ToString();
            //atk2Range.text = activeMonster.info.attack2.Range.Value.ToString();
            //atk2TypeSp.sprite = types[activeMonster.info.attack2.type].typeSprite;

            monsterName.text    = activeMonster.info.name;
            attack1BtnText.text = activeMonster.info.attack1Name;
            atk1Power.text      = activeMonster.info.baseAttack1.Power.Value.ToString();
            atk1Range.text      = activeMonster.info.baseAttack1.Range.Value.ToString();
            atk1TypeSp.sprite   = types[activeMonster.info.baseAttack1.type].typeSprite;

            attack2BtnText.text = activeMonster.info.attack2Name;
            atk2Power.text      = activeMonster.info.baseAttack2.Power.Value.ToString();
            atk2Range.text      = activeMonster.info.baseAttack2.Range.Value.ToString();
            atk2TypeSp.sprite   = types[activeMonster.info.baseAttack2.type].typeSprite;


            //levelText.text = "Level: " + activeMonster.info.level.ToString();
            //atkText.text = "Atk: " + Math.Round(activeMonster.attack, 0).ToString();
            //defText.text = "Def: " + Math.Round(activeMonster.defense, 0).ToString();
            //speText.text = "Speed: " + Math.Round(activeMonster.speed, 0).ToString();
            //precText.text = "Prec: " + Math.Round(activeMonster.precision, 0).ToString();
            //typeText.text = "Type: " + activeMonster.info.type1 + "/" + activeMonster.info.type2;
            //evasText.text = "Evasion: " + Math.Round(activeMonster.evasion, 0) + "%";
            //enGenText.text = "En Gen: " + Math.Round((activeMonster.energyGeneration / 60), 2) + " /s";
            //enCostText.text = "Cost: " + activeMonster.energyCost;

            levelText.text = "Level: " + activeMonster.info.level.ToString();
            atkText.text   = "Atk: " + Math.Round(activeMonster.info.Attack.Value, 0).ToString();
            defText.text   = "Def: " + Math.Round(activeMonster.info.Defense.Value, 0).ToString();
            speText.text   = "Speed: " + Math.Round(activeMonster.info.Speed.Value, 0).ToString();
            precText.text  = "Prec: " + Math.Round(activeMonster.info.Precision.Value, 0).ToString();
            //typeText.text = "Type: " + activeMonster.info.type1 + "/" + activeMonster.info.type2;
            evasText.text    = "Evasion: " + Math.Round(activeMonster.info.evasionBase, 0) + "%";
            enGenText.text   = "En Gen: " + Math.Round((activeMonster.info.EnergyGeneration.Value / 60), 2) + " /s";
            enCostText.text  = "Cost: " + activeMonster.info.EnergyCost.Value;
            staminaText.text = "Stamina: " + activeMonster.info.Stamina.Value;



            if (activeMonster.expToLevel.ContainsKey(activeMonster.info.level))
            {
                int toNextLevel    = activeMonster.expToLevel[activeMonster.info.level + 1];
                int totalNextLevel = activeMonster.totalExpForLevel[activeMonster.info.level + 1];
                int nextLevelDiff  = totalNextLevel - activeMonster.info.totalExp;

                expSlider.maxValue = toNextLevel;
                expSlider.value    = toNextLevel - nextLevelDiff;


                toLevelText.text = "EXP Until Level Up: " + nextLevelDiff.ToString();
            }

            //checks the monster's type against the type sprites and changes their images to match the correct type sprite
            if (types.ContainsKey(activeMonster.info.type1))
            {
                type1.GetComponent <Image>().sprite = types[activeMonster.info.type1].typeSprite;
                type1.GetComponent <Image>().color  = Color.white;
                //type1.transform.localScale = new Vector3(3.5f, 1.25f, type1.transform.localScale.z);
                type1.name = activeMonster.info.type1;
            }
            else
            {
                type1.GetComponent <Image>().sprite = null;
                type1.name = "Type1";
            }

            if (types.ContainsKey(activeMonster.info.type2))
            {
                type2.GetComponent <Image>().sprite = types[activeMonster.info.type2].typeSprite;
                type2.GetComponent <Image>().color  = Color.white;
                //type2.transform.localScale = new Vector3(3.5f, 1.25f, type2.transform.localScale.z);
                type2.name = activeMonster.info.type2;
            }
            else
            {
                type2.GetComponent <Image>().sprite = null;
                type2.GetComponent <Image>().color  = Color.clear;
                type2.name = "Type2";
            }

            targetModeDropdown.value = (int)Enum.ToObject(typeof(TargetMode), activeMonster.GetComponent <Tower>().targetMode);
            staminaBar.BarProgress   = activeMonster.GetComponent <Tower>().staminaBar.BarProgress;


            if (activeMonster.GetComponent <Tower>().staminaBar.BarProgress >= 1 && (activeMonster.info.specialAbility.castingAmmo - activeMonster.info.specialAbility.castingCount) > 0)
            {
                activateAbilityBtn.interactable = true;
                activateAbilityBtn.gameObject.GetComponent <GoldFX>().enabled = true;
            }
            else
            {
                activateAbilityBtn.interactable = false;
                activateAbilityBtn.gameObject.GetComponent <GoldFX>().enabled = false;
            }


            //set the status of the find/place monster button
            if (activeMonster.GetComponent <Tower>().mapTileOn != null)
            {
                findMonsterBtn.interactable = true;
                findMonsterBtn.GetComponentInChildren <TMP_Text>().text = "Find Monster";
            }
            else
            {
                findMonsterBtn.GetComponentInChildren <TMP_Text>().text = "Summon Monster";


                if (tileToBePlaced != null)
                {
                    findMonsterBtn.interactable = true;
                }
                else
                {
                    findMonsterBtn.interactable = false;
                }
            }


            abiNameText.text        = activeMonster.info.specialAbility.abilityName;
            abiDescriptionText.text = activeMonster.info.specialAbility.description;
            ammoText.text           = "Ammo: " + (activeMonster.info.specialAbility.castingAmmo - activeMonster.info.specialAbility.castingCount).ToString();
            //if (activeMonster.GetComponent<Tower>().
            //indicator.transform.position = new Vector2(activeMonster.specs.head.transform.position.x, activeMonster.specs.head.transform.position.y + 40);
        }
    }