Beispiel #1
0
    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
    }
Beispiel #2
0
 internal void updateNSObjectSend(string uid, Vector3 position, Quaternion rotation)
 {
     if (Network.peerType != NetworkPeerType.Disconnected)
     {
         networkView.RPC("updateNSObjectSend_Remote", RPCMode.Others, uid, position, rotation);
     }
 }
Beispiel #3
0
 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);
         }
     }
 }
Beispiel #6
0
 // 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);
     }
 }
Beispiel #8
0
 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);
     }
 }
Beispiel #9
0
    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());
        }
    }
Beispiel #10
0
 // 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);
    }
Beispiel #12
0
 public void putObjectOnTopOf(GameObject that, GameObject there)
 {
     if (_main.location == Location.Assembler)
     {
         _networkView.RPC("RPC_putObjectOnTopOf", RPCMode.Others, that.name, there.name);
     }
 }
Beispiel #13
0
    // 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
    }
Beispiel #14
0
 void StartGameS()
 {
     if (!running)
     {
         devicePairPlayer.RPC("StartGame", RPCMode.All, 1);
     }
 }
Beispiel #15
0
 void OnConnectedToServer()
 {
     if (Network.isClient)
     {
         networkview.RPC("AddClient", RPCMode.Others, myId, "Armafia");
     }
 }
Beispiel #16
0
    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);
    }
Beispiel #17
0
 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);
            }
        }
    }
Beispiel #19
0
    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);
                }
            }
        }
    }
Beispiel #20
0
    // 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);
        }
    }
Beispiel #21
0
    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);
     }
 }
Beispiel #23
0
 IEnumerator ValidatePosition()
 {
     while (true)
     {
         networkView.RPC("ClientReceivePosition", RPCMode.Others, transform.position);
         yield return(new WaitForSeconds(validationPeriod));
     }
 }
Beispiel #24
0
    public void OnclickGameStartBtn()
    {
        _netWorkView.RPC("BroadcastStart", RPCMode.All);
        clicount = (Network.connections.Length) + 1;

        allPlayer = clicount;

        StartCoroutine(this.RanInfect());
    }
Beispiel #25
0
 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);
     }
 }
Beispiel #27
0
 /// <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.
        }
    }
Beispiel #29
0
    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);
                }
            }
        }
    }
Beispiel #30
0
        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);
                }
            }
        }