Exemple #1
0
    public static void ShowLosePanel()
    {
        MusicManager.StopBgm();
        losePanel.SetActive(true);
        tip.SetActive(true);
        Transform lose = losePanel.transform;

        losePanel.GetComponent <Button>().onClick.AddListener(() =>
                                                              { GameFuncs.GoToSceneAsync("Main"); });
        BattleGlobals.selectHeroes.Clear();
    }
Exemple #2
0
 // 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());
 }
    private void MouseInputs()
    {
        if (Input.GetMouseButtonDown(0))
        {
            foreach (SpellSlot slot in Stats.SpellSlots)
            {
                if (slot.OnPressed)
                {
                    if (Stats.Resource.Curr < slot.Ability.Cost)
                    {
                        GameFuncs.ResetSpellSlot(slot, IndicatorSystem);
                        return;
                    }

                    //if (IndicatorSystem.CheckDistance() == false)
                    //{
                    //    GameFuncs.ResetSpellSlot(slot, IndicatorSystem);
                    //    return;
                    //}

                    Stats.Resource.Curr -= slot.Ability.Cost;

                    slot.CastSpell(tag, IndicatorSystem.SpawnLocation.transform, transform);
                    GameFuncs.ResetSpellSlot(slot, IndicatorSystem);
                    break;
                }
            }
        }

        else if (Input.GetMouseButtonDown(1))
        {
            foreach (SpellSlot slot in Stats.SpellSlots)
            {
                if (slot.OnPressed)
                {
                    GameFuncs.ResetSpellSlot(slot, IndicatorSystem);
                    break;
                }
            }

            if (IndicatorSystem.UpdateAutoTarget( ) && UpdateAutoAttack())
            {
                //ATTACK THE TARGET
                CastAutoAttack(tag, IndicatorSystem.AutoTarget.transform, transform, IndicatorSystem);
                CurrentAttack = 0;
            }
            else
            {
                Movement();
            }
        }
    }
Exemple #4
0
    // 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());
    }
Exemple #5
0
    void OndressBtnClick(string modelPath)
    {
        MusicManager.PlaySe("click");
        Transform point = GameObject.Find("point").transform;

        if (point.childCount > 0)
        {
            Destroy(point.GetChild(0).gameObject);
        }
        GameObject hero = Instantiate((GameObject)GameFuncs.GetResource(modelPath), point);

        hero.AddComponent <OnHeroInfoModel>();
    }
Exemple #6
0
    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());
    }
Exemple #7
0
 void OnchangeHeadBtnClick()
 {
     if (!changeHeadImage.activeInHierarchy)
     {
         changeHeadImage.SetActive(true);
         headImageGrid = changeHeadImage.transform.Find("headImages/headImageGrid");
         //create headImage
         string path = "0";
         foreach (var item in Resources.LoadAll <Sprite>("HeadImage"))
         {
             GameObject headImage = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/HeadImage"));
             headImage.transform.SetParent(headImageGrid);
             headImage.transform.Find("Image").GetComponent <Image>().sprite = item;
             Toggle t = headImage.GetComponent <Toggle>();
             t.onValueChanged.AddListener((bool isOn) =>
             {
                 if (t.isOn)
                 {
                     path = headImage.transform.Find("Image").GetComponent <Image>().sprite.name;
                 }
             });
             t.group = headImageGrid.GetComponent <ToggleGroup>();
             if (Globals.player.headImagePath == item.name)
             {
                 t.isOn = true;
             }
         }
         UIManager.GetButton("okHeadImageBtn").onClick.AddListener(() =>
         {
             Globals.player.headImagePath = path;
             UIManager.ChangeImage("headImage", "HeadImage/" + path);
             foreach (Transform hi in headImageGrid)
             {
                 Destroy(hi.gameObject);
             }
             changeHeadImage.SetActive(false);
             if (changeName.activeInHierarchy)
             {
                 changeName.SetActive(false);
             }
             if (changeSex.activeInHierarchy)
             {
                 changeSex.SetActive(false);
             }
             if (headMenu.activeInHierarchy)
             {
                 headMenu.SetActive(false);
             }
         });
     }
 }
