Exemple #1
0
 public float[] GetMyTeamHP(NetworkPlayer me, out int team)
 {
     //if(team == 0) {
     for(int i=0; i<m_teamOnePlayers.Count; i++) {
         //Debug.Log ("Running through team");
         if(m_teamOnePlayers[i] == me) {
             team = 0;
             float[] temp = m_teamOneHealth.ToArray();
             temp[0] = m_teamOneHealth[i];
             temp[i] = m_teamOneHealth[0];
             return temp;
         }
     }
     //}
     //if(team == 1) {
     for(int i=0; i<m_teamTwoPlayers.Count; i++) {
         if(m_teamTwoPlayers[i] == me) {
             team = 1;
             float[] temp = m_teamTwoHealth.ToArray();
             temp[0] = m_teamTwoHealth[i];
             temp[i] = m_teamTwoHealth[0];
             return temp;
         }
     }
     //}
     team = -1;
     return null;
 }
	void OnPlayerDisconnected(NetworkPlayer player)
	{
		//if player disconnects destroy its last player 
		Debug.Log ("player disconected from: " + player.ipAddress + ":" + player.port);
		Network.RemoveRPCs (player);
		Network.DestroyPlayerObjects (player);
	}
Exemple #3
0
    /// <summary>
    /// Called by UserManagementObjectController on the server whenever a new player has successfully connected.
    /// </summary>
    /// <param name="player">Newly connected player</param>
    /// <param name="isClient">True if Client connected</param>
    public void AddNewPlayer(NetworkPlayer player,bool isClient)
    {
        if (!networkPlayerMap.ContainsKey(player))
        {

            int playerCounter = 1;
            while (networkPlayerMap.ContainsValue("player" + System.Convert.ToString(playerCounter)))
            {
                playerCounter++;
            }

            Debug.Log("UserManager Unity player " + player.ToString() + "added as UserManager player" + System.Convert.ToString(playerCounter));
            networkPlayerMap.Add(player,"player" + System.Convert.ToString(playerCounter));

            if(isClient)
            {
                Debug.Log("RPC Call setname sent to player"+System.Convert.ToString(playerCounter));
                GameObject.Find("GUIObj").networkView.RPC("setName", player, "player" + System.Convert.ToString(playerCounter));
            }
            else
            {
                Debug.Log("Server setname sent to player"+System.Convert.ToString(playerCounter));
                GameObject.Find("GUIObj").GetComponent<MobileNetworkGUI>().setName("player" + System.Convert.ToString(playerCounter));
            }
        }
    }
    public GameObject NetworkServerSpawn(NetworkPlayer owner, Vector3 direction)
    {
        Vector3 position = transform.position + direction + new Vector3(0,0.5f,0);

        // instantiate a local copy of the object
        GameObject clone = (GameObject)GameObject.Instantiate(projectilePrefab, position, Quaternion.identity);

        clone.rigidbody.AddForce(direction * force, ForceMode.Impulse);

        if (clone.collider)
        {
            Collider parentCollider = transform.parent.parent.collider;
            Physics.IgnoreCollision(parentCollider, clone.collider);
        }

        clone.networkView.viewID = Network.AllocateViewID();

        // plant a component on the prefab to send us callbacks
        // we need to know when this object is destroyed
        NetworkOwnedPrefab handle = clone.AddComponent<NetworkOwnedPrefab>();
        handle.owner = this;

        living.Add(clone);

        networkView.RPC("NetworkClientSpawn", RPCMode.OthersBuffered, owner, clone.networkView.viewID, position);

        // call the builtin OnNetworkInstantiate
        clone.SendMessage("OnNetworkInstantiate", new NetworkMessageInfo());

        return clone;
    }
    void DisconnectPlayer(NetworkPlayer player)
    {
        if(Network.isClient)
        {
            Debug.Log("Player Disconnected: " + player.ToString());
        }

        // now we have to do the reverse lookup from
        // the NetworkPlayer --> GameObject
        // this is easy with the Hashtable

        if(players.ContainsKey(player))
        {
            // we check to see if the gameobject exists
            // or not first just as a safety measure
            // trying to destory a gameObject that
            // doesn't exist causes a runtime error

            if((GameObject)players[player]) {
                Destroy((GameObject)players[player]);
            }

            // we also have to remove the Hashtable entry

            players.Remove(player);
        }
    }
    public void callSong(NetworkPlayer player, string name, string subtitle, int step, int difficulty, int level)
    {
        if(!isSearching)
        {
            var theSIP = new SongInfoProfil(name, subtitle, step, (Difficulty)difficulty, level);
            if(lastSongChecked.Equals(default(KeyValuePair<Difficulty, Dictionary<Difficulty, Song>>)) || !lastSongChecked.Value[lastSongChecked.Key].sip.CompareId(theSIP))
            {
                for(int i=0; i < LANManager.Instance.players.Count; i++)
                {
                    LANManager.Instance.players.ElementAt(i).Value.songChecked = 0;
                }
                isSearching = true;
                networkView.RPC("setSearching", RPCMode.Others, true);
                networkView.RPC ("checkSong", RPCMode.Others, name, subtitle, step, difficulty, level);
                playerSearching = player;
                lastSongChecked = LoadManager.Instance.FindSong(theSIP);
                LANManager.Instance.players[Network.player].songChecked = lastSongChecked.Equals(default(KeyValuePair<Difficulty, Dictionary<Difficulty, Song>>)) ? 2 : 1;

            }else
            {
                isSearching = true;
                playerSearching = player;
            }

        }
    }
    void PlayerSwap(int newMode, NetworkPlayer player)
    {
        // find the player
        foreach (PlayerInfo p in nvs.players)
        {
            if (p.player==player) {
                p.currentMode = newMode;
                if (p.currentMode==0) {			// if they're now in a buggy
                    // set them in buggy
                    p.characterGameObject.transform.parent = p.cartGameObject.transform;
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,0);
                    p.characterGameObject.transform.rotation = p.cartGameObject.transform.rotation;
                    // unlock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.None;
                    // change animation
                    p.characterGameObject.transform.FindChild("lil_patrick").animation.Play("driveIdle",PlayMode.StopAll);

                } else if (p.currentMode==1) {	// if they're now at golf ball
                    // set them at golf ball
                    p.characterGameObject.transform.parent = p.ballGameObject.transform;
                    p.ballGameObject.transform.rotation = Quaternion.identity;		// reset rotation to make it nice
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,-2);
                    p.characterGameObject.transform.rotation = Quaternion.identity;
                    // lock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
                    // change animation
                    p.characterGameObject.transform.FindChild("lil_patrick").animation.Play("golfIdle",PlayMode.StopAll);
                }

                // reset keyboard buffer
                p.h = 0f;
                p.v = 0f;
            }
        }
    }
 PlayerData GeneratePlayerData(NetworkPlayer player)
 {
     PlayerData newPlayer = new PlayerData();
     newPlayer.player = player;
     newPlayer.team = -1;
     return newPlayer;
 }
