Exemple #1
0
        public void OnTouchBegin(EventContext context)
        {
            if (_touchCardIndex != -1)
            {
                ResetCardIndex(_lastTouchedCard);
            }

            var sender = (GObject)context.sender;

            _lastTouchedCard = sender;
            sender.SetScale(1, 1);

            _touchCardIndex = g_handComp.GetChildIndex(sender);
            g_handComp.SetChildIndex(sender, 99);
        }
Exemple #2
0
    // Use this for initialization
    void Start()
    {
        //赋值组件
        mainComponent       = GetComponent <UIPanel>().ui;
        tankViewComponent   = mainComponent.GetChild("tankViewComponent").asCom;
        selectModeComponent = mainComponent.GetChild("selectModeComponent").asCom;
        roomListComponent   = UIPackage.CreateObject("BattleCity8102", "RoomList_Component").asCom;
        //设置钱
        moneyTextField = mainComponent.GetChild("moneyTextField").asTextField;
        mainComponent.GetChild("configButton").asButton.displayObject.layer = 0;
        mainComponent.GetChildIndex(mainComponent.GetChild("configButton").asButton);

        moneyTextField.text = money.ToString();
        //设置经验
        experienceBar       = mainComponent.GetChild("experienceBar").asProgress;
        experienceBar.value = experience;

        //给按钮注册监听
        //设置按钮按下,显示设置窗口
        configWindow = new ConfigWindow(50);//初始音量设置为50
        mainComponent.GetChild("configButton").asButton.onClick.Add(() => {
            configWindow.Show();
        });

        //返回按钮按下,返回主页面
        mainComponent.GetChild("returnButton").asButton.onClick.Add(() => {
            //关闭窗口,移除房间列表组件,将模式选择组件渲染先于经验条
            if (roomInfoWindow != null)
            {
                roomInfoWindow.Dispose();
            }
            roomListComponent.GetChild("entryRoomButton").asButton.enabled = false;
            currentRoom = null;//当前选中房间为空
            mainComponent.RemoveChild(roomListComponent);
            mainComponent.AddChild(selectModeComponent);
            mainComponent.SetChildIndexBefore(selectModeComponent, mainComponent.GetChildIndex(experienceBar));

            mainComponent.GetChild("configButton").asButton.visible = true;
            mainComponent.GetChild("returnButton").asButton.visible = false;
        });

        //对战按钮按下,加载roomConponent
        selectModeComponent.GetChild("LANBattleButton").onClick.Add(() => {
            //隐藏设置按钮,显示返回按钮
            mainComponent.GetChild("configButton").asButton.visible = false;
            mainComponent.GetChild("returnButton").asButton.visible = true;

            BattleButtonOnClick(roomListComponent);
        });

        //进入房间按钮按下,显示TankListWindow
        roomListComponent.GetChild("entryRoomButton").asButton.enabled = false;//防止不选房间进行点击
        roomListComponent.GetChild("entryRoomButton").asButton.onClick.Add(() => {
            if (roomInfoWindow != null)
            {
                roomInfoWindow.Dispose();//关闭房间信息窗口
            }
            tankListWindow = new TankListWindow(tankNum);
            tankListWindow.Show();
        });

        //创建房间时弹窗,创建完成循环发送房间信息
        roomListComponent.GetChild("createRoomButton").asButton.onClick.Add(() => {
            MainUI.player.isHost = true;
            createRmWindow       = new CreateRmWindow();
            createRmWindow.Show();
        });

        //刷新时清空当前房间,播放动效,查询房间,重新渲染列表
        Transition t = roomListComponent.GetTransition("t0");

        roomListComponent.GetChild("refreshButton").asButton.onClick.Add(() => {
            currentRoom = null;
            roomListComponent.GetChild("entryRoomButton").asButton.enabled = false;
            t.ChangePlayTimes(2);
            t.Play(() => {
                roomListComponent.GetChild("refreshMask").visible      = false;
                roomListComponent.GetChild("refreshTextField").visible = false;
            });
            rooms = RoomManager.SearchRoom(rooms);
            roomList.itemRenderer = RenderListItem;
            roomList.numItems     = rooms.Count;
        });
    }