Esempio n. 1
0
 public void Start()
 {
     m_trans   = transform;
     m_ch      = m_trans.GetComponent <CharacterController>();
     netplayer = new NetPlayer();
     global    = new GlobalClass();
 }
Esempio n. 2
0
    // Called when player connects with their phone
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        Init();

        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += Remove;
        m_netPlayer.OnNameChange += ChangeName;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler <MessageMove>("move", OnMove);
        m_netPlayer.RegisterCmdHandler <MessageJump>("jump", OnJump);

        MoveToRandomSpawnPoint();

        SetName(m_netPlayer.Name);

        // Pick a random amount to adjust the hue and saturation
        float           hue   = Random.value;
        float           sat   = (float)Random.Range(0, 3) * -0.25f;
        MessageSetColor color = new MessageSetColor(
            hue,
            sat,
            0.0f,
            m_material.GetFloat("_HSVRangeMin"),
            m_material.GetFloat("_HSVRangeMax"));

        SetColor(color);

        // Send it to the phone
        m_netPlayer.SendCmd("setColor", color);
    }
 void InvokeOnPlayerCreated(NetPlayer player)
 {
     if (OnPlayerCreated != null)
     {
         OnPlayerCreated(player);
     }
 }
 void InvokeOnPlayerDestroyed(NetPlayer player)
 {
     if (OnPlayerDestroyed != null)
     {
         OnPlayerDestroyed(player);
     }
 }
    public void ServerCreatePlayer(int id, string pName)
    {
        NetPlayer player = Instantiate <NetPlayer>(playerPrefab);

        player.Init(id, pName);
        InvokeOnPlayerCreated(player);
    }
    public void ServerCreateLocalPlayer()
    {
        NetPlayer player = Instantiate <NetPlayer>(localPlayerPrefab);

        player.Init(0, playerName);
        InvokeOnPlayerCreated(player);
    }
        /// <summary>
        /// Finds command aliases related to the input command that may have been spelled incorrectly.
        /// </summary>
        private List <string> FindRelatedCommands(string input, NetPlayer caller)
        {
            var related = new List <string>();

            foreach (var command in Commands)
            {
                if (caller == null && command.RequireCaller)
                {
                    continue;
                }

                if (caller != null && (int)caller.AccessLevel < command.AccessLevel)
                {
                    continue;
                }

                foreach (var alias in command.Aliases)
                {
                    if ((alias.StartsWith(input)) //If the user did not complete the command.
                                                  //If the user missed the last few letters.
                        || (input.Length >= 2 && alias.StartsWith(input.Substring(0, 2)))
                        //If user missed last few letters.
                        || (input.Length > 2 && alias.EndsWith(input.Substring(input.Length - 2, 2)))
                        //If user misspelled middle characters.
                        ||
                        (alias.StartsWith(input.Substring(0, 1)) && alias.EndsWith(input.Substring(input.Length - 1, 1))))
                    {
                        //Add related command to the "Did you mean?" list.
                        related.Add(alias);
                        break;
                    }
                }
            }
            return(related);
        }
Esempio n. 8
0
    private void Start()
    {
        player = GetComponentInParent <NetPlayer>();
        if (player == null)
        {
            base.gameObject.SetActive(value: false);
            return;
        }
        TruncateName();
        int stringWidth = CalculateStringWidth();
        int lineHeight  = textMesh.font.lineHeight;

        rendererText = textMesh.GetComponent <Renderer>();
        rendererText.sharedMaterial.shader = textShader;
        rendererBG = textBG.GetComponent <Renderer>();
        meshFilter = textBG.transform.GetComponent <MeshFilter>();
        Mesh mesh = new Mesh();

        BuildMesh(stringWidth, lineHeight);
        mesh.vertices = vertices;
        mesh.SetIndices(kIndices, MeshTopology.Triangles, 0);
        mesh.MarkDynamic();
        mesh.UploadMeshData(markNoLogerReadable: false);
        meshFilter.sharedMesh = mesh;
        EnableRenderers(enable: false);
    }
