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); }
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); }
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); }
void SendSpawnInfoToGameObject(string msg, GameObject gameObject, NetPlayerState netPlayerState, SendMessageOptions sendMessageOptions = SendMessageOptions.RequireReceiver) { SpawnInfo spawnInfo = new SpawnInfo(); spawnInfo.netPlayer = netPlayerState.netPlayer; spawnInfo.data = netPlayerState.data; gameObject.SendMessage(msg, spawnInfo, sendMessageOptions); }