public int DebugSkillUpDown(string kaitou, bool log = true) { int u = 0; int d = 0; int u1 = 0; int d1 = 0; int u2 = 0; int d2 = 0; int u3 = 0; int d3 = 0; foreach (var m in NeedFixRecords) { if (m.GetSpeedType() == SpeedChangeType.SkillUp) { u3++; } else if (m.GetSpeedType() == SpeedChangeType.SkillDown) { d3++; } } foreach (var m in HistoryRecords) { if (m.GetSpeedType() == SpeedChangeType.SkillUp) { u1++; } else if (m.GetSpeedType() == SpeedChangeType.SkillDown) { d1++; } } if (CurMagicRecord.GetSpeedType() == SpeedChangeType.SkillUp) { u++; } else if (CurMagicRecord.GetSpeedType() == SpeedChangeType.SkillDown) { d++; } foreach (var m in FutureExeMoves) { if (m.GetSpeedType() == SpeedChangeType.SkillUp) { u2++; } else if (m.GetSpeedType() == SpeedChangeType.SkillDown) { d2++; } } if (log) { DebugConsole.LogWarning(kaitou + " UPDOWN:History(" + u1 + ":" + d1 + ") " + "Future(" + u2 + ":" + d2 + ") " + "Now(" + u + ":" + d + ") " + "Fix(" + u3 + ":" + d3 + ") " + "Sum(" + (u + u1 + u2 + u3) + ":" + (d + d1 + d2 + d3) + ")"); } return((u + u1 + u2 + u3) - (d + d1 + d2 + d3)); }
void OnPlayerDisconnected(NetworkPlayer player) { DebugConsole.LogWarning("The following player disconnected, cleaning up: " + player); GameStateServer.Instance.PlayerDisconnected(player); Network.RemoveRPCs(player); Network.DestroyPlayerObjects(player); }
//from the client public void SendServerMess( NetworkClient.MessType_ToServer messType, string args ) //public void SendServerMess( NetworkClient.MessType messType, string args ) { DebugConsole.LogWarning( "Sending message to server: " + messType.ToString() ); if( args != null && args.Length > 0 ) DebugConsole.Log( "args: " + args ); if( Network.isClient ) { //DebugConsole.LogWarning("network: " + Network.peerType); if( args != null && args.Length > 0 ) { //DebugConsole.Log( " args - [" + string.Join(",",args) + "]" ); //networkView.RPC("ToServerWString", RPCMode.Server, networkView.viewID, messType, string.Join(",",args) ); networkView.RPC("ToServerWString", RPCMode.Server, networkView.viewID, (int)messType, args ); } else { //DebugConsole.LogWarning( "null or zero length arguments to SendServerMess." ); networkView.RPC("ToServerNoArgs", RPCMode.Server, networkView.viewID, (int)messType ); } //DebugConsole.LogWarning( "Done sending message to server." ); } else{ DebugConsole.LogError( "Did not send server mess, because I AM THE SERVER." ); } }
//from the server public void SendClientMess(NetworkPlayer player, NetworkClient.MessType_ToClient messType, params string[] args) { DebugConsole.LogWarning("Sending message to player " + player + ": " + messType.ToString()); if (args != null && args.Length > 0) { DebugConsole.Log("args: " + RayToString(args, ",")); } if (Network.isServer) { //DebugConsole.Log( "SendClientMess( int messType )" ); if (args != null && args.Length > 0) { networkView.RPC("FromServerWString", player, networkView.viewID, (int)messType, RayToString(args, ",")); } else { //DebugConsole.LogWarning( "null or zero length arguments to SendClientMess." ); networkView.RPC("FromServerNoArgs", player, networkView.viewID, (int)messType); } //DebugConsole.LogWarning( "Done sending message to client." ); } else { DebugConsole.LogWarning("Did not send client mess, because I AM A CLIENT."); } }
void ServerConfigWindow(int windowID) { //DebugConsole.IsOpen = true; if (GUILayout.Button("Quit")) { Application.Quit(); } if (GUILayout.Button("Start Server")) { NetworkServer.Instance.StartServer(); } if (GUILayout.Button("Stop Server")) { NetworkServer.Instance.StopServer(); } if (GUILayout.Button("Test Connection")) { NetworkServer.Instance.TestConnection(); } if (GUILayout.Button("Toggle debug")) { DebugConsole.IsOpen = !DebugConsole.IsOpen; } if (GUILayout.Button("Network Info")) { //DebugConsole.IsOpen = true; DebugConsole.LogWarning("network: " + Network.peerType); if (networkView == null) { DebugConsole.Log("networkView == null"); if (NetworkClient.Instance.target != null) { DebugConsole.Log("Got target from client controller."); DebugConsole.Log("networkView: " + NetworkClient.Instance.target.networkView); DebugConsole.Log("networkView.viewID: " + NetworkClient.Instance.target.networkView.viewID); } } else { DebugConsole.Log("networkView != null" + networkView); /* * if( networkView.viewID == null ) * { * DebugConsole.Log("networkView.viewID == null"); * } * else * { * DebugConsole.Log("networkView.viewID != null" + networkView.viewID); * } * * DebugConsole.Log("networkView.group != null" + networkView.group); */ } } }
public bool TestCancelMoveCtrlCommand(long time, float dirX, float dirZ, SpeedChangeType speedType, int index, int deleteIndex) { DebugSkillUpDown("Cancel Before ADD"); bool ret = true; NeedFixRecords.Clear(); //如果要取消的操作已经执行了,那么就不需要取消了 if (FutureExeMoves.Count > 0) { int deleteIdx = -1; bool bAdd = false; MagicMoveRecord tar = null; for (int i = FutureExeMoves.Count - 1; i >= 0; i--) { var tmp = FutureExeMoves[i]; if (tmp.GetCMDIndex() == deleteIndex && tmp.GetSpeedType() == SpeedChangeType.SkillDown) { bAdd = true; deleteIdx = i; tar = tmp; break; } } if (deleteIdx >= 0) { DebugConsole.LogWarning("discard 22222:" + tar.ToString()); FutureExeMoves.RemoveAt(deleteIdx); } if (bAdd) { ret = true; TestAddMoveCtrlCommand(time, dirX, dirZ, speedType, index); } else { ret = false; } } DebugSkillUpDown("Cancel After ADD"); return(ret); }
void FromServerWString( NetworkViewID viewID , int messType, string args )//, NetworkMessageInfo nmi { //DebugConsole.LogWarning( "Called the string param version of the rpc." ); if( Network.isServer ) DebugConsole.LogError( "Oh noz, FromServer invoked on the server (bad)." ); //if( Network.isClient ) DebugConsole.LogWarning( "FromServer invoked on client (good)." ); string[] rayArgs = null; if( args == null ) DebugConsole.LogWarning( "FromServer had null string arguments." ); else { //DebugConsole.Log( "args - " + args ); rayArgs = args.Split( new char[] {','} ); } NetworkClient.MessType_ToClient castMess = (NetworkClient.MessType_ToClient) messType; GameStateClient.Instance.MessageFromServer( castMess, rayArgs ); }
void ToServerWString( NetworkViewID viewID , int messType, string args , NetworkMessageInfo nmi ) { #if UNITY_WEBPLAYER #else //DebugConsole.LogWarning( "Called the string param version of the rpc." ); DebugConsole.LogWarning( "Message from client: " + nmi.sender ); DebugConsole.LogWarning("Type: " + ((NetworkClient.MessType_ToServer)messType).ToString() + ". Args: " + args); if( Network.isClient ) DebugConsole.LogError( "Oh noz, ToServer invoked on the client." ); //if( Network.isServer ) DebugConsole.LogWarning( "ToServer invoked on server." ); //string[] rayArgs = null; if( args == null ) DebugConsole.LogWarning("ToServerWString had null string arguments."); NetworkClient.MessType_ToServer castMess = (NetworkClient.MessType_ToServer) messType; GameStateServer.Instance.MessageFromClient( nmi.sender, castMess, args ); #endif }
public void PlayerDisconnected(NetworkPlayer player) { //clean up waiting pool int tmpI = playersWaitingToGo.IndexOf(player); if (tmpI >= 0) //disconnected from wait room. { playersWaitingToGo.RemoveAt(tmpI); } else { //disconnected from active game. //clean up active pool if (dPlayerToGamedata.ContainsKey(player)) { RunningGameData rgd = dPlayerToGamedata[player]; rgd.PlayerDisconnected(player); } else { Debug.LogWarning("Player disconnected, however they were not in the waiting pool nor do I have running game data for them."); } } DebugConsole.LogWarning("Number players in waiting: " + playersWaitingToGo.Count); }
//always sends relation list; handles wait room && pair up logic //autmotatically invoked public void PlayerConnected(NetworkPlayer player) { DebugConsole.LogWarning("Have a single player waiting to begin: player" + player); playersWaitingToGo.Add(player); // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.RelationsList, strListRelations ); }
//THIS IS THE KEY METHOD OF THIS CLASS public void MessageFromClient(NetworkPlayer player, NetworkClient.MessType_ToServer messType, string args) { DebugConsole.LogWarning("GameStateServer.MessageFromClient " + player + ": " + messType.ToString()); DebugConsole.Log("args: "); if (args == null || args.Length == 0) { DebugConsole.Log("<null or zero length>"); } else { DebugConsole.Log(args); } //if( args != null && args.Length > 0 ) DebugConsole.Log( NetworkClient.RayToString( args ) ); RunningGameData rgd = getRunningGameData(player, messType, args); if (rgd == null) { return; //this is ok. } DebugConsole.Log("Hitting big message demux."); switch (messType) { //TODO case NetworkClient.MessType_ToServer.ReadDBStr: "udid" arg case NetworkClient.MessType_ToServer.ReadDBStr: if (String.Compare("udid", args, true) == 0) { NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.UNTYPED, dbManip.getPlayerUDID(rgd.dPlayerData[player].playerid)); } break; case NetworkClient.MessType_ToServer.SaveDBStr: DebugConsole.Log("client requested save string : " + args); dbManip.dataDump(rgd.gameID, rgd.dPlayerData[player].playerid, args); DebugConsole.Log("dumped string info : " + rgd.gameID + ", " + rgd.dPlayerData[player].playerid + ", " + args); break; case NetworkClient.MessType_ToServer.DomainObjectIDsDeleted: // rgd.Mess_DomainObjectIDsDeleted( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.DomainObjectIDsNOTDeleted: // rgd.Mess_DomainObjectIDsNOTDeleted( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.DomainObjectNamesAdded: // rgd.Mess_DomainObjectNamesAdded( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.JustGotToSwanScreen: //has playerScore arg; for when we're not doing add/remove objects screen // rgd.Mess_JustGotToSwanScreen( player, args ); break; case NetworkClient.MessType_ToServer.SelectedRelation: //DebugConsole.Log( "MessageFromClient: MessType.SelectedRelation" ); // rgd.Mess_SelectedRelation( player, args ); break; case NetworkClient.MessType_ToServer.SwanAtEndOfScreen: //has playerScore, millisec args // rgd.Mess_SwanAtEndOfScreen( player, args ); break; case NetworkClient.MessType_ToServer.PlayerHasNoLives: //has playerScore arg // rgd.Mess_PlayerHasNoLives( player, args ); break; case NetworkClient.MessType_ToServer.PlayAgain: //HANDLED IN getRunningGameData //PlayerConnected( player ); // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.RelationsList, strListRelations ); //select, send the domain // System.Collections.Generic.KeyValuePair<int,System.Text.StringBuilder> ansPair = rgd.SelectDomainid(); // if( ansPair.Equals( default(KeyValuePair<int,System.Text.StringBuilder>) ) ) // { //no more domains to work on! // rgd.EndGame( "No more domains to play!", null ); // }else{ // rgd.ResetVarsForNewGame(); // rgd.domainID = ansPair.Key; // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.DomainDescription, ansPair.Value.ToString() ); // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.PlayerPairReady ); // } break; case NetworkClient.MessType_ToServer.DeviceUniqueIdentifier: //may be HANDLED IN getRunningGameData rgd.SetUniqueDeviceID(player, args); //comes from NetworkClient.OnConnectedToServer DebugConsole.Log("Got a UDID of: " + args); break; // UNIQUE AND SPECIFIC TO SNG ONLY // Whenever we want to create a new game, we do this. case NetworkClient.MessType_ToServer.SNGRequestNewGame: int gameId = dbManip.SaveGameBasics(dbManip.getPlayerUDID(rgd.dPlayerData[player].playerid)); rgd.gameID = gameId; dbManip.SaveGameType(rgd.gameID, rgd.gameMode); List <string> objectSet = DBGWAPLoader.GenerateRandomObjectSet(7); List <string> tagSet = DBGWAPLoader.GenerateRandomTagset(); rgd.objectSet = objectSet; rgd.tagSet = tagSet; // Sends the game mode NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGGameMode, rgd.gameMode.ToString()); // Construct the object and tag sets. if (objectSet != null) { NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGObjectSet, DBStringHelper.listToString(objectSet, ',')); } if (tagSet != null) { if (rgd.gameMode == 3) { List <string> modifiedTagSet = new List <string>(tagSet); modifiedTagSet[1] = tagSet[1] + "-compete"; modifiedTagSet.Add(tagSet[1] + "-collab"); NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGTagSet, DBStringHelper.listToString(modifiedTagSet, ',')); } else { NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGTagSet, DBStringHelper.listToString(tagSet, ',')); } } int gamemode = dbManip.LookupPlayerGametype(rgd.dPlayerData[player].playerid); DebugConsole.Log("Game mode found = " + gamemode); if (gamemode == -1) { DebugConsole.Log("Need to add a new player."); dbManip.SavePlayerGameType(rgd.dPlayerData[player].playerid, rgd.gameMode); } break; case NetworkClient.MessType_ToServer.SNGRequestGameMode: if (rgd.gameMode == -1) { int gt = dbManip.LookupPlayerGametype(rgd.dPlayerData[player].playerid); if (gt != -1) { DebugConsole.Log("Found an old player. Their gametype is : " + gt); rgd.gameMode = gt; } else { rgd.gameMode = UnityEngine.Random.Range(1, 4); DebugConsole.Log("Found a new player! Assigning a random gametype of " + rgd.gameMode); dbManip.SavePlayerGameType(rgd.dPlayerData[player].playerid, rgd.gameMode); } } NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGGameMode, rgd.gameMode.ToString()); break; case NetworkClient.MessType_ToServer.SNGRequestTrace: // (OH GOD BAD HARDCODED NUMBERS) string[] times = (dbManip.LookupRandomTraces(1, 1))[0].Split(','); DebugConsole.Log("Got a random timing thing from the database."); // Construct and send the partner trace. List <Triple <double, string, string> > partnerTrace; if (rgd.gameMode == 3) // BOTH MODE { List <string> opponentTrace = new List <string>(); opponentTrace.Add(rgd.tagSet[1]); opponentTrace.Add(rgd.tagSet[0] + "-compete"); opponentTrace.Add(rgd.tagSet[0] + "-collab"); partnerTrace = DBGWAPLoader.ConstructRandomPartnerTrace(times, rgd.objectSet, opponentTrace); } else { partnerTrace = DBGWAPLoader.ConstructRandomPartnerTrace(times, rgd.objectSet, rgd.tagSet); } if (partnerTrace != null) { NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.SNGOpponentTrace, DBStringHelper.traceToString(partnerTrace, ':')); DebugConsole.Log("SENT A TRACE!"); } else { DebugConsole.Log("DIDN'T SEND TRACE!"); } break; case NetworkClient.MessType_ToServer.SNGSaveDBTrace: DebugConsole.Log("Got a trace from a player."); string[] traces = args.Split(','); // This is a really awful hack...someone just kill me please. // Basically, if I want to reuse all of my string helper functions, I have to manhandle some strings. // THIS IS WHY THE CLIENT SHOULDN'T AUTOSPLIT STRINGS WHEN READING FROM THE SERVER DAMMIT. // YOUR LOGIC IS NOT TWO-WAY...RANT...RANT...RAAAAAAAAAAAAAANT. for (int i = 0; i < traces.Length; i++) { traces[i] = traces[i].Replace(':', ','); } if (traces.Length != 3) { DebugConsole.Log("Ill-formed trace info."); break; } dbManip.SaveTraceResults(rgd.gameID, 1, traces[0]); dbManip.SaveTraceResults(rgd.gameID, 2, traces[1]); dbManip.SaveTraceResults(rgd.gameID, 3, traces[2]); string objSetStr = DBStringHelper.listToString(rgd.objectSet, ','); string tagSetStr = DBStringHelper.listToString(rgd.tagSet, ','); // XXX (kasiu): Need to save score properly dbManip.SaveGameGwapData(rgd.gameID, 0, rgd.dPlayerData[player].playerid, objSetStr, tagSetStr); // Increment player score: dbManip.IncrementPlayerGameCount(rgd.dPlayerData[player].playerid); break; case NetworkClient.MessType_ToServer.SNGSavePlayerData: // used for SNG only int gametype = dbManip.LookupPlayerGametype(rgd.dPlayerData[player].playerid); if (gametype != -1) { DebugConsole.Log("Found an old player. Their gametype is : " + gametype); rgd.gameMode = gametype; } else { rgd.gameMode = UnityEngine.Random.Range(1, 4); DebugConsole.Log("Found a new player! Assigning a random gametype of " + rgd.gameMode); dbManip.SavePlayerGameType(rgd.dPlayerData[player].playerid, rgd.gameMode); //dbManip.SavePlayerInformation(dbManip.getPlayerUDID(rgd.dPlayerData[player].playerid), rgd.gameMode); } break; case NetworkClient.MessType_ToServer.SNGSavePlayerLikertData: DebugConsole.Log("Got some survey data! We'll be saving this!"); string[] answers = args.Split(':'); dbManip.SavePlayerLikertScores(rgd.dPlayerData[player].playerid, answers); break; case NetworkClient.MessType_ToServer.SNGSavePlayerScore: dbManip.SaveGameScore(rgd.gameID, System.Convert.ToInt32(args)); break; /* * BULLETHELL CODE */ case NetworkClient.MessType_ToServer.BHSaveParamTrace: DebugConsole.Log("Got a trace from a player."); dbManip.SaveTraceResults(rgd.gameID, 4, args); // trace type 4 = bullethell parameter tuning trace // Increment player score: dbManip.IncrementPlayerBHDesignCount(rgd.dPlayerData[player].playerid); break; default: DebugConsole.Log("MessageFromClient: default"); break; } }
public static void SystemLogWarning(string message, string stackTrace) { DebugExecution.AddSystemLog(LogType.Warning, message, stackTrace, "ALL"); DebugConsole.LogWarning(message); }
public static void LogWarning(object message, UnityEngine.Object context) { DebugExecution.AddLog(LogType.Warning, message.ToString(), "ALL"); DebugConsole.LogWarning(message); }
public static void LogWarning(object message, string messagegroup) { DebugExecution.AddLog(LogType.Warning, message.ToString(), messagegroup); DebugConsole.LogWarning(message, messagegroup); }
//THIS IS THE KEY METHOD OF THIS CLASS public void MessageFromClient(NetworkPlayer player, NetworkClient.MessType_ToServer messType, string args) { DebugConsole.LogWarning("GameStateServer.MessageFromClient " + player + ": " + messType.ToString()); DebugConsole.Log("args: "); if (args == null || args.Length == 0) { DebugConsole.Log("<null or zero length>"); } else { DebugConsole.Log(args); } //if( args != null && args.Length > 0 ) DebugConsole.Log( NetworkClient.RayToString( args ) ); RunningGameData rgd = getRunningGameData(player, messType, args); if (rgd == null) { return; //this is ok. } DebugConsole.Log("Hitting big message demux."); switch (messType) { //TODO case NetworkClient.MessType_ToServer.ReadDBStr: "udid" arg case NetworkClient.MessType_ToServer.ReadDBStr: if (String.Compare("udid", args, true) == 0) { NetworkClient.Instance.SendClientMess(player, NetworkClient.MessType_ToClient.UNTYPED, dbManip.getPlayerUDID(rgd.dPlayerData[player].playerid)); } break; case NetworkClient.MessType_ToServer.SaveDBStr: DebugConsole.Log("client requested save string : " + args); dbManip.dataDump(rgd.gameID, rgd.dPlayerData[player].playerid, args); DebugConsole.Log("dumped string info : " + rgd.gameID + ", " + rgd.dPlayerData[player].playerid + ", " + args); break; case NetworkClient.MessType_ToServer.DomainObjectIDsDeleted: // rgd.Mess_DomainObjectIDsDeleted( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.DomainObjectIDsNOTDeleted: // rgd.Mess_DomainObjectIDsNOTDeleted( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.DomainObjectNamesAdded: // rgd.Mess_DomainObjectNamesAdded( player, args ); // rgd.SendFinalListAndFirstPairWhenReady( player ); break; case NetworkClient.MessType_ToServer.JustGotToSwanScreen: //has playerScore arg; for when we're not doing add/remove objects screen // rgd.Mess_JustGotToSwanScreen( player, args ); break; case NetworkClient.MessType_ToServer.SelectedRelation: //DebugConsole.Log( "MessageFromClient: MessType.SelectedRelation" ); // rgd.Mess_SelectedRelation( player, args ); break; case NetworkClient.MessType_ToServer.SwanAtEndOfScreen: //has playerScore, millisec args // rgd.Mess_SwanAtEndOfScreen( player, args ); break; case NetworkClient.MessType_ToServer.PlayerHasNoLives: //has playerScore arg // rgd.Mess_PlayerHasNoLives( player, args ); break; case NetworkClient.MessType_ToServer.PlayAgain: //HANDLED IN getRunningGameData //PlayerConnected( player ); // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.RelationsList, strListRelations ); //select, send the domain // System.Collections.Generic.KeyValuePair<int,System.Text.StringBuilder> ansPair = rgd.SelectDomainid(); // if( ansPair.Equals( default(KeyValuePair<int,System.Text.StringBuilder>) ) ) // { //no more domains to work on! // rgd.EndGame( "No more domains to play!", null ); // }else{ // rgd.ResetVarsForNewGame(); // rgd.domainID = ansPair.Key; // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.DomainDescription, ansPair.Value.ToString() ); // NetworkClient.Instance.SendClientMess( player, NetworkClient.MessType_ToClient.PlayerPairReady ); // } break; case NetworkClient.MessType_ToServer.DeviceUniqueIdentifier: //may be HANDLED IN getRunningGameData rgd.SetUniqueDeviceID(player, args); //comes from NetworkClient.OnConnectedToServer DebugConsole.Log("Got a UDID of: " + args); break; default: DebugConsole.Log("MessageFromClient: default"); break; } }
void ConfigWindow(int windowID) { //DebugConsole.IsOpen = true; if (GUILayout.Button("Quit")) { DebugConsole.Log("quit from login screen"); Application.Quit(); } if (GUILayout.Button("Connect To Server")) { if (NetworkClient.Instance.ConnectToFirstAvailable()) { DebugConsole.Log("I connected !"); Application.LoadLevel(2); } } if (GUILayout.Button("RPC - Spawn network box")) { //NetworkViewID viewID = Network.AllocateViewID(); //networkView.RPC("SpawnBox", RPCMode.AllBuffered, viewID, transform.position); NetworkViewID nvid = Network.AllocateViewID(); DebugConsole.Log("Calling 'SendAllSpawnBox' with network view ID: " + nvid); NetworkClient.Instance.SendAllSpawnBox(Vector3.zero, nvid); //consider doing something like http://docs.unity3d.com/Documentation/Components/net-NetworkInstantiate.html //Network.Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube), Vector3.zero, Quaternion.identity, 0); } if (GUILayout.Button("State Synchronization - Spawn network box")) { NetworkViewID nvid = Network.AllocateViewID(); DebugConsole.Log("Calling 'SendAllSpawnBoxSync' with network view ID: " + nvid); NetworkClient.Instance.SendAllSpawnBoxSync(Vector3.zero, nvid); //consider doing something like http://docs.unity3d.com/Documentation/Components/net-NetworkInstantiate.html //Network.Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube), Vector3.zero, Quaternion.identity, 0); } if (GUILayout.Button("State Synchronization - sync global variable")) { NetworkViewID nvid = Network.AllocateViewID(); DebugConsole.Log("Calling 'SendAllScoreSync' with network view ID: " + nvid); NetworkClient.Instance.SendAllScoreSync(Vector3.zero, nvid); //consider doing something like http://docs.unity3d.com/Documentation/Components/net-NetworkInstantiate.html //Network.Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube), Vector3.zero, Quaternion.identity, 0); } if (GUILayout.Button("Spawn DB box")) { GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube); go.transform.position = Vector3.zero; go.transform.rotation = Quaternion.identity; go.AddComponent <Rigidbody>(); go.GetComponent <Rigidbody>().useGravity = false; //go.gameObject.tag = "DB_cube"; go.name = "DB_cube"; go.AddComponent <DBPositionToString>(); // attach component to enable DB string representation of position go.AddComponent <DBSaveString>(); // attach component to enable send message to server go.GetComponent <DBSaveString>().dbStr = go.GetComponent <DBPositionToString>(); // connect sender w/string-maker } if (GUILayout.Button("DB writing - position")) { DebugConsole.Log("searching for DB_cube"); GameObject go = GameObject.Find("DB_cube"); //GameObject[] goes = GameObject.FindGameObjectsWithTag("DB_cube"); // find DB cube from scene //foreach (GameObject go in goes) { DebugConsole.Log("sending DB_cube string for position: " + go.transform.position); go.GetComponent <DBSaveString>().SendStringToServer(); //} // get all objects tagged saveable // invoke their DBstring construction } if (GUILayout.Button("DB writing - save all")) { DebugConsole.Log("searching for DB_cube"); DBSaveString[] goes = GameObject.FindObjectsOfType(typeof(DBSaveString)) as DBSaveString[]; // find DB cube from scene foreach (DBSaveString go in goes) { //DebugConsole.Log("sending DBSave string for position: " + go.transform.position); DebugConsole.Log("sending DBSave string for position: " + go.dbStr.DBString()); go.SendStringToServer(); } // get all objects tagged saveable // invoke their DBstring construction } if (GUILayout.Button("DB writing - singleton-style")) { DebugConsole.Log("searching for DB_cube"); GameObject go = GameObject.Find("DB_cube"); DebugConsole.Log("sending DB_cube string for position: " + go.transform.position); DebugConsole.Log("DBClientProxy instance is: " + DBClientProxy.Instance.ToString()); DBClientProxy.Instance.SaveToDB(go.transform.position.ToString()); } if (GUILayout.Button("DB reading - udid")) { DebugConsole.Log("DB reading - udid... start."); if (messObserver == null) { messObserver = new SillyObserver(); } messObserver.disposable = GameStateClient.Instance.mailbox.Subscribe(messObserver, NetworkClient.MessType_ToClient.UNTYPED); NetworkClient.Instance.SendServerMess(NetworkClient.MessType_ToServer.ReadDBStr, "udid"); //not a blocking call DebugConsole.Log("DB reading - udid... done."); } if (GUILayout.Button("Toggle debug")) { DebugConsole.IsOpen = !DebugConsole.IsOpen; } if (GUILayout.Button("Network Info")) { //DebugConsole.IsOpen = true; DebugConsole.LogWarning("network: " + Network.peerType); if (networkView == null) { DebugConsole.Log("networkView == null"); if (NetworkClient.Instance.target != null) { DebugConsole.Log("Got target from client controller."); DebugConsole.Log("networkView: " + NetworkClient.Instance.target.networkView); DebugConsole.Log("networkView.viewID: " + NetworkClient.Instance.target.networkView.viewID); } } else { DebugConsole.Log("networkView != null" + networkView); /* * if( networkView.viewID == null ) * { * DebugConsole.Log("networkView.viewID == null"); * } * else * { * DebugConsole.Log("networkView.viewID != null" + networkView.viewID); * } * * DebugConsole.Log("networkView.group != null" + networkView.group); */ } } }