127 lines
3.7 KiB
C#
127 lines
3.7 KiB
C#
using Assets.MyGame.Scripts.Net;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public enum GameType
|
|
{
|
|
JQQD = 0,
|
|
defaultPanel =999,
|
|
FXZY = 1,
|
|
TGXX = 2,
|
|
ZGXQ = 3,
|
|
XJMH = 4,
|
|
HHWK = 5,
|
|
}
|
|
[Serializable]
|
|
public class BG_SelectRoom
|
|
{
|
|
public string name;
|
|
public GameType gameType;
|
|
public Sprite sprite;
|
|
}
|
|
public class UIHome_BY_SelectRoomLevelPanel : SubUIBase
|
|
{
|
|
[Header("DefaultGame")]
|
|
[Header("快速进入")]
|
|
public Button SelectRoom1;
|
|
public Button SelectRoom2;
|
|
public Button SelectRoom3;
|
|
[Header("手动选择")]
|
|
public Button MySelectRoom1;
|
|
public Button MySelectRoom2;
|
|
public Button MySelectRoom3;
|
|
public UIHome_BY_MySelectRoomPanel panel_UIHome_BY_MySelectRoomPenel;
|
|
public GameType currGameType;
|
|
public List<BG_SelectRoom> bG_SelectRooms=new List<BG_SelectRoom>();
|
|
public Image img_BG;
|
|
int leave = 1;
|
|
public override void Awake()
|
|
{
|
|
base.Awake();
|
|
WebSocketManager.Instance.Connect(SocketType.room);
|
|
MySelectRoom1.onClick.AddListener(() =>
|
|
{
|
|
OnSelectRoom(currGameType);
|
|
leave = 1;
|
|
});
|
|
MySelectRoom2.onClick.AddListener(() =>
|
|
{
|
|
OnSelectRoom(currGameType);
|
|
leave = 2;
|
|
});
|
|
MySelectRoom3.onClick.AddListener(() =>
|
|
{
|
|
OnSelectRoom(currGameType);
|
|
leave = 3;
|
|
});
|
|
SelectRoom1.onClick.AddListener(() =>
|
|
{
|
|
StartGame(currGameType);
|
|
});
|
|
SelectRoom2.onClick.AddListener(() =>
|
|
{
|
|
StartGame(currGameType);
|
|
});
|
|
SelectRoom3.onClick.AddListener(() =>
|
|
{
|
|
StartGame(currGameType);
|
|
});
|
|
}
|
|
public void OnSelectRoom(object json)
|
|
{
|
|
WebSocketSendList.GetRoomListFish(1,1);
|
|
//WebSocketManager.Instance.Send(SocketType.room, "{\"type\":1,\"target\":\"GetRoomList\",\"invocationId\":\"1\",\"arguments\":[\""+GameManager.Instance.user.id+"\","+(int)GameManager.Instance.gameData.currGameType+","+leave+",1]}");
|
|
//这里想websocket发送链接请求
|
|
//panel_UIHome_BY_MySelectRoomPenel.Show(json);
|
|
}
|
|
public void StartGame(object o)
|
|
{
|
|
//这里写判断条件
|
|
GameManager.Instance.StartGame();
|
|
|
|
|
|
}
|
|
public override void Show(object args = null)
|
|
{
|
|
base.Show(args);
|
|
if (args != null && args is GameType)
|
|
{
|
|
currGameType = (GameType)args;
|
|
GameManager.Instance.gameData.currGameType = currGameType;
|
|
if (currGameType!= GameType.JQQD)
|
|
{
|
|
SelectRoom1.transform.GetChild(((int)currGameType)+2).gameObject.SetActive(true);
|
|
SelectRoom2.transform.GetChild(((int)currGameType) + 2).gameObject.SetActive(true);
|
|
SelectRoom3.transform.GetChild(((int)currGameType) + 2).gameObject.SetActive(true);
|
|
}
|
|
foreach (var item in bG_SelectRooms)
|
|
{
|
|
if (item.gameType==currGameType)
|
|
{
|
|
img_BG.sprite = item.sprite;
|
|
img_BG.color =Color.white;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
public override void Hide()
|
|
{
|
|
base.Hide();
|
|
img_BG.color = new Color(1,1,1,0);
|
|
if (currGameType != GameType.JQQD)
|
|
{
|
|
SelectRoom1.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
SelectRoom2.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
SelectRoom3.transform.GetChild((int)currGameType).gameObject.SetActive(false);
|
|
currGameType = GameType.JQQD;
|
|
}
|
|
|
|
}
|
|
}
|