Exemple #9
0
 public void deletePlayer(NetworkPlayer player)
 {
     GameObject go = (GameObject) players[player];
     Network.RemoveRPCs(go.networkView.viewID);
     Network.Destroy(go);
     players.Remove(player);
 }
 void PlayerWantToMoveRight(NetworkPlayer p)
 {
     if (Network.isServer)
     {
         _myNetworkView.RPC("PlayerWantToMoveRight", RPCMode.Others, p);
     }
 }
Exemple #11
0
    void OnPlayerDisconnected(NetworkPlayer player)
    {
        //Debug.Log("Clean up after player " + player);

        foreach(CurrentPlayer script in playerScripts){
            if(player == script.owner){//We found the players object
                Network.RemoveRPCs(script.gameObject.networkView.viewID);//remove the bufferd SetPlayer call
                Network.Destroy(script.gameObject.networkView.viewID);//Destroying the GO will destroy everything
                playerList.Remove(script.owner);
                playerScripts.Remove(script);//Remove this player from the list

                break;
            }
        }

        //Remove the buffered RPC call for instantiate for this player.
        int playerNumber = int.Parse(player+"");
        Network.RemoveRPCs(player , 1);
        //Debug.Log(playerNumber);

        // The next destroys will not destroy anything since the players never
        // instantiated anything nor buffered RPCs
        //Network.RemoveRPCs(player);
        Network.DestroyPlayerObjects(player);
    }
Exemple #12
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     Debug.Log("Server destroying player");
     enabled = false;
     Network.RemoveRPCs(player, 0);
     Network.DestroyPlayerObjects(player);
 }
