/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: SetAman * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee & Jerry Jia * -- * -- INTERFACE: void SetAman() * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function to inidicate whether or not the current player has aman status. * -----------------------------------------------------------------------------------------------------------------*/ public void SetAman() { // NOTE:: This can only be called when either the player has already selected to be the aman, which he can deselect it // or no one on the team has selected aman. Functionality handled over network GameData.AllyKingID = aman_toggle.isOn ? GameData.MyPlayer.PlayerID : -1; LobbyNetwork.SendLobbyData(NetworkCode.AmanSelection); }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: StartGame * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee * -- * -- INTERFACE: void StartGame() * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function for starting the game. * -----------------------------------------------------------------------------------------------------------------*/ public void StartGame() { if (GameData.AllyKingID != -1 && GameData.EnemyKingID != -1) { LobbyNetwork.SendLobbyData(NetworkCode.GameStart); } team_select_panel.SetActive(false); }
// Set references for private variables when the game starts void Start() { gameHandler = GetComponent <GameHandler>(); championRoster = GetComponent <ChampionRoster>(); lobbyNetwork = GetComponent <LobbyNetwork>(); photonView = GetComponent <PhotonView>(); lockinButton.onClick.AddListener(LockChampion); SetupChampions(); }
void Awake() { if (instance != null) { DestroyImmediate(gameObject); return; } DontDestroyOnLoad(gameObject); instance = this; }
// Fetch references and listeners once the game starts. void Start() { lobbyNetwork = LobbyNetwork.Instance; button = GetComponent<Button>(); scaleOnHover = GetComponent<ScaleOnHover>(); button.onClick.AddListener(OnClick); // Disable if button not interactable if (!button.interactable) this.enabled = false; }
// Set listeners and assign private variables when the game starts. void Start() { shouldAttemptRejoin = true; Instance = this; mainMenuManager = GetComponent <MainMenuManager>(); championSelect = GetComponent <ChampionSelect>(); mapManager = GetComponent <MapManager>(); gameHandler = GetComponent <GameHandler>(); searchingLabel = SearchingLabel.Instance; cancelButton.onClick.AddListener(StopPlay); }
// Assign listeners and get references to other scripts once the game begins void Start() { UserManager.onXPChanged += SetUserXP; system = EventSystem.current; userManager = GetComponent <UserManager>(); lobbyNetwork = GetComponent <LobbyNetwork>(); authenticationManager = GetComponent <AuthenticationManager>(); socialButton.onClick.AddListener(OnSocialButtonClick); UIHandler = GetComponent <UIHandler>(); authenticationManager.loginUsername.Select(); }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: Update * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee * -- * -- INTERFACE: void Update() * -- * -- RETURNS: void * -- * -- NOTES: * -- Called once per frame. Waits for new incoming network messages and will update the lobby list if changes are * -- made. (e.g. new player, team changes etc.) * -----------------------------------------------------------------------------------------------------------------*/ void Update() { if (LobbyNetwork.connected) { string tmp = Marshal.PtrToStringAnsi(NetworkingManager.TCP_GetData()); if (!String.Equals(tmp, "[]")) { LobbyNetwork.ParseLobbyData(tmp); UpdateLobbyList(); } } }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: LeaveLobby * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee & Jerry Jia * -- * -- PROGRAMMER: Spenser Lee & Jerry Jia * -- * -- INTERFACE: void LeaveLobby() * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function to leave the lobby. Sends necessary netorking messages to disconnect from the server * -- and clears the lobby menu UI as necessary. * -----------------------------------------------------------------------------------------------------------------*/ public void LeaveLobby() { GameData.LobbyData.Remove(GameData.MyPlayer.PlayerID); LobbyNetwork.SendLobbyData(NetworkCode.PlayerLeftLobby); if (LobbyNetwork.connected) { LobbyNetwork.connected = false; NetworkingManager.TCP_DisposeClient(); } foreach (Transform slot in team1_list.transform) { slot.gameObject.SetActive(false); } foreach (Transform slot in team2_list.transform) { slot.gameObject.SetActive(false); } Back(); }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: SelectTeam * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee * -- * -- INTERFACE: void SelectTeam(int team) * -- team: the team number * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function for selecting a team. Sends a network packet indicating which team was selected. * -----------------------------------------------------------------------------------------------------------------*/ public void SelectTeam(int team) { team_select_panel.SetActive(false); if (GameData.MyPlayer.TeamID != team && GameData.MyPlayer.TeamID > 0) { int temp = GameData.AllyKingID; GameData.AllyKingID = GameData.EnemyKingID; GameData.EnemyKingID = temp; } GameData.MyPlayer.TeamID = team; LobbyNetwork.SendLobbyData(NetworkCode.TeamChangeRequest); _team_set = true; if (_class_set == false) { class_select_panel.SetActive(true); } }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: SelectClass * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee * -- * -- INTERFACE: void SelectClass(int value) * -- value: class value * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function for selecting a class. Enables/disables the necessary class information panels and sends * -- a netork packet indicating which class was selected. * -----------------------------------------------------------------------------------------------------------------*/ public void SelectClass(int value) { class_select_panel.SetActive(false); switch (value) { case 1: soldier_panel.SetActive(true); mage_panel.SetActive(false); ninja_panel.SetActive(false); aman_panel.SetActive(false); break; case 2: soldier_panel.SetActive(false); mage_panel.SetActive(false); ninja_panel.SetActive(true); aman_panel.SetActive(false); break; case 3: soldier_panel.SetActive(false); mage_panel.SetActive(true); ninja_panel.SetActive(false); aman_panel.SetActive(false); break; case 4: soldier_panel.SetActive(false); mage_panel.SetActive(false); ninja_panel.SetActive(false); aman_panel.SetActive(true); break; } GameData.MyPlayer.ClassType = (ClassType)value; LobbyNetwork.SendLobbyData(NetworkCode.ClassChangeRequest); _class_set = true; }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: JoinLobby * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee * -- * -- INTERFACE: void JoinLobby() * -- * -- RETURNS: void * -- * -- NOTES: * -- Function called when a player attemps to join the lobby. User inputs a name and IP address, then attempts to * -- connect to the server. * -----------------------------------------------------------------------------------------------------------------*/ public void JoinLobby() { string name = _GetInputText("NameInput"); _host_ip = _GetInputText("IPInput"); GameData.IP = _host_ip; if (Application.platform != RuntimePlatform.LinuxPlayer) { _SwitchMenu(MenuStates.Lobby); return; } if (!(name.Length == 0) && name.Length <= 12 && !(_host_ip.Length == 0)) { GameData.MyPlayer.Username = name; if (!LobbyNetwork.Connect(_host_ip)) { return; } LobbyNetwork.SendLobbyData(NetworkCode.PlayerJoinedLobby); _SwitchMenu(MenuStates.Lobby); } }
private void Awake() { Instance = this; }
/*----------------------------------------------------------------------------------------------------------------- * -- FUNCTION: SetReady * -- * -- DATE: April 04, 2016 * -- * -- DESIGNER: Spenser Lee * -- * -- PROGRAMMER: Spenser Lee & Jerry Jia * -- * -- INTERFACE: void SetReady() * -- * -- RETURNS: void * -- * -- NOTES: * -- On click function to change ready status in the lobby. Sends a netorking packet to update ready status. * -----------------------------------------------------------------------------------------------------------------*/ public void SetReady() { GameData.MyPlayer.Ready = (ready_toggle.isOn ? true : false); LobbyNetwork.SendLobbyData(NetworkCode.ReadyRequest); }
public void SetLobbyNetworkRoom() { LobbyNetwork LN = FindObjectOfType <LobbyNetwork>(); LN.SetRoom(this); }
private void Start() { LN = LobNet.GetComponent <LobbyNetwork>(); }