Ejemplo n.º 1
0
    void Start()
    {
        if (debug)
        {
            CClientInfo.ThisUser = new CClientInfo.User(1, "test", 5);
        }

        _tcpManager = Network.CTcpClient.instance;
        _tcpManager.SetPacketInterpret(PacketInterpret);
        RefreshRoom();

        if (RefreshBtn != null)
        {
            RefreshBtn.onClick.AddListener(RefreshRoom);
        }
        if (CreateBtn != null)
        {
            CreateBtn.onClick.AddListener(CreateRoomHandler);
        }
        if (QuitBtn != null)
        {
            QuitBtn.onClick.AddListener(QuitLobby);
        }

        Debug.Log("UID : " + CClientInfo.ThisUser.uid);
    }
Ejemplo n.º 2
0
    private void Start()
    {
        _tcpManager = (Network.CTcpClient)FindObjectOfType(typeof(Network.CTcpClient));

        if (startBtn != null)
        {
            startBtn.onClick.AddListener(StartGame);
        }
        if (networkBtn != null)
        {
            networkBtn.onClick.AddListener(ReadyToNetwork);
        }
        if (exitBtn != null)
        {
            exitBtn.onClick.AddListener(() => Application.Quit());
        }
        if (RegisterBtn != null)
        {
            RegisterBtn.onClick.AddListener(RegisterAccess);
        }
        if (LoginBtn != null)
        {
            LoginBtn.onClick.AddListener(LoginAccess);
        }
        if (CancelBtn != null)
        {
            CancelBtn.onClick.AddListener(CancelNetwork);
        }
    }
Ejemplo n.º 3
0
    private void Start()
    {
        _tcpManager    = Network.CTcpClient.instance;
        _playerCommand = CPlayerCommand.instance;

        // 연결되면 패킷 받을거 설정
        if (_tcpManager != null && _tcpManager.IsConnect == true)
        {
            Debug.Log("Network Connected");
            _inGameInterpreter = new Network.CPacketInterpreter(_tcpManager);
            _tcpManager.SetPacketInterpret(_inGameInterpreter.PacketInterpret);
            PlayerMoveStartEvent.AddListener(_inGameInterpreter.SendMoveStart);
            PlayerMoveStopEvent.AddListener(_inGameInterpreter.SendMoveStop);
            PlayerActionEvent.AddListener(_inGameInterpreter.SendActionStart);

            // 캐릭터 설정
            Debug.Log($"Set Character : Send Message");
            _playerCommand.SetActivePlayers(CClientInfo.PlayerCount);
            _inGameInterpreter.SendCharacterInfoRequest();
        }
        // 싱글 플레이 시에 일부 동작들은 서버에 거치지 않고 동작해야 함
        else if (_playerCommand != null)
        {
            Debug.Log("Network not Connected");
            //_playerCommand.SetMyCharacter(0);
        }
    }
Ejemplo n.º 4
0
    void Start()
    {
        Debug.Log("In Ready Room");
        if (nonNetwork)
        {
            CClientInfo.ThisUser = new CClientInfo.User(1, "test", 1);

            int[] slot = new int[4] {
                0, -1, 0, -1
            };
            var others = new List <CClientInfo.User> {
                new CClientInfo.User(0, "abc", 10, 0),
                new CClientInfo.User(0, "kim", 15, 2)
            };
            CClientInfo.ThisRoom      = new CClientInfo.JoinRoom(150, slot, others, false);
            CClientInfo.ThisUser.Slot = 1;
        }
        else
        {
            _tcpManager = GameObject.Find("Network").GetComponent <Network.CTcpClient>();
            if (_tcpManager != null)
            {
                _tcpManager.SetPacketInterpret(PacketInterpret);
            }
        }

        if (CClientInfo.ThisRoom.isHost)
        {
            Debug.Log("I'm Host");
            // 방 생성 시
            var u = CClientInfo.ThisUser;
            AddPlayerToListView(u.Slot, u.id, u.clear);
        }
        else
        {
            Debug.Log("I'm not Host");
            // 방에 접속할 경우
            UpdateRoomListView();
        }

        if (startBtn != null)
        {
            if (!CClientInfo.ThisRoom.isHost)
            {
                startBtn.interactable = false;
            }
            startBtn.onClick.AddListener(GameStartRequest);
        }
        if (leaveBtn != null)
        {
            //leaveBtn.onClick.AddListener(QuitRoomRequest);
            leaveBtn.onClick.AddListener(QuitRoomRequest);
        }
    }
Ejemplo n.º 5
0
        private void Awake()
        {
            if (instance == null)
            {
                instance = this;
            }
            else
            {
                Destroy(gameObject);
            }
            DontDestroyOnLoad(gameObject);

            StartClient();

#if UNITY_EDITOR
            string[] args = Environment.GetCommandLineArgs();
            CClientInfo.ThisUser = new CClientInfo.User(0, "a4", 0);
#else
            string[] args = Environment.GetCommandLineArgs();
            CClientInfo.ThisUser = new CClientInfo.User(0, args[1], 0);
#endif
        }