Esempio n. 1
0
        public void RPC_SendPlayerData()
        {
            var matchManager = MatchManager.Instance;

            matchManager.PlayersInGame.Add(this); //allows the manager know when the player has started the of sending information

            PlayerMatchData = GetComponent <PlayerMatchData>();
            PlayerMatchData.NetworkOwner = this;

            PlayerNumber = photonView.Owner.ActorNumber; //player photon network specific data
            PlayerName   = photonView.Owner.NickName;

            if (mobileControls) //set player cam
            {
                mobileControls.transform.position    = SpawnContainer.Instance.CameraSpawnPoints[PlayerNumber - 1].position;
                mobileControls.transform.rotation    = SpawnContainer.Instance.CameraSpawnPoints[PlayerNumber - 1].rotation;
                mobileControls.DisableMobileControls = true;
            }

            if (grid) //set player gridgen
            {
                grid.name.Replace("(Clone)", "");

                grid.transform.position = SpawnContainer.Instance.GridSpawnPoints[PlayerNumber - 1].position;
                grid.GetComponent <GridGenerator>().GridWorldSize.Set(6, 10);
                grid.GetComponent <GridGenerator>().NetworkOwner = this;
            }

            if (playerControllers) //create playercontrollers such as creepsender & towerplacer
            {
                playerControllers.name.Replace("(Clone)", "");

                var creepSender = playerControllers.GetComponent <CreepSender>();
                var towerPlacer = playerControllers.GetComponent <TowerPlacer>();

                creepSender.NetworkOwner    = this;
                creepSender.PlayerMatchData = PlayerMatchData;

                creepSender.CreepSpawnPoint = SpawnContainer.Instance.CreepSpawnAreas[PlayerNumber - 1];
                SpawnContainer.Instance.GoalPoints[PlayerNumber - 1].GetComponent <Goal>().NetworkOwner = this;

                creepSender.CreepDestination = SpawnContainer.Instance.GoalDestinations[PlayerNumber - 1];

                towerPlacer.NetworkOwner    = this;
                towerPlacer.PlayerMatchData = PlayerMatchData;
            }

            PlayerReadyUI.Instance.PopulateInfo(this);                           //join the ready queue

            gameObject.name += " " + GetComponent <PhotonView>().Owner.NickName; //set object with network nickname
            gameObject.name.Replace("(Clone)", "");

            Debug.Log("SendingPlayerData for: " + PlayerName);
        }