public static void CreateCharacter(Transform point, string modelPath) { GameObject selectCharacter = GameFuncs.FindHiden("selectCharacterParent"); //Instantiate Model GameObject pre = (GameObject)GameFuncs.GetResource(modelPath); GameObject obj = GameObject.Instantiate(pre); obj.transform.position = point.transform.position; //MusicManager.PlaySe("click"); if (point.name == "point1") { obj.transform.SetParent(point.transform); } else if (point.name == "point2") { obj.transform.Rotate(Vector3.up * 90); obj.transform.SetParent(point.transform); } obj.AddComponent <OnModel>(); //Destroy selectCharacter Transform grid = selectCharacter.transform.Find("grid"); foreach (Transform child in grid) { Destroy(child.gameObject); } //Active False selectCharacter.SetActive(false); }
void OneleToggleClick(Toggle toggle, bool isOn) { MusicManager.PlaySe("click"); string eleName = toggle.gameObject.name.Replace("Toggle", ""); string panelParentName = eleName + "PanelParent"; GameObject panel = GameFuncs.FindHiden(panelParentName); panel.SetActive(isOn); }
void OnstoryBtnClick() { MusicManager.PlaySe("click"); RoomGlobals.menu.SetActive(false); GameObject story = GameFuncs.FindHiden("storyParent"); story.SetActive(true); story.AddComponent <Story>(); }
void OngiftBtnClick() { MusicManager.PlaySe("click"); RoomGlobals.menu.SetActive(false); GameObject gifts = GameFuncs.FindHiden("giftsParent"); gifts.SetActive(true); gifts.AddComponent <Gift>(); }
// Use this for initialization void Start() { canvas = transform.Find("canvas").gameObject; canvas.SetActive(false); winPanel = GameFuncs.FindHiden("winPanelParent"); losePanel = GameFuncs.FindHiden("losePanelParent"); tip = transform.Find("tipText").gameObject; getsBtn = transform.Find("getsBtn").gameObject; gets = GameFuncs.FindHiden("GetsParent"); StartCoroutine(IShowUI()); }
// Use this for initialization void Start() { summonGetPre = (GameObject)GameFuncs.GetResource("Prefabs/summonGet"); gets = GameFuncs.FindHiden("GetsParent"); oneBtn = UIManager.GetButton("oneBtn"); tenBtn = UIManager.GetButton("tenBtn"); oneBtn.onClick.AddListener(OnoneBtnClick); tenBtn.onClick.AddListener(OntenBtnClick); UIManager.ChangeText("goldText", Globals.player.gold.ToString()); UIManager.ChangeText("diaText", Globals.player.dia.ToString()); }
IEnumerator IShowUI() { yield return(new WaitForSeconds(6)); canvas.SetActive(true); UIManager.ChangeText("waveText", "Battle " + BattleGlobals.currentWave.ToString() + "/" + BattleGlobals.waves.ToString()); //Set set = GameFuncs.FindHiden("setParent"); heroPanel = GameFuncs.FindHiden("heroPanelParent"); skillPanel = GameFuncs.FindHiden("skillPanelParent"); Button setBtn = UIManager.GetButton("setBtn"); setBtn.onClick.AddListener(OnsetBtnClick); //create state(image,hp,mp,cp) for (int i = 0; i < BattleGlobals.selectHeroes.Count; i++) { string hid = BattleGlobals.selectHeroes[i]; string id = "h" + i; GameObject heroObj = BattleFuncs.FindObj(id); Hero hero = heroObj.GetComponent <Hero>(); Transform states = GameObject.Find("States").transform; GameObject state = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/state")); state.transform.SetParent(states); state.transform.Find("Image").GetComponent <Image>().sprite = Resources.Load <Sprite>("Character/Image/" + hid + "_001"); Slider hpSlider = state.transform.Find("hpSlider").GetComponent <Slider>(); Slider mpSlider = state.transform.Find("mpSlider").GetComponent <Slider>(); Slider cpSlider = state.transform.Find("cpSlider").GetComponent <Slider>(); hpSlider.value = (float)hero.currentHp / hero.infos[0]; mpSlider.value = (float)hero.currentMp / hero.infos[1]; cpSlider.value = (float)hero.cp / 100; Text hpText = state.transform.Find("hpText").GetComponent <Text>(); Text mpText = state.transform.Find("mpText").GetComponent <Text>(); Text cpText = state.transform.Find("cpText").GetComponent <Text>(); hpText.text = hero.currentHp.ToString() + "/" + hero.infos[0].ToString(); mpText.text = hero.currentMp.ToString() + "/" + hero.infos[1].ToString(); cpText.text = hero.cp.ToString() + "/100"; hero.hpSlider = hpSlider; hero.mpSlider = mpSlider; hero.cpSlider = cpSlider; hero.hpText = hpText; hero.mpText = mpText; hero.cpText = cpText; } //create heads bar = canvas.transform.Find("Bar"); start = bar.Find("start"); end = bar.Find("end"); CreateHeads(); StartCoroutine(IStartBattle()); }
IEnumerator IShowActs() { yield return(new WaitForSeconds(1f)); //Acts acts = GameFuncs.FindHiden("ActsParent"); acts.SetActive(true); GameObject menu = acts.transform.Find("menu").gameObject; RoomGlobals.menu = menu; RoomGlobals.menu.SetActive(true); BindActsBtns(); RoomFuncs.ChangeLove(); }
void Start() { Globals.lastScene = "Room"; RoomFuncs.LoadStoryDic(); if (GameObject.Find("point1Btn")) { Button point1Btn = UIManager.GetButton("point1Btn"); RoomGlobals.point1Btn = point1Btn.gameObject; point1Btn.onClick.AddListener(() => { OnpointBtn(point1Btn.gameObject.name); }); } if (GameObject.Find("point1Btn")) { Button point2Btn = UIManager.GetButton("point2Btn"); RoomGlobals.point2Btn = point2Btn.gameObject; point2Btn.onClick.AddListener(() => { OnpointBtn(point2Btn.gameObject.name); }); } RoomGlobals.backBtn = GameObject.Find("backBtn"); GameObject point1 = GameObject.Find("point1"); RoomGlobals.point1 = point1; GameObject point2 = GameObject.Find("point2"); RoomGlobals.point2 = point2; selectCharacter = GameFuncs.FindHiden("selectCharacterParent"); //Load RoomImfos if (RoomGlobals.roomInfos.Count > 0) { foreach (var info in RoomGlobals.roomInfos) { Transform point = GameObject.Find(info.Key).transform; RoomFuncs.CreateCharacter(point, info.Value); string id = info.Value.Replace("Prefabs/", ""); if (!RoomGlobals.loveDic.ContainsKey(id)) { Hero h = GameFuncs.GetHero(id); RoomGlobals.loveDic.Add(id, h.li); } } } //如果有人则隐藏添加图标 if (point1.transform.childCount > 0) { RoomGlobals.point1Btn.SetActive(false); } if (point2.transform.childCount > 0) { RoomGlobals.point2Btn.SetActive(false); } MusicManager.PlayBgm("room"); }
// Use this for initialization void Start() { BattleFuncs.ResetBattle(); BattleGlobals.monsters = JsonFuncs.LoadEnemys(BattleGlobals.placeName); MusicManager.PlayBgm("battle"); MusicManager.SetVolume(); //Load Infos string place = BattleGlobals.placeName; BattleGlobals.currentWave = 1; currentMonsters = BattleGlobals.monsters[BattleGlobals.currentWave - 1]; RenderSettings.skybox = (Material)GameFuncs.GetResource("SkyBox/" + place); GameFuncs.FindHiden(place + "Parent").SetActive(true); //Load Transforms BattleGlobals.hpoints = GameObject.Find("hpoints").transform; BattleGlobals.mpoints = GameObject.Find("mpoints").transform; foreach (Transform t in BattleGlobals.hpoints) { hpoints.Add(t); } foreach (Transform t in BattleGlobals.mpoints) { if (!t.gameObject.name.Contains("one")) { mpoints.Add(t); } else { mone = t; } } //Create Hero for (int i = 0; i < BattleGlobals.selectHeroes.Count; i++) { //create hero GameObject hero = Instantiate((GameObject)GameFuncs.GetResource ("Prefabs/" + BattleGlobals.selectHeroes[i]), hpoints[i]); Hero h = hero.AddComponent <Hero>(); GameFuncs.CopyHero(h, BattleGlobals.selectHeroes[i]); h.anim = hero.GetComponent <Animator>(); h.currentMp = h.infos[1]; h.cp = 100; hero.name = "h" + i; h.battleId = hero.name; BattleGlobals.liveHeroes.Add(hero.name); } CreateCurrentEnemy(); }
private void Start() { backBtn = RoomGlobals.backBtn; point1Btn = RoomGlobals.point1Btn; point2Btn = RoomGlobals.point2Btn; selectCharacter = GameFuncs.FindHiden("selectCharacterParent"); anim = Camera.main.GetComponent <Animation>(); parent = gameObject.transform.parent; if (GameObject.Find("Acts")) { acts = GameObject.Find("Acts"); if (acts.activeInHierarchy) { BindActsBtns(); GetComponent <CapsuleCollider>().enabled = false; } } }
void ShowAll(Transform panel) { panel = GameFuncs.FindHiden("allPanelParent").transform; Text lvText = panel.Find("lvImage/lvText").GetComponent <Text>(); Slider expSlider = panel.Find("expSlider").GetComponent <Slider>(); lvText.text = currentHero.exps[0].ToString(); expSlider.value = (float)currentHero.exps[1] / currentHero.exps[2]; panel.Find("alls/hp").GetComponent <Text>().text = currentHero.infos[0].ToString(); panel.Find("alls/mp").GetComponent <Text>().text = currentHero.infos[1].ToString(); panel.Find("alls/atk").GetComponent <Text>().text = currentHero.infos[2].ToString(); panel.Find("alls/def").GetComponent <Text>().text = currentHero.infos[3].ToString(); panel.Find("alls/ats").GetComponent <Text>().text = currentHero.infos[4].ToString(); panel.Find("alls/spd").GetComponent <Text>().text = currentHero.infos[5].ToString(); //ui UIManager.ChangeText("upItemText", HeroGlobals.upItemCount.ToString()); UIManager.ChangeText("breakItemText", HeroGlobals.breakItemCount.ToString()); UIManager.ChangeText("goldText", Globals.player.gold.ToString()); }
// Use this for initialization void Start() { heroPre = (GameObject)GameFuncs.GetResource("Prefabs/hero"); Transform selectGrid = GameObject.Find("selectGrid").transform; Transform heroes = GameObject.Find("heroes").transform; //Load selectToggles selectToggles = selectGrid.GetComponentsInChildren <Toggle>(false); foreach (Toggle t in selectToggles) { t.onValueChanged.AddListener((bool isOn) => { OnselectToggleClick(t, isOn); }); } currentToggle = selectToggles[0]; //Load eleToggles Toggle[] eleToggles = heroes.GetComponentsInChildren <Toggle>(false); foreach (Toggle t in eleToggles) { t.onValueChanged.AddListener((bool isOn) => { OneleToggleClick(t, isOn); }); } //Show All Heroes foreach (Toggle t in eleToggles) { string eleName = t.gameObject.name.Replace("Toggle", ""); string panelParentName = eleName + "PanelParent"; GameObject panel = GameFuncs.FindHiden(panelParentName); Transform grid = panel.transform.Find(eleName + "Grid"); ShowHeroes(eleName, grid); grids.Add(grid); } UIManager.ChangeText("energyText", Globals.player.energy.ToString() + "/" + Globals.player.maxEnergy); UIManager.ChangeSlider("energySlider", (float)Globals.player.energy / Globals.player.maxEnergy); Button goBtn = UIManager.GetButton("goBtn"); goBtn.onClick.AddListener(OngoBtnClick); Button backBtn = UIManager.GetButton("backBtn"); backBtn.onClick.AddListener(() => { GameFuncs.GoToScene("SelectBattleMap"); }); }
void Start() { heroPre = (GameObject)GameFuncs.GetResource("Prefabs/hero"); //Load eleToggles Toggle[] toggles = GameObject.FindObjectsOfType <Toggle>(); foreach (Toggle t in toggles) { t.onValueChanged.AddListener((bool isOn) => { OneleToggleClick(t, isOn); }); } //Items int upItemCount = 0; int breakItemCount = 0; for (int i = 0; i < Globals.items.Count; i++) { if (Globals.items[i].itemId == "001")//合成剂 { upItemCount = Globals.items[i].count; } if (Globals.items[i].itemId == "003")//突破晶石 { breakItemCount = Globals.items[i].count; } } UIManager.ChangeText("upItemText", upItemCount.ToString()); UIManager.ChangeText("breakItemText", breakItemCount.ToString()); UIManager.ChangeText("goldText", Globals.player.gold.ToString()); HeroGlobals.upItemCount = upItemCount; HeroGlobals.breakItemCount = breakItemCount; //Show All Heroes foreach (Toggle t in toggles) { string eleName = t.gameObject.name.Replace("Toggle", ""); string panelParentName = eleName + "PanelParent"; GameObject panel = GameFuncs.FindHiden(panelParentName); Transform grid = panel.transform.Find(eleName + "Grid"); ShowHeroes(eleName, grid); } }
// Use this for initialization void Start() { options = GameObject.Find("options"); log = GameFuncs.FindHiden("logParent"); set = GameFuncs.FindHiden("setParent"); //绑定Buttons Button setBtn = UIManager.GetButton("setBtn"); setBtn.onClick.AddListener(OnsetBtnClick); Button skipBtn = UIManager.GetButton("skipBtn"); skipBtn.onClick.AddListener(OnskipBtnClick); Button logBtn = UIManager.GetButton("logBtn"); logBtn.onClick.AddListener(OnlogBtnClick); //更换背景 UIManager.ChangeImage("BG", "Background/" + Globals.currentBg); //显示首句 ChatFuncs.Instance.ShowDialog(0); //PlayBGM MusicManager.PlayBgm("normal"); }
// Use this for initialization void Start() { //Load Head(Image,name,energy,exp) string headImagePath = "HeadImage/" + Globals.player.headImagePath; string name = Globals.player.nickname; int energy = Globals.player.energy; int maxEnergy = Globals.player.maxEnergy; int exp = Globals.player.exp; int maxExp = Globals.player.maxExp; characterId = Globals.player.characterId; //Find UIs //Head headMenu = GameFuncs.FindHiden("headMenuParent"); changeName = GameFuncs.FindHiden("changeNameParent"); changeSex = GameFuncs.FindHiden("changeSexParent"); changeHeadImage = GameFuncs.FindHiden("changeHeadImageParent"); Image headImage = UIManager.GetImage("headImage"); Text energyText = UIManager.GetText("energyText"); Text expText = UIManager.GetText("expText"); Slider energySlider = UIManager.GetSlider("energySlider"); Slider expSlider = UIManager.GetSlider("expSlider"); Text nameText = UIManager.GetText("nameText"); Button headImageBtn = UIManager.GetButton("headImageBtn"); //Character Button character = UIManager.GetButton("character"); //Items Text goldText = UIManager.GetText("goldText"); Text diaText = UIManager.GetText("diaText"); //Menus Button battleBtn = UIManager.GetButton("battleBtn"); Button heroesBtn = UIManager.GetButton("heroesBtn"); Button roomBtn = UIManager.GetButton("roomBtn"); Button summonBtn = UIManager.GetButton("summonBtn"); Button packBtn = UIManager.GetButton("packBtn"); Button settingBtn = UIManager.GetButton("settingBtn"); //ChatWindow chatWindow = GameFuncs.FindHiden("chatWindowParent"); //UIs'value //Head UIManager.ChangeImage("headImage", headImagePath); energyText.text = energy.ToString() + "/" + maxEnergy; expText.text = exp.ToString() + "/" + maxExp; energySlider.value = (float)energy / maxEnergy; expSlider.value = (float)exp / maxExp; nameText.text = name; //Items goldText.text = Globals.player.gold.ToString(); diaText.text = Globals.player.dia.ToString(); //Load Hero(Image,Dialog) string characterPath = "Character/Image/" + characterId + "_001"; UIManager.ChangeImage("character", characterPath); string dialogPath = characterId + "_click"; ChatFuncs.LoadDialogs(dialogPath); //Bind Buttons headImageBtn.onClick.AddListener(OnheadImageBtnClick); battleBtn.onClick.AddListener(OnbattleBtnClick); heroesBtn.onClick.AddListener(OnheroesBtnClick); roomBtn.onClick.AddListener(OnroomBtnClick); summonBtn.onClick.AddListener(OnsummonBtnClick); packBtn.onClick.AddListener(OnpackBtnClick); settingBtn.onClick.AddListener(OnsettingBtnClick); character.onClick.AddListener(OncharacterBtnClick); //Play BGM MusicManager.SetVolume(); MusicManager.PlayBgm("main"); }
// 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"); }); }