Exemple #13
0
    private void RPCSetUserView(NetworkPlayer nwid, string nick, int uid, string photo, int tk, int td, int tzk, int tzd)
    {

        CallRPC(true, localuser.nwid, localuser.nick, localuser.uid, localuser.photo, tk, td, tzk, tzd);
        if (nwid == Network.player) return;

        z0Vk.user user = new z0Vk.user();
        user.nick = nick;
        user.uid = uid;
        user.photo = photo;
        user.nwid = nwid;
        user.totalkills = tk;
        user.totaldeaths = td;
        user.totalzombiekills = tzk;
        user.totalzombiedeaths = tzd;

        if (photo != "")
            new WWW2(photo).done += delegate(WWW2 www)
            {
                print("loaded texture");
                user.texture = www.www.texture;
                DontDestroyOnLoad(user.texture);
            };
        userviews.Add(nwid.GetHashCode(), user);

    }
    private void Start ()
    {
		PhotonNetwork.sendRate = 25;
		PhotonNetwork.sendRateOnSerialize = 25;

		instance = this; 
        if (offline == true)
            return;

        // if this is the local player
        if (photonView.isMine == true) 
        {
            // disable the third person model
            firstPersonObject.SetActive(true);
            this.thirdPersonObject.SetActive(false);
            this.GetComponent<GameLogic.Player>().enabled = true;
			// make sure all other player componenents are enabled
            //foreach (Behaviour childCompnent in this.gameObject.GetComponentsInChildren<Behaviour>())
                //childCompnent.enabled = true;
        }
        // if this is the remote player
        else
        {
            // enable the third person model
            firstPersonObject.SetActive(false);
            this.thirdPersonObject.SetActive(true);
            this.GetComponent<GameLogic.Player>().enabled = false;
            // make sure all other player components are disabled
            //foreach (Behaviour childCompnent in this.gameObject.GetComponentsInChildren<Behaviour>())
              //  childCompnent.enabled = false;
        }
    }
Exemple #15
0
    void AddPlayerBack(NetworkPlayer nPlayer)
    {
        //the players to be added are recorded in a list so that no player is missed
        nPlayerList.Add(nPlayer);

        addPlayerAgain = true;
    }
    void PlayerSwap(int newMode, NetworkPlayer player)
    {
        // find the player
        foreach (PlayerInfo p in nvs.players)
        {
            if (p.player==player) {
                p.currentMode = newMode;
                if (p.currentMode==0) {			// if they're now in a buggy
                    // set them in buggy
                    p.characterGameObject.transform.parent = p.cartGameObject.transform;
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,0);
                    p.characterGameObject.transform.rotation = p.cartGameObject.transform.rotation;
                    // unlock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.None;

                } else if (p.currentMode==1) {	// if they're now at golf ball
                    // set them at golf ball
                    p.characterGameObject.transform.parent = p.ballGameObject.transform;
                    p.ballGameObject.transform.rotation = Quaternion.identity;		// reset rotation to make it nice
                    p.characterGameObject.transform.localPosition = new Vector3(0,0,-2);
                    p.characterGameObject.transform.rotation = Quaternion.identity;
                    // lock golf ball
                    p.ballGameObject.rigidbody.constraints = RigidbodyConstraints.FreezeAll;
                }

                // reset keyboard buffer
                p.KBState = 0;
            }
        }
    }
Exemple #17
0
 void OnTriggerEnter(Collider other)
 {
     collided = true;
     if (other.isTrigger ==  false){
         colliderNetworkPlayer = ((CurrentPlayer)other.GetComponent(typeof(CurrentPlayer))).owner;
     }
 }
Exemple #18
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     Debug.Log("Player " + playerCount + " Disconnected from " + player.ipAddress + ":" + player.port);
 
     playerCount--;
     
 }
    private void CreateNewPlayerOnServer( NetworkPlayer id )
    {
        GameObject newPlayer = Network.Instantiate( playerPrefab, Vector3.zero, Quaternion.identity, 0 ) as GameObject;
        newPlayer.GetComponent<PlayerClientBehaviour>().SetPlayerID( id );

        gameControllerBahviour.Manager.AddNewPlayer( newPlayer );
    }
 void OnPlayerDisconnected( NetworkPlayer player  )
 {
     // Removing player if Network is disconnected
      Debug.Log("Server destroying player");
      Network.RemoveRPCs(player, 0);
      Network.DestroyPlayerObjects(player);
 }
 public static void setScope(Bounds pBounds, Transform pParent,NetworkPlayer pPlayer)
 {
     foreach (Transform lTransform in pParent)
     {
         lTransform.networkView.SetScope(pPlayer,pBounds.Contains(lTransform.position));
     }
 }
Exemple #22
0
	//Need to send level data to new players
	void OnPlayerConnected(NetworkPlayer player)
	{
		if(IsHost)
		{
			Debug.Log ("New player connected\n");

			//Find and get the current chunk
			GameObject Chunk = GameObject.Find ("Chunk(Clone)");
			byte[,,] map = Chunk.GetComponent<Chunk>().map;

			string ChunkData = "";
			for ( int x = 0; x < 16; x++ )
			{
				for ( int z = 0; z < 16; z++ )
				{
					ChunkData = ChunkData + map[x,0,z];
					ChunkData = ChunkData + map[x,1,z];
				}
			}

			//Send current chunk data to other players
			Debug.Log ("Sending chunk data across the network\n");
			//Sends to all clients that are connected to the server
			networkView.RPC("ChunkData", RPCMode.OthersBuffered, ChunkData);
		}
	}
