Beispiel #1
0
        public static void boss(int x, int y, TileData otherTileData)
        {
            Guaiwu guaiwu = otherTileData.gameObject.GetComponent <Guaiwu>();

            DialogManager.Instance.infoDabuguo  = "你打不过他。\n\n";
            DialogManager.Instance.infoDabuguo += "怪物属性:\n";
            DialogManager.Instance.infoDabuguo += "生命:" + guaiwu.shengming + "\n";
            DialogManager.Instance.infoDabuguo += "攻击:" + guaiwu.gongji + "\n";
            DialogManager.Instance.infoDabuguo += "防御:" + guaiwu.fangyu + "\n";
            DialogManager.Instance.infoDabuguo += "金币:" + guaiwu.jinbi + "\n";
            DialogManager.Instance.infoDabuguo += "经验:" + guaiwu.jingyan + "\n";
            if (PlayerInfo.Instance.Data.Attack.Value <= guaiwu.fangyu)
            {
                DialogManager.Instance.state = "dabuguo";
            }
            else
            {
                int   shanghai     = PlayerInfo.Instance.Data.Attack.Value - guaiwu.fangyu;
                float cishu        = Mathf.Ceil(guaiwu.shengming / shanghai);
                float zongshanghai = 0;
                if (guaiwu.gongji > PlayerInfo.Instance.Data.Defence.Value)
                {
                    float shoushang = guaiwu.gongji - PlayerInfo.Instance.Data.Defence.Value;
                    zongshanghai = shoushang * cishu;
                }
                if (zongshanghai >= PlayerInfo.Instance.Data.Life.Value)
                {
                    DialogManager.Instance.state = "dabuguo";
                }
                else
                {
                    Application.LoadLevel(2);
                }
            }
        }
