Exemplo n.º 1
0
 private void Start()
 {
     mg = GameObject.Find("MultiplayerGameManager").GetComponent <MultiplayerGameManager>();
     MultiplayerGameTextBox.transform.Find("OKButton").GetComponent <Button>().onClick.AddListener(LeaveGame);
     MultiplayerGameTextBox.transform.Find("CancelButton").GetComponent <Button>().onClick.AddListener(CancelLeaveAttempt);
     SoundManager = GameObject.Find("SoundFX").GetComponent <SoundFX>();
 }
Exemplo n.º 2
0
    public override void OnStartClient()
    {
        //base.OnStartClient();
        string myPlayerID = PLAYER_TAG + "_" + netId.ToString();

        MultiplayerGameManager.RegisterPlayer(myPlayerID, this);
        //OnTeamChanged(Team);
    }
Exemplo n.º 3
0
 private void Awake()
 {
     if (instance == null)
     {
         instance        = this;
         Physics.gravity = new Vector3(0, -15f, 0);
         InstantiatePostProcessingProfiles();
     }
     else
     {
         Destroy(gameObject);
     }
 }
    private void Start()
    {
        #region Singleton Setup
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(this);
        }
        #endregion

        if (!PhotonNetwork.IsConnected)
        {
            //PhotonNetwork.OfflineMode = true;
            player2 = PhotonNetwork.Instantiate(this.playerPrefab.name, new Vector3(0f, 0f, 25f), Quaternion.identity, 0);
        }
        else
        {
            // we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate
            GameObject player = null;
            if (PlayerData.instance != null)
            {
                Debug.LogFormat("We are Instantiating LocalPlayer from {0}", SceneManager.GetActiveScene().name);
                player = PhotonNetwork.Instantiate(playerPrefabs[(int)PlayerData.instance.faction], new Vector3(0f, 0f, 0f), Quaternion.identity, 0);
                if (PhotonNetwork.IsMasterClient)
                {
                    player1        = player;
                    player1Faction = PlayerData.instance.faction;
                }
                else
                {
                    photonView.RPC("RpcRegisterPlayer", RpcTarget.MasterClient, (int)PlayerData.instance.faction);
                    player2 = player;
                    foreach (GameObject item in GameObject.FindGameObjectsWithTag("Player"))
                    {
                        if (player2 != item)
                        {
                            player1 = item;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    public override void SpawnPlayer(MultiplayerGameManager gm)
    {
        if (spawnpoints.Length < PhotonNetwork.PlayerList.Length)
        {
            Debug.LogError("Not enough spawnpoints for every player in the room.");
        }

        int idx = 0;

        foreach (Player p in PhotonNetwork.PlayerList)
        {
            if (p == PhotonNetwork.LocalPlayer)
            {
                gm.InstantiatePlayer(spawnpoints[idx]);
                return;
            }
            idx++;
        }

        //Fallback
        Debug.LogError("Faling back to spawn player at the first spawnpoint.");
        gm.InstantiatePlayer(spawnpoints[0]);
    }
Exemplo n.º 6
0
 // Start is called before the first frame update
 void Start()
 {
     gameManager            = FindObjectOfType <GameManager>();
     multiplayerGameManager = FindObjectOfType <MultiplayerGameManager>();
 }
Exemplo n.º 7
0
 public void RpcDamagePlayer(int damage, string receiverID, string attackerID)
 {
     MultiplayerGameManager.GetPlayer(receiverID).TakeDamage(damage, attackerID);
 }
Exemplo n.º 8
0
 public void RpcGiveShield(int amount, string ID)
 {
     MultiplayerGameManager.GetPlayer(ID).ReceiveShield(amount);
 }
Exemplo n.º 9
0
 public void RpcGiveAttackerScore(string attackerID)
 {
     MultiplayerGameManager.GetPlayer(attackerID).AddScore();
 }
Exemplo n.º 10
0
 public void RpcGivePlayerScore(string ID)
 {
     MultiplayerGameManager.GetPlayer(ID).AddScore();
 }
 public abstract void SpawnPlayer(MultiplayerGameManager gm);