Пример #1
0
    void Start()
    {
        GameData.networkPlayers.Clear();
        discoveredServers.Clear();

        roomListPanel.SetActive(!GameData.isHost);
        playerListPanel.SetActive(GameData.isHost);
        networkDiscovery = GetComponent <MyNetworkDiscovery>();
        networkDiscovery.OnServerFound.AddListener(OnDiscoveredServer);
        roomPanelBackBtn.onClick.AddListener(Back);
        playerPanelBackBtn.onClick.AddListener(Back);
        startGameBtn.gameObject.SetActive(false); // 开始不显示游戏开始按钮
        startGameBtn.onClick.AddListener(OnClickStartGame);
        MyNetworkRoomManager mamager = NetworkManager.singleton as MyNetworkRoomManager;

        mamager.onCreateRoomPlayer     = OnCreateRoomPlayer;
        mamager.onClientDisconnect     = OnClientDisconnect;
        mamager.onGameStartStateChange = OnGameStartStateChange;
        if (GameData.isHost)
        {
            roomName.text = $"[{GameData.playerName}的房间]";
            NetworkManager.singleton.StartHost();
            networkDiscovery.AdvertiseServer();
        }
        else
        {
            networkDiscovery.MyStartDiscovery();
        }
    }
Пример #2
0
 public void Construct(ServiceProvider provider, ConnectionStateMachine connMachine, UIManager uiManager)
 {
     _netManager   = provider.networkManager;
     _netDiscovery = provider.networkDiscovery;
     _connMachine  = connMachine;
     _uiManager    = uiManager;
 }
Пример #3
0
    private void Awake()
    {
        base.Initialize();
        StartListen();
        StartCoroutine(CleanupExpiredEntries());

        instance = this;
    }
Пример #4
0
 void Start()
 {
     StartCoroutine("WaitForNetworkManager");
     StartCoroutine("WaitForNetwork");
     singleton = this;
     didInit   = Initialize();
     isServer  = false;
     isClient  = false;
 }
 private void Start()
 {
     soundManager     = FindObjectOfType <SoundManager>();
     networkManager   = GameObject.FindObjectOfType <NetworkManager>();
     networkDiscovery = GameObject.FindObjectOfType <MyNetworkDiscovery>();
     hudManager       = FindObjectOfType <HUDNetworkManagerCostumized>();
     CreateRoomBtn.SetActive(true);
     FindRoomBtn.SetActive(true);
     DifficultyLevelDropDownPanel.SetActive(true);
 }
Пример #6
0
    void Start()
    {
        client = new NetworkClient();

        if (networkDiscovery == null)
        {
            networkDiscovery = GetComponent <MyNetworkDiscovery>();
        }
        //if (networkDiscovery == null) throw new System.Exception();

        RegisterHandlers();
    }
    IEnumerator Startup(float delay)
    {
        if (!isInDelayedStart)
        {
            isInDelayedStart = true;
            yield return(new WaitForSeconds(delay));

            if (isInDelayedStart)
            {
                discovery = GetComponent <MyNetworkDiscovery>();
                if (PlayerList == null)
                {
                    PlayerList = FindObjectOfType <PlayerList>();
                }

                if (AutoStartDiscovery)
                {
                    StartBroadcastDiscovery();
                }
            }
            isInDelayedStart = false;
        }
    }
Пример #8
0
    // Use this for initialization
    void Start () {

        // Get NetworkDiscovery to initialize broadcast in OnStartHost hook
        networkDiscovery = GetComponent<MyNetworkDiscovery>();

        // Get StartController for handling UI changes
        startController = GameObject.Find("StartController").GetComponent<StartController>();

        // Get LobbyPlayer RectTransform for positioning lobby players when they spawn
        lobbyPlayerRectTransform = lobbyPlayerPrefab.GetComponent<RectTransform>();
        lobbyPlayerOffset = lobbyPlayerRectTransform.rect.height * lobbyPlayerRectTransform.localScale.y * 1.2f;
        Debug.Log("lobby player offset is " + lobbyPlayerOffset);
        /*for(int i = 0; i < MaxPlayers; i++)
        {
            GameObject start = Instantiate(startPositionPrefab, new Vector2(0, height - offset * i), Quaternion.identity) as GameObject;
            start.transform.SetParent(canvasObj.transform, false);

        }*/


        // Set round robin player spawn method
        playerSpawnMethod = PlayerSpawnMethod.RoundRobin;
    }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        messageBuffer = new List <KeyValuePair <int, BufferedMessage> >();
        if (networkDiscovery == null)
        {
            networkDiscovery = gameObject.GetComponent <MyNetworkDiscovery>();
        }
        // if (networkDiscovery == null) throw new System.Exception();

        // running server in background
        Application.runInBackground = true;
        ipAddress = LocalIPAddress();

        for (int i = 0; i < 4; i++)
        {
            HRZTAxis[i] = new CrossPlatformInputManager.VirtualAxis(hrztaxis_n + i); CrossPlatformInputManager.RegisterVirtualAxis(HRZTAxis[i]);
            VTCAxis[i]  = new CrossPlatformInputManager.VirtualAxis(vtcaxis_n + i); CrossPlatformInputManager.RegisterVirtualAxis(VTCAxis[i]);
        }

        bool networkStart = false;

        do
        {
            try
            {
                networkStart = NetworkServer.Listen(port);
            }
            catch (System.Exception err)
            {
                Debug.LogWarning("Start Server Not complete: " + err + "Try Changing port");
                port++;
            }
        }while (!networkStart);

        //Debug.Log("listening at port: " + port);
        RegisterHandlers();
    }
Пример #10
0
 public void Construct(ServiceProvider provider, PrefabManager prefabManager, DiContainer container)
 {
     _netDiscovery  = provider.networkDiscovery;
     _prefabManager = prefabManager;
     _container     = container;
 }
Пример #11
0
 public void StartLocalBroadcast()
 {
     localNetworkDiscovery = GetComponent <MyNetworkDiscovery>();
     localNetworkDiscovery.Initialize();
     localNetworkDiscovery.StartAsServer();
 }
Пример #12
0
 private void Start()
 {
     _discovery = GetComponent <MyNetworkDiscovery>();
     //this require on network discovery
     _discovery.Initialize();
 }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     m_NetworkDiscovery = GetComponent <MyNetworkDiscovery>();
 }
Пример #14
0
 //public string myName;
 // Use this for initialization
 void Start()
 {
     originalNetDis = transform.root.GetComponent <MyNetworkDiscovery>();
 }
Пример #15
0
 void Awake()
 {
     my_network_discovery_ = GetComponent<MyNetworkDiscovery>();
 }
Пример #16
0
 public void StartReceiveLocalBroadcast()
 {
     localNetworkDiscovery = GetComponent <MyNetworkDiscovery>();
     localNetworkDiscovery.Initialize();
     localNetworkDiscovery.StartAsClient();
 }
Пример #17
0
 void Awake()
 {
     myNetworkDiscovery = FindObjectOfType <MyNetworkDiscovery>();
 }
 private void Awake()
 {
     networkDiscovery = GetComponent <MyNetworkDiscovery>();
 }