Beispiel #2
0
        void OnGUI()
        {
            //定义GUI皮肤
            GUI.skin.box.normal.textColor  = new Vector4(1, 1, 1, 1);
            GUI.skin.box.padding           = new RectOffset(15, 15, 15, 15);
            GUI.skin.box.fontSize          = scaleGUI(18);
            GUI.skin.box.alignment         = TextAnchor.UpperLeft;
            GUI.skin.box.normal.background = dialogboxbg;
            GUI.skin.button.fontSize       = scaleGUI(18);
            switch (state)
            {
            case "nodata":
                player.canMove         = false;
                dialogbox              = new Rect(Screen.width / 2 - scaleGUI(110), Screen.height / 2 - scaleGUI(150), scaleGUI(220), scaleGUI(250));
                GUI.skin.box.alignment = TextAnchor.UpperCenter;
                GUI.Box(dialogbox, "当前没有存档\n...无法读取...\n是否重新开始?");
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(20), scaleGUI(180), scaleGUI(45)), "确定"))
                {
                    Application.LoadLevel(1);
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 + scaleGUI(35), scaleGUI(180), scaleGUI(45)), "取消"))
                {
                    player.canMove = true;
                    state          = "";
                }
                break;

            case "dabuguo":
                player.canMove = false;
                GUI.Box(new Rect(Screen.width / 2 - scaleGUI(72), Screen.height / 2 - scaleGUI(120), scaleGUI(144), scaleGUI(240)), infoDabuguo);
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(60), Screen.height / 2 + scaleGUI(75), scaleGUI(120), scaleGUI(35)), "知道了"))
                {
                    state          = "";
                    player.canMove = true;
                }
                break;

            case "floorchange":
                if (dialogTime > 0)
                {
                    player.canMove = false;
                    dialogTime    -= Time.deltaTime;
                    GUI.skin.box.normal.textColor  = new Vector4(1, 1, 1, 1);
                    GUI.skin.box.padding           = new RectOffset(15, 15, 15, 15);
                    GUI.skin.box.fontSize          = scaleGUI(24);
                    GUI.skin.box.alignment         = TextAnchor.MiddleCenter;
                    GUI.skin.box.normal.background = dialogboxbg;
                    dialogbox = new Rect(Screen.width / 2 - scaleGUI(100), Screen.height / 2 - scaleGUI(30), scaleGUI(200), scaleGUI(60));
                    GUI.Box(dialogbox, "当前第 " + GM.CurrentFloor.Value + " 层");
                }
                else
                {
                    player.canMove = true;
                    dialogTime     = 0;
                    state          = "";
                }
                break;

            case "menu":
                player.canMove = false;
                dialogbox      = new Rect(Screen.width / 2 - scaleGUI(110), Screen.height / 2 - scaleGUI(150), scaleGUI(220), scaleGUI(250));
                GUI.Box(dialogbox, "");
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(130), scaleGUI(180), scaleGUI(45)), "保存进度"))
                {
                    GDM.SaveGame();
                    player.canMove = true;
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(75), scaleGUI(180), scaleGUI(45)), "读取进度"))
                {
                    if (GDM.checkGameData())
                    {
                        PlayerPrefs.SetInt("loadgame", 1);
                        Application.LoadLevel(1);
                    }
                    else
                    {
                        state = "nodata";
                    }
                    player.canMove = true;
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 - scaleGUI(20), scaleGUI(180), scaleGUI(45)), "退出游戏"))
                {
                    Application.Quit();
                }
                if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(90), Screen.height / 2 + scaleGUI(35), scaleGUI(180), scaleGUI(45)), "取消"))
                {
                    state          = "";
                    player.canMove = true;
                }
                break;

            case "tujian":
                if (Input.GetMouseButton(0))
                {
                    GameObject mycamera = GameObject.Find("Camera");
                    Vector3    position = mycamera.GetComponent <Camera>().ScreenToWorldPoint(Input.mousePosition);
                    TileIndex  ti       = TM.tileSystem.ClosestTileIndexFromWorld(position);
                    TileData   tile     = TM.tileSystem.GetTile(ti);
                    if (tile != null && tile.GetUserFlag(3))
                    {
                        AuM.playAudio("talk");
                        Guaiwu guaiwu = tile.gameObject.GetComponent <Guaiwu>();
                        string info   = "";
                        if (!tile.GetUserFlag(10))
                        {
                            if (PlayerInfo.Instance.Data.Attack.Value <= guaiwu.fangyu)
                            {
                                info = "你破不了它的防御。\n";
                            }
                            else
                            {
                                int   shanghai     = PlayerInfo.Instance.Data.Attack.Value - guaiwu.fangyu;
                                float cishu        = Mathf.Ceil(guaiwu.shengming / shanghai);
                                float zongshanghai = 0;
                                if (guaiwu.gongji > PlayerInfo.Instance.Data.Defence.Value)
                                {
                                    float shoushang = guaiwu.gongji - PlayerInfo.Instance.Data.Defence.Value;
                                    zongshanghai = shoushang * cishu;
                                }
                                info = "战胜它你将损失:" + zongshanghai + "生命。\n";
                            }
                        }
                        info += "生命:" + guaiwu.shengming + "  /  ";
                        info += "攻击:" + guaiwu.gongji + "  /  ";
                        info += "防御:" + guaiwu.fangyu + "\n";
                        info += "金币:" + guaiwu.jinbi + "  /  ";
                        info += "经验:" + guaiwu.jingyan;
                        if (position.y > -5)
                        {
                            //显示在下面
                            GUI.Box(new Rect(0, Screen.height / 2 + scaleGUI(63), Screen.width, scaleGUI(100)), info);
                        }
                        else
                        {
                            //显示在上面
                            GUI.Box(new Rect(0, Screen.height / 2 - scaleGUI(237), Screen.width, scaleGUI(100)), info);
                        }
                    }
                }
                break;

            case "feixing":
                player.canMove = false;
                for (int i = 1; i < GM.MaxFloor.Value + 1; i++)
                {
                    int y = i % 3;
                    if (y == 0)
                    {
                        y = -1;
                    }
                    else if (y == 2)
                    {
                        y = 0;
                    }
                    int z = (i - 1) / 3;
                    if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(120 * y + 50), Screen.height / 2 - scaleGUI(220) + scaleGUI(50 * z), scaleGUI(100), scaleGUI(40)), "第 " + i + " 层"))
                    {
                        AuM.playAudio("feixing");
                        GM.changeFloor(i);
                        state          = "";
                        player.canMove = true;
                    }
                }
                break;

            case "dialog":
                player.canMove = false;
                if (_text != "")
                {
                    dialogbox = new Rect(Screen.width / 2 - scaleGUI(150), Screen.height / 2 - scaleGUI(150), scaleGUI(300), scaleGUI(300));
                    GUI.Box(dialogbox, _text);
                }
                if (_choices == null)
                {
                    if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(135), Screen.height / 2 + scaleGUI(95), scaleGUI(270), scaleGUI(40)), "继续"))
                    {
                        Dialoguer.ContinueDialogue();
                    }
                }
                else
                {
                    pressed = false;
                    for (int i = _choices.Length - 1; i > -1; i--)
                    {
                        if (GUI.Button(new Rect(Screen.width / 2 - scaleGUI(135), Screen.height / 2 + scaleGUI(40 + (i - _choices.Length + 2) * 45), scaleGUI(270), scaleGUI(40)), _choices[i]))
                        {
                            Dialoguer.ContinueDialogue(i);
                        }
                    }
                }
                break;

            default:
                break;
            }
            if (tipTime > 0 && tipContent != "")
            {
                GUI.skin.box.alignment = TextAnchor.MiddleCenter;
                GUI.Box(new Rect(Screen.width / 2 - scaleGUI(200), Screen.height / 2 + scaleGUI(115), scaleGUI(400), scaleGUI(50)), tipContent);
                tipTime -= Time.deltaTime;
            }
            else
            {
                tipTime    = 0;
                tipContent = "";
            }
            if (state == "")
            {
                player.canMove = true;
            }
        }