Esempio n. 9
0
        public void SetAccessLevel(IPAddress ipAddress, AccessLevel accessLevel)
        {
            uint uintIp = ipAddress.ToUint32();

            if (accessLevel == AccessLevel.Player)
            {
                Config.AccessLevels.RemoveAll(id => id.Type == IdentityType.Ip && id.Ip == uintIp);
                Config.Save();
                return;
            }

            var identity = Config.AccessLevels.FirstOrDefault(id => id.Type == IdentityType.Ip && id.Ip == uintIp) ?? new PlayerAccessLevelIdentity(uintIp, accessLevel);

            identity.AccessLevel = accessLevel;

            if (!Config.AccessLevels.Contains(identity))
            {
                Config.AccessLevels.Add(identity);
            }

            Config.Save();
            NetPlayer player = FindPlayer(ipAddress);

            if (player != null)
            {
                UpdateAccessLevel(player);
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Setup object.
        /// </summary>
        /// <param name="type">Object type.</param>
        /// <param name="objectID">Object ID to assign.</param>
        /// <returns>Assigned Object ID</returns>
        public int Setup(ObjectSyncManager.ObjectTypes type, int objectID)
        {
            if (!NetWorld.Instance.playerIsLoading)
            {
                if (!NetManager.Instance.IsHost && objectID == ObjectSyncManager.AUTOMATIC_ID)
                {
                    Logger.Debug("Ignoring spawned object as client is not host!");
                    GameObject.Destroy(gameObject);
                    return(-1);
                }
            }
            IsSetup     = false;
            SyncEnabled = false;
            Owner       = null;
            ObjectType  = type;
            ObjectID    = objectID;

            // Assign object's ID.
            ObjectID = ObjectSyncManager.Instance.AddNewObject(this, ObjectID);

            if (!NetWorld.Instance.playerIsLoading && !IsSetup)
            {
                CreateObjectSubtype();
            }

            return(ObjectID);
        }
    void RemovePlayerFromLobby(NetPlayer player)
    {
        var lobbyPlayer = lobbyPlayers[player];

        lobbyPlayers.Remove(player);
        Destroy(lobbyPlayer.gameObject);
    }
Esempio n. 12
0
 /// <summary>
 /// Call this to rotate an active player out and start the next waiting player.
 /// </summary>
 /// <param name="netPlayer">The NetPlayer of the player to return</param>
 public void ReturnPlayer(NetPlayer netPlayer)
 {
     if (m_playerManager != null)
     {
         m_playerManager.ReturnPlayer(netPlayer);
     }
 }
Esempio n. 13
0
 private void RPC_SetUpPlayer(int ParentIndex, string displayName)
 {
     //Debug.LogError("Dummy Error");
     ParentObject = PhotonView.Find(ParentIndex).gameObject;
     if (ParentPlayer == null)
     {
         ParentPlayer = ParentObject.GetComponent <NetPlayer>();
     }
     if (LocalPlayer == null)
     {
         LocalPlayer = ParentPlayer.LocalPlayer;
     }
     //ParentPlayer = GetComponentInParent<NetPlayer>();
     //if (LocalPlayer == null && ParentPlayer.LocalPlayer != null)
     //    LocalPlayer = ParentPlayer.LocalPlayer;
     //SetTeamNum(TeamNum);
     TextName.text = displayName;
     PNT.ForceStart();
     if (LocalPlayer == ParentPlayer)
     {
         TextName.gameObject.SetActive(false);
     }
     if (LocalPlayer.GetTeamNum() != ParentPlayer.GetTeamNum())
     {
         TextName.gameObject.SetActive(false);
     }
     SetTeamNum(TeamNum);
 }
Esempio n. 14
0
    // Called when player connects with their phone
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        Init();

        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += Remove;
        m_netPlayer.OnNameChange += ChangeName;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageMove>("move", OnMove);
        m_netPlayer.RegisterCmdHandler<MessageJump>("jump", OnJump);

        SetName(m_netPlayer.Name);

        // Pick a random amount to adjust the hue and saturation
        float hue = Random.value;
        float sat = (float)Random.Range(0, 3) * -0.25f;
        MessageSetColor color = new MessageSetColor(
            hue,
            sat,
            0.0f,
            m_material.GetFloat("_HSVRangeMin"),
            m_material.GetFloat("_HSVRangeMax"));
        SetColor(color);

        // Send it to the phone
        m_netPlayer.SendCmd("setColor", color);
    }
Esempio n. 15
0
    private string GetSteamNameTag(NetPlayer player)
    {
        ulong    ulSteamID     = ulong.Parse(player.skinUserId);
        CSteamID steamIDFriend = new CSteamID(ulSteamID);

        return(SteamFriends.GetFriendPersonaName(steamIDFriend));
    }
Esempio n. 16
0
    /// <summary>Sends the client into the game and informs other clients of the new player.</summary>
    /// <param name="_playerName">The username of the new player.</param>
    public void SendIntoGame(string _playerName)
    {
        player = NetworkManager.instance.InstantiatePlayer();
        player.Initialize(id, _playerName);

        // Send all players in the new player's scene
        foreach (Client _client in Server.clients.Values)
        {
            if (_client.player != null)
            {
                if (_client.id != id)
                {
                    ServerSend.SpawnPlayer(id, _client.player);
                }
            }
        }

        // Send the new player in all playerss scenes (including himself)
        foreach (Client _client in Server.clients.Values)
        {
            if (_client.player != null)
            {
                ServerSend.SpawnPlayer(_client.id, player);
            }
        }
    }
Esempio n. 17
0
    public void PlaceMessage(int id, string msg)
    {
        var       text   = Instantiate <TextMeshProUGUI>(msgPrefab, msgPlace);
        NetPlayer player = NetPlayer.players[id];

        text.text = $"{player.playerName} : {msg}";
    }
Esempio n. 18
0
        public void SetAccessLevel(ulong steamId, AccessLevel accessLevel)
        {
            if (accessLevel == AccessLevel.Player)
            {
                Config.AccessLevels.RemoveAll(id => id.Type == IdentityType.SteamId && id.SteamId == steamId);
                Config.Save();
                return;
            }

            var identity = Config.AccessLevels.FirstOrDefault(id => id.Type == IdentityType.SteamId && id.SteamId == steamId) ?? new PlayerAccessLevelIdentity(steamId, accessLevel);

            identity.AccessLevel = accessLevel;

            if (!Config.AccessLevels.Contains(identity))
            {
                Config.AccessLevels.Add(identity);
            }

            Config.Save();
            NetPlayer player = FindPlayer(steamId);

            if (player != null)
            {
                UpdateAccessLevel(player);
            }
        }
        // Called by ExampleCharacterSelect using GameObject.SendMessage
        void InitializeFromCharacterSelect(ExampleCharacterSelect.StartInfo startInfo)
        {
            Init();
            // Save the netplayer object so we can use it send messages to the phone
            m_netPlayer = startInfo.netPlayer;

            // Register handler to call if the player disconnects from the game.
            m_netPlayer.OnDisconnect += Remove;

            // Handle Namechange. Either use the one passed in or make a new one
            m_playerNameManager = startInfo.playerNameManager;
            m_playerNameManager.OnNameChange += ChangeName;

            // Setup events for the different messages.
            m_netPlayer.RegisterCmdHandler<MessageMove>("move", OnMove);

            ExampleCharacterSelectGameSettings settings = ExampleCharacterSelectGameSettings.settings();
            m_position = new Vector3(Random.Range(0.0f, settings.areaWidth), 0, Random.Range(0.0f, settings.areaHeight));
            transform.localPosition = m_position;

            SetName(m_playerNameManager.Name);
            Color color = new Color(Random.value, Random.value, Random.value);
            // make one random component a minimum brightness
            color[RandInt(3)] = Random.value * 0.5f + 0.5f;
            SetColor(color);
        }
Esempio n. 20
0
    public GameObject flyGuy;                   // a reference to the FlyGuy Prefab GameObejct

    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        NetPlayer m_netPlayer = spawnInfo.netPlayer;

        GameObject newChar;

        if (!GameObject.FindWithTag("Mario"))
        {
            newChar = Instantiate(mario);
        }
        else if (!GameObject.FindWithTag("Luigi"))
        {
            newChar = Instantiate(luigi);
        }
        else if (!GameObject.FindWithTag("PurpleMario"))
        {
            newChar = Instantiate(purpleMario);
        }
        else if (!GameObject.FindWithTag("YellowLuigi"))
        {
            newChar = Instantiate(yellowLuigi);
        }
        else
        {
            newChar = Instantiate(flyGuy);
        }

        newChar.GetComponent <HFTGamepad>().InitializeNetPlayer(m_netPlayer);
        Destroy(this.gameObject);
    }
	void InitializeNetPlayer(NetPlayer m_netPlayer) 
	{	
		GameObject newChar;
		if (!GameObject.FindWithTag ("Mario")) 
		{
			newChar = Instantiate(mario);
		} 
		else if (!GameObject.FindWithTag ("Luigi")) 
		{
			newChar = Instantiate(luigi);
		} 
		else if (!GameObject.FindWithTag ("PurpleMario")) 
		{
			newChar = Instantiate(purpleMario);
		} 
		else if (!GameObject.FindWithTag ("YellowLuigi")) 
		{
			newChar = Instantiate(yellowLuigi);
		} 
		else 
		{
			newChar = Instantiate(flyGuy);
		}
		
		newChar.GetComponent<HFTGamepad> ().InitializeNetPlayer (m_netPlayer);
		
		Destroy (this.gameObject);
	}
        internal void PlayerConnected(NetPlayer netPlayer)
        {
            string id = netPlayer.host.connection.ToString();

            allPlayers[id]       = new HumanFallFlatPlayer(netPlayer);
            connectedPlayers[id] = new HumanFallFlatPlayer(netPlayer);
        }
