public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { Debug.Log("Inventory Update Recieved"); int[] iDArray = anObjectIn.GetIntArray("IDArray"); int[] itemArray = anObjectIn.GetIntArray("ItemIDArray"); int[] quantityArray = anObjectIn.GetIntArray("QuantityArray"); string[] nameArray = anObjectIn.GetUtfStringArray("NameArray"); string[] descriptionArray = anObjectIn.GetUtfStringArray("DescriptionArray"); string[] locationArray = anObjectIn.GetUtfStringArray("SubLocationArray"); bool reopenInventory = false; if(GameObject.Find("InventoryPanel") != null) { GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().openInventory(); reopenInventory = true; } if(itemArray.Length != quantityArray.Length) { Debug.Log("Item array and quantity array are not the same size."); } int iPos = 0; foreach (int ID in iDArray) { //If the inventory already has this item in it, simply update its data. if(ourGWM.getLPC().getInventory().ContainsKey(ID)) { ourGWM.getLPC().getInventory()[ID].updateItemData(itemArray[iPos], quantityArray[iPos], nameArray[iPos], descriptionArray[iPos], locationArray[iPos]); } else if(!ourGWM.getLPC().getInventory().ContainsKey(ID)) { ourGWM.getLPC().getInventory().Add(ID, new Item(ID, itemArray[iPos], quantityArray[iPos], nameArray[iPos], descriptionArray[iPos], locationArray[iPos])); } iPos++; } if(reopenInventory) { GameObject.Find("SceneScriptsObject").GetComponent<GameUI>().openInventory(); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { ourGWM.destroyObject("GameCharacter_" + aCharacterName); ourGWM.getPlayerDictionary().Remove(aCharacterName); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float Rotation = anObjectIn.GetFloat("Rotation"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetRotation(Rotation); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(aCharacterName == ourGWM.getLPC().GetName()) { return; } else if(ourGWM.getPlayerDictionary().ContainsKey(aCharacterName)) { float[] LocationArray = anObjectIn.GetFloatArray("Location"); bool IsMoving = anObjectIn.GetBool("IsMoving"); ourGWM.getPlayerDictionary()[aCharacterName].GetComponent<RemotePlayerController>().SetPlayerMoving(IsMoving); ourGWM.getPlayerDictionary()[aCharacterName].transform.position = new Vector3(LocationArray[0], LocationArray[1], LocationArray[2]); } }
public void HandleResponse(ISFSObject anObjectIn, GameWorldManager ourGWM) { Debug.Log("Server spawning player."); float[] locationArray = anObjectIn.GetFloatArray("Location"); float aRotation = anObjectIn.GetFloat("Rotation"); string aCharacterName = anObjectIn.GetUtfString("CharacterName"); if(anObjectIn.GetBool("IsLocal")) { GameObject aLocalPlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aLocalPlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aLocalPlayer.transform.rotation = Quaternion.identity; // Since this is the local player, lets add a controller and fix the camera aLocalPlayer.AddComponent<LocalPlayerController>(); aLocalPlayer.AddComponent<InputController>(); ourGWM.setLPC(aLocalPlayer.GetComponent<LocalPlayerController>()); ourGWM.getLPC().SetName(aCharacterName); aLocalPlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; GameObject cameraAttach = new GameObject(); cameraAttach.transform.parent = aLocalPlayer.transform; cameraAttach.transform.localPosition = new Vector3(1f, 2.5f, 1.0f); cameraAttach.name = "Camera Target"; Camera.main.transform.parent = cameraAttach.transform; Camera.main.GetComponent<CameraController>().setTarget(cameraAttach); Camera.main.GetComponent<CameraController>().setCursorVisible(false); } else if(!anObjectIn.GetBool("IsLocal")) { GameObject aRemotePlayer = ourGWM.createObject("Prefabs/Player/PlayerBasic"); aRemotePlayer.name = "GameCharacter_" + aCharacterName; aRemotePlayer.AddComponent<RemotePlayerController>(); aRemotePlayer.transform.position = new Vector3(locationArray[0], locationArray[1], locationArray[2]); aRemotePlayer.GetComponent<RemotePlayerController>().SetRotation(aRotation); aRemotePlayer.GetComponentInChildren<TextMesh>().text = aCharacterName; //Add Newly spawned player to Dictionary ourGWM.getPlayerDictionary().Add(aCharacterName, aRemotePlayer); } }