public void GetSpawnpoint_RPC(int team) { if (!PhotonNetwork.IsMasterClient) { matchController = FindObjectOfType <MatchController>(); matchController.AddPlayer(this); } teamId = team; if (PV.IsMine) { hudManager.setBackground(); } spawnPoint = matchController.GetSpawnPoint(this); GetComponent <Transform>().position = spawnPoint.transform.position; }
private void Start() { rigidBody.drag = playerDeceleration; life = maxLife; score = 0; canShoot = true; canShield = true; damageable = true; stunSlider.maxValue = stunTime; lifeText.text = "Vida: " + life; scoreText.GetComponent <TMPro.TextMeshProUGUI>().text = score + " pts"; hudManager = GetComponent <HUDmanager>(); GetBalaIndex(); if (PhotonNetwork.IsConnected && PV.IsMine) { canvas.SetActive(true); mainCamera.enabled = true; playerInput.enabled = true; mobileCharacter.enabled = true; audioListener.enabled = true; sAlas.Play(); } if (PhotonNetwork.IsConnected && PhotonNetwork.IsMasterClient) { matchController = FindObjectOfType <MatchController>(); matchController.AddPlayer(this); teamId = FindObjectOfType <RoomManager>().FindTeamIdByPlayer(PV.Owner); if (teamId == -1) { teamId = 0; Debug.Log("No se ha encontrado el teamId, se le ha añadido al equipo 0"); } PV.RPC("GetSpawnpoint_RPC", RpcTarget.All, teamId); } else if (!PhotonNetwork.IsConnected) { canvas.SetActive(true); mainCamera.enabled = true; playerInput.enabled = true; mobileCharacter.enabled = true; RoomManagerOffline RMO = FindObjectOfType <RoomManagerOffline>(); if (RMO.gamemodeIndex == 3) { teamId = 0; } else { teamId = RMO.jugadoresInfo[GetComponentInChildren <PlayerInput>().playerIndex + 1][1]; } if (playerInput.playerIndex == 0) { audioListener.enabled = true; } matchController = FindObjectOfType <MatchController>(); matchController.AddPlayer(this); spawnPoint = matchController.GetSpawnPoint(this); GetComponent <Transform>().position = spawnPoint.transform.position; hudManager.setBackground(); } movementSM = new StateMachine(); groundedState = new GroundedState(this, movementSM); shootingState = new ShootingState(this, movementSM); shieldState = new ShieldState(this, movementSM); deadState = new DeadState(this, movementSM); stunState = new StunState(this, movementSM); feederState = new FeederState(this, movementSM); movementSM.Initialize(groundedState); }