Esempio n. 23
0
                static void Postfix(NetPlayer __instance)
                {
                    Singleton.Manager <ManNetwork> .inst.SubscribeToClientMessage(__instance.netId, WaterChange, new ManNetwork.MessageHandler(OnClientChangeWaterHeight));

                    Console.WriteLine("Subscribed " + __instance.netId.ToString() + " to water level updates from host. Sending current level");
                    TryBroadcastNewHeight(serverWaterHeight);
                }
Esempio n. 24
0
 internal void addPlayer(NetPlayer player)
 {
     context.clients.Add(player);
     context.scene.bodies[player] = new List <NetScene.Body>();
     onClientJoin?.Invoke(player); // call handler
     Global.log.trace($"added client {player}");
 }
Esempio n. 25
0
 internal void removePlayer(NetPlayer player)
 {
     context.server !.onClientLeave?.Invoke(player);
     context.scene.bodies.Remove(player);
     context.clients.Remove(player);
     Global.log.trace($"removed client {player}");
 }
Esempio n. 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        bool Server_OnClientConnect(NetPlayer client)
        {
            LogBox.Text += "New client connected" + Environment.NewLine;


            return(true);
        }
Esempio n. 27
0
 private void OnDestroy()
 {
     if (this == local)
     {
         local = null;
     }
 }
