public void ProcessDealCard(NetworkResponse response) { ResponseDealCard args = response as ResponseDealCard; int status = args.status; Debug.Log ("DealCard status (actions in queue?): " + status); }
public void ProcessWorld(NetworkResponse response) { ResponseWorld args = response as ResponseWorld; /* if (args.status == 0) { GameState.world = args.world; SwitchToTileSelect(1); GameObject gObject = GameObject.Find("Global Object"); if (gObject != null) { if (gObject.GetComponent<EcosystemScore>() == null) { gObject.AddComponent<EcosystemScore>(); } if (gObject.GetComponent<GameResources>() == null) { gObject.AddComponent<GameResources>(); } if (gObject.GetComponent<Clock>() == null) { gObject.AddComponent<Clock>(); } if (gObject.GetComponent<Chat>() == null) { gObject.AddComponent<Chat>(); } } } */ }
public void ProcessDealCard(NetworkResponse response) { ResponseDealCard args = response as ResponseDealCard; Debug.Log("DealCard status" + args.status); // TODO: //dealDummyCard(1); }
public void ProcessMatchStatus(NetworkResponse response) { ResponseMatchStatus args = response as ResponseMatchStatus; isActive = args.isActive; opponentIsReady = args.opponentIsReady; Debug.Log("Player iActive: " + isActive + " opponentIsReady " + opponentIsReady); }
public void ProcessPrediction(NetworkResponse response) { ResponsePrediction args = response as ResponsePrediction; if (args.status == 0) { results = args.results; } }
public void ProcessGameOver(NetworkResponse response) { ResponseMatchOver args = response as ResponseMatchOver; short statusResponse = args.status; int creditsWon = args.creditsWon; Debug.Log("MatchOver creditsWon: " + args.creditsWon); }
public List <NetworkResponse> Read(int numPackets = 20) { List <NetworkResponse> responses = new List <NetworkResponse> (); while (theStream.DataAvailable && responses.Count < numPackets) { byte[] buffer = new byte[2]; theStream.Read(buffer, 0, 2); short bufferSize = BitConverter.ToInt16(buffer, 0); buffer = new byte[bufferSize]; //to allow for network latency, check number of bytes read and continue reading //until expected data is received int bytesRead = 0; int counter = 0; do { bytesRead += theStream.Read(buffer, bytesRead, bufferSize - bytesRead); counter++; } while(bytesRead < bufferSize); MemoryStream dataStream = new MemoryStream(buffer); short protocol_id = DataReader.ReadShort(dataStream); Type pType = NetworkProtocolTable.Get(protocol_id); if (counter > 1) { Debug.Log(string.Format( "Note, network latency issue identified, wait count = {0}, protocol ID = {1}", counter, protocol_id )); } //output packet-level info to screen for debugging purposes //DebugPacket (buffer, true, false); if (pType == null) { Debug.LogError("Invalid Response No. " + protocol_id + " [" + "Unknown" + "]"); } else { try { NetworkResponse args = pType.GetMethod("Parse").Invoke(null, new object[] { dataStream }) as NetworkResponse; if (args != null) { responses.Add(args); } } catch (Exception ex) { Debug.LogError("Failed Response No. " + protocol_id + " [" + pType.ToString() + "]"); Debug.LogException(ex); } } } return(responses); }
public void ProcessMatchInit(NetworkResponse response) { ResponseMatchInit args = response as ResponseMatchInit; if (args.status == 0) { matchID = args.matchID; Debug.Log("MatchID set to: " + matchID); } }
public void ProcessMatchInit(CW.NetworkResponse response) { CW.ResponseMatchInit args = response as CW.ResponseMatchInit; if (args.status == 0) { Debug.Log("MatchID set to: " + args.matchID); Game.SwitchScene("CWBattle"); } }
public void processMatchAction(NetworkResponse response) { ResponseMatchAction args = response as ResponseMatchAction; short actionID = args.actionID; if (actionID != 0) { TurnAction action = args.action; action.execute(); } Debug.Log("Match Action code:= " + args.actionID); }
public void ProcessGetDeck(NetworkResponse response) { ResponseGetDeck args = response as ResponseGetDeck; int numFields = args.numFields; int numCards = args.numCards; DeckData deck = args.deck; CardData card = deck.popCard(); Debug.Log("Deck Response: deck count: " + deck.getSize() + " numCards: " + numCards + " num fields: " + numFields); Debug.Log ("Card data: cardID: " + card.cardID + " diet Type: " + card.dietType + " SpeciesName: " + card.speciesName); }
public void ProcessGetDeck(NetworkResponse response) { ResponseGetDeck args = response as ResponseGetDeck; int numFields = args.numFields; int numCards = args.numCards; DeckData deck = args.deck; CardData card = deck.popCard(); Debug.Log("Deck Response: deck count: " + deck.getSize() + " numCards: " + numCards + " num fields: " + numFields); Debug.Log("Card data: cardID: " + card.cardID + " diet Type: " + card.dietType + " SpeciesName: " + card.speciesName); }
public void ProcessPlayerSelect(NetworkResponse response) { /* * ResponsePlayerSelect args = response as ResponsePlayerSelect; * * //TODO: scene is null * if (args.status == 0) { * GameState.player = args.player; * //Application.LoadLevel("Battle"); * //Game.SwitchScene("BattleMainMenu"); //"World"); * Debug.Log ("Switching to CWBattleMainMenu"); * * } */ }
public void ProcessZoneList(NetworkResponse response) { ResponseZoneList args = response as ResponseZoneList; if (args.status == 0) { playerList = args.players; height = args.height; width = args.width; Generate(args.height, args.width, args.zones); Game.StartEnterTransition(); Camera.main.GetComponent <MapCamera>().Setup(); Camera.main.GetComponent <MapCamera>().Center(GameState.player.GetID()); } }
public void ProcessMessage(NetworkResponse response) { ResponseMessage args = response as ResponseMessage; if (args.status == 0) { string message = ""; if (args.type == 0) { if (args.username.Equals(GameState.player.name)) { return; } message += "[" + args.username + "] says: "; } message += args.message; SetMessage(message); } }
public void ProcessLogin(NetworkResponse response) { /* ResponseLogin args = response as ResponseLogin; if (args.status == 0) { GameState.account = args.account; NetworkManager.Send ( PlayerSelectProtocol.Prepare (0), ProcessPlayerSelect ); } else { Debug.Log ("login failed, server message = " + args.status); //mainObject.GetComponent<Main>().CreateMessageBox("Login Failed"); } */ }
public void ProcessLogin(NetworkResponse response) { /* * ResponseLogin args = response as ResponseLogin; * * if (args.status == 0) { * GameState.account = args.account; * * NetworkManager.Send ( * PlayerSelectProtocol.Prepare (0), * ProcessPlayerSelect * ); * * } else { * Debug.Log ("login failed, server message = " + args.status); * //mainObject.GetComponent<Main>().CreateMessageBox("Login Failed"); * } */ }
//Response to the server's ready request public void ProcessMatchStatus(NetworkResponse response) { short status; //Retrieve the response arguments ResponseMatchStatus args = response as ResponseMatchStatus; status = args.status; if (status == Constants.STATUS_SUCCESS) //Request the deck from Server { GetDeck(); //Set variables passed in from server related to the match's status GameManager.player1.isActive = args.isActive; GameManager.opponentIsReady = args.opponentIsReady; //Display the arguments passed from server Debug.Log("GameManager.player1 isActive: " + GameManager.player1.isActive + " opponentIsReady " + GameManager.opponentIsReady); } else { Debug.Log("Failed to acquire Match Status"); // Could return to Lobby Here } }
// void OnGUI() { // windowRect = GUILayout.Window((int) Constants.GUI_ID.World_Menu, windowRect, MakeWindow, "World Menu"); // // windowRect.x = (Screen.width - windowRect.width) / 2; // windowRect.y = (Screen.height - windowRect.height) / 2; // } // // void MakeWindow(int id) { // avatarRect = new Rect(20, 30, 80, 80); // GUI.Box(avatarRect, ""); //// GUI.DrawTexture(avatarRect, avatar); // // List<WorldData> wListSorted = new List<WorldData>(worldList.Values); // // Rect wListBox = new Rect(20, 120, 180, 30); // GUI.Box(wListBox, ""); // // scrollViewVector = GUI.BeginScrollView(wListBox, scrollViewVector, new Rect(0, 0, wListBox.width - 16, wListBox.height * wListSorted.Count), false, true); // for (int i = 0; i < wListSorted.Count; i++) { // if (wListSorted[i] == worldSelected) { // GUI.backgroundColor = Color.black; // } // // if (GUI.Button(new Rect(0, i * 30, wListBox.width - 16, wListBox.height), wListSorted[i].name)) { // worldSelected = wListSorted[i]; // } // // GUI.backgroundColor = Color.white; // } // GUI.EndScrollView(); // // GUIStyle style = new GUIStyle(); // // if (avatarSelected != null) { // style.alignment = TextAnchor.UpperLeft; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(115, 40, 100, 100), name, style); // GUI.Label(new Rect(115, 60, 100, 100), "Level " + avatarSelected.level, style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperRight; // style.normal.textColor = Color.white; // //// GUI.Label(new Rect(170, 60, 100, 100), avatarSelected.coins + " Coins", style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperCenter; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(140, 80, 100, 100), "Last Played on " + last_logout.Split(' ')[0], style); // } // // if (worldSelected != null) { // style = new GUIStyle(); // style.alignment = TextAnchor.UpperLeft; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(20, 160, 100, 100), "Type " + (worldSelected.type + 1), style); // GUI.Label(new Rect(20, 180, 100, 100), "Played " + (worldSelected.play_time / 3600).ToString() + ":" + (worldSelected.play_time % 3600 / 60).ToString().PadLeft(2, '0'), style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperRight; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(100, 160, 100, 100), "Credits: " + worldSelected.credits, style); // GUI.Label(new Rect(100, 180, 100, 100), "Score: " + worldSelected.score, style); // } // // GUILayout.Space(190); // // for (int i = 0; i < 3; i++) { // buttonRectList[i] = new Rect(windowRect.width - 85, 120 + i * 30, 75, 25); // } // // if (GUI.Button(buttonRectList[0], "Join")) { // Join(); // } // // if (GUI.Button(buttonRectList[1], "Create")) { // Create(); // } // // if (GUI.Button(buttonRectList[2], "Delete")) { // Delete(); // } // } // // public void SetAvatarImage(string avatar_id) { // } // // public void Create() { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.CreateAction(0, "", 1, "Savanna", 1, ""); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Creating World..."); // // // Get Default Species // NetworkManager.Send( // SpeciesActionProtocol.Prepare(0, 0), // ProcessSpeciesAction // ); // } // // public void Join() { // ConnectionManager cManager = mainObject.GetComponent<ConnectionManager>(); // // if (cManager) { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.JoinAction(worldSelected.world_id); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Joining World..."); // } // } // // public void Delete() { // ConnectionManager cManager = mainObject.GetComponent<ConnectionManager>(); // // if (cManager) { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.DeleteAction(worldSelected.world_id); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Deleting World..."); // } // } // // public void SwitchToLogin() { // Destroy(this); // GameObject.Find("LoginObject").GetComponent<Login>().Show(); // } // // public void ResponseWorldMenuAction(NetworkResponse response) { //// ResponseWorldMenuActionresponse args = response as ResponseWorldMenuActionresponse; //// //// switch (args.action) { //// case 1: // Create //// if (args.status == 0) { //// WorldData world = new WorldData(args.world_id); //// world.name = args.name; //// world.credits = args.credits; //// world.month = args.month; //// //// worldList.Add(args.world_id, world); //// } //// break; //// case 2: // Join //// if (args.status == 0) { //// WorldData world = new WorldData(args.world_id); //// world.name = args.name; //// world.credits = args.credits; //// world.month = args.month; //// //// GameState.world = world; //// Application.LoadLevel("World");//World //// } //// break; //// case 3: // Delete //// worldList.Remove(args.world_id); //// //// if (worldList.Count > 0) { //// worldSelected = new List<WorldData>(worldList.Values)[0]; //// } //// break; //// default: //// break; //// } // } public void ProcessSpeciesAction(NetworkResponse response) { ResponseSpeciesAction args = response as ResponseSpeciesAction; if (args.action == 0) { Dictionary <int, int> speciesList = new Dictionary <int, int>(); foreach (string item in args.selectionList.Split(',')) { string[] pair = item.Split(':'); int species_id = int.Parse(pair[0]); int biomass = int.Parse(pair[1]); speciesList.Add(species_id, biomass); Debug.Log(species_id + " " + biomass); } NetworkManager.Send( SpeciesActionProtocol.Prepare(1, speciesList), ProcessSpeciesAction ); } }
public void ProcessZoneUpdate(NetworkResponse response) { ResponseZoneUpdate args = response as ResponseZoneUpdate; if (args.status == 0) { // Debug.Log("update tile"); // var tile = (GameObject)zoneList[args.tile_id]; // // var oldOwner = tile.GetComponent<Zone>().player_id; // Debug.Log("Old Owner: " + oldOwner); // tile.GetComponent<Zone>().player_id = args.owner_id; // var ownerID = tile.GetComponent<Zone>().player_id; // Debug.Log("New Owner: " + ownerID); // if (oldOwner == 0 ) // { // GameObject tileOwnershipGameObject = GameObject.Instantiate(owned_tile) as GameObject; // tileOwnershipGameObject.SetActive(true); // tileOwnershipGameObject.transform.position = tile.transform.position; // tileOwnershipGameObject.transform.parent = tile.transform; // tileOwnershipGameObject.renderer.material = colorMats[playerList[ownerID].color - 1]; // } } }
public void ProcessUpdateTime(NetworkResponse response) { ResponseUpdateTime args = response as ResponseUpdateTime; currentTime = (args.day - 1) * Constants.MONTH_DURATION / 30; scale = args.rate; }
public void ProcessPlayerSelect(NetworkResponse response) { /* ResponsePlayerSelect args = response as ResponsePlayerSelect; //TODO: scene is null if (args.status == 0) { GameState.player = args.player; //Application.LoadLevel("Battle"); //Game.SwitchScene("BattleMainMenu"); //"World"); Debug.Log ("Switching to CWBattleMainMenu"); } */ }
public void ProcessReturnToLobby(NetworkResponse response) { ResponseReturnLobby args = response as ResponseReturnLobby; Debug.Log("Return To Lobby processed" + args.status); }
public void ProcessCardAttack(NetworkResponse response) { ResponseCardAttack args = response as ResponseCardAttack; Debug.Log("CardAttack MatchID: " + args.status); }
public void ProcessEndTurn(NetworkResponse response) { ResponseEndTurn args = response as ResponseEndTurn; Debug.Log("End Turn Response: isActive :" + args.status); }
public void ProcessSummonCard(NetworkResponse response) { ResponseSummonCard args = response as ResponseSummonCard; Debug.Log("Summon Response MatchID: "); }
public void ProcessTreeAttack(NetworkResponse response) { ResponseTreeAttack args = response as ResponseTreeAttack; Debug.Log("TreeAttack attack: " + args.status ); }
public void ProcessQuitMatch(NetworkResponse response) { ResponseQuitMatch args = response as ResponseQuitMatch; bool opponentReadyResponse = false; Debug.Log ("Quit Match Response: opponentIsReady :" + opponentReadyResponse); }
public void ProcessMatchStatus(NetworkResponse response) { ResponseMatchStatus args = response as ResponseMatchStatus; isActive = args.isActive; opponentIsReady = args.opponentIsReady; Debug.Log("Player iActive: " + isActive + " opponentIsReady " + opponentIsReady ); }
public void ProcessClient(NetworkResponse response) { ResponseClient args = response as ResponseClient; Constants.SESSION_ID = args.session_id; }
public void ProcessZoneList(NetworkResponse response) { ResponseZoneList args = response as ResponseZoneList; if (args.status == 0) { playerList = args.players; height = args.height; width = args.width; Generate(args.height, args.width, args.zones); Game.StartEnterTransition(); Camera.main.GetComponent<MapCamera>().Setup(); Camera.main.GetComponent<MapCamera>().Center(GameState.player.GetID()); } }
public void ProcessSpeciesList(NetworkResponse response) { ResponseSpeciesList args = response as ResponseSpeciesList; // SpeciesTable.Update(args.speciesList); // SpeciesTable.speciesList = args.speciesList; }
public void ProcessParameters(NetworkResponse response) { }
public void ProcessZone(NetworkResponse response) { ResponseZone args = response as ResponseZone; }
public void ProcessTreeAttack(NetworkResponse response) { ResponseTreeAttack args = response as ResponseTreeAttack; Debug.Log("TreeAttack attack: " + args.status); }
public void ProcessEndTurn(NetworkResponse response) { ResponseEndTurn args = response as ResponseEndTurn; bool activeResponse = false; Debug.Log ("End Turn Response: isActive :" + activeResponse); }
public void ProcessGameOver(NetworkResponse response) { ResponseMatchOver args = response as ResponseMatchOver; int statusResponse = args.status; Debug.Log ("MatchOver status: " + statusResponse); }
public void CW_ProcessPlayerSelect(CW.NetworkResponse response) { CW.ResponsePlayerSelect args = response as CW.ResponsePlayerSelect; }
// void OnGUI() { // windowRect = GUILayout.Window((int) Constants.GUI_ID.World_Menu, windowRect, MakeWindow, "World Menu"); // // windowRect.x = (Screen.width - windowRect.width) / 2; // windowRect.y = (Screen.height - windowRect.height) / 2; // } // // void MakeWindow(int id) { // avatarRect = new Rect(20, 30, 80, 80); // GUI.Box(avatarRect, ""); //// GUI.DrawTexture(avatarRect, avatar); // // List<WorldData> wListSorted = new List<WorldData>(worldList.Values); // // Rect wListBox = new Rect(20, 120, 180, 30); // GUI.Box(wListBox, ""); // // scrollViewVector = GUI.BeginScrollView(wListBox, scrollViewVector, new Rect(0, 0, wListBox.width - 16, wListBox.height * wListSorted.Count), false, true); // for (int i = 0; i < wListSorted.Count; i++) { // if (wListSorted[i] == worldSelected) { // GUI.backgroundColor = Color.black; // } // // if (GUI.Button(new Rect(0, i * 30, wListBox.width - 16, wListBox.height), wListSorted[i].name)) { // worldSelected = wListSorted[i]; // } // // GUI.backgroundColor = Color.white; // } // GUI.EndScrollView(); // // GUIStyle style = new GUIStyle(); // // if (avatarSelected != null) { // style.alignment = TextAnchor.UpperLeft; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(115, 40, 100, 100), name, style); // GUI.Label(new Rect(115, 60, 100, 100), "Level " + avatarSelected.level, style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperRight; // style.normal.textColor = Color.white; // //// GUI.Label(new Rect(170, 60, 100, 100), avatarSelected.coins + " Coins", style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperCenter; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(140, 80, 100, 100), "Last Played on " + last_logout.Split(' ')[0], style); // } // // if (worldSelected != null) { // style = new GUIStyle(); // style.alignment = TextAnchor.UpperLeft; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(20, 160, 100, 100), "Type " + (worldSelected.type + 1), style); // GUI.Label(new Rect(20, 180, 100, 100), "Played " + (worldSelected.play_time / 3600).ToString() + ":" + (worldSelected.play_time % 3600 / 60).ToString().PadLeft(2, '0'), style); // // style = new GUIStyle(); // style.alignment = TextAnchor.UpperRight; // style.normal.textColor = Color.white; // // GUI.Label(new Rect(100, 160, 100, 100), "Credits: " + worldSelected.credits, style); // GUI.Label(new Rect(100, 180, 100, 100), "Score: " + worldSelected.score, style); // } // // GUILayout.Space(190); // // for (int i = 0; i < 3; i++) { // buttonRectList[i] = new Rect(windowRect.width - 85, 120 + i * 30, 75, 25); // } // // if (GUI.Button(buttonRectList[0], "Join")) { // Join(); // } // // if (GUI.Button(buttonRectList[1], "Create")) { // Create(); // } // // if (GUI.Button(buttonRectList[2], "Delete")) { // Delete(); // } // } // // public void SetAvatarImage(string avatar_id) { // } // // public void Create() { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.CreateAction(0, "", 1, "Savanna", 1, ""); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Creating World..."); // // // Get Default Species // NetworkManager.Send( // SpeciesActionProtocol.Prepare(0, 0), // ProcessSpeciesAction // ); // } // // public void Join() { // ConnectionManager cManager = mainObject.GetComponent<ConnectionManager>(); // // if (cManager) { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.JoinAction(worldSelected.world_id); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Joining World..."); // } // } // // public void Delete() { // ConnectionManager cManager = mainObject.GetComponent<ConnectionManager>(); // // if (cManager) { //// RequestWorldMenuAction request = new RequestWorldMenuAction(); //// request.DeleteAction(worldSelected.world_id); //// //// cManager.Send(request); //// messageBox = mainObject.GetComponent<Main>().CreateMessageBox("Deleting World..."); // } // } // // public void SwitchToLogin() { // Destroy(this); // GameObject.Find("LoginObject").GetComponent<Login>().Show(); // } // // public void ResponseWorldMenuAction(NetworkResponse response) { //// ResponseWorldMenuActionresponse args = response as ResponseWorldMenuActionresponse; //// //// switch (args.action) { //// case 1: // Create //// if (args.status == 0) { //// WorldData world = new WorldData(args.world_id); //// world.name = args.name; //// world.credits = args.credits; //// world.month = args.month; //// //// worldList.Add(args.world_id, world); //// } //// break; //// case 2: // Join //// if (args.status == 0) { //// WorldData world = new WorldData(args.world_id); //// world.name = args.name; //// world.credits = args.credits; //// world.month = args.month; //// //// GameState.world = world; //// Application.LoadLevel("World");//World //// } //// break; //// case 3: // Delete //// worldList.Remove(args.world_id); //// //// if (worldList.Count > 0) { //// worldSelected = new List<WorldData>(worldList.Values)[0]; //// } //// break; //// default: //// break; //// } // } public void ProcessSpeciesAction(NetworkResponse response) { ResponseSpeciesAction args = response as ResponseSpeciesAction; if (args.action == 0) { Dictionary<int, int> speciesList = new Dictionary<int, int>(); foreach (string item in args.selectionList.Split(',')) { string[] pair = item.Split(':'); int species_id = int.Parse(pair[0]); int biomass = int.Parse(pair[1]); speciesList.Add(species_id, biomass); Debug.Log(species_id + " " + biomass); } NetworkManager.Send( SpeciesActionProtocol.Prepare(1, speciesList), ProcessSpeciesAction ); } }
public void ProcessSummonCard(NetworkResponse response) { ResponseSummonCard args = response as ResponseSummonCard; Debug.Log("Summon Response MatchID: " ); }