Exemple #8
0
    //timer to auto slide
    // Use this for initialization
    void Start()
    {
        switch (SceneManager.GetActiveScene().name)
        {
        case "Main":
            num         = 4;
            boardImages = Resources.LoadAll <Sprite>("Background");
            boardTexts  = new string[] { "Battle", "Heroes", "Room", "Summon" };
            break;

        case "Summon":
            num         = 3;
            boardImages = Resources.LoadAll <Sprite>("Summon");
            boardTexts  = new string[num];
            break;

        default:
            break;
        }
        boardBtns    = transform.Find("boardBtns");
        sr           = GetComponent <ScrollRect>();
        boardToggles = transform.Find("boardToggles");
        width        = boardBtns.GetComponent <RectTransform>().sizeDelta.x;
        height       = boardBtns.GetComponent <RectTransform>().sizeDelta.y;
        posX         = width / 2;
        boardBtns.GetComponent <RectTransform>().anchoredPosition = new Vector2(posX * (num - 1), 0);
        boardBtns.GetComponent <RectTransform>().sizeDelta        = new Vector2(width * num, boardBtns.GetComponent <RectTransform>().rect.height);
        //instantiate btns and toggles
        for (int i = 0; i < num; i++)
        {
            //btns
            GameObject boardBtn = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/boardBtn"));
            boardBtn.GetComponent <RectTransform>().sizeDelta = new Vector2(width, height);
            boardBtn.transform.SetParent(boardBtns);
            boardBtn.GetComponent <Image>().sprite        = boardImages[i];
            boardBtn.GetComponentInChildren <Text>().text = boardTexts[i];
            boardBtn.GetComponent <Button>().onClick.AddListener(() => { OnboardBtnClick(boardBtn.GetComponentInChildren <Text>().text); });
            //toggles
            GameObject boardToggle = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/boardToggle"));
            boardToggle.transform.SetParent(boardToggles);
            Toggle bt = boardToggle.GetComponent <Toggle>();
            bt.group = boardToggles.GetComponent <ToggleGroup>();
            if (i == 0)
            {
                bt.isOn = true;
            }
            bt.onValueChanged.AddListener((bool isOn) => { OnboardToggleClick(isOn, bt); });
            toggles[i] = bt;
        }
    }
Exemple #9
0
    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();
    }
Exemple #10
0
    public static void LoadDialogs(string path)
    {
        Globals.dialogs = new List <Dialog>();
        Globals.dialogs.Clear();
        string context = GameFuncs.GetResource("Dialogs/" + path).ToString();

        string[] dialogs = context.Split('#');
        for (int i = 0; i < dialogs.Length; i++)
        {
            string d      = dialogs[i];
            Dialog dialog = new Dialog(d);
            Globals.dialogs.Add(dialog);
        }
    }
Exemple #11
0
    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");
    }
Exemple #12
0
    // 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();
    }
Exemple #13
0
    void OnboardBtnClick(string boardStr)
    {
        switch (SceneManager.GetActiveScene().name)
        {
        case "Main":
            GameFuncs.GoToSceneAsync(boardStr);
            break;

        case "Summon":
            break;

        default:
            break;
        }
    }
Exemple #14
0
 void OnplaceBtnClick(string index)
 {
     MusicManager.PlaySe("click");
     //Change Love
     RoomGlobals.loveDic[RoomGlobals.currentId].love += int.Parse(index) * 10;
     if (RoomGlobals.loveDic[RoomGlobals.currentId].love >= RoomGlobals.loveDic[RoomGlobals.currentId].maxLove)
     {
         RoomGlobals.loveDic[RoomGlobals.currentId].lv++;
         RoomGlobals.loveDic[RoomGlobals.currentId].love -= RoomGlobals.loveDic[RoomGlobals.currentId].maxLove;
     }
     //Load Dialogs
     Globals.currentDialog = RoomGlobals.currentId + "_date" + index;
     //Globals.lastScene = "Room";
     GameFuncs.GoToScene("Chat");
 }
