public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer localPlayer = gamePlayer.GetComponent <SetupLocalPlayer>(); localPlayer.pname = lobby.playerName; }
void Start() { if (isLocalPlayer) { localPlayer = GetComponent <SetupLocalPlayer>(); switch (localPlayer.pRoleName) { case "MS": loadedScene = Instantiate(MapScene, Vector2.zero, Quaternion.identity, transform); // loadedScene.GetComponentInChildren<MapManager>().network = GetComponent<GameNetworkManager>(); break; case "CMS": loadedScene = Instantiate(CakeMakerScene, Vector2.zero, Quaternion.identity, transform); loadedScene.GetComponentInChildren <CakeMakerManager>().network = GetComponent <GameNetworkManager>(); break; case "DS": loadedScene = Instantiate(DoughScene, Vector2.zero, Quaternion.identity, transform); loadedScene.GetComponentInChildren <DoughManager>().network = GetComponent <GameNetworkManager>(); break; case "CS": loadedScene = Instantiate(cashierScene, Vector2.zero, Quaternion.identity, transform); loadedScene.GetComponentInChildren <CashierManager>().network = GetComponent <GameNetworkManager>(); break; default: Debug.Log("Scene not registred"); break; } localPlayer.playerNameTxt.enabled = true; localPlayer.playerNameTxt.text = localPlayer.pRoleName; loadedScene.GetComponentInChildren <Canvas>().worldCamera = Camera.main; } }
public void StartRunning() { isRunning = true; n_anim.SetTrigger("StartRuning"); SetupLocalPlayer e = this.GetComponent <SetupLocalPlayer>(); e.CmdChangeAnimState("StartRuning"); }
public override bool OnRoomServerSceneLoadedForPlayer(NetworkConnection conn, GameObject roomPlayer, GameObject gamePlayer) { SetupLocalPlayer ChoosenClass = gamePlayer.GetComponent <SetupLocalPlayer>(); ChoosenClass.ChoosenClass = "SwordBerserker"; Debug.Log("lobbbyyyyyyyyyyyyyyyyyyyyyyy"); return(base.OnRoomServerSceneLoadedForPlayer(conn, roomPlayer, gamePlayer)); }
public void SwitchPlayer(SetupLocalPlayer player, int cid) { GameObject newPlayer = Instantiate(spawnPrefabs[cid], player.gameObject.transform.position, player.gameObject.transform.rotation); playerPrefab = spawnPrefabs[cid]; Destroy(player.gameObject); NetworkServer.ReplacePlayerForConnection(player.connectionToClient, newPlayer, 0); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer car = gamePlayer.GetComponent <SetupLocalPlayer>(); car.pName = lobby.playerName; car.pColour = ColorUtility.ToHtmlStringRGBA(lobby.playerColor); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer carInLobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer car = gamePlayer.GetComponent <SetupLocalPlayer>(); //The names in my SetupLocalPlayer script MUST be SyncVar so server can update them car.pName = carInLobby.playerName; car.pColour = ColorUtility.ToHtmlStringRGBA(carInLobby.playerColor); }
public void SwitchPlayer(SetupLocalPlayer player, int id) { var prefab = spawnPrefabs[id]; var playerObj = Instantiate(prefab, player.gameObject.transform.position, player.gameObject.transform.rotation); playerPrefab = prefab; Destroy(player.gameObject); NetworkServer.ReplacePlayerForConnection(player.connectionToClient, playerObj, 0); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer localPlayer = gamePlayer.GetComponent <SetupLocalPlayer>(); localPlayer.playerColor = lobby.playerColor; localPlayer.playerName = lobby.playerName; Debug.Log("Uruchomione"); }
// Use this for initialization void Start() { cam = GameObject.Find("Main Camera").transform; distToGround = GetComponent <Collider> ().bounds.extents.y; mBody = GetComponent <Rigidbody> (); mBody.useGravity = false; animator = this.GetComponent <Animator> (); jumping = false; localPlayer = GetComponent <SetupLocalPlayer> (); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer localPlayer = gamePlayer.GetComponent <SetupLocalPlayer>(); //localPlayer.name = lobby.playerName; //localPlayer.playerColor = lobby.playerColor; //spaceship.score = 0; // spaceship.lifeCount = 3; }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); SetupLocalPlayer localPlayer = gamePlayer.GetComponent <SetupLocalPlayer>(); // variables below set from Player Info script in the lobby localPlayer.playerColor = lobby.playerColor; }
//When player loads, takes lobbyPlayer info, gamePlayer, and giving lobby player levels //to the gameplayer //This connects all values that are in player info to values that are in the game public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { //Grab lobby player from PlayerInfo LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); //Grab local player SetupLocalPlayer localPlayer = gamePlayer.GetComponent <SetupLocalPlayer>(); localPlayer.playerColor = lobby.playerColor; localPlayer.pname = lobby.playerName; }
// Start is called before the first frame update void Start() { animator = GetComponent <Animator>(); //if (Application.isMobilePlatform && isLocalPlayer || !Application.isMobilePlatform && !isLocalPlayer) { localArkitInstance = this; arkitPart.SetActive(true); } /* * else * { * //gameObject.transform.localPosition = new Vector3(0, -1.25f, 0); * vrPart.SetActive(true); * if(!Application.isMobilePlatform) * { * vrCamera.enabled = true; * playArea.enabled = true; * leftHand.enabled = true; * rightHand.enabled = true; * viveCursor.enabled = true; * * vrInitialized = true; * } * * } */ if (isLocalPlayer && Application.isMobilePlatform) { //Debug.Log("LOCAL PLAYER SPAWNED"); UnityARFaceAnchorManager.instance.anchorPrefab = gameObject; blendshapeDriver.enabled = true; InvokeRepeating("UpdateBlendshapes", 5, 0.05f); } else { //Debug.Log("NOT LOCAL PLAYER SPAWNED"); blendshapeDriver.enabled = false; } for (int i = 0; i < 52; i++) { syncListFloat.Add(0); } myVector = gameObject.AddComponent <VectorN>(); myVector.values = new float[52]; lastReceivedArray = new float[104]; oldReceivedArray = new float[104]; InvokeRepeating("MasksImitationLoop", 1.0f, 0.1f); }
public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) { LobbyPlayer lobby = lobbyPlayer.GetComponent <LobbyPlayer>(); // car is the SetupLocalPlayer script. SetupLocalPlayer player = gamePlayer.GetComponent <SetupLocalPlayer>(); // pName and pColor are variables in that script. Thus you can call those values using car.pName. // Want to get the team number value here and sync it player.pName = lobby.playerName; base.OnLobbyServerSceneLoadedForPlayer(manager, lobbyPlayer, gamePlayer); }
// Use this for initialization void Start() { finished = false; canUpdate = false; messageSent = false; steps = 0; foreach (SkinnedMeshRenderer r in GetComponentsInChildren <SkinnedMeshRenderer>()) { r.material = Instantiate(r.material) as Material; } stepDelay = 0.05f; stepTime = stepTimer = 0; StartCoroutine(LateCall(1f)); localPlayer = GetComponent <SetupLocalPlayer> (); }
void OnCollisionEnter(Collision collider) { SetupLocalPlayer pacman = collider.gameObject.GetComponent <SetupLocalPlayer>(); if (pacman.pname == "Player1") { score1.AddScore(); } else if (pacman.pname == "Player2") { score2.AddScore(); } AudioSource.PlayClipAtPoint(food, transform.position); Destroy(gameObject); }
public override void OnStartLocalPlayer() { base.OnStartLocalPlayer(); localPlayerInstance = this; }
void Start() { audioSync = this.GetComponent <SetupLocalPlayer> (); }
public void AbilitiesSelectButton() { GameObject player = GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject; SetupLocalPlayer SetupLocalPlayerScript = player.GetComponent <SetupLocalPlayer> (); if (SelectedAbilities == 1) { Health = player.GetComponent <Hp> (); Button1.GetComponent <Image> ().enabled = true; if (EventSystem.current.currentSelectedGameObject.name == "Melee") { Button1.GetComponent <Image>().sprite = Melee; SkillPassif.GetComponent <Image>().sprite = Melee; InGamePassif.GetComponent <Image>().sprite = Melee; UpdateSkin(player, "Melee"); SetupLocalPlayerScript.Passif = "Melee"; Health.Health = 1300; Health.maxHealth = 1300; Health.HealthSlider.maxValue = 1300; Health.HealthSlider.value = 1300; } if (EventSystem.current.currentSelectedGameObject.name == "MidRange") { Button1.GetComponent <Image>().sprite = MidRange; SkillPassif.GetComponent <Image>().sprite = MidRange; InGamePassif.GetComponent <Image>().sprite = MidRange; UpdateSkin(player, "MidRange"); SetupLocalPlayerScript.Passif = "MidRange"; Health.Health = 1000; Health.maxHealth = 1000; Health.HealthSlider.maxValue = 1000; Health.HealthSlider.value = 1000; } if (EventSystem.current.currentSelectedGameObject.name == "LongRange") { Button1.GetComponent <Image>().sprite = LongRange; SkillPassif.GetComponent <Image>().sprite = LongRange; InGamePassif.GetComponent <Image>().sprite = LongRange; SetupLocalPlayerScript.Passif = "LongRange"; UpdateSkin(player, "LongRange"); Health.Health = 900; Health.maxHealth = 900; Health.HealthSlider.maxValue = 900; Health.HealthSlider.value = 900; } AbilitiesButton2(); return; } if (SelectedAbilities == 2 && EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name != SetupLocalPlayerScript.Abilities2 && EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name != SetupLocalPlayerScript.Abilities3) { foreach (Component comp in player.GetComponents(typeof(Component))) { if (comp.name == SetupLocalPlayerScript.Abilities1) { Destroy(comp); } } Button2.GetComponent <Image> ().enabled = true; Button2.GetComponent <Image> ().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite; Skill1.GetComponent <Image> ().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; InGameSkill1.GetComponent <Image>().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; SetupLocalPlayerScript.Abilities1 = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name; GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject.GetComponent <AbilitiesNetworker>().CmdAddScript(GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject, EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name); AbilitiesButton3(); return; } if (SelectedAbilities == 3 && EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name != SetupLocalPlayerScript.Abilities1 && EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name != SetupLocalPlayerScript.Abilities3) { foreach (Component comp in player.GetComponents(typeof(Component))) { if (comp.name == SetupLocalPlayerScript.Abilities2) { Destroy(comp); } } Button3.GetComponent <Image> ().enabled = true; Button3.GetComponent <Image> ().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite; Skill2.GetComponent <Image>().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; InGameSkill2.GetComponent <Image>().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; SetupLocalPlayerScript.Abilities2 = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name; GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject.GetComponent <AbilitiesNetworker>().CmdAddScript(GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject, EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name); AbilitiesButton4(); return; } if (SelectedAbilities == 4 && EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name != SetupLocalPlayerScript.Abilities1 && EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name != SetupLocalPlayerScript.Abilities2) { foreach (Component comp in player.GetComponents(typeof(Component))) { if (comp.name == SetupLocalPlayerScript.Abilities3) { Destroy(comp); } } Button4.GetComponent <Image> ().enabled = true; Button4.GetComponent <Image> ().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite; Skill3.GetComponent <Image>().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; InGameSkill3.GetComponent <Image>().sprite = EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite; SetupLocalPlayerScript.Abilities3 = EventSystem.current.currentSelectedGameObject.GetComponent <Image> ().sprite.name; GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject.GetComponent <AbilitiesNetworker>().CmdAddScript(GameObject.FindGameObjectWithTag("MainCamera").transform.parent.gameObject, EventSystem.current.currentSelectedGameObject.GetComponent <Image>().sprite.name); AreYouReady(); } }