public void ToggleState() { bool wasClosedEh = closedEh; SetState(!wasClosedEh); networkView.RPC("SetState", RPCMode.AllBuffered, !wasClosedEh); // note that the previous SetState will have toggled closedEh but not wasClosedEh }
internal void updateNSObjectSend(string uid, Vector3 position, Quaternion rotation) { if (Network.peerType != NetworkPeerType.Disconnected) { networkView.RPC("updateNSObjectSend_Remote", RPCMode.Others, uid, position, rotation); } }
public void LowKick() { if (game.OnlineGame && game.PlayerControlsMan) { NetworkView.RPC("Kick", RPCMode.Others, "LowKick"); } }
public void SendLoadLevel(int levelVal) { if (levelVal == (int)GameLeve.None || levelVal == (int)GameLeve.SetPanel || levelVal == (int)GameLeve.Waterwheel) { return; } if (GlobalData.GetInstance().gameLeve == (GameLeve)levelVal) { return; } MaxLinkServerCount = Network.connections.Length; RequestMasterServer.GetInstance().ResetIsClickConnect(); GlobalData.GetInstance().gameLeve = (GameLeve)levelVal; Debug.Log("SendLoadLevel -> levelVal = " + (GameLeve)levelVal); if (Network.peerType != NetworkPeerType.Disconnected) { netViewCom.RPC("SendLoadLevelMsgToOthers", RPCMode.OthersBuffered, levelVal); } /*if (Network.peerType == NetworkPeerType.Server) { * NetworkServerNet.GetInstance().RemoveMasterServerHost(); * if (MaxLinkServerCount == 0) { * MaxLinkServerCount = NoLinkClientCount; * } * }*/ //Application.LoadLevel(levelVal); //Application.LoadLevelAsync(levelVal); }
public void UpdateTimer() { if (timer > 0) { if (isDay) { Invoke("UpdateTimer", 1); timer--; } else { Invoke("UpdateTimer", 1); timer--; } } else { isDay = !isDay; timer = max; Invoke("UpdateTimer", 0); if (isDay) { networkview.RPC("SetDay", RPCMode.AllBuffered); } else { networkview.RPC("SetNight", RPCMode.AllBuffered); } } }
// called by server public void StartGame(int num_player) { netView.RPC("StartGame2", RPCMode.All, num_player); //max_player = num_player; //cur_player = 0; //StartTurn(cur_player+1); }
/// <summary> /// 发送将要加载的游戏场景信息. /// </summary> public void NetSendLoadLevel(int levelVal) { if (Network.peerType == NetworkPeerType.Server) { mNetViewCom.RPC("RpcSendLoadLevelMsg", RPCMode.AllBuffered, levelVal); } }
public void broadcastLine(string lineID, int slice, string structure, Vector3[] line) { if (Network.peerType != NetworkPeerType.Disconnected) { _networkView.RPC("RPC_broadcastLine", RPCMode.Others, lineID, slice, structure, line); } }
void CheckStats() { if (health > 0) { alive = true; boxCollider.enabled = true; for (int i = 0; i < childrenMeshRenderer.Count; i++) { childrenMeshRenderer[i].enabled = true; } } if (health <= 0) { alive = false; } if (!alive) { for (int i = 0; i < childrenMeshRenderer.Count; i++) { childrenMeshRenderer[i].enabled = false; } Network.Instantiate(explosion, new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity, 0); boxCollider.enabled = false; nView.RPC("Died", RPCMode.All, false); StartCoroutine(RespawnTime()); } }
// Lancer le jeu public void GUIStartGame() { if (Network.isServer) { nView.RPC("StartGame", RPCMode.All); } }
void SetCannonAimPlayerState() { int aimState = 0; // if (SpawnPointScript.PointType == SpawnPointType.KongZhong) { // aimState = 0; // } // else if (SpawnPointScript.PointType == SpawnPointType.DiMian) { // aimState = 1; // } // else { // if (SpawnPointScript.IsAimFeiJiPlayer) { // aimState = 2; // } // } SetCannonNpcInfo(aimState, SpawnPointScript.FireDistance); if (Network.peerType != NetworkPeerType.Server) { return; } if (Network.connections.Length <= 0 || NetworkServerNet.ServerSendState != 0) { return; } NetViewCom.RPC("XKHuoCheSendSetNpcAimPlayerState", RPCMode.OthersBuffered, aimState, SpawnPointScript.FireDistance); }
public void putObjectOnTopOf(GameObject that, GameObject there) { if (_main.location == Location.Assembler) { _networkView.RPC("RPC_putObjectOnTopOf", RPCMode.Others, that.name, there.name); } }
// Spawns a player over the network void SpawnPlayer(NetworkPlayer player) { string tempPlayerString = player.ToString(); int playerNumber = Convert.ToInt32(tempPlayerString); // Instanciate the new player over the network Transform spawnPoint = spawnPoints[UnityEngine.Random.Range(0, spawnPoints.Count - 1)]; while (Physics.OverlapSphere(spawnPoint.position, prefabs["Unit"].localScale.z).Length > 0) { spawnPoint.position += new Vector3(1f, 0, 1f); } Transform newPlayerTransform = (Transform)Network.Instantiate( prefabs["Unit"], spawnPoint.position, transform.rotation, playerNumber); // Get the new player's script playerScripts.Add(player, newPlayerTransform.GetComponent <Unit>()); NetworkView playerNetworkView = newPlayerTransform.networkView; playerNetworkView.RPC("SetPlayer", RPCMode.AllBuffered, player); // Give the player a weapon playerNetworkView.RPC("TakeWeapon", player, "RocketLauncher"); // Give the player a default weapon playerNetworkView.RPC("TakeWeapon", player, "Gun"); // Give the player a default weapon }
void StartGameS() { if (!running) { devicePairPlayer.RPC("StartGame", RPCMode.All, 1); } }
void OnConnectedToServer() { if (Network.isClient) { networkview.RPC("AddClient", RPCMode.Others, myId, "Armafia"); } }
void SendPlayerTransformInfo() { if (!IsHandleRpc) { return; } if (NetworkServerNet.ServerSendState != 0) { // Debug.Log("ServerSendState "+NetworkServerNet.ServerSendState); return; } if (!ScreenDanHeiCtrl.IsStartGame || XKTriggerOpenPlayerUI.IsActiveOpenPlayerUI) { // Debug.Log("IsStartGame "+ScreenDanHeiCtrl.IsStartGame // +", IsActiveOpenPlayerUI "+XKTriggerOpenPlayerUI.IsActiveOpenPlayerUI); return; } if (Network.peerType != NetworkPeerType.Server) { return; } NetViewCom.RPC("XKPlayerSendOtherTranformInfo", RPCMode.OthersBuffered, PlayerTran.position, PlayerTran.rotation); }
public void SetBool(string name, bool value) { if (netView != null) { netView.RPC("boolRPC", RPCMode.AllBuffered, name, (value) ? 1 : 0); } }
void FixedUpdate() { if (!IsHandlePlayer) { return; } if (!MoveCameraByPath.IsMovePlayer) { return; } if (GameCtrlXK.IsStopMoveAiPlayer) { return; } if (Network.peerType != NetworkPeerType.Disconnected) { if (PositionCur != PlayerTran.position) { PositionCur = PlayerTran.position; netView.RPC("SendAiPlayerPosToOther", RPCMode.OthersBuffered, PositionCur, mSpeed); } if (RotationCur != PlayerTran.rotation) { RotationCur = PlayerTran.rotation; netView.RPC("SendAiPlayerRotToOther", RPCMode.OthersBuffered, RotationCur); } } }
void FixedUpdate() { if (!IsNetControlPort) { //非主控制端. SynNetPosition(); SynNetRotation(); return; } if (Network.peerType == NetworkPeerType.Client || Network.peerType == NetworkPeerType.Server) { if (NetworkServerNet.GetInstance().mNetworkRootGame.ePlayerGameNetState == NetworkServerNet.PlayerGameNetType.GameBackMovie) { //游戏准备返回循环动画场景,无需继续同步信息! } else { //主控制端同步坐标. if (mNetPos != transform.position) { mNetPos = transform.position; mNetworkView.RPC("RpcNetSynPosition", RPCMode.Others, mNetPos); } //主控制端同步转向. if (mNetRot != transform.forward) { mNetRot = transform.forward; mNetworkView.RPC("RpcNetSynRotation", RPCMode.Others, mNetRot); } } } }
// Update is called once per frame void Update() { if (mNetworkView.isMine) { //if (Input.GetMouseButton(0)) //{ // Fire(); // _networkView.RPC("Fire", RPCMode.Others); //} if (Input.GetMouseButtonDown(0)) { //총알 발사. Fire(); mNetworkView.RPC("Fire", RPCMode.Others); // audio.clip = bulletSound; // audio.Play(); } if (Input.GetButtonDown("Fire1")) { Fire(); mNetworkView.RPC("Fire", RPCMode.Others); } transform.Rotate(Vector3.left * Time.deltaTime * mPlayerRotSpeed * Input.GetAxis("Mouse Y")); // transform.Rotate(Vector3.up * Time.deltaTime * mPlayerRotSpeed * Input.GetAxis("Mouse X")); } else { // transform.position = currPos; transform.rotation = Quaternion.Slerp(transform.rotation, currRot, Time.deltaTime * 10.0f); } }
private void mover(Vector3 target) { float distaciapunto = 0.5f; CharacterController controller = GetComponent <CharacterController> (); if (Vector3.Distance(new Vector3(target.x, transform.position.y, target.z), transform.position) > distaciapunto && movimiento) { Quaternion rotacion = Quaternion.LookRotation(new Vector3(target.x, transform.position.y, target.z) - transform.position); transform.rotation = Quaternion.Slerp(transform.rotation, rotacion, 6.0f * Time.deltaTime); moveDirection = new Vector3(0, 0, 1); moveDirection = transform.TransformDirection(moveDirection); moveDirection *= speed; animator.SetFloat("speed", 1.0f); if (Application.loadedLevelName != "introduccion") { nw.RPC("activarCaminar", RPCMode.AllBuffered, 1.0f); } } else { moveDirection = Vector3.zero; animator.SetFloat("speed", 0.0f); if (Application.loadedLevelName != "introduccion") { nw.RPC("activarCaminar", RPCMode.AllBuffered, 0.0f); } } moveDirection.y -= gravity * Time.deltaTime; controller.Move(moveDirection * Time.deltaTime); }
private void GetBallsInMotion(NetworkMessageInfo info) { for (int i = 0; i < BallsInMotion.Count; i++) { GameObject _ball = BallsInMotion[i]; mNetworkView.RPC("ReceiveBallsInMotion", info.sender, (int)_ball.GetComponent <DodgeBall>().mBallType, _ball.GetComponent <Rigidbody>().velocity, _ball.transform.position, _ball.transform.rotation, _ball.GetComponent <DodgeBall>().Owner); } }
IEnumerator ValidatePosition() { while (true) { networkView.RPC("ClientReceivePosition", RPCMode.Others, transform.position); yield return(new WaitForSeconds(validationPeriod)); } }
public void OnclickGameStartBtn() { _netWorkView.RPC("BroadcastStart", RPCMode.All); clicount = (Network.connections.Length) + 1; allPlayer = clicount; StartCoroutine(this.RanInfect()); }
public void LoadServerGame() { OnlineGame = true; controlMan = false; controlCroco = true; Debug.Log("Loading server game... " + controlMan); NetworkView.RPC("LoadClientGame", RPCMode.Others, !controlMan); StartLevel("Tutorial"); }
public void SetObjType(string type) { tag = type; transform.parent = GameCtrlXK.MissionCleanup; if (Network.peerType != NetworkPeerType.Disconnected && netView != null) { netView.RPC("SendSetDaoJuObjType", RPCMode.OthersBuffered); } }
/// <summary> /// Transfer all data by a combined string. /// </summary> /// <param name="data"> Dynamic length of any object type data </param> public void DataTransfer(string data) { transferedData = data; if (Network.connections.Length > 0) { view.RPC("DataReceive", RPCMode.OthersBuffered, transferedData); Debug.Log("Transfer: " + transferedData); } }
//[RPC] //public void UpdateQuantity(int i) { //quantity += i; //Debug.Log("Quantity: " + quantity); //} // SetUsername - Changes a player's username across the network. [RPC] public void SetUsername(string name) { nametag.GetComponent <TextMesh>().text = name; if (netView.isMine) { netView.RPC("SetUsername", RPCMode.OthersBuffered, name); // Buffered means anyone who joins later will see the change. } }
public void OnGUI() { if (Network.peerType == NetworkPeerType.Disconnected) { //We are currently disconnected: Not a client or host GUILayout.Label("Cliente desconectado."); connectToIP = GUILayout.TextField(connectToIP, GUILayout.MinWidth(100)); connectPort = int.Parse(GUILayout.TextField(connectPort.ToString())); playerName = GUILayout.TextField(playerName, GUILayout.MinWidth(100)); GUILayout.BeginVertical(); if (GUILayout.Button("Connectar no servidor")) { //Connect to the "connectToIP" and "connectPort" as entered via the GUI //Ignore the NAT for now Network.useNat = false; Network.Connect(connectToIP, connectPort); } GUILayout.EndVertical(); } else { if (Network.peerType == NetworkPeerType.Connecting) { GUILayout.Label("Conectando..."); } else if (Network.peerType == NetworkPeerType.Client) { GUILayout.Label("Cliente Connectado com sucesso!"); //GUILayout.Label("idPlayer: " + idPlayer); GUILayout.Label("NomeSala: " + idSala); GUILayout.Label("NomeJogador: " + playerName); //GUILayout.Label("Ping: " + Network.GetAveragePing(Network.connections[0])); if (GUILayout.Button("Desconectar")) { netWorkView.RPC("ShowText", RPCMode.All, "", "O jogador " + playerName + " desconectou!"); Network.Disconnect(200); } if (GUILayout.Button("Clear")) { chatEntries.Clear(); } textChat = GUILayout.TextField(textChat, GUILayout.MinWidth(100)); foreach (string tx in chatEntries) { GUILayout.Label(tx); } } } }
protected void Update() { if (Network.isServer && _state != MatchState.Ended) { MatchState previousState = _state; int team1Count = TeamHelper.GetPlayersCountInTeam(1); int team2Count = TeamHelper.GetPlayersCountInTeam(2); // Checks if there is missing players if ((team1Count < NumberOfPlayersRequiredInTeam || team2Count < NumberOfPlayersRequiredInTeam) && !BypassWaiting) { // If so, set the state to Waiting for players _state = MatchState.WaitingForPlayers; } else { _state = MatchState.Running; // Otherwise increases the timer _timeElapsed += Time.deltaTime; _networkView.RPC("SetTimer", RPCMode.OthersBuffered, _timeElapsed); // If the time allotted for the game is elapsed, ended the match if (_timeElapsed > MaxTime && false) // enless matches, edited by Damien { _state = MatchState.Ended; // Figures which team has won int team1Kills = _registeredKills[1]; int team2Kills = _registeredKills[2]; if (team1Kills > team2Kills) { _resultState = MatchResultState.Victory_Team1; } else if (team2Kills > team1Kills) { _resultState = MatchResultState.Victory_Team2; } else { _resultState = MatchResultState.Draw; } // Updates the clients' MatchResultState _networkView.RPC("SetMatchResultState", RPCMode.OthersBuffered, (int)_resultState); } } if (previousState != _state) { // Updates the clients' MatchState _networkView.RPC("SetMatchState", RPCMode.OthersBuffered, (int)_state); } } }