Exemple #15
0
    public virtual void Magic(string sid, Entity other = null)
    {
        Skill      s      = GameFuncs.GetSkill(sid);
        Hero       h      = BattleGlobals.currentObj.GetComponent <Hero>();
        GameObject effect = Instantiate((GameObject)GameFuncs.GetResource("Effect/" + sid));

        Destroy(effect, 2);
        BattleCamera.Shake();
        int   cost  = s.isCp ? s.cost : s.cost / 5;
        float ats   = s.isCp ? h.infos[4] : (h.infos[2] + h.infos[4]) / 2;
        float value = cost * ats;

        if (s.isAoe)
        {
            if (BattleGlobals.currentObj.tag == "Hero")
            {
                effect.transform.position = Battle.mone.position;
                List <string> temp = new List <string>();
                foreach (string lm in BattleGlobals.liveMonsters)
                {
                    temp.Add(lm);
                }
                for (int i = 0; i < temp.Count; i++)
                {
                    string es = temp[i];
                    Enemy  en = BattleFuncs.FindObj(es).GetComponent <Enemy>();
                    en.GetHurt(value, GetRestrict(en, ref value));
                }
            }
            else if (BattleGlobals.currentObj.tag == "Enemy")
            {
                List <string> temp = BattleGlobals.liveHeroes;
                for (int i = 0; i < temp.Count; i++)
                {
                    string hs = temp[i];
                    Hero   he = BattleFuncs.FindObj(hs).GetComponent <Hero>();
                    he.GetHurt(value, GetRestrict(he, ref value));
                }
            }
        }
        else
        {
            effect.transform.position = other.gameObject.transform.position;
            other.GetHurt(value, GetRestrict(other, ref value));
        }
        BattleGlobals.currentSid = "";
        Invoke("SetTurnOver", 2);
    }
Exemple #16
0
    public void UpdateIndicator()
    {
        if (CurrentIndicator == null)
        {
            return;
        }

        if (CurrentSpell.Ability.Effect == GameConsts.EFFECT.PROJECTILE)
        {
            CurrentIndicator.transform.rotation = Quaternion.Slerp(CurrentIndicator.transform.rotation, GameFuncs.RotateTowardsMouse(CurrentIndicator.transform), GameConsts.ROTATE_SPEED * Time.deltaTime);
        }
        else
        {
            CurrentIndicator.transform.position = GameFuncs.MoveTowardsMouse(CurrentIndicator.transform);
        }
    }
Exemple #17
0
    /// <summary>
    /// 初始化Globals.heroList
    /// </summary>
    public static void InitHeroList()
    {
        SqlDataReader dr = DBHelper.Select("select * from HeroList");

        while (dr.Read())
        {
            int[] tempinfos = new int[6] {
                (int)dr["hp"], (int)dr["mp"], (int)dr["atk"], (int)dr["def"], (int)dr["ats"], (int)dr["spd"],
            };
            Skill ss = GameFuncs.GetSkill((string)dr["superSkill"]);
            Hero  h  = new Hero((string)dr["id"], (string)dr["ename"], (string)dr["imagePath"], (string)dr["ele"],
                                tempinfos, (int)dr["isNearAttack"] == 1 ? true : false, ss);
            Globals.heroList.Add(h);
        }
        DBHelper.Closedr(dr);
    }
Exemple #18
0
    public static GameObject CreateHead(string id, bool isHero, int index)
    {
        Sprite     sprite = Resources.Load <Sprite>("Character/Portrait/" + id);
        GameObject head   = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/head"), bar);

        head.transform.Find("Image").GetComponent <Image>().sprite = sprite;
        if (isHero)
        {
            head.name = "h" + index;
        }
        else
        {
            head.name = "m" + index;
        }
        return(head);
    }
Exemple #19
0
 void Oncharacter_roomSelectBtnClick(Transform point, string modelPath, string btnName)
 {
     MusicManager.PlaySe("click");
     RoomFuncs.CreateCharacter(point, modelPath);
     RoomGlobals.currentId = modelPath.Replace("Prefabs/", "");
     if (!RoomGlobals.roomInfos.ContainsKey(point.gameObject.name))
     {
         RoomGlobals.roomInfos.Add(point.gameObject.name, modelPath);
     }
     if (!RoomGlobals.loveDic.ContainsKey(RoomGlobals.currentId))
     {
         Hero h = GameFuncs.GetHero(RoomGlobals.currentId);
         RoomGlobals.loveDic.Add(RoomGlobals.currentId, h.li);
     }
     GameObject.Find(btnName).SetActive(false);
 }
