Esempio n. 1
0
    public void ConnectToServer(Button button)
    {
        ConnectManager = this.gameObject.GetComponent <OnlineManager>();
        int IDToFire = button.GetComponentInParent <ToonId>().ID;

        ConnectManager.ConnectClient(IDToFire);
    }
Esempio n. 2
0
        /// <summary>
        /// </summary>
        public MenuScreen()
        {
            try
            {
                ModManager.RemoveSpeedMods();
            }
            catch (Exception e)
            {
                // ignored
            }

            View = new MenuScreenView(this);

            if (!FirstMenuLoad && ConfigManager.AutoLoginToServer.Value)
            {
                try
                {
                    OnlineManager.Login();
                }
                catch (Exception)
                {
                    // ignored
                }

                FirstMenuLoad = true;
            }
        }
Esempio n. 3
0
 public void InviteClick()
 {
                             #if UNITY_ANDROID
     OnlineManager.CreateWithInvitationScreen();
                             #elif UNITY_IPHONE
                             #endif
 }
Esempio n. 4
0
    private void Start()
    {
        quitButton.onClick.AddListener(() =>
        {
            OnlineManager.DestroyServer();

            gameObject.SetActive(false);
            menuPanel.gameObject.SetActive(true);
        });

        stopButton.onClick.AddListener(() =>
        {
            OnlineManager.StopServer();
        });

        OnlineManager.ConnectionCallback += (Client client) =>
        {
            clientListUI.AddClient(client.SocketInfo.RemoteIpAddress.ToString(), client.SocketInfo.RemotePort.ToString());
        };

        OnlineManager.DisconnectionCallBack += (Client client) =>
        {
            clientListUI.RemoveClient(client.SocketInfo.RemoteIpAddress.ToString(), client.SocketInfo.RemotePort.ToString());
        };

        OnlineManager.LogCallback += (string log) =>
        {
            logViewUI.AddLog(log);
        };
    }
Esempio n. 5
0
    private void Update()
    {
        if (OnlineManager.IsOwner(onlineId.PlayerOwner))
        {
            if (Input.GetKeyDown(KeyCode.Delete))
            {
                this.OnlineDestroy(gameObject);
            }

            int axisX = 0;
            if (Input.GetKey(KeyCode.D))
            {
                axisX += 1;
            }
            if (Input.GetKey(KeyCode.Q))
            {
                axisX += -1;
            }

            int axisY = 0;
            if (Input.GetKey(KeyCode.Z))
            {
                axisY += 1;
            }
            if (Input.GetKey(KeyCode.S))
            {
                axisY += -1;
            }

            transform.position += new Vector3(axisX, axisY, 0.0f).normalized * 20 * Time.deltaTime;
        }
    }
    public GameObject Instantiate(GameObject _prefab, Vector3?_pos = null, Quaternion?_rot = null, uint _playerID = 0)
    {
        if (_prefab == null || !OnlineManager.Instance.IsHost())
        {
            return(null);
        }
        GameObject obj = Array.Find(m_DynamicObject, go => go.name == _prefab.name);

        if (obj.GetComponent <OnlineIdentity>() == null)
        {
            OnlineManager.LogError("No Online Identity on object " + _prefab.name);
            return(null);
        }
        if (_pos == null)
        {
            _pos = Vector3.zero;
        }
        if (_rot == null)
        {
            _rot = Quaternion.identity;
        }
        GameObject newObj   = GameObject.Instantiate(obj, _pos.Value, _rot.Value);
        var        onlineID = newObj.GetComponent <OnlineIdentity>();

        onlineID.m_srcName = _prefab.name;
        onlineID.m_type    = OnlineIdentity.Type.Dynamic;
        onlineID.m_localPlayerAuthority = _playerID;
        return(newObj);
    }
Esempio n. 7
0
        //todo добавить на сервер ValidateMove, чтобы сначала вызвать его, потом клиентский Move, потом серверный Move

        public void Move(MoveContent move)
        {
            PlayerLock.GameLock = true;
            var primary = move.MovingPiecePrimary;

            OnlineManager.Move(primary.SrcPosition, primary.DstPosition, move.PawnPromotedTo);
        }
Esempio n. 8
0
    private void Awake()
    {
        if (serverButton != null)
        {
            serverButton.onClick.AddListener(() =>
            {
                OnlineManager.CreateServer();

                gameObject.SetActive(false);
                serverPanel.SetActive(true);
            });
        }

        if (clientButton != null)
        {
            clientButton.onClick.AddListener(() =>
            {
                if (OnlineManager.ConnectClient())
                {
                    gameObject.SetActive(false);
                    clientPanel.SetActive(true);
                }
            });
        }
    }
