static PhotonNetwork() { MAX_VIEW_IDS = 1000; PhotonServerSettings = (ServerSettings)Resources.Load("PhotonServerSettings", typeof(ServerSettings)); precisionForVectorSynchronization = 9.9E-05f; precisionForQuaternionSynchronization = 1f; precisionForFloatSynchronization = 0.01f; InstantiateInRoomOnly = true; logLevel = PhotonLogLevel.ErrorsOnly; UsePrefabCache = true; PrefabCache = new Dictionary <string, GameObject>(); isOfflineMode = false; offlineModeRoom = null; UseNameServer = true; _mAutomaticallySyncScene = false; m_autoCleanUpPlayerObjects = true; autoJoinLobbyField = true; sendInterval = 50; sendIntervalOnSerialize = 100; m_isMessageQueueRunning = true; lastUsedViewSubId = 0; lastUsedViewSubIdStatic = 0; manuallyAllocatedViewIds = new List <int>(); Application.runInBackground = true; GameObject gameObject = new GameObject(); photonMono = gameObject.AddComponent <PhotonHandler>(); gameObject.name = "PhotonMono"; gameObject.hideFlags = HideFlags.HideInHierarchy; networkingPeer = new NetworkingPeer(photonMono, string.Empty, Guardian.Networking.NetworkHelper.Connection.Protocol); CustomTypes.Register(); }
public void Initialize() { CustomTypes.Register(); PhotonServer.OnStateChangeAction += OnStateChanged; PhotonServer.OnEventAction += OnEventAction; PhotonServer.OnOpResponseAction += OnOperationResponse; }
private void Awake() { this.LoadGlobalConfig(); CustomTypes.Register(); this.MyRaceType = RaceType.Terran; }
static PhotonNetwork() { #if UNITY_EDITOR if (!UnityEditor.EditorApplication.isPlaying || !UnityEditor.EditorApplication.isPlayingOrWillChangePlaymode) { return; } // This can happen when you recompile a script IN play made // This helps to surpress some errors, but will not fix breaking bool doubleInstall = false; GameObject pGO = GameObject.Find("PhotonMono"); doubleInstall = pGO != null; if (doubleInstall) { GameObject.Destroy(pGO); Debug.LogWarning("The Unity recompile forced a restart of UnityPhoton!"); } #endif Application.runInBackground = true; // Set up a MonoBheaviour to run Photon, and hide it. GameObject photonGO = new GameObject(); photonMono = (PhotonHandler)photonGO.AddComponent <PhotonHandler>(); photonGO.name = "PhotonMono"; photonGO.hideFlags = UnityEngine.HideFlags.HideInHierarchy; // Set up the NetworkingPeer. // TODO: Add parameter for custom(ers) client version (being v1.0 now) networkingPeer = new NetworkingPeer(photonMono, "Guest " + UnityEngine.Random.Range(1, 9999), "v1.0", ExitGames.Client.Photon.ConnectionProtocol.Udp); networkingPeer.LimitOfUnreliableCommands = 20; // Local player CustomTypes.Register(); }
void Start() { Application.runInBackground = true; CustomTypes.Register(); this.GameInstance = new DemoGame(); this.GameInstance.MasterServerAddress = "app.exitgamescloud.com:5055"; this.GameInstance.ConnectToMaster("<insert your app id here>", "1.0", "unityPlayer"); }
static PhotonNetwork() { Application.runInBackground = true; GameObject obj2 = new GameObject(); photonMono = obj2.AddComponent <PhotonHandler>(); obj2.name = "PhotonMono"; obj2.hideFlags = HideFlags.HideInHierarchy; networkingPeer = new NetworkingPeer(photonMono, string.Empty, ConnectionProtocol.Udp); CustomTypes.Register(); }
static PhotonNetwork() { Application.runInBackground = true; GameObject gameObject = new GameObject(); photonMono = gameObject.AddComponent <PhotonHandler>(); gameObject.name = "PhotonMono"; gameObject.hideFlags = HideFlags.HideInHierarchy; networkingPeer = new NetworkingPeer(photonMono, string.Empty, Anarchy.Network.NetworkSettings.ConnectProtocol); CustomTypes.Register(); }
static PhotonNetwork() { Application.runInBackground = true; var obj2 = new GameObject(); photonMono = obj2.AddComponent <PhotonHandler>(); obj2.name = "PhotonMono"; obj2.hideFlags = HideFlags.HideInHierarchy; networkingPeer = new NetworkingPeer(photonMono, String.Empty, Settings.ConnectionProtocolSettings == 0 ? ConnectionProtocol.Udp : Settings.ConnectionProtocolSettings == 1 ? ConnectionProtocol.Tcp : ConnectionProtocol.WebSocket); CustomTypes.Register(); }
void Start() { Application.runInBackground = true; CustomTypes.Register(); this.GameInstance = new DemoGame(); this.GameInstance.MasterServerAddress = "localhost:5055"; this.GameInstance.AppId = this.AppId; // edited in Inspector! this.GameInstance.AppVersion = "1.0"; this.GameInstance.NickName = "unityPlayer"; this.GameInstance.Connect(); }
public Rect leftToolbar; // set in inspector to position the lobby screen public void Start() { Application.runInBackground = true; CustomTypes.Register(); leftToolbar = new Rect(leftToolbar.x, leftToolbar.y, leftToolbar.width, Screen.height - leftToolbar.y); this.GameInstance = new DemoGame(); this.GameInstance.AppId = this.AppId; // set in Inspector this.GameInstance.AppVersion = "1.0"; this.GameInstance.PlayerName = !string.IsNullOrEmpty(NamepickerGui.NickName) ? NamepickerGui.NickName : "unityPlayer"; this.GameInstance.OnStateChangeAction += this.OnStateChanged; this.GameInstance.ConnectToRegionMaster("EU"); // Turnbased games have to use this connect via Name Server }
public void Start() { Application.runInBackground = true; CustomTypes.Register(); leftToolbar = new Rect(leftToolbar.x, leftToolbar.y, leftToolbar.width, Screen.height - leftToolbar.y); this.GameInstance = new DemoGame(); this.GameInstance.AppId = this.AppId; // set in Inspector this.GameInstance.AppVersion = "1.0"; this.GameInstance.PlayerName = !string.IsNullOrEmpty(NamepickerGui.NickName) ? NamepickerGui.NickName : "unityPlayer"; this.GameInstance.OnStateChangeAction += this.OnStateChanged; playfabComponent.LoginToPlayFab(); }
void Start() { if (string.IsNullOrEmpty(this.AppId)) { Debug.LogError("AppId not set! Edit GameObject 'Scripts', 'Demo GUI', AppId first."); Debug.Break(); } Application.runInBackground = true; CustomTypes.Register(); this.GameInstance = new DemoGame(); this.GameInstance.AppId = this.AppId; // edited in Inspector! this.GameInstance.AppVersion = "1.0"; this.GameInstance.NickName = "unityPlayer"; this.GameInstance.ConnectToRegionMaster("eu"); }
void Start() { if (string.IsNullOrEmpty(this.AppId)) { Debug.LogError("AppId not set! Edit GameObject 'Scripts', 'Demo GUI', AppId first."); Debug.Break(); } Application.runInBackground = true; CustomTypes.Register(); this.GameInstance = new DemoGame(); this.GameInstance.MasterServerAddress = "app-eu.exitgamescloud.com:5055"; this.GameInstance.AppId = this.AppId; // edited in Inspector! this.GameInstance.AppVersion = "1.0"; this.GameInstance.PlayerName = "unityPlayer"; this.GameInstance.Connect(); }
public override void NetInitHandler(NetInit data) { base.NetInitHandler(data); PlayFab.PlayFabSettings.TitleId = TitleId; ClientStateRP = new ReactiveProperty <ClientState> (ClientState.Uninitialized); RefreshNetInfo("请输入 CustomId 进行登录"); Application.runInBackground = true; CustomTypes.Register(); Client = new EPokerClient(this); Client.AppId = AppId; Client.AppVersion = AppVersion; Client.OnStateChangeAction += this.OnStateChanged; Observable.EveryUpdate().Subscribe(_ => { Client.Service(); }).AddTo(this.gameObject); }
public void Awake() { if (string.IsNullOrEmpty(this.AppId)) { Debug.LogError("You must enter your AppId from the Dashboard in the component: Scripts, MemoryGui, AppId before you can use this demo."); Debug.Break(); } Application.runInBackground = true; CustomTypes.Register(); this.GameClientInstance = new MemoryGameClient(); this.GameClientInstance.memoryGui = this; this.GameClientInstance.AppId = this.AppId; // set in Inspector this.GameClientInstance.AppVersion = "1.0"; board = this.GetComponentInChildren <MemoryBoard>(); board.GameClientInstance = this.GameClientInstance; GameClientInstance.board = board; board.MemoryGui = this; this.DisableButtons(); }
public void Awake() { if (string.IsNullOrEmpty(this.AppId)) { Debug.LogError("AppId not set!"); Debug.Break(); } Application.runInBackground = true; CustomTypes.Register(); gameManager = GetComponent <GameManager>(); this.gameClient = new CitadelsGameClient(); this.gameClient.MasterServerAddress = "app-eu.exitgamescloud.com:5055"; this.gameClient.AppId = this.AppId; // edited in Inspector! this.gameClient.AppVersion = "1.0"; this.gameClient.PlayerName = "unityPlayer"; this.gameClient.citadelsGUI = this; this.gameClient.gameManager = gameManager; this.gameClient.Connect(); nameField.text = PlayerPrefs.GetString("PlayerName", ""); }
void Awake() { Application.runInBackground = true; //防止后台掉线 CustomTypes.Register(); _client = new PhotonClient(); _client.AppId = "49395063-2a0e-4e1f-a35d-3d4600790bc2"; //Turnbased 的 ID //_client.AppId="bc31b098-957d-4231-9ad5-b75adc3c6fb7";// RealTime 的ID bool connectInProcess = _client.ConnectToRegionMaster("asia"); _go_GuessBricks = GameObject.Find("GuessBricks").transform; MyDock = GameObject.Find("DockD").transform; PickPop = GameObject.Find("PickPop").transform; _planet = GameObject.Find("Planet"); _table = _planet.transform.GetChild(0).gameObject; _unOccupied = _table.transform.GetChild(5).gameObject; //--------------找到UI元素------------ Notify = GetComponent <Notification>(); Panel = GameObject.Find("Panel").transform; StartBtn = GameObject.Find("Start").transform; _canvas = GameObject.Find("Canvas"); _winBanner = GameObject.Find("Win").transform; _panel = GameObject.Find("Panel"); _readyPanel = GameObject.Find("ReadyPanel"); _overPanel = GameObject.Find("OverPanel"); DoneBtn = GameObject.Find("AdjustDone").transform; CancelBtn = GameObject.Find("Cancel").transform; ContinueBtn = GameObject.Find("ContinueGuess").transform; _loading = GameObject.Find("Loading").transform; //----------------------- if (GameControl._instance == null) { GameControl._instance = this; } DontDestroyOnLoad(gameObject); #region 注册UI事件 GameObject.Find("Create").GetComponent <Button>().onClick.AddListener( () => { if (_roomName != "") { _client.OpCreateRoom(_roomName, new RoomOptions() { MaxPlayers = _playerNum }, TypedLobby.Default); } }); GameObject.Find("Join").GetComponent <Button>().onClick.AddListener( () => { if (_roomName != "") { _client.OpJoinRoom(_roomName); } }); GameObject.Find("PlayerNum").GetComponent <Dropdown>().onValueChanged .AddListener(x => { _playerNum = (byte)(x + 2); }); GameObject.Find("RoomName").GetComponent <InputField>().onValueChanged .AddListener(x => { _roomName = x; }); GameObject.Find("Leave").GetComponent <Button>().onClick.AddListener( () => { //销毁玩家头像 foreach (var icon in _playerIcons) { Destroy(icon.gameObject); } _playerIcons.Clear(); //通知其他人 我离开了 _client.OpRaiseEvent(MyEventCode.OneLeave, _myID, true, RaiseEventOptions.Default); _client.OpLeaveRoom(false); _overPanel.SetActive(false); _panel.SetActive(true); }); GameObject.Find("Again").GetComponent <Button>().onClick.AddListener( () => { //currentID 为自己 CurrentID = _myID; //重新设置玩家头像的parent for (int i = 0; i < _playerNum; i++) { var icon = _playerIcons[i]; icon.SetParent(_readyPanel.transform); } //自己的头像放到readypos 并且通知别人 //playerIcons readyPos的顺序和id一样 注意ID从1 开始 var myIcon = _playerIcons[_myID - 1]; AnimElement.Prepare() .InitUGUI(myIcon.localPosition, readyPos[_myID - 1], myIcon, 0, 40) .AddScaleAnimation(myIcon.localScale, Vector3.one * 0.6f) .Play(); _client.OpRaiseEvent(MyEventCode.OnePlayAgain, _myID, true, RaiseEventOptions.Default); //载入等待面板 _overPanel.SetActive(false); _readyPanel.SetActive(true); EnterRoom(_playerNum); }); //房主开始游戏 GameObject.Find("Start").GetComponent <Button>().onClick.AddListener( () => { //洗牌 ShuffleDeck(); //----------------------------- //把所有的牌发送给其他玩家 //----------------------- _client.OpRaiseEvent(MyEventCode.SyncAllBricks, indexMap, true , RaiseEventOptions.Default); //放置牌到桌子上 PlaceAllBricksOnTable(indexMap); StartGame(); }); // 完成 按钮的点击逻辑 DoneBtn.GetComponent <Button>().onClick.AddListener(() => { // 玩家确认完成Adjust过程中的joker放置后 点击 if (GameState.Instance.CurrentState == GameState.State.Adjust) { //通知其他玩家在逻辑层更新我的Joker位置 int msgType = 0; int[] msg = new int[4]; msg[0] = _myID; if (_decks[_myDeckIndex].Contains(_jokerWhite)) { msgType = -1; msg[2] = _decks[_myDeckIndex].IndexOf(_jokerWhite); } if (_decks[_myDeckIndex].Contains(_jokerBlack)) { msgType = -msgType; msg[3] = _decks[_myDeckIndex].IndexOf(_jokerBlack); } msg[1] = msgType; _client.OpRaiseEvent(MyEventCode.SyncJoker, msg, true, RaiseEventOptions.Default); // LocalReadyToGo(); //隐藏所有arrows for joker _jokerBlack.GetComponent <Brick>().DestroyArrows(); _jokerWhite.GetComponent <Brick>().DestroyArrows(); } // 每一round中抽到joker的玩家确认完成joker的放置后点击 else if (GameState.Instance.CurrentState == GameState.State.PlacingJoker) { //进入Guess状态 GameState.Instance.CurrentState = GameState.State.GuessABrick; //视觉提示 让我猜牌 Notify.autoNtf("请猜牌", Vector2.zero, new Vector2(1, 1), 1); //隐藏所有arrows for joker _jokerBlack.GetComponent <Brick>().DestroyArrows(); _jokerWhite.GetComponent <Brick>().DestroyArrows(); } else if (GameState.Instance.CurrentState == GameState.State.GuessingABrick) { //不猜了 轮到下一个玩家 ToNextOne(); //隐藏按钮 ContinueBtn.gameObject.SetActive(false); DoneBtn.gameObject.SetActive(false); //切换状态 GameState.Instance.CurrentState = GameState.State.WaitForOthers; } DoneBtn.gameObject.SetActive(false); }); //取消猜牌按钮的点击逻辑 CancelBtn.GetComponent <Button>().onClick.AddListener(() => { CancelBtn.gameObject.SetActive(false); //隐藏所有PossibleBrick HidePossibleBricks(); //状态回到GuessABrick GameState.Instance.CurrentState = GameState.State.GuessABrick; }); //继续猜 ContinueBtn.GetComponent <Button>().onClick.AddListener(() => { GameState.Instance.CurrentState = GameState.State.GuessABrick; ContinueBtn.gameObject.SetActive(false); DoneBtn.gameObject.SetActive(false); }); #endregion //----初始化UI状态---------- _readyPanel.SetActive(false); DoneBtn.gameObject.SetActive(false); CancelBtn.gameObject.SetActive(false); ContinueBtn.gameObject.SetActive(false); Panel.gameObject.SetActive(false); StartBtn.gameObject.SetActive(false); _overPanel.SetActive(false); //-------------------------------------- }