Exemple #20
0
    void OnskillBtnClick()
    {
        MusicManager.PlaySe("click");
        //show skill panel
        skillPanel.SetActive(true);
        Transform panel         = skillPanel.transform;
        Button    closeSkillBtn = UIManager.GetButton("closeSkillBtn");

        closeSkillBtn.onClick.AddListener(() => { OncloseSkillBtn(panel); });
        Button okSkillBtn = UIManager.GetButton("okSkillBtn");

        okSkillBtn.onClick.AddListener(() => { OnokSkillBtn(panel); });
        //create skill list
        Hero         currentHero = BattleGlobals.currentObj.GetComponent <Hero>();
        List <Skill> skills      = currentHero.skills;

        for (int i = 0; i < skills.Count; i++)
        {
            Skill s = skills[i];
            if (s.ele == currentHero.ele)
            {
                Transform  grid     = panel.Find("list/grid");
                Text       infoText = panel.Find("infoText").GetComponent <Text>();
                GameObject skill    = Instantiate((GameObject)GameFuncs.GetResource("Prefabs/skill"));
                skill.transform.SetParent(grid);
                skill.transform.Find("ele").GetComponent <Image>().sprite
                    = Resources.Load <Sprite>("Icons/" + s.ele);
                skill.transform.Find("name").GetComponent <Text>().text = s.sname;
                if (s.isCp)
                {
                    skill.transform.Find("cost").GetComponent <Text>().text = s.cost.ToString() + "cp";
                }
                else
                {
                    skill.transform.Find("cost").GetComponent <Text>().text = s.cost.ToString() + "mp";
                }
                Toggle st = skill.GetComponent <Toggle>();
                st.group = grid.GetComponent <ToggleGroup>();
                string info = s.info + "\n" + (s.isAoe ? "群体" : "单体");
                st.onValueChanged.AddListener((bool isOn) => { OnskillToggleClick(st, isOn, infoText, s, grid); });
            }
        }
        for (int i = skills.Count; i < panel.Find("list/grid").childCount; i++)
        {
            Destroy(panel.Find("list/grid").GetChild(i).gameObject);
        }
    }
Exemple #21
0
    public virtual void Attack(Entity e)
    {
        float value    = this.infos[2] - e.infos[3];//atk-def
        int   restrict = GetRestrict(e, ref value);

        if (value <= 1)
        {
            value = 1;
        }
        e.GetHurt(value, restrict);
        AnimationClip ac = GameFuncs.GetAnim(anim, "attack");

        if (ac.events.Length <= 0)
        {
            Invoke("SetReturn", GameFuncs.GetAnim(anim, "attack").length);
        }
    }
    // Use this for initialization
    void Start()
    {
        //ui
        UIManager.ChangeText("energyText", Globals.player.energy.ToString() + "/" + Globals.player.maxEnergy);
        UIManager.ChangeSlider("energySlider", (float)Globals.player.energy / Globals.player.maxEnergy);
        //get place
        Transform grid = GameObject.Find("grid").transform;

        foreach (Transform place in grid)
        {
            place.GetComponent <Button>().onClick.AddListener(() =>
            {
                BattleGlobals.placeName = place.gameObject.name[place.gameObject.name.Length - 1].ToString();
                GameFuncs.GoToScene("SelectHero");
            });
        }
    }
Exemple #23
0
    void OnchatBtnClick()
    {
        MusicManager.PlaySe("click");
        parent = transform.parent;
        string id     = GameFuncs.GetId(parent.transform);
        int    indexs = 0;

        foreach (var dialog in Resources.LoadAll("Dialogs"))
        {
            if (dialog.name.Contains(id) && dialog.name.Contains("chat"))
            {
                indexs++;
            }
        }
        Globals.currentDialog = id + "_chat" + Random.Range(1, indexs + 1);
        GameFuncs.GoToScene("Chat");
    }
Exemple #24
0
 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;
         }
     }
 }
Exemple #25
0
 void OnskipBtnClick()
 {
     //PlaySE
     MusicManager.PlaySe("click");
     //Go to next scene(stop at options)
     if (Globals.lastScene == "Login")
     {
         Globals.nextScene = "Main";
     }
     if (Globals.lastScene == "Room")
     {
         GameFuncs.GoToScene("Room");
     }
     else
     {
         GameFuncs.GoToSceneAsync(Globals.nextScene);
     }
 }
Exemple #26
0
    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());
    }
