public void InvokePlayerScore(int _enemyID, Enemy.EnemyType _type, int playerID)
        {
            int enemyKill = GetEnemyKillFromID(playerID);

            playerControllerInstance.UpdateScore(_enemyID, _type);
            EnemyKill?.Invoke(playerControllerInstance.GetID(), enemyKill);
        }
        public void SpawnPlayers()
        {
            enemyKillCountData.Clear();
            playerGamesPlayedData.Clear();
            playerID = 0;
            PlayerController _playerControllerInstance;

            if (listOfPlayerInputComponents)
            {
                Vector3 pos = new Vector3(0, 0, 0);


                for (int i = 0; i < listOfPlayerInputComponents.playerList.Count; i++)
                {
                    playerInstance = SpawnPrefabInstance(pos);

                    _playerControllerInstance = new PlayerController(playerInstance.GetComponent <PlayerView>(), playerID, listOfPlayerInputComponents.playerList.ElementAt(i), _rewardedMat);
                    listOfPlayerControllers.Add(_playerControllerInstance);
                    if (!GameApplication.Instance.GetService <IReplayService>().GetReplayValue())
                    {
                        enemyKillCountData.Add(_playerControllerInstance.GetID(), GameApplication.Instance.GetService <IPlayerSaveService>().GetEnemyKillData(_playerControllerInstance.GetID()));
                        playerGamesPlayedData.Add(_playerControllerInstance.GetID(), GameApplication.Instance.GetService <IPlayerSaveService>().GetGamesPlayedData(_playerControllerInstance.GetID()));
                        GameApplication.Instance.GetService <IScoreManager>().AddPlayerUI(_playerControllerInstance);
                    }
                    SetGameJoined(_playerControllerInstance.GetID());

                    SetupCameras(_playerControllerInstance, playerID);

                    pos      += new Vector3(3, 0, 0);
                    playerID += 1;
                }
            }
            else
            {
                Vector3 pos = new Vector3(0, 0, 0);
                playerInstance            = SpawnPrefabInstance(pos);
                _playerControllerInstance = new PlayerController(playerInstance.GetComponent <PlayerView>(), playerID, null, _rewardedMat);
                listOfPlayerControllers.Add(_playerControllerInstance);
                enemyKillCountData.Add(_playerControllerInstance.GetID(), 0);
                GameApplication.Instance.GetService <IScoreManager>().AddPlayerUI(_playerControllerInstance);
                SetupCameras(_playerControllerInstance, playerID);
            }
        }
        private void SetupCameras(PlayerController _controller, int _id)
        {
            GameObject miniMapInstance = GameObject.Instantiate(miniMapCameraPrefab.gameObject) as GameObject;

            var       mcam = miniMapInstance.GetComponent <MiniMapSetup>();
            Transform t    = _controller.GetFollowTarget();

            mcam.SetupTarget(t);
            miniMapInstance.GetComponent <MiniMapSetup>().SetRenderTexture(_id);
            Camera _mainCamera = _controller.GetMainCamera();

            playerMainCamera.Add(_mainCamera);
            if (playerMainCamera[_id] != null)
            {
                playerMainCamera[_id].rect = new Rect((1f / noOfPlayers) * _controller.GetID(), 0, 1f / noOfPlayers, 1);
            }
        }
Example #4
0
 public IEnumerator DestroySelf()
 {
     GameApplication.Instance.GetService <IPlayerService>().InvokePlayerDeath(currentPlayerController.GetID(), currentPlayerController.GetNoOfDeaths());
     GameApplication.Instance.GetService <IPlayerService>().DestroyPlayer(currentPlayerController);
     yield return(new WaitForSeconds(5f));
 }