Esempio n. 9
0
 public void OnDestroy()
 {
     OnlineManager.OnOpponentMove  -= OnlineManagerOnOnOpponentMove;
     OnlineManager.OnEndGame       -= OnlineManagerOnEndGame;
     OnlineManager.OnSessionClosed -= OnlineManagerOnSessionClosed;
     OnlineManager.CloseConnection();
 }
Esempio n. 10
0
 private static void MakeSureOnlineIsReady([CanBeNull] Uri uri)
 {
     if (uri?.OriginalString.Contains(@"/online.xaml", StringComparison.OrdinalIgnoreCase) == true)
     {
         OnlineManager.EnsureInitialized();
     }
 }
Esempio n. 11
0
        /// <summary>
        ///     Returns a list of scores from multiplayer users
        /// </summary>
        /// <returns></returns>
        private static List <Score> GetScoresFromMultiplayerUsers()
        {
            var playingUsers = OnlineManager.OnlineUsers.ToList().FindAll(x =>
                                                                          OnlineManager.CurrentGame.PlayerIds.Contains(x.Key) &&
                                                                          !OnlineManager.CurrentGame.PlayersWithoutMap.Contains(x.Key) &&
                                                                          OnlineManager.CurrentGame.RefereeUserId != x.Key &&
                                                                          x.Value != OnlineManager.Self);

            var scores = new List <Score>();

            playingUsers.ForEach(x =>
            {
                scores.Add(new Score
                {
                    PlayerId      = x.Key,
                    SteamId       = x.Value.OnlineUser.SteamId,
                    Name          = x.Value.OnlineUser.Username,
                    Mods          = (long)OnlineManager.GetUserActivatedMods(x.Value.OnlineUser.Id),
                    IsMultiplayer = true,
                    IsOnline      = true
                });
            });

            return(scores);
        }
Esempio n. 12
0
    private void OnEnable()
    {
        var tmp = OnlineManager.GetSocketInfo();

        clientInfoUI.SetIpAndPort(tmp.LocalIpAddress.ToString(), tmp.LocalPort.ToString());
        connectedServerInfoUI.SetIpAndPort(tmp.RemoteIpAddress.ToString(), tmp.RemotePort.ToString());
    }
Esempio n. 13
0
    public virtual void Init()
    {
        networkManager = LogicManager.GetLogicComponent <NetworkManager>();
        onlineManager  = LogicManager.GetLogicComponent <OnlineManager>();

        networkManager.On(ServerEvents.CHAT_MSG, ReciveMessage);
    }
    private void Recv(byte[] _msg)
    {
        using (MemoryStream m = new MemoryStream(_msg))
        {
            using (BinaryReader w = new BinaryReader(m))
            {
                m_players.Clear();
                int count = w.ReadInt32();
                for (int i = 0; i < count; i++)
                {
                    Player          player    = new Player();
                    BinaryFormatter formatter = new BinaryFormatter();
                    try
                    {
                        player.m_endpoint = (EndPoint)formatter.Deserialize(m);
                    }
                    catch (SerializationException e)
                    {
                        OnlineManager.Log("Failed to deserialize. Reason: " + e.Message);
                    }
                    player.m_ID = w.ReadUInt32();
                    m_players.Add(player);
                }
            }
        }
        //Compute Local player ID
        int index = m_players.FindIndex(p => p.m_endpoint.Equals(OnlineManager.Instance.GetLocalEndpoint()));

        if (index >= 0)
        {
            m_localPlayerID = m_players[index].m_ID;
        }
    }
    void Update()
    {
        deltaTimeCumulative += Time.unscaledDeltaTime;
        totalTimeCumulative += Time.unscaledDeltaTime;

        if (!HasAuthority())
        {
            switch (m_smoothing)
            {
            case Smoothing.NoInterpolation:
            {
                transform.position = pos;
                transform.rotation = rot;
                break;
            }

            case Smoothing.Lerp:
            {
                if (SyncDeltaMax > m_LerpDelay)
                {
                    m_LerpDelay = SyncDeltaMax;
                    OnlineManager.Log("Warning : Lerp delay < sync frequency, will result in glitches");
                }
                LinearInterpolation();

                break;
            }
            }
        }
    }
Esempio n. 16
0
 // Start is called before the first frame update
 void Start()
 {
     if (OnlineManager.GetInstance() != null)
     {
         HostID.GetComponent <Text>().text = OnlineManager.GetInstance().user_number.ToString();
     }
 }