Exemple #23
0
	void OnPlayerConnected (NetworkPlayer player)
	{
		networkPlayers[playersConnected++] = player;
		if (playersConnected >= players) {
			InitGame();
		}
	}
Exemple #24
0
 void ClientAddPlayerToList(string playerName, NetworkPlayer view)
 {
     MPPlayer team = new MPPlayer();
     team.teamName = playerName;
     team.playerNetwork = view;
     playersList.Add(team);
 }
	//Server function
	void OnPlayerDisconnected(NetworkPlayer player)
	{
		addGameChatMessage("Player disconnected from: " + player.ipAddress + ":" + player.port);
		
		//Remove player from the server list
		playerList.Remove(GetPlayerNode(player));
	}
Exemple #26
0
 public void InitializePlayer(string userName, NetworkPlayer networkPlayer)
 {
     string newName = RectifyUserName(userName, networkPlayer);
     Player player = new Player(newName, "A wild nerd appears.", GameManager.startingRoom, networkPlayer, null, Action.None);
     playerList.Add(player);
     chat.addGameChatMessage(player.name + " joined the chat.");
 }
    public static void CreatePlayerShip(NetworkPlayer target, Player player, int objectID)
    {
        if (StopSend())
            return;

        Channel.networkView.RPC("CreatePlayerShipRPC", target, player.ID, objectID);
    }
 public Player(NetworkPlayer data)
 {
     netInfo = data;
     handManager = Object.FindObjectOfType<GUIHandManager>();
     if (handManager == null)
     { Debug.LogError("No HandManager Found!"); }
 }
    void OnPlayerConnected(NetworkPlayer player)
    {
        if (Network.isServer)
        {

        }
    }
Exemple #30
0
 private void RequestUpdatePlayer(NetworkPlayer player)
 {
     C2Request request;
     request = new C2Request(C2MessageType.Request_UpdateAlive);
     request.putData("NetworkPlayer" , player);
     this.SendRequest(request);
 }
Exemple #31
0
 void movePlayer(NetworkPlayer player)
 {
 }
Exemple #32
0
 void OnConnectedToServer()
 {
     thisPlayer = Network.player;
     GetComponent <NetworkView>().RPC("makePlayer", RPCMode.Server, thisPlayer);
 }
Exemple #33
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     callIfExist(idOnPlayerDisconnected, player);
 }
Exemple #34
0
 public void Damage(float damage, NetworkPlayer networkPlayer)
 {
     networkView.RPC("_Damage", RPCMode.All, damage, networkPlayer);
 }
Exemple #35
0
 void makePlayer(NetworkPlayer player)
 {
 }
Exemple #36
0
 void Awake()
 {
     networkPlayer  = transform.parent.GetComponent <NetworkPlayer>();
     networkManager = GameObject.Find("GameManager").GetComponent <NetworkManager>();
     playerStatus   = GameObject.Find("GameManager").GetComponent <NetworkPlayerStatus>();
 }
Exemple #37
0
 void _Damage(float damage, NetworkPlayer networkPlayer)
 {
 }
 // プレイヤーが切断した
 // (サーバーが動作しているコンピュータで呼び出される)
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     Network.RemoveRPCs(player);
     Network.DestroyPlayerObjects(player);
 }
Exemple #39
0
 void OnPlayerConnected(NetworkPlayer player)
 {
     playerList.Add(new RemotePlayer(player));
     GameInfo.info.writeToConsole("Player " + player.guid + " connected.");
 }
Exemple #40
0
 public NetPlayerEvent(Type type, NetworkPlayer network_player) : base(type)
 {
     network_player_ = network_player;
 }
