public void StartClient(Action onStartSuccess, Action onStartFail, bool forceRestart) { StopAllCoroutines(); networkingMode = NetworkingMode.Client; StartCoroutine(StartClientRoutine(onStartSuccess, onStartFail, forceRestart)); }
private void OnMapLoaded(string map, NetworkingMode mode) { Assert.AreEqual(mode, NetworkingMode.Server); worldManager = new WorldServerManager(false); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, worldManager); }
public static void Start(string ipAdress, int port, NetworkingMode networkingMode) { NetMode = networkingMode; string ipAndPort = string.Format("{0}:{1}", ipAdress.ToString(), port); if (NetMode == NetworkingMode.Server) { Debug.LogFormat("Try to establish connection to {0}", ipAndPort.ColorTag(ColorStringTag.Yellow)); //Create ip and port listener serverListener = new TcpListener(IPAddress.Parse(ipAdress), port); serverListener.Start(); oponentWaitingThread.Start(); } else { //Connect to ip:port oponentMessagesGateway = new TcpClient(); oponentMessagesGateway.Connect(IPAddress.Parse(ipAdress), port); Debug.LogFormat("Try to connect as client to {0}", ipAndPort.ColorTag(ColorStringTag.Yellow)); onOponentConnect?.Invoke(); listenForNewMessagesThread.Start(); } IsInited = true; Debug.LogFormat("Start as {0}", NetMode.ToString()); }
public PositionMessage(NetworkingMode id, float x, float y, float z) { this.id = id; xPosition = x; yPosition = y; zPosition = z; }
public void StartSinglePlayer(ServerRoomToken serverToken, Action onStartSuccess, Action onStartFail) { StopAllCoroutines(); networkingMode = NetworkingMode.Both; serverToken.Version = Version; StartCoroutine(StartServerRoutine(serverToken, true, onStartSuccess, onStartFail)); }
public void StartServer(ServerRoomToken serverToken, bool withClientLogic, Action onStartSuccess, Action onStartFail) { StopAllCoroutines(); networkingMode = withClientLogic ? NetworkingMode.Both : NetworkingMode.Server; serverToken.Version = Version; StartCoroutine(StartServerRoutine(serverToken, false, onStartSuccess, onStartFail)); }
public void StartConnection(UdpSession session, ClientConnectionToken token, Action onConnectSuccess, Action <ClientConnectFailReason> onConnectFail) { StopAllCoroutines(); networkingMode = NetworkingMode.Client; state = State.Connecting; token.Version = Version; StartCoroutine(ConnectClientRoutine(session, token, onConnectSuccess, onConnectFail)); }
private void OnGameMapLoaded(string map, NetworkingMode mode) { bool hasServerLogic = mode == NetworkingMode.Server || mode == NetworkingMode.Both; bool hasClientLogic = mode == NetworkingMode.Client || mode == NetworkingMode.Both; gameManager.CreateWorld(hasServerLogic ? (World) new WorldServer(hasClientLogic) : new WorldClient(false)); interfaceReference.HideScreen <LobbyScreen>(); interfaceReference.ShowScreen <BattleScreen, BattleHudPanel>(); }
private void OnGameMapLoaded(string map, NetworkingMode mode) { bool hasServerLogic = mode == NetworkingMode.Server || mode == NetworkingMode.Both; bool hasClientLogic = mode == NetworkingMode.Client || mode == NetworkingMode.Both; worldManager = hasServerLogic ? (WorldManager) new WorldServerManager(hasClientLogic) : new WorldClientManager(false); EventHandler.ExecuteEvent(EventHandler.GlobalDispatcher, GameEvents.WorldInitialized, worldManager); interfaceReference.HideScreen <LobbyScreen>(); interfaceReference.ShowScreen <BattleScreen, BattleHudPanel>(); }
private void OnMapLoaded(string map, NetworkingMode mode) { Assert.AreEqual(mode, NetworkingMode.Server); gameManager.CreateWorld(new WorldServer(false)); }