Esempio n. 17
0
        // 如果缓存中存在,则直接返回
        void publisher_Begin_ProcessMvc(object sender, MvcEventArgs e)
        {
            String cPath = e.ctx.url.Path;

            if (cPath.ToLower().IndexOf("/layouts/topnav/nav") >= 0)
            {
                if (e.ctx.web.UserIsLogin == false)
                {
                    OnlineManager.Refresh(e.ctx);

                    OnlineStats o          = OnlineStats.Instance;
                    String      onlineInfo = "{\"count\":" + o.Count + ",\"member\":" + o.MemberCount + ",\"guest\":" + o.GuestCount + ",\"max\":" + o.MaxCount + ",\"maxTime\":\"" + o.MaxTime.ToShortDateString() + "\"}";

                    String isSite   = cPath.IndexOf("/Layouts/") == 0 ? "true" : "false";
                    String connects = getConnectLinks();

                    //String json = "{\"viewer\":{\"obj\" :{\"Id\":0,\"Name\":\"guest\",\"Url\":\"\"},\"Id\":0,\"IsLogin\":false,\"IsAdministrator\":false,\"HasPic\":false}, \"owner\":{\"IsSite\":" + isSite + ", \"LoginValidImg\":" + config.Instance.Site.LoginNeedImgValidation.ToString().ToLower() + "},\"navInfo\":{\"topNavDisplay\":" + config.Instance.Site.TopNavDisplay + "}, \"online\":" + onlineInfo + "}";
                    String json = "{\"viewer\":{\"obj\" :{\"Id\":0,\"Name\":\"guest\",\"Url\":\"\"},\"Id\":0,\"IsLogin\":false,\"IsAdministrator\":false,\"HasPic\":false}, \"owner\":{\"IsSite\":" + isSite + ", \"LoginValidImg\":" + config.Instance.Site.LoginNeedImgValidation.ToString().ToLower() + "},\"navInfo\":{\"topNavDisplay\":" + config.Instance.Site.TopNavDisplay + "}, \"online\":" + onlineInfo + ", \"connects\":" + connects + "}";



                    e.ctx.RenderJson(json);
                    e.ctx.utils.end();
                    e.ctx.utils.skipRender();

                    return;
                }
            }
        }
Esempio n. 18
0
    // Start is called before the first frame update
    void Awake()
    {
        manager         = GameObject.Find("NetworkManager").GetComponent <OnlineManager>();
        fightController = GameObject.Find("FightContainer(Clone)").GetComponent <FightController>();
        uIController    = GameObject.Find("PlayerUI").GetComponent <PlayerUIController>();
        team            = GetComponent <PlayerTeamController>();

        uIController.SubscribeFightController(fightController);

        fightController.FightFinished += OnFightEnd;
        enemyEncounter = FightController.Enemy;


        if (isHost)
        {
            manager.StartServer();
            OnlinePlayer.ReceivedAck += OnHostReceivedAck;
        }
        else
        {
            manager.JoinServer();
            OnlinePlayer.ReceivedEncounter += OnClientReceivedEncounter;
        }
        OnlinePlayer.CastedSkill += OnCastedSkill;


        //player = NetworkClient.connection.identity.GetComponent<OnlinePlayer>();
        //Debug.Log("Started as " + player.name);
    }
Esempio n. 19
0
 public virtual void Init(MvcContext ctx)
 {
     if (ctx.utils.isEnd())
     {
         return;
     }
     OnlineManager.Refresh(ctx);
 }
Esempio n. 20
0
    private void OnEnable()
    {
        OnlineManager.StartServer();

        var tmp = OnlineManager.GetSocketInfo();

        serverInfoUI.SetIpAndPort(tmp.LocalIpAddress.ToString(), tmp.LocalPort.ToString());
    }
Esempio n. 21
0
 public ViewModel()
 {
     OnlineManager.EnsureInitialized();
     Entries = new BetterObservableCollection <ListEntry>(
         FileBasedOnlineSources.Instance.GetBuiltInSources().Select(x => new ListEntry(x, true)).Concat(
             FileBasedOnlineSources.Instance.GetUserSources().Select(x => new ListEntry(x, false))));
     FileBasedOnlineSources.Instance.Update += OnUpdate;
 }
