Exemple #1
0
 void OnregBtnClick()
 {
     nameStr = UIManager.GetInputStr("nameInput");
     pwdStr  = UIManager.GetInputStr("pwdInput");
     //PlaySE
     MusicManager.PlaySe("click");
     if (nameStr == "" || pwdStr == "")
     {
         GameFuncs.CreateMsg("用户名或密码不能为空!");
         return;
     }
     else
     {
         if (DBFuncs.FindPlayer(nameStr, pwdStr))
         {
             //弹出对话框"用户名已存在!"
             GameFuncs.CreateMsg("用户名已存在!");
         }
         else
         {
             //Register
             DBFuncs.AddPlayer(nameStr, pwdStr);
             GameFuncs.CreateMsg("注册成功!请点击登录进入游戏");
         }
     }
 }
Exemple #2
0
 void OnokSkillBtn(Transform panel)
 {
     MusicManager.PlaySe("click");
     if (BattleGlobals.currentSid != "")
     {
         Skill s = GameFuncs.GetSkill(BattleGlobals.currentSid);
         Hero  h = BattleGlobals.currentObj.GetComponent <Hero>();
         if ((!s.isCp && h.currentMp >= s.cost) || (s.isCp && h.cp >= s.cost))//可消耗
         {
             BattleCamera.SetAnimStop();
             skillPanel.SetActive(false);
             heroPanel.SetActive(false);
             if (!s.isAoe)//单体
             {
                 BattleGlobals.isSelectEnemy = true;
             }
             else
             {
                 BattleCamera.Instance.SetPos(0);
                 BattleGlobals.currentObj.GetComponent <Hero>().Magic(BattleGlobals.currentSid);
             }
             foreach (Transform so in panel.Find("list/grid"))
             {
                 Destroy(so.gameObject);
             }
             BattleGlobals.isMagic = true;
         }
         else//mp(cp)不足
         {
             string msg = (s.isCp ? "cp" : "mp") + "不足!";
             GameFuncs.CreateMsg(msg);
         }
     }
 }
Exemple #3
0
    void OnloginBtnClick()
    {
        nameStr = UIManager.GetInputStr("nameInput");
        pwdStr  = UIManager.GetInputStr("pwdInput");
        //PlaySE
        MusicManager.PlaySe("click");;
        //Formal
        //Globals.isFirst = DBFuncs.FindSingle<int>("Players", "isFirst");
        if (nameStr == "" || pwdStr == "")
        {
            GameFuncs.CreateMsg("用户名或密码不能为空!");
            return;
        }
        else
        {
            if (DBFuncs.FindPlayer(nameStr, pwdStr))
            {
                //Enter Loading->Chat/Main
                if (Globals.player.isFirst)
                {
                    Globals.player.isFirst = false;
                    //Test
                    Globals.currentDialog = "test";

                    Globals.nextScene = "Main";
                    GameFuncs.GoToSceneAsync("Chat");
                }
                else
                {
                    //Load Globals.items&Globals.heroes
                    GameFuncs.GoToSceneAsync("Main");
                }
            }
            else
            {
                //弹出对话框"用户名或密码错误!"
                GameFuncs.CreateMsg("用户名或密码错误!");
            }
        }
    }
