Exemple #1
0
    // Use this for initialization
    void Start()
    {
        GameObject go = Game.CreatePrefab(gameObject, new GameObjectItem
        {
            name   = "伙伴按钮",
            text   = "伙伴",
            width  = 100,
            height = 60,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = 600,
            y      = -350
        });
        var button = go.GetComponent <Button>();

        button.onClick.AddListener(() =>
        {
            HeroHelper.ShowHeroSence(gameObject);
        });

        GameObject bag = Game.CreatePrefab(gameObject, new GameObjectItem
        {
            name   = "背包按钮",
            text   = "背包",
            width  = 100,
            height = 60,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = 500,
            y      = -350
        });

        var bagButton = bag.GetComponent <Button>();

        bagButton.onClick.AddListener(() =>
        {
            Bag.ShowBag();
        });

        GameObject chat = Game.CreatePrefab(gameObject, new GameObjectItem
        {
            name   = "聊天按钮",
            text   = "聊天",
            width  = 100,
            height = 60,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = -600,
            y      = -350
        });

        chat.GetComponent <Button>().onClick.AddListener(() =>
        {
            StartCoroutine(Chat.Init(gameObject, () =>
            {
                InputField text = Game.Find <InputField>("ChatText");

                if (!string.IsNullOrEmpty(text.text))
                {
                    Debug.Log("send");
                    StartCoroutine(User.Post("/Chat/send", new
                    {
                        toId    = "world",
                        content = text.text
                    }, (ChatResponse res) =>
                    {
                        Debug.Log("send1");
                        text.text        = "";
                        Chat.refreshTime = Chat.REFRESH_TIME;
                    })
                                   );
                }
            }));
        });
    }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        GameObject parent = GameObject.Find("UI");

        SpriteHelper.Init();
        Application.targetFrameRate = 60;
        Time.fixedDeltaTime         = 1f / 60;
        User.configs = User.HttpSend <List <Value> >("/config/enum", new { });
        var userResource = new List <string>();

        userResource.Add("金币");
        userResource.Add("绑定钻石");
        userResource.Add("钻石");
        foreach (var item in userResource)
        {
            Game.ChangeText(item + "/Count", User.GetCountByName(item).ToString());
        }
        mapManager = new MapManager(GameObject.Find("Map"), "主场景");
        GameObject go = Game.CreatePrefab(parent, new GameObjectItem
        {
            name   = "伙伴按钮",
            text   = "伙伴",
            width  = 116,
            height = 119,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = 600,
            y      = -300,
            sprite = "mainScene/14伙伴"
        });
        var button = go.GetComponent <Button>();

        button.onClick.AddListener(() =>
        {
            HeroHelper.ShowHeroSence(parent);
        });

        GameObject bag = Game.CreatePrefab(parent, new GameObjectItem
        {
            name   = "背包按钮",
            text   = "背包",
            width  = 116,
            height = 119,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = 500,
            y      = -300,
            sprite = "mainScene/13背包"
        });

        var bagButton = bag.GetComponent <Button>();

        bagButton.onClick.AddListener(() =>
        {
            Bag.ShowBag();
        });

        GameObject chat = Game.CreatePrefab(parent, new GameObjectItem
        {
            name   = "聊天按钮",
            text   = "聊天",
            width  = 100,
            height = 60,
            prefab = "Prefabs/Button",
            type   = 1,
            x      = -600,
            y      = -350
        });

        chat.GetComponent <Button>().onClick.AddListener(() =>
        {
            StartCoroutine(Chat.Init(parent, () =>
            {
                InputField text = Game.Find <InputField>("ChatText");

                if (!string.IsNullOrEmpty(text.text))
                {
                    Debug.Log("send");
                    StartCoroutine(User.Post("/Chat/send", new
                    {
                        toId    = "world",
                        content = text.text
                    }, (ChatResponse res) =>
                    {
                        Debug.Log("send1");
                        text.text        = "";
                        Chat.refreshTime = Chat.REFRESH_TIME;
                    })
                                   );
                }
            }));
        });
    }