Exemplo n.º 1
0
        public void ProcessDealCard(NetworkResponse response)
        {
            ResponseDealCard args = response as ResponseDealCard;
            int status = args.status;

            Debug.Log ("DealCard status (actions in queue?): " + status);
        }
Exemplo n.º 2
0
        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>();
                }
            }
            }
            */
        }
Exemplo n.º 3
0
        public void ProcessDealCard(NetworkResponse response)
        {
            ResponseDealCard args = response as ResponseDealCard;

            Debug.Log("DealCard status" + args.status);
            // TODO:
            //dealDummyCard(1);
        }
Exemplo n.º 4
0
        public void ProcessMatchStatus(NetworkResponse response)
        {
            ResponseMatchStatus args = response as ResponseMatchStatus;

            isActive        = args.isActive;
            opponentIsReady = args.opponentIsReady;
            Debug.Log("Player iActive: " + isActive + " opponentIsReady " + opponentIsReady);
        }
Exemplo n.º 5
0
        public void ProcessPrediction(NetworkResponse response)
        {
            ResponsePrediction args = response as ResponsePrediction;

            if (args.status == 0) {
            results = args.results;
            }
        }
Exemplo n.º 6
0
        public void ProcessGameOver(NetworkResponse response)
        {
            ResponseMatchOver args           = response as ResponseMatchOver;
            short             statusResponse = args.status;
            int creditsWon = args.creditsWon;

            Debug.Log("MatchOver creditsWon: " + args.creditsWon);
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        public void ProcessPrediction(NetworkResponse response)
        {
            ResponsePrediction args = response as ResponsePrediction;

            if (args.status == 0)
            {
                results = args.results;
            }
        }
Exemplo n.º 9
0
        public void ProcessMatchInit(NetworkResponse response)
        {
            ResponseMatchInit args = response as ResponseMatchInit;

            if (args.status == 0)
            {
                matchID = args.matchID;
                Debug.Log("MatchID set to: " + matchID);
            }
        }
Exemplo n.º 10
0
    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");
        }
    }
Exemplo n.º 11
0
        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);
        }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
 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");
      *
      * }
      */
 }
Exemplo n.º 15
0
        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());
            }
        }
Exemplo n.º 16
0
        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);
            }
        }
Exemplo n.º 17
0
        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");
            }
            */
        }
Exemplo n.º 18
0
 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");
      * }
      */
 }
Exemplo n.º 19
0
        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);
            }
        }
Exemplo n.º 20
0
        //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
            }
        }
Exemplo n.º 21
0
//	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
                    );
            }
        }
Exemplo n.º 22
0
        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];
//			}
            }
        }
Exemplo n.º 23
0
 public void ProcessUpdateTime(NetworkResponse response)
 {
     ResponseUpdateTime args = response as ResponseUpdateTime;
     currentTime = (args.day - 1) * Constants.MONTH_DURATION / 30;
     scale = args.rate;
 }
Exemplo n.º 24
0
        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");

            }
            */
        }
Exemplo n.º 25
0
        public void ProcessReturnToLobby(NetworkResponse response)
        {
            ResponseReturnLobby args = response as ResponseReturnLobby;

            Debug.Log("Return To Lobby processed" + args.status);
        }
Exemplo n.º 26
0
        public void ProcessCardAttack(NetworkResponse response)
        {
            ResponseCardAttack args = response as ResponseCardAttack;

            Debug.Log("CardAttack MatchID:  " + args.status);
        }
Exemplo n.º 27
0
        public void ProcessEndTurn(NetworkResponse response)
        {
            ResponseEndTurn args = response as ResponseEndTurn;

            Debug.Log("End Turn Response: isActive :" + args.status);
        }
Exemplo n.º 28
0
        public void ProcessSummonCard(NetworkResponse response)
        {
            ResponseSummonCard args = response as ResponseSummonCard;

            Debug.Log("Summon Response MatchID:  ");
        }
Exemplo n.º 29
0
        public void ProcessTreeAttack(NetworkResponse response)
        {
            ResponseTreeAttack args = response as ResponseTreeAttack;

            Debug.Log("TreeAttack attack: " + args.status );
        }