Exemple #41
0
    public override IEnumerator SlowUpdate()
    {
        if (IsLocalPlayer)
        {
            foreach (NetworkPlayer p in FindObjectsOfType <NetworkPlayer>())
            {
                if (p.Owner == this.Owner && !p.IsPaused)
                {
                    Cursor.lockState = CursorLockMode.Locked;
                    Cursor.visible   = false;
                    NP = p;
                    break;
                }
                else if (p.Owner == this.Owner && p.IsPaused)
                {
                    NP = p;
                    break;
                }
            }

            this.transform.GetChild(0).GetComponent <SkinnedMeshRenderer>().enabled = false;
            this.transform.GetChild(7).GetChild(0).GetComponent <Text>().enabled    = false;

            WeaponPanel.transform.parent.gameObject.SetActive(true);
        }

        yield return(new WaitForSeconds(0.3f));

        if (IsClient)
        {
            foreach (NetworkPlayer p in FindObjectsOfType <NetworkPlayer>())
            {
                if (p.Owner == this.Owner)
                {
                    PNAME = p.PNAME;
                    SendCommand("PNAME", p.PNAME);
                }
            }
        }

        if (IsServer)
        {
            AddWeapon(0);
        }

        yield return(new WaitForSeconds(0.3f));



        if (IsLocalPlayer)
        {
            SwitchWeapon(0);
        }

        while (true)
        {
            if (IsLocalPlayer && IsClient && !NP.IsPaused)
            {
                SendCommand("MOVE", Input.GetAxisRaw("Vertical").ToString() + ',' + Input.GetAxisRaw("Horizontal").ToString(), false);
                SendCommand("ROTATE", cameraX.ToString() + ',' + cameraY.ToString(), false);

                if (Input.GetAxisRaw("Jump") > 0 && JumpNum > 0 && !JumpButtonDown)
                {
                    SendCommand("JUMP", "1");
                    JumpButtonDown = true;
                    JumpNum--;
                }

                if (Input.GetAxisRaw("Fire1") != 0)
                {
                    WepInHand.TryFire();
                }

                if (Input.inputString != "")
                {
                    bool IsNum = int.TryParse(Input.inputString, out int num);
                    if (IsNum && num > 0 && num < 6)
                    {
                        SwitchWeapon(num - 1);
                    }
                }

                for (int i = 0; i < keyCodes.Length; i++)
                {
                    if (Input.GetKey(keyCodes[i]))
                    {
                        SwitchWeapon(i);
                        break;
                    }
                }
            }

            if (IsLocalPlayer)
            {
                for (int i = 0; i < WeaponPanel.transform.childCount; i += 3)
                {
                    if (Weapons.Contains(i / 3) && WeaponParent.transform.GetChild(i / 3).GetComponent <Weapon>() != null)
                    {
                        WeaponPanel.transform.GetChild(i + 1).GetComponent <Text>().text = WeaponParent.transform.GetChild(i / 3).GetComponent <Weapon>().ItemName;
                        WeaponPanel.transform.GetChild(i + 2).GetComponent <Text>().text = WeaponParent.transform.GetChild(i / 3).GetComponent <Weapon>().CurrentAmmo.ToString();
                    }
                    else if (Weapons.Contains(i / 3) && WeaponParent.transform.GetChild(i / 3).GetComponent <Weapon>() == null && WepInHand != null)
                    {
                        WeaponPanel.transform.GetChild(i + 1).GetComponent <Text>().text = WepInHand.ItemName;
                        WeaponPanel.transform.GetChild(i + 2).GetComponent <Text>().text = WepInHand.CurrentAmmo.ToString();
                    }
                }
                if (WepInHand != null)
                {
                    AmmoPanel.transform.GetChild(1).GetComponent <Text>().text = WepInHand.CurrentAmmo.ToString();
                }
                ScorePanel.transform.GetChild(1).GetComponent <Text>().text = gm.scoreTeamRed.ToString();
                ScorePanel.transform.GetChild(3).GetComponent <Text>().text = gm.scoreTeamGreen.ToString();
            }

            //IfClient...
            if (IsServer)
            {
                if (IsLaunched)
                {
                    if ((MyRig.velocity.x > -MoveSpeed && MyRig.velocity.x < MoveSpeed) && (MyRig.velocity.z > -MoveSpeed && MyRig.velocity.z < MoveSpeed))
                    {
                        IsLaunched = false;
                    }
                    //StartCoroutine(LaunchDelay());
                }

                if (IsDirty)
                {
                    //Update non-movement varialbes
                    SendUpdate("PNAME", PNAME);
                    IsDirty = false;
                }
            }
            yield return(new WaitForSeconds(MyCore.MasterTimer)); //Master timer is 0.05f
        }
    }
Exemple #42
0
 void OnPlayerDisconnected(NetworkPlayer player)
 {
     event_queue.Enqueue(new NetPlayerEvent(NetEvent.Type.PLAYER_DISCONNECTED, player));
 }
Exemple #43
0
 public override void OnPlayerConnectedBase(NetworkPlayer np)
 {
     RPCSetLaser(laser);
     base.OnPlayerConnectedBase(np);
 }