Example #1
0
    /*public void AddMaxHealth(float hp)
     * {
     *  MaxHealth += hp;
     *  Health += hp;
     * }*/

    public void LoseControl(float control)
    {
        SelfControl -= control;
        if (SelfControl <= 0 && !controlLost)
        {
            // Game Over
            SelfControl = 0;
            HeroUserControl controller = playerObject.GetComponent <HeroUserControl>();
            controller.enabled = false;
            Instantiate(endGamePopup);
            controlLost = true;
            Camera.main.GetComponent <CameraFollow>().enabled = false;
            GameObject.FindGameObjectWithTag("User Interface").SetActive(false);
            Rigidbody2D rb = playerObject.GetComponent <Rigidbody2D>();
            playerObject.GetComponent <HeroCharacter2D>().enabled = false;
            Destroy(rb);
            RunTheFuckAway runAway = GameObject.FindGameObjectWithTag("Player").AddComponent <RunTheFuckAway>();
            runAway.SetDirection(playerObject.transform.localScale.x);
        }
    }
Example #2
0
        /// <summary>
        /// 以折叠形式将所有式神展示到面板上
        /// </summary>
        private void ShowHerosFold(string rarity, int star, string name)
        {
            //清除面板上所有信息
            panel1.Controls.Clear();
            heroShowInfos.Clear();
            //御魂面板上,SP-SSR-SR-R-N顺序,稀有度相同的按照等级,等级相同的按照获得顺序,若两个相同类型的式神经验都是0则可以折叠显示
            HeroShowInfo heroShowInfo = new HeroShowInfo();
            int          x            = 0;
            int          y            = 0;
            int          count        = 0;

            //将式神信息放入list中
            for (int i = 0; i < GlobalData.root.data.heroes.Count; i++)
            {
                if (rarity != string.Empty)
                {
                    if (GlobalData.root.data.heroes[i].rarity != rarity)
                    {
                        continue;
                    }
                }

                if (star != -1)
                {
                    if (GlobalData.root.data.heroes[i].star != star)
                    {
                        continue;
                    }
                }

                if (name != string.Empty)
                {
                    if (!GameConfig.GetHeroName(GlobalData.root.data.heroes[i].hero_id).Contains(name))
                    {
                        continue;
                    }
                }
                heroShowInfo.hero_id = GlobalData.root.data.heroes[i].id;
                heroShowInfo.born    = GlobalData.root.data.heroes[i].born;
                heroShowInfo.exp     = GlobalData.root.data.heroes[i].exp;
                heroShowInfo.id      = GlobalData.root.data.heroes[i].hero_id;
                heroShowInfo.level   = GlobalData.root.data.heroes[i].level;
                heroShowInfo.name    = GameConfig.GetHeroName(GlobalData.root.data.heroes[i].hero_id);
                heroShowInfo.rarity  = GlobalData.root.data.heroes[i].rarity;
                heroShowInfo.star    = GlobalData.root.data.heroes[i].star;
                heroShowInfo.awake   = GlobalData.root.data.heroes[i].awake;
                heroShowInfo.count   = 1;
                heroShowInfos.Add(heroShowInfo);
            }
            //对式神稀有度进行排序
            for (int i = 0; i < heroShowInfos.Count - 1; i++)
            {
                for (int j = i + 1; j < heroShowInfos.Count; j++)
                {
                    if (CompareAsLevel(heroShowInfos[i], heroShowInfos[j]) < 0)
                    {
                        HeroShowInfo temp = heroShowInfos[i];
                        heroShowInfos[i] = heroShowInfos[j];
                        heroShowInfos[j] = temp;
                    }
                }
            }


            for (int i = 0; i < heroShowInfos.Count; i++)
            {
                if (heroShowInfos[i].rarity == "R" || heroShowInfos[i].rarity == "N")
                {
                    continue;
                }
                HeroUserControl heroUserControl = new HeroUserControl(heroShowInfos[i]);
                x = (count % 10) * 126 + 10;
                y = (count - count % 10) / 10 * 159 + 10;
                heroUserControl.Location = new Point(x, y);
                heroUserControl.Tag      = heroShowInfos[i].hero_id;
                panel1.Controls.Add(heroUserControl);

                count++;
            }
        }