void SpawnPlayer(PlayerSpawnData playerSpawnData)
        {
            PlayerController playerController = new PlayerController(playerSpawnData, this
                                                                     , weaponService, localPlayerID);

            playerControllerDictionary.Add(playerSpawnData.playerID, playerController);
        }
Esempio n. 2
0
        public PlayerController(PlayerSpawnData playerSpawnData, PlayerService playerService
                                , IWeaponService weaponSystem, string localPlayerID)
        {
            playerHolder                    = new GameObject();
            this.playerService              = playerService;
            this.weaponService              = weaponSystem;
            this.playerID                   = playerSpawnData.playerID;
            this.localPlayerID              = localPlayerID;
            playerHolder.name               = playerID;
            spawnCharacterPos               = playerSpawnData.playerPosition;
            fixedPos                        = playerSpawnData.playerPosition;
            playerCharacterControllerList   = new Dictionary <int, PlayerCharacterController>();
            playerHolder.transform.position = playerSpawnData.playerPosition;

            if (playerHolder.transform.position.x > 0)
            {
                playerHolder.transform.rotation = Quaternion.Euler(new Vector3(0, 180, 0));
            }

            for (int i = 0; i < 3; i++)
            {
                if (i == 0)
                {
                    PlayerCharacterController playerCharacterController = new CharacterAirController(
                        i, this, playerService.ReturnPlayerScriptableObj(PlayerCharacterType.Air)
                        , weaponService, spawnCharacterPos, playerHolder, localPlayerID
                        );
                    playerCharacterController.SetHealthBarFirst(playerSpawnData.char1Health);
                    playerCharacterControllerList.Add(i, playerCharacterController);
                }
                else if (i == 1)
                {
                    PlayerCharacterController playerCharacterController = new CharacterWaterController(
                        i, this, playerService.ReturnPlayerScriptableObj(PlayerCharacterType.Water)
                        , weaponService, spawnCharacterPos, playerHolder, localPlayerID
                        );
                    playerCharacterController.SetHealthBarFirst(playerSpawnData.char2Health);
                    playerCharacterControllerList.Add(i, playerCharacterController);
                }
                else if (i == 2)
                {
                    PlayerCharacterController playerCharacterController = new CharacterFireController(
                        i, this, playerService.ReturnPlayerScriptableObj(PlayerCharacterType.Fire)
                        , weaponService, spawnCharacterPos, playerHolder, localPlayerID
                        );
                    playerCharacterController.SetHealthBarFirst(playerSpawnData.char3Health);
                    playerCharacterControllerList.Add(i, playerCharacterController);
                }
                if (playerHolder.transform.position.x > 0)
                {
                    spawnCharacterPos.x += 2;
                }
                else
                {
                    spawnCharacterPos.x -= 2;
                }

                spawnCharacterPos.y += 1.95f;
            }
        }
 public void PlayerConnected(PlayerSpawnData playerSpawnData)
 {
     SpawnPlayer(playerSpawnData);
 }