public MatchPlayerLocal CreatePlayer(string name, ControlType ctrlType, int characterId) { // Esto aparece la primera vez que estamos iniciando un personajew Debug.Log("Creating Player"); var p = new MatchPlayerLocal(name, ctrlType, characterId); // en servidor, esto ocurre una vez.... Players.Add(p); if (inLobby) { SpawnLobbyBall(p); } p.ChangedReady += AnyPlayerChangedReadyHandler; StopLobbyTimer(); if (MatchPlayerAdded != null) { MatchPlayerAdded(this, new MatchPlayerLocalEventArgs(p)); } return(p); }
public MatchPlayerLocal AddReadyEvent(MatchPlayerLocal p) { p.ChangedReady += AnyPlayerChangedReadyHandler; if (MatchPlayerAdded != null) { MatchPlayerAdded(this, new MatchPlayerLocalEventArgs(p)); } return(p); }
public void SetCharacter(MatchPlayerLocal player, int character) { if (!inLobby) { Debug.LogError("Cannot set character outside of lobby!"); } player.CharacterId = character; SpawnLobbyBall(player); }
/* * public static void OnDestroyMatch(BasicResponse response) * { * Debug.Log("Match Destroyed" + response.ToString()); * if(NetworkManager.singleton){ * Destroy(GameObject.Find("Match Manager(Clone)")); * * NetworkManager.singleton.ServerChangeScene("Menu"); * * NetworkManager.singleton.StopHost(); * NetworkManager.singleton.StopMatchMaker(); * NetworkManager.Shutdown(); * // Destroy(NetworkManager.singleton.GetComponent<SanicNetworkManager>().matchManager.gameObject);Match Manager(Clone) * * Destroy(GameObject.Find("SanicNetworkManager")); * * NetworkTransport.Shutdown(); * * * } * * } */ // aparece el lobbyBall private void SpawnLobbyBall(MatchPlayerLocal player) { // var spawner = LobbyReferences.Active.BallSpawner; var spawner = FindObjectOfType <LobbyBallSpawnerLocal>(); if (player.BallObject != null) { Destroy(player.BallObject.gameObject); } player.BallObject = spawner.SpawnBall(Data.PlayerType.Normal, player.CtrlType, player.CharacterId, player.Name); }
public void RemovePlayer(MatchPlayerLocal player) { if (Players.Contains(player)) { Players.Remove(player); if (player.BallObject) { Destroy(player.BallObject.gameObject); } if (MatchPlayerRemoved != null) { MatchPlayerRemoved(this, new MatchPlayerLocalEventArgs(player)); } } }
public MatchPlayerLocalEventArgs(MatchPlayerLocal player) { Player = player; }