Exemple #4
0
    void OngoBtnClick()
    {
        bool canGo = false;

        foreach (Toggle t in selectToggles)
        {
            if (IsToggleHasHero(t))
            {
                canGo = true;
                break;
            }
        }
        if (canGo)
        {
            BattleGlobals.selectHeroes = new List <string>();
            foreach (Toggle t in selectToggles)
            {
                if (IsToggleHasHero(t))
                {
                    BattleGlobals.selectHeroes.Add(t.transform.Find("Image").GetComponent <Image>().sprite.name);
                }
            }
            if (Globals.player.energy >= int.Parse(BattleGlobals.placeName) * 10)
            {
                Globals.player.energy -= int.Parse(BattleGlobals.placeName) * 10;
                UIManager.ChangeText("energyText", Globals.player.energy.ToString() + "/" + Globals.player.maxEnergy);
                UIManager.ChangeSlider("energySlider", (float)Globals.player.energy / Globals.player.maxEnergy);
                StartCoroutine(Wait(1));
            }
            else
            {
                GameFuncs.CreateMsg("体力不足!");
            }
        }
        else//弹出对话框“所选英雄不能为空”
        {
            GameFuncs.CreateMsg("所选英雄不能为空!");
        }
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        //Load Hero
        string id = HeroGlobals.currentid;

        for (int i = 0; i < Globals.heroes.Count; i++)
        {
            if (Globals.heroes[i].id == id)
            {
                currentHero = Globals.heroes[i];
            }
        }
        Transform  point = GameObject.Find("point").transform;
        GameObject hero  = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/" + id), point);

        hero.AddComponent <OnHeroInfoModel>();
        hero.GetComponent <Rigidbody>().useGravity = false;
        //Load Toggle
        Toggle[] toggles = GameObject.FindObjectsOfType <Toggle>();
        foreach (Toggle t in toggles)
        {
            t.onValueChanged.AddListener((bool isOn) => { OninfoToggleClick(t, isOn); });
        }
        foreach (Toggle t in toggles)
        {
            string infoName        = t.gameObject.name.Replace("Toggle", "");
            string panelParentName = infoName + "PanelParent";
            panel = GameFuncs.FindHiden(panelParentName).transform;
            //Load All
            if (infoName == "all")
            {
                ShowAll(panel);
                //Bind Btns
                Button upBtn    = UIManager.GetButton("upBtn");
                Button breakBtn = UIManager.GetButton("breakBtn");
                upBtn.onClick.AddListener(() =>
                {
                    MusicManager.PlaySe("click");
                    if (Globals.player.gold >= 100)
                    {
                        if (HeroGlobals.upItemCount > 0)
                        {
                            //values
                            currentHero.exps[1] += 10;
                            HeroGlobals.upItemCount--;
                            Globals.player.gold -= 100;
                            for (int i = 0; i < Globals.items.Count; i++)
                            {
                                if (Globals.items[i].itemId == "001")//合成剂
                                {
                                    Globals.items[i].count = HeroGlobals.upItemCount;
                                }
                            }
                            if (currentHero.exps[1] >= currentHero.exps[2])//lv up
                            {
                                currentHero.exps[0]++;
                                for (int i = 0; i < currentHero.infos.Length; i++)
                                {
                                    currentHero.infos[i] += (currentHero.exps[0] - 1) * 1;
                                }
                                currentHero.exps[1] -= currentHero.exps[2];
                                currentHero.exps[2] += (currentHero.exps[0] - 1) * 100;
                            }
                            ShowAll(panel);
                        }
                        else
                        {
                            GameFuncs.CreateMsg("合成剂不足!");
                        }
                    }
                    else
                    {
                        GameFuncs.CreateMsg("金币不足!");
                    }
                });
                breakBtn.onClick.AddListener(() =>
                {
                    MusicManager.PlaySe("click");
                    if (Globals.player.gold >= 1000)
                    {
                        if (HeroGlobals.breakItemCount > 0)
                        {
                            //values
                            currentHero.exps[0]++;
                            for (int i = 0; i < currentHero.infos.Length; i++)
                            {
                                currentHero.infos[i] += (currentHero.exps[0] - 1) * 1;
                            }
                            HeroGlobals.breakItemCount--;
                            for (int i = 0; i < Globals.items.Count; i++)
                            {
                                if (Globals.items[i].itemId == "003")//突破晶石
                                {
                                    Globals.items[i].count = HeroGlobals.breakItemCount;
                                }
                            }
                            Globals.player.gold -= 1000;
                            currentHero.exps[1]  = 0;
                            currentHero.exps[2] += (currentHero.exps[0] - 1) * 100;
                            //add skill
                            foreach (Skill s in Globals.skillList)
                            {
                                if (!currentHero.skills.Contains(s))
                                {
                                    if (!s.isCp && s.ele == currentHero.ele && s.lv <= currentHero.exps[0])    //学会
                                    {
                                        currentHero.skills.Add(s);
                                        currentHero.skills.Sort();
                                        GameFuncs.CreateMsg("学会[" + s.sname + "]技能!");
                                        CreateSkill(s);
                                    }
                                }
                            }
                            ShowAll(panel);
                        }
                        else
                        {
                            GameFuncs.CreateMsg("突破晶石不足!");
                        }
                    }
                    else
                    {
                        GameFuncs.CreateMsg("金币不足!");
                    }
                });
            }
            //Load Skill
            else if (infoName == "skill")
            {
                skillGrid = panel.Find("list/grid");
                infoText  = panel.Find("infoText").GetComponent <Text>();
                List <Skill> skills = currentHero.skills;
                skills.Sort();
                //skills.Add(currentHero.superSkill);
                for (int i = 0; i < skills.Count; i++)
                {
                    Skill s = skills[i];
                    CreateSkill(s);
                }
            }
            //Load Dresses
            else if (infoName == "dress")
            {
                Image  image    = panel.Find("Image").GetComponent <Image>();
                Text   text     = panel.Find("Text").GetComponent <Text>();
                Button imageBtn = panel.Find("Image").GetComponent <Button>();
                Button nextBtn  = panel.Find("nextBtn").GetComponent <Button>();
                nextBtn.interactable = dressIndex < currentHero.dresses.Count - 1 ? true : false;
                Button preBtn = panel.Find("preBtn").GetComponent <Button>();
                preBtn.interactable = dressIndex > 0 ? true : false;
                nextBtn.onClick.AddListener(() => {
                    MusicManager.PlaySe("click");
                    if (dressIndex < currentHero.dresses.Count - 1)
                    {
                        dressIndex++;
                    }
                });
                nextBtn.onClick.AddListener(() => {
                    MusicManager.PlaySe("click");
                    if (dressIndex > 0)
                    {
                        dressIndex--;
                    }
                });
                image.sprite = Resources.Load <Sprite>("Character/Portrait/" + currentHero.dresses[0].imagePath);
                text.text    = currentHero.dresses[0].dname;
                imageBtn.onClick.AddListener(() => { OndressBtnClick("Prefabs/" + currentHero.dresses[0].modelPath); });
            }
        }
        Button setHeadBtn = UIManager.GetButton("setHeadBtn");//弹出对话框

        setHeadBtn.onClick.AddListener(() => {
            MusicManager.PlaySe("click");
            GameFuncs.CreateMsg("设为首席成功!");
            Globals.player.characterId = currentHero.id;
        });
        Button backBtn = UIManager.GetButton("backBtn");

        backBtn.onClick.AddListener(() => { GameFuncs.GoToScene("Heroes"); });
    }