Exemplo n.º 30
0
 public void ProcessQuitMatch(NetworkResponse response)
 {
     ResponseQuitMatch args = response as ResponseQuitMatch;
     bool opponentReadyResponse = false;
     Debug.Log ("Quit Match Response: opponentIsReady :" + opponentReadyResponse);
 }
Exemplo n.º 31
0
 public void ProcessMatchStatus(NetworkResponse response)
 {
     ResponseMatchStatus args = response as ResponseMatchStatus;
     isActive = args.isActive;
     opponentIsReady = args.opponentIsReady;
     Debug.Log("Player iActive: " + isActive + " opponentIsReady " + opponentIsReady );
 }
Exemplo n.º 32
0
 public void ProcessClient(NetworkResponse response)
 {
     ResponseClient args = response as ResponseClient;
     Constants.SESSION_ID = args.session_id;
 }
Exemplo n.º 33
0
        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());
            }
        }
Exemplo n.º 34
0
        public void ProcessSpeciesList(NetworkResponse response)
        {
            ResponseSpeciesList args = response as ResponseSpeciesList;
//		SpeciesTable.Update(args.speciesList);
//		SpeciesTable.speciesList = args.speciesList;
        }
Exemplo n.º 35
0
        public void ProcessCardAttack(NetworkResponse response)
        {
            ResponseCardAttack args = response as ResponseCardAttack;

            Debug.Log("CardAttack MatchID:  " + args.status);
        }
Exemplo n.º 36
0
 public void ProcessParameters(NetworkResponse response)
 {
 }
Exemplo n.º 37
0
 public void ProcessZone(NetworkResponse response)
 {
     ResponseZone args = response as ResponseZone;
 }
Exemplo n.º 38
0
        public void ProcessTreeAttack(NetworkResponse response)
        {
            ResponseTreeAttack args = response as ResponseTreeAttack;

            Debug.Log("TreeAttack attack: " + args.status);
        }
Exemplo n.º 39
0
 public void ProcessEndTurn(NetworkResponse response)
 {
     ResponseEndTurn args = response as ResponseEndTurn;
     bool activeResponse = false;
     Debug.Log ("End Turn Response: isActive :" + activeResponse);
 }
Exemplo n.º 40
0
 public void ProcessSpeciesList(NetworkResponse response)
 {
     ResponseSpeciesList args = response as ResponseSpeciesList;
     //		SpeciesTable.Update(args.speciesList);
     //		SpeciesTable.speciesList = args.speciesList;
 }
Exemplo n.º 41
0
 public void ProcessGameOver(NetworkResponse response)
 {
     ResponseMatchOver args = response as ResponseMatchOver;
     int statusResponse = args.status;
     Debug.Log ("MatchOver status: " + statusResponse);
 }
Exemplo n.º 42
0
 public void CW_ProcessPlayerSelect(CW.NetworkResponse response)
 {
     CW.ResponsePlayerSelect args = response as CW.ResponsePlayerSelect;
 }
Exemplo n.º 43
0
 public void ProcessMatchInit(NetworkResponse response)
 {
     ResponseMatchInit args = response as ResponseMatchInit;
     if (args.status == 0) {
     matchID = args.matchID;
     Debug.Log("MatchID set to: " + matchID);
     }
 }
Exemplo n.º 44
0
        public void ProcessClient(NetworkResponse response)
        {
            ResponseClient args = response as ResponseClient;

            Constants.SESSION_ID = args.session_id;
        }
Exemplo n.º 45
0
 public void ProcessZone(NetworkResponse response)
 {
     ResponseZone args = response as ResponseZone;
 }
Exemplo n.º 46
0
 public void ProcessParameters(NetworkResponse response)
 {
 }
Exemplo n.º 47
0
        //    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
            );
            }
        }
Exemplo n.º 48
0
        public void ProcessSummonCard(NetworkResponse response)
        {
            ResponseSummonCard args = response as ResponseSummonCard;

            Debug.Log("Summon Response MatchID:  " );
        }
Exemplo n.º 49
0
        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];
            //			}
            }
        }