Esempio n. 22
0
        /// <summary>
        ///     Exits the lobby and returns back to the main menu
        /// </summary>
        public void ExitToMenu() => Exit(() =>
        {
            if (OnlineManager.Connected)
            {
                OnlineManager.LeaveLobby();
            }

            return(new MenuScreen());
        });
        /// <summary>
        /// Handles the DoWork event of the backGetOnlineList control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DoWorkEventArgs"/> instance containing the event data.</param>
        private void backGetOnlineList_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                DataTable dt = OnlineManager.ListDataHubDatasetsWithSubscriptions();

                foreach (DataRow dr in dt.Rows)
                {
                    if (dr["IS_SUBSCRIBED"].ToString() == "Y")
                    {
                        if (dr["SERVICETYPE"].ToString().Equals("MAP", StringComparison.InvariantCultureIgnoreCase))
                        {
                            Bitmap b = null;
                            try
                            {
                                System.Net.WebRequest  request        = System.Net.WebRequest.Create(dr["THUMBNAIL_URL"].ToString());
                                System.Net.WebResponse response       = request.GetResponse();
                                System.IO.Stream       responseStream =
                                    response.GetResponseStream();
                                b = new Bitmap(responseStream);
                                int    w = 165; int h = 130;
                                int    borderx = 10; int bordery = 10;
                                Bitmap newImage = new Bitmap(w, h);
                                using (Graphics graphics = Graphics.FromImage(newImage))
                                {
                                    graphics.Clear(Color.White);
                                    int x = (newImage.Width - b.Width) / 2;
                                    int y = (newImage.Height - b.Height) / 2;
                                    graphics.DrawImage(b, new Rectangle(borderx, bordery, newImage.Width - 2 * borderx, newImage.Height - 2 * bordery), 0, 0, b.Width, b.Height, GraphicsUnit.Pixel);
                                }
                                b = newImage;
                            }
                            catch (Exception)
                            {
                            }

                            string id     = dr["ID"].ToString();
                            string name   = dr["NAME"].ToString();
                            string mapurl = dr["URL"].ToString();
                            lock (mylock)
                            {
                                DataRow dn = _BaseData.NewRow();
                                dn["ID"]        = id;
                                dn["NAME"]      = name;
                                dn["THUMBNAIL"] = b;
                                dn["MAP_URL"]   = mapurl;
                                _BaseData.Rows.Add(dn);
                            }
                            backGetOnlineList.ReportProgress(1);
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Esempio n. 24
0
 void Start()
 {
     Cam = GetComponent <Camera>();
     AS  = GetComponent <AudioSource>();
     //FFP = GameObject.FindWithTag("Information").GetComponent<Mirror.FizzySteam.FizzyFacepunch>();
     OM = GameObject.FindWithTag("Information").GetComponent <OnlineManager>();
     SceneManager.sceneLoaded += OnSceneLoaded;
     VC = GameObject.FindGameObjectWithTag("Volume").GetComponent <VolumeController>();
     SetScreen("Main");
 }
Esempio n. 25
0
 private void Awake()
 {
     onlineManager  = GameObject.FindGameObjectWithTag("OnlineController").GetComponent <OnlineManager>();
     gameController = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameController>();
     GameObject.Find("version").GetComponent <Text>().text = GameController.GameData.gamePlatform + "_" + GameController.GameData.gameVersion + "_" + GameController.GameData.gameBuildType;
     DontDestroyOnLoad(this);
     if (FindObjectsOfType(GetType()).Length > 1)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 26
0
 private void Awake()
 {
     Application.targetFrameRate = 60;
     uIManager     = GameObject.FindGameObjectWithTag("UIController").GetComponent <UIManager>();
     onlineManager = GameObject.FindGameObjectWithTag("OnlineController").GetComponent <OnlineManager>();
     DontDestroyOnLoad(this);
     if (FindObjectsOfType(GetType()).Length > 1)
     {
         Destroy(gameObject);
     }
 }
Esempio n. 27
0
        public void Prepare(OnlineManager onlineManager)
        {
            this.onlineManager = onlineManager;
            dataKeeper         = onlineManager.dataKeeper;
            dataKeeper.diagDataList.ListChanged += diagDataList_ListChanged;

            foreach (var valueInfo in dataKeeper.valueInfos)
            {
                chartsSet.Items.Add(valueInfo.Title);
            }
        }
Esempio n. 28
0
    private void LateUpdate()
    {
        if (OnlineManager.IsOwner(onlineID.PlayerOwner))
        {
            if (lastFramePosition != transform.position)
            {
                SendMSG();
            }
        }

        lastFramePosition = transform.position;
    }
Esempio n. 29
0
        /// <summary>
        /// </summary>
        public LobbyScreen()
        {
            CheckConnected();
            OnlineManager.JoinLobby();

            DiscordHelper.Presence.Details      = "Finding a Game";
            DiscordHelper.Presence.State        = "In the Multiplayer Lobby";
            DiscordHelper.Presence.EndTimestamp = 0;
            DiscordRpc.UpdatePresence(ref DiscordHelper.Presence);

            View = new LobbyScreenView(this);
        }
Esempio n. 30
0
    public void ReadMSG(byte[] msg)
    {
        if (OnlineManager.IsHost())
        {
            OnlineManager.SendMsg(msg);
        }

        if (!OnlineManager.IsOwner(onlineID.PlayerOwner))
        {
            Deserialize(msg);
        }
    }