Esempio n. 28
0
 /// <summary>
 /// Send sync response to clients.
 /// </summary>
 /// <param name="player">Player to send message to.</param>
 /// <param name="accepted">If the request was approved.</param>
 public static void SendSyncResponse(NetPlayer player, int objectID, bool accepted)
 {
     Network.Messages.ObjectSyncResponseMessage msgResponse = new Network.Messages.ObjectSyncResponseMessage();
     msgResponse.objectID = objectID;
     msgResponse.accepted = accepted;
     NetManager.Instance.SendMessage(player, msgResponse, Steamworks.EP2PSend.k_EP2PSendReliable);
 }
Esempio n. 29
0
    public void Surrender()
    {
//		NM = NetworkManager.singleton;
        NetPlayer[] NPs = GameObject.FindObjectsOfType <NetPlayer>();
        foreach (NetPlayer NP in NPs)
        {
            if (NP.isLocalPlayer)
            {
                netplayer = NP;
            }
        }

        if (isServer)
        {
            netplayer.CmdServerSurrender();
        }
        else if (isClient)
        {
            netplayer.CmdClientSurrender();
        }

//		if(isServer)
//			NetworkManager.StopHost();
//		else if(isClient)
//			NetworkManager.StopClient();
    }
Esempio n. 30
0
    void Start()
    {
        enemysprite = this.GetComponent <SpriteRenderer>();
        if (isFly)
        {
            Destination = FindClosestPlayer();
        }

        GameObject[] NetPlayers = GameObject.FindGameObjectsWithTag("Play");

        if (!isOffline)
        {
            foreach (GameObject NP in NetPlayers)
            {
                if (!isServer)
                {
                    if (NP.GetComponent <NetworkIdentity>().isLocalPlayer)
                    {
                        NetPlayer = NP.GetComponent <NetPlayer>();
                    }
                }
                if (isServer)
                {
                    if (NP.GetComponent <NetworkIdentity>().isLocalPlayer)
                    {
                        NetPlayer = NP.GetComponent <NetPlayer>();
                    }
                }
            }
        }
        healthNow = health;
        prevLoc   = transform.position;
        InvokeRepeating("ChangeDirection", 0f, 0.2f);
        InvokeRepeating("RecordPosition", 0f, 0.1f);
    }