Exemple #27
0
    // Use this for initialization
    void Start()
    {
        GameObject storyBtnPre   = (GameObject)GameFuncs.GetResource("Prefabs/storyBtn");
        Button     closeStoryBtn = UIManager.GetButton("closeStoryBtn");
        Transform  storyList     = transform.Find("storyList");

        storyGrid = storyList.Find("storyGrid");
        closeStoryBtn.onClick.AddListener(OncloseStoryBtnClick);
        //Load StoryBtns
        for (int i = 0; i < RoomGlobals.storyInfos.Count; i++)
        {
            StoryInfo si   = RoomGlobals.storyInfos[i];
            string    path = si.storyPath;
            string    id   = path.Substring(0, 3);
            if (id == RoomGlobals.currentId)
            {
                storyCount++;
                GameObject story = GameObject.Instantiate(storyBtnPre);
                story.transform.SetParent(storyGrid);
                storys.Add(story);
                story.transform.Find("Text").GetComponent <Text>().text = si.storyName;
                story.GetComponent <Button>().onClick.AddListener(() => { OnstoryBtnClick(path); });
                //for i<lv,if(si.storyName[last]<=lv) interactable=true;
                story.GetComponent <Button>().interactable = !si.isLocked;
                for (int j = 0; j < RoomGlobals.loveDic[RoomGlobals.currentId].lv; j++)
                {
                    if (int.Parse(si.storyName[si.storyName.Length - 1].ToString())
                        <= RoomGlobals.loveDic[RoomGlobals.currentId].lv)
                    {
                        story.GetComponent <Button>().interactable = true;
                    }
                }
            }
        }
        for (int i = 0; i < storyGrid.childCount; i++)
        {
            if (i >= storyCount)
            {
                Destroy(storyGrid.GetChild(i).gameObject);
            }
        }
    }
Exemple #28
0
    public void CastSpell(string ownerTag, Transform loc, Transform playerLoc)
    {
        OnCoolDown = true;
        Debug.Log("CastSpell ::" + Ability.Name);

        playerLoc.rotation = GameFuncs.RotateTowardsMouse(playerLoc);

        Vector3 pos = Ability.Effect == GameConsts.EFFECT.PROJECTILE ? loc.position : loc.position;

        GameObject go = GameObject.Instantiate(Ability.Prefab, pos, loc.rotation);

        Projectile projectile = (Projectile)go.GetComponent(typeof(Projectile));

        switch (Ability.Effect)
        {
        case GameConsts.EFFECT.PROJECTILE:
        {
            Projectile proj = go.GetComponent <Projectile>();
            proj.Ability  = Ability;
            proj.OwnerTag = ownerTag;
            break;
        }

        case GameConsts.EFFECT.AOE:
        {
            AoE aoe = go.GetComponent <AoE>();
            aoe.Ability  = Ability;
            aoe.OwnerTag = ownerTag;

            //Size of AOE
            float scale = Ability.Range.x * 0.2f;
            go.transform.GetChild(0).localScale = new Vector3(scale, 0.1f, scale);
            break;
        }

        case GameConsts.EFFECT.CLICK:
        {
            break;
        }
        }
    }
Exemple #29
0
    void OnpointBtn(string btnName)
    {
        MusicManager.PlaySe("click");
        GameObject point = GameObject.Find(btnName.Replace("Btn", ""));

        if (point.transform.childCount == 0)//Add Chracter(Select UI->Instantiate)
        {
            if (!selectCharacter.activeInHierarchy)
            {
                selectCharacter.SetActive(true);
                //Create Characters
                Transform grid = selectCharacter.transform.Find("grid");
                for (int i = 0; i < Globals.heroes.Count; i++)
                {
                    if (!RoomFuncs.FindModel(Globals.heroes[i].id))
                    {
                        GameObject character_roomSelect = GameObject.Instantiate(
                            (GameObject)GameFuncs.GetResource("Prefabs/character_roomSelect"), grid);
                        string modelPath = "Prefabs/" + Globals.heroes[i].id;
                        string imagePath = "Character/Portrait/" + Globals.heroes[i].id;
                        Image  image     = character_roomSelect.transform.Find("Image").GetComponent <Image>();
                        image.sprite = Resources.Load <Sprite>(imagePath);

                        Button character_roomSelectBtn = character_roomSelect.GetComponent <Button>();
                        character_roomSelectBtn.onClick.AddListener(() =>
                                                                    { Oncharacter_roomSelectBtnClick(point.transform, modelPath, btnName); });
                    }
                }
            }
            else
            {
                Transform grid = selectCharacter.transform.Find("grid");
                foreach (Transform child in grid)
                {
                    Destroy(child.gameObject);
                }
                selectCharacter.SetActive(false);
            }
        }
    }
Exemple #30
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("用户名或密码错误!");
            }
        }
    }