Esempio n. 31
0
 public void GiveParametersPlayer(NetPlayer obj)
 {
     player      = obj;
     TextHp.text = "Прочность: " + player.Health + "/" + player.MaxHealth;
     CancelInvoke();
     InvokeRepeating("RefreshWindowPlayer", 0, 0.34f);
 }
        public override void Handle(string[] args)
        {
            NetPlayer target = Caller;

            if (PlayerName != null)
            {
                target = Server.FindPlayer(PlayerName, NameSearchOption.StartsWith);

                if (target == null)
                {
                    SendMessage($"Could not find a player with a name starting with '{PlayerName}'.", LogMessageType.Error);
                    return;
                }
            }

            if (target == null)
            {
                SendMessage("Missing player name, if typed in server console a player name needs to be specified.", LogMessageType.Error);
                return;
            }

            if (target.Spectating)
            {
                SendMessage($"Can't set pot color on spectating players.", LogMessageType.Error);
                return;
            }

            target.SetPotColor(new Color(R, G, B));
        }
Esempio n. 33
0
    void Awake()
    {
        if (control == null)
        {
            control = GameObject.Find("board").GetComponent <SystemControl>();
        }

        netPlayer = transform.parent.gameObject.GetComponent <NetPlayer>();

        if (!chessMap.ContainsKey(gameObject.name))
        {
            chessMap.Add(gameObject.name, gameObject);
        }
        else
        {
            chessMap[gameObject.name] = gameObject;
        }

        coord.Set(initCoordRow, initCoordCol);

        switch (chessTypeId)
        {
        case ChessTypeId.Empty:
            chessType = Empty.GetChessType();
            break;

        case ChessTypeId.JIANG:
            chessType = JIANG.GetChessType();
            break;

        case ChessTypeId.SHI:
            chessType = SHI.GetChessType();
            break;

        case ChessTypeId.XIANG:
            chessType = XIANG.GetChessType();
            break;

        case ChessTypeId.MA:
            chessType = MA.GetChessType();
            break;

        case ChessTypeId.CHE:
            chessType = CHE.GetChessType();
            break;

        case ChessTypeId.PAO:
            chessType = PAO.GetChessType();
            break;

        case ChessTypeId.BING:
            chessType = BING.GetChessType();
            break;

        default:
            chessType = Empty.GetChessType();
            break;
        }
    }
Esempio n. 34
0
 public virtual void Start()
 {
     connectionManager = GameObject.Find("World").GetComponent("ConnectionManager") as ConnectionManager;
     playerManager     = GameObject.Find("World").GetComponent("PlayerManager") as PlayerManager;
     netPlayer = GameObject.Find("World").GetComponent("NetPlayer") as NetPlayer;
     inputDispatcher = GameObject.Find("World").GetComponent("InputDispatcher") as InputDispatcher;
     inputReceiver = GameObject.Find("World").GetComponent("InputReceiver") as InputReceiver;
     //gameManager = GameObject.Find("World").GetComponent<GameManager>() as GameManager;
     mapManager = GameObject.Find("World").GetComponent<MapManager>() as MapManager;
     menuManager = GameObject.Find("World").GetComponent<MenuManager>() as MenuManager;
     world = GameObject.Find("World");
 }
Esempio n. 35
0
 //Creates a collection based on player and all options
 public InputCollection(NetPlayer player, float f, float s, float tR, float tU, bool j, bool f1, bool f2, bool sp, bool c)
 {
     forward = f;
     straff = s;
     turnRight = tR;
     turnUp = tU;
     jump = j;
     fireOne = f1;
     fireTwo = f2;
     sprint = sp;
     crouch = c;
     netPlayer = player;
 }
        void InitializeNetPlayer(SpawnInfo spawnInfo)
        {
            // Save the netplayer object so we can use it send messages to the phone
            m_netPlayer = spawnInfo.netPlayer;

            // Register handler to call if the player disconnects from the game.
            m_netPlayer.OnDisconnect += Remove;

            // Track name changes
            m_playerNameManager = new HFTPlayerNameManager(m_netPlayer);

            // Setup events for the different messages.
            m_netPlayer.RegisterCmdHandler<MessageCharacter>("character", OnCharacter);
        }
        void InitializeNetPlayer(SpawnInfo spawnInfo)
        {
            // Save the netplayer object so we can use it send messages to the phone
            m_netPlayer = spawnInfo.netPlayer;

            // Register handler to call if the player disconnects from the game.
            m_netPlayer.OnDisconnect += Remove;

            // Track name changes
            m_playerNameManager = new HFTPlayerNameManager(m_netPlayer);
            m_playerNameManager.OnNameChange += ChangeName;

            // Setup events for the different messages.
            m_netPlayer.RegisterCmdHandler<MessageMove>("move", OnMove);
            m_netPlayer.RegisterCmdHandler<MessageColor>("color", OnColor);

            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();
            m_position = new Vector3(UnityEngine.Random.Range(0, settings.areaWidth), 0, UnityEngine.Random.Range(0, settings.areaHeight));
            transform.localPosition = m_position;

            SetName(m_playerNameManager.Name);
        }
Esempio n. 38
0
        private void StartPlayer(int id, string name)
        {
            if (m_players.ContainsKey(id)) {
            return;
            }

            if (string.IsNullOrEmpty(name)) {
            name = "Player" + (++m_totalPlayerCount);
            }

            NetPlayer player = new NetPlayer(this, id);
            m_players[id] = player;
            m_eventProcessor.QueueEvent(delegate() {
            // UGH! This is not thread safe because someone might add handler to OnPlayerConnect
            // Odds or low though.
            OnPlayerConnect.Emit(this, new PlayerConnectMessageArgs(player));
            });
        }
Esempio n. 39
0
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += HandleDisconnect;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageButton>("button", HandleButton);
        m_netPlayer.RegisterCmdHandler<MessageDPad>("dpad", HandleDPad);
        m_netPlayer.RegisterCmdHandler<MessageOrient>("orient", HandleOrient);
        m_netPlayer.RegisterCmdHandler<MessageAccel>("accel", HandleAccel);
        m_netPlayer.RegisterCmdHandler<MessageRot>("rot", HandleRot);
        m_netPlayer.RegisterCmdHandler<MessageTouch>("touch", HandleTouch);

        m_playerNameManager = new HFTPlayerNameManager(m_netPlayer);
        m_playerNameManager.OnNameChange += HandleNameChange;

        // If the controller is showing the player "game full"
        // then tell it can play.
        m_netPlayer.SendCmd("play");
        SendControllerOptions();
        SendColor();
    }
 public StartInfo(NetPlayer netPlayer, HFTPlayerNameManager playerNameManager)
 {
     this.netPlayer = netPlayer;
     this.playerNameManager = playerNameManager;
 }
 public HFTPlayerNameManager(NetPlayer netPlayer)
 {
     m_netPlayer = netPlayer;
     AddHandlers();
 }
 public PlayerDisconnectMessageArgs(NetPlayer _netPlayer)
 {
     netPlayer = _netPlayer;
 }
Esempio n. 43
0
 void InitializeNetPlayer(SpawnInfo spawnInfo)
 {
     m_netPlayer = spawnInfo.netPlayer;
     score.caughtEvent += delegate (){spawnInfo.netPlayer.SendCmd ("customText", new CustomTextParcel(GetPhoneChasingText()));};
     score.catchPlayerEvent += delegate (){spawnInfo.netPlayer.SendCmd ("customText", new CustomTextParcel(GetPhoneChasingText()));};
 }
Esempio n. 44
0
 public void StartLocalPlayer(NetPlayer netPlayer, string name = "", object data = null)
 {
     if (m_playerManager != null)
     {
         m_playerManager.StartLocalPlayer(netPlayer, name, data);
     }
     else
     {
         StartPlayer(netPlayer, data);
     }
 }
Esempio n. 45
0
 public void setNetPlayer(NetPlayer pNetPlayer)
 {
     _NetPlayer = pNetPlayer;
 }
	public RespawnCharacterDecider(NetPlayer netPlayer)
	{
		myPlayer = netPlayer;
	}
Esempio n. 47
0
        void StartPlayer(NetPlayer netPlayer, object data)
        {
            m_log.Info("Spawn Player");
            GameObject gameObject = (GameObject)Instantiate(prefabToSpawnForPlayer);

            SpawnInfo spawnInfo = new SpawnInfo();
            spawnInfo.netPlayer = netPlayer;
            spawnInfo.data = data;
            gameObject.SendMessage("InitializeNetPlayer", spawnInfo);
        }
 public void Init(NetPlayer netPlayer)
 {
     m_netPlayer = netPlayer;
 }
Esempio n. 49
0
 //--------------------------------------------------------------------------------------------------------------------
 //Name:
 //Description:
 //Parameters:
 //Returns:
 //--------------------------------------------------------------------------------------------------------------------
 private bool arePlayerStatesSynced(NetPlayer.PLAYER_STATE pState)
 {
     bool bResult = true;
     foreach(GameObject p in players){
       if (p == null)
     continue;
       if (p.GetComponent<NetPlayer> ().PlayerState != pState){
     bResult = false;
     break;
       }// End if (p.GetComponent<NetPlayer> ().PlayerState != pState)
     } //End foreach(GameObject p in players)
     return bResult;
 }
 public PlayerConnectMessageArgs(NetPlayer _netPlayer, string _name, object _data)
 {
     netPlayer = _netPlayer;
     name = _name;
     data = _data;
 }
 public NetPlayerState(NetPlayer _netPlayer, object _data)
 {
     netPlayer = _netPlayer;
     data = _data;
 }
Esempio n. 52
0
 /// <summary>
 /// Call this to rotate an active player out and start the next waiting player.
 /// </summary>
 /// <param name="netPlayer">The NetPlayer of the player to return</param>
 public void ReturnPlayer(NetPlayer netPlayer)
 {
     if (m_playerManager != null)
     {
         m_playerManager.ReturnPlayer(netPlayer);
     }
 }
 NetPlayerState GetWaitingNetPlayerState(NetPlayer netPlayer)
 {
     return m_waitingPlayers.Find((NetPlayerState otherNetPlayerState) => {
     return otherNetPlayerState.netPlayer == netPlayer;
     });
 }
 PlayerState GetPlayerState(NetPlayer netPlayer)
 {
     for (int pndx = 0; pndx < m_playerState.Length; ++pndx) {
     PlayerState playerState = m_playerState[pndx];
     if (playerState.netPlayer == netPlayer) {
         return playerState;
     }
     }
     return null;
 }
 /// <summary>
 /// Call this to rotate an active player out and start the next waiting player.
 /// </summary>
 /// <param name="netPlayer">The NetPlayer of the player to return</param>
 public void ReturnPlayer(NetPlayer netPlayer)
 {
     m_playerManager.ReturnPlayer(netPlayer);
 }
Esempio n. 56
0
    void InitializeNetPlayer(SpawnInfo spawnInfo)
    {
        MapGeneration.doDestroy += DieAnim;

        m_netPlayer = spawnInfo.netPlayer;
        m_netPlayer.OnDisconnect += Remove;

        // Setup events for the different messages.
        m_netPlayer.RegisterCmdHandler<MessageButton>("button", HandleButton);
        m_netPlayer.RegisterCmdHandler<MessageDPad>("dpad", HandleDPad);
        m_netPlayer.RegisterCmdHandler<MessageOrient>("orient", HandleOrient);
        m_netPlayer.RegisterCmdHandler<MessageAccel>("accel", HandleAccel);
        m_netPlayer.RegisterCmdHandler<MessageRot>("rot", HandleRot);
        m_netPlayer.RegisterCmdHandler<MessageTouch>("touch", HandleTouch);

        m_netPlayer.OnNameChange += ChangeName;

        // If the controller is showing the player "game full"
        // then tell it can play.
        m_netPlayer.SendCmd("play");
        SendControllerOptions();
        SendColor();

        //COLOR
        MeshRenderer rend = this.gameObject.GetComponent<MeshRenderer>();
        Material mat = new Material(Shader.Find("Standard"));
        mat.color = m_color;
        rend.material = mat;

        //SPAWNING
        MapGeneration map = GameObject.FindWithTag ("Map").GetComponent<MapGeneration> ();
        int xSpawnPos = Random.Range(map.size - 3, map.size - 1);
        int ySpawnPos = Random.Range(map.size - 3, map.size - 1);
        this.gameObject.transform.position = new Vector3 (xSpawnPos,
                                                          map.getHeight (xSpawnPos, ySpawnPos) + 1.5f, // stop harcoding shit, amir
                                                         ySpawnPos);
        onCreate(this.gameObject);
        PlayerMovement.onSpawn += delegate(ref Vector2 currentCell) {
            currentCell.x = xSpawnPos;
            currentCell.y = ySpawnPos;
        };
    }
        void InitializeNetPlayer(SpawnInfo spawnInfo)
        {
            m_netPlayer = spawnInfo.netPlayer;
            m_netPlayer.OnDisconnect += Remove;

            // Setup events for the different messages.
            m_netPlayer.RegisterCmdHandler<MessageColor>(OnColor);
            m_netPlayer.RegisterCmdHandler<MessageMove>(OnMove);
            m_netPlayer.RegisterCmdHandler<MessageSetName>(OnSetName);
            m_netPlayer.RegisterCmdHandler<MessageBusy>(OnBusy);
            m_netPlayer.RegisterCmdHandler<MessageOrient>(OnOrient);

            m_netPlayer.RegisterCmdHandler<MessageCmdData>("needID", OnNeedID);
            m_netPlayer.RegisterCmdHandler<MessageCheckID>("checkID", OnCheckID);
            m_netPlayer.RegisterCmdHandler<MessageRequestPartner>("requestPartner", OnRequestPartner);

            ExampleSimpleGameSettings settings = ExampleSimpleGameSettings.settings();
            m_position = new Vector3(m_rand.Next(settings.areaWidth), 0, m_rand.Next(settings.areaHeight));
            //transform.localPosition = m_position;

            SetName(spawnInfo.name);
        }
 public void Init(NetPlayer netPlayer)
 {
     m_netPlayer = netPlayer;
     m_name = "Player" + (++s_nextPlayerId);
 }
Esempio n. 59
0
    public void setNetPlayer(NetPlayer pNP)
    {
        _NetPlayer = pNP;

        cdtimer.SetActive (false);
        HUD.GetComponent<Image>().sprite = Huds [_NetPlayer.iShipChoice];
        HUD.GetComponent<Image> ().enabled = true;
        HUD.transform.FindChild("MiniMapBack").GetComponent<Image>().sprite = MapBorders[_NetPlayer.iShipChoice];
        UIState = UI_STATE.Waiting;
    }
Esempio n. 60
0
 public NetGame(NetPlayer np)
 {
     InitializeComponent();
     game = np;
     game.InitNetPlayer(gameGrid1, gameGrid2, Scoring_Board1, Scoring_Board2, PreviewImage1, 19, 10);
 }