Ejemplo n.º 1
0
        public static void SpawnPlayerAtPosition(Player player, Vector3 position, Quaternion rotation)
        {
            //Make sure player controlled entities are destroyed.
            PlayerManager.Instance.DestroyPlayerControlledEntities(player);

            LoadOut loadOut = new LoadOut();

            loadOut.itemNames = new string[] { "Scout", "PlasmaFusor", "GrenadeLauncher", "ChainGun" };

            LoadOutToken loadOutToken = new LoadOutToken(loadOut);

            GameObject baseMech = DatabaseManager.Instance.PrefabDatabase.GetPrefabByName("BaseMech");
            BoltEntity entity   = BoltNetwork.Instantiate(baseMech, loadOutToken, position, rotation);

            if (entity != null)
            {
                Unit unit = entity.GetComponent <Unit>();
                unit.Setup(player.guid, player.teamId);
                unit.gameObject.AddComponent <AbilityVelocityRedirection>();

                if (player.connection == null)
                {
                    entity.TakeControl();
                }
                else
                {
                    entity.AssignControl(player.connection);
                }

                player.SetControlledEntity(entity);
            }
        }
Ejemplo n.º 2
0
 public BoltEntity SpawnPlayer()
 {
     if (PlayerEntity == null)
     {
         if (SpawnManager.HasSpawnPoints)
         {
             PlayerEntity = BoltNetwork.Instantiate(BoltPrefabs.Player, SpawnManager.GetSpawnPoint(), Quaternion.identity);
         }
         else
         {
             PlayerEntity = BoltNetwork.Instantiate(BoltPrefabs.Player);
             PlayerEntity.gameObject.SetActive(false);
         }
         if (PlayerEntity.gameObject.activeSelf)
         {
             if (IsServer)
             {
                 PlayerEntity.TakeControl();
             }
             else
             {
                 PlayerEntity.AssignControl(Connection);
             }
         }
     }
     return(PlayerEntity);
 }
Ejemplo n.º 3
0
 // Spawner
 private void SpawnGamePlayer()
 {
     playerEntity = BoltNetwork.Instantiate(BoltPrefabs.LocalPlayer);
     playerEntity.TakeControl();
     CrisisHandler.instance.CallCrisis(NetworkGameState.instance.getCurrentCrisis());
     playerEntity.GetComponent <Player>().setup(localPlayerSpellcasterID);
 }
    public void Spawn()
    {
        if (!character)
        {
            // assign the colors/numbers etc for the player.
            var playerToken = new PlayerToken();
            playerToken.playerNumber = playerNumber;
            playerToken.playerColor  = playerColor;
            playerToken.playerName   = playerName;

            character = BoltNetwork.Instantiate(BoltPrefabs.PlayerMultiplayer, playerToken);

            if (IsServer)
            {
                character.TakeControl();
            }
            else
            {
                character.AssignControl(connection);
            }

            // move entity to random spawn position
            character.transform.position = GamemanagerNetwork.instance.RandomSpawnPoint();
        }
    }
Ejemplo n.º 5
0
        public override void BoltStartDone()
        {
            if (!BoltNetwork.IsRunning)
            {
                return;
            }

            if (BoltNetwork.IsServer)
            {
                RoomProtocolToken token = new RoomProtocolToken()
                {
                    ArbitraryData = "My DATA",
                };

                BoltLog.Info("Starting Server");
                // Start Photon Room
                BoltNetwork.SetServerInfo(_matchName, token);

                // Setup Host
                infoPanel.gameObject.SetActive(false);
                ChangeTo(lobbyPanel);

                backDelegate = Stop;
                SetServerInfo("Host", "");

                // Build Server Entity
                BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.PlayerInfo);
                entity.TakeControl();
            }
            else if (BoltNetwork.IsClient)
            {
                backDelegate = Stop;
                SetServerInfo("Client", "");
            }
        }
Ejemplo n.º 6
0
 public override void SceneLoadLocalDone(string map)
 {
     if (BoltNetwork.isServer)
     {
         BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.Player, new Vector3(43, 1, 11), Quaternion.identity);
         entity.TakeControl();
     }
 }
 public override void SceneLoadLocalDone(string scene)
 {
     if (BoltNetwork.IsServer)
     {
         BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.Cube);
         entity.TakeControl();
     }
 }
Ejemplo n.º 8
0
    public void Spawn()
    {
        if (isServer && !coconut) {
            coconut = BoltNetwork.Instantiate (BoltPrefabs.Coconut_1, new Vector3 (1000f, 5f, 1000f), Quaternion.identity);
            coconut.TakeControl ();

        }

        // teleport entity to a random spawn position
        //coconut.transform.position = new Vector3 (1000f, 5f, 1000f);
    }
Ejemplo n.º 9
0
 void SetControl(PlayerObject player, BoltEntity entity)
 {
     if (player.IsServer)
     {
         entity.TakeControl();
     }
     else
     {
         entity.AssignControl(player.connection);
     }
 }
Ejemplo n.º 10
0
        private void TakeControlOfDummy()
        {
            entity.ReleaseControl();
            GetComponentInParent <ControllableDisabler>().DisableAllInChildren();
            Enabled = true;
            _lastInstantiatedDummy.TakeControl();
            _lastInstantiatedDummy.GetComponent <ObserversSetup>().SetObservers();
            _lastInstantiatedDummy.GetComponent <ControllableDisabler>().EnableAllInChildren();

            _hasControlOfDummy = true;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// このプログラムがシーンを読み込んだ時の処理
        /// </summary>
        /// <param name="map"></param>
        public override void SceneLoadLocalDone(string map)
        {
            // プレイヤー1を生成して、操作を担当します
            BoltEntity be = BoltNetwork.Instantiate(BoltPrefabs.Player);

            be.transform.position = NetworkSceneManager.Instance.GetPlayerPosition(be.prefabId.Value);
            be.TakeControl();

            // ボールを作ります
            be = BoltNetwork.Instantiate(BoltPrefabs.Ball);
            be.transform.position = NetworkSceneManager.Instance.ballPosition.position;
        }
Ejemplo n.º 12
0
    public void InstantiatePlayer(BoltConnection connection)
    {
        Vector3    pos    = new Vector3(Random.Range(-16, 16), 0, Random.Range(-16, 16));
        BoltEntity entity = BoltNetwork.Instantiate(BoltPrefabs.Player, pos, Quaternion.identity);

        playerList.Add(entity, connection);
        if (connection == null)
        {
            entity.TakeControl();
        }
        else
        {
            entity.AssignControl(connection);
        }
    }
Ejemplo n.º 13
0
        public Player(BoltConnection cn)
        {
            entity = BoltNetwork.Instantiate(BoltPrefabs.Player, new Vector3(20, 0, 20), Quaternion.identity);

            this.cn = cn;

            if (cn == null)
            {
                entity.TakeControl();
            }
            else
            {
                entity.AssignControl(cn);
            }
        }
Ejemplo n.º 14
0
        public override void BoltStartDone()
        {
            BoltConsole.Write("BoltStartDone breh");
            if (!BoltNetwork.IsRunning)
            {
                return;
            }

            if (BoltNetwork.IsServer)
            {
                RoomProtocolToken token = new RoomProtocolToken()
                {
                    ArbitraryData = "My DATA",
                };

                BoltLog.Info("Starting Server");
                // Start Photon Room
                BoltNetwork.SetServerInfo(_matchName, token);
                //BoltNetwork.EnableLanBroadcast();
                // Setup Host
                infoPanel.gameObject.SetActive(false);
                //PanelHolder.instance.hideConnectingPanel();
                ChangeTo(lobbyPanel);

                backDelegate = Stop;
                SetServerInfo("Host", "");
                connection_spellcaster = new Dictionary <string, int>();
                //SoundManager.instance.musicSource.Play();

                // Build Server Entity

                characterSelection = BoltNetwork.Instantiate(BoltPrefabs.CharacterSelectionEntity);
                characterSelection.TakeControl();

                gameStateEntity = BoltNetwork.Instantiate(BoltPrefabs.GameState);
                gameStateEntity.TakeControl();
                gameStateEntity.GetComponent <NetworkGameState>().onCreateRoom(_matchName);

                numPlayersInfo.text = gameStateEntity.GetComponent <NetworkGameState>().onPlayerJoined() + "";
            }
            else if (BoltNetwork.IsClient)
            {
                backDelegate = Stop;
                SetServerInfo("Client", "");
            }
        }
Ejemplo n.º 15
0
    public override void SceneLoadLocalDone(string scene, IProtocolToken token)
    {
        var spawnPos = new Vector3(Random.Range(-5, 5), 0, 0);

        if (myEntityPos != Vector3.zero)
        {
            spawnPos = myEntityPos;
        }

        myEntity = BoltNetwork.Instantiate(SpawnPrefab, spawnPos,
                                           Quaternion.EulerAngles(myEntityRot));
        myEntity.TakeControl();

        if (BoltNetwork.IsServer)
        {
            myEntity.GetState <IFPSPlayerState>().isServer = true;
        }
    }
    public void Spawn()
    {
        if (PlayerInstance.instance != null)
        {
            if (IsServer)
            {
                //character = BoltNetwork.Instantiate(BoltPrefabs.NetworkPlayer, RoundSystem.Instance.spawnRoom.position, Quaternion.identity);
                character.TakeControl();
            }
            else
            {
                //character = BoltNetwork.Instantiate(BoltPrefabs.NetworkPlayer_1, RoundSystem.Instance.spawnRoom.position, Quaternion.identity);
                character.AssignControl(connection);
            }
        }

        // teleport entity to a random spawn position
    }
Ejemplo n.º 17
0
    public void Spawn()
    {
        if (!character)
        {
            character = BoltNetwork.Instantiate(BoltPrefabs.BoltPlayer, RandomPosition(), Quaternion.identity);

            if (IsServer)
            {
                character.TakeControl();
            }
            else
            {
                character.AssignControl(connection);
            }
        }

        character.transform.position = RandomPosition();
    }
Ejemplo n.º 18
0
        public void InstantiateEntity()
        {
            entity = BoltNetwork.Instantiate(BoltPrefabs.Player, new TestToken(), RandomSpawn(), Quaternion.identity);

            state.name = name;
            state.team = redPlayers.Count() >= bluePlayers.Count() ? TEAM_BLUE : TEAM_RED;

            if (isServer)
            {
                entity.TakeControl(new TestToken());
            }
            else
            {
                entity.AssignControl(connection, new TestToken());
            }

            Spawn();
        }
Ejemplo n.º 19
0
    public void Spawn()
    {
        if (!character)
        {
            character = BoltNetwork.Instantiate(BoltPrefabs.SpaceCadet);
            PlanetManager.Instance.PhysicsObjects.Add(character.gameObject.GetComponent <PhysicsObject>());
            if (IsServer)
            {
                character.TakeControl();
            }
            else
            {
                character.AssignControl(connection);
            }
        }

        // teleport entity to a spawn position
        character.transform.position = new Vector3(0, 0, 0);
    }
Ejemplo n.º 20
0
        public void Spawn()
        {
            if (!character)
            {
                character = BoltNetwork.Instantiate(BoltPrefabs.Player);

                if (IsServer)
                {
                    character.TakeControl();
                }
                else
                {
                    character.AssignControl(connection);
                }
            }

            // teleport entity to a random spawn position
            character.transform.position = RandomPosition();
        }
Ejemplo n.º 21
0
    public void Spawn()
    {
        //character = BoltNetwork.Instantiate (BoltPrefabs.PlayerObject3d);
        if (!character) {

            character = BoltNetwork.Instantiate (BoltPrefabs.PlayerObject3dWithColliders);
            if (MenuScript.hasPickedTeamOne) {
                //character.renderer.material.color = Color.red;
                teamId = 1;

                foreach (SkinnedMeshRenderer smr in character.GetComponentsInChildren<SkinnedMeshRenderer>())
                {
                    smr.material.mainTexture = Resources.Load<Texture>("Textures/Layer_lambert1_u1_v2_Diffuse_merged_wNoise_Fish");
                    smr.material.SetTexture(1, Resources.Load<Texture>("Textures/Layer_lambert1_u1_v2_Diffuse_merged_wNoise_Fish_normal"));
                }
            } else if (MenuScript.hasPickedTeamTwo) {
                // character.renderer.material.color = Color.green;
                teamId = 2;

                foreach (SkinnedMeshRenderer smr in character.GetComponentsInChildren<SkinnedMeshRenderer>())
                {
                    smr.material.mainTexture = Resources.Load<Texture>("Textures/Layer_lambert1_u1_v2_Diffuse_merged_wNoise_Banana");
                    smr.material.SetTexture(1, Resources.Load<Texture>("Textures/Layer_lambert1_u1_v2_Diffuse_merged_wNoise_Banana_normal"));
                }
            }
            if (isServer) {
                //character = BoltNetwork.Instantiate (BoltPrefabs.PlayerObject3d);
                character.TakeControl ();
                //Coconut.Instantiate ();
            } else if (isClient) {
                //	character = BoltNetwork.Instantiate (BoltPrefabs.PlayerObject3d);
                character.AssignControl (connection);
                GameObject.FindWithTag ("nut").GetComponent<Coconut> ().entity.AssignControl (connection);
            }
        }

        // teleport entity to a random spawn position
        if (MenuScript.hasPickedTeamOne == true) {
            character.transform.position = SpawnRandomPositionTeamOne ();
        } else if (MenuScript.hasPickedTeamTwo == true) {
            character.transform.position = SpawnRandomPositionTeamTwo();
        }
    }
Ejemplo n.º 22
0
    public void Spawn()
    {
        if (!character)
        {
            character = BoltNetwork.Instantiate(BoltPrefabs.Player);

            if (IsServer)
            {
                character.TakeControl();
            }
            else
            {
                character.AssignControl(connection);
            }
        }

        // TODO: Get spawn point from the current map
        character.transform.position = RandomPosition();
        behavior = character.GetComponent <PlayerBehavior>();
    }
Ejemplo n.º 23
0
        public static void Spawn()
        {
            var        pos          = new Vector3(Random.Range(-16, 16), 0.6f, Random.Range(-16, 16));
            BoltEntity playerEntity = BoltNetwork.Instantiate(BoltPrefabs.BomberPlayer, pos, Quaternion.identity);

            playerEntity.TakeControl();

            BomberPlayerController playerController = playerEntity.GetComponent <BomberPlayerController>();

            Photon.Lobby.LobbyPlayer lobbyPlayer = Photon.Lobby.LobbyPlayer.localPlayer;

            if (lobbyPlayer)
            {
                playerController.Setup(lobbyPlayer.playerName, lobbyPlayer.playerColor);
            }
            else
            {
                playerController.Setup("Player #" + Random.Range(1, 100), Random.ColorHSV());
            }
        }
Ejemplo n.º 24
0
    /// <summary>
    /// Spawns a player prefab with the given actor token.
    /// </summary>
    /// <param name="prefab"></param>
    /// <param name="token"></param>
    public void Spawn(Bolt.PrefabId prefab, ActorSpawnToken token)
    {
        if (!actor)
        {
            //actor = BoltNetwork.Instantiate(BoltPrefabs.Player, token);
            //actor = BoltNetwork.Instantiate(token.actorPrefab, token, token.actorPos, Quaternion.identity);
            actor = BoltNetwork.Instantiate(prefab, token, token.actorPos, Quaternion.identity);
        }

        // Server takes control of the char it spawns;
        // client is GIVEN control of the char it spawns.
        if (isServer)
        {
            Debug.Log("Server taking control of " + actor.prefabId);
            actor.TakeControl();
        }
        else
        {
            BoltConsole.Write("Server has NOT taken control of the actor.");
        }
    }
Ejemplo n.º 25
0
    public void Spawn()
    {
        if (!character)
        {
            if (IsServer)
            {
                character = BoltNetwork.Instantiate(BoltPrefabs.Player1);
                character.TakeControl();

                Player newPlayer = character.GetComponent <Player>();
                newPlayer.Respawn(0);
            }
            else
            {
                character = BoltNetwork.Instantiate(BoltPrefabs.Player2);
                character.AssignControl(connection);

                Player newPlayer = character.GetComponent <Player>();
                newPlayer.Respawn(1);
            }
        }
    }
Ejemplo n.º 26
0
    // This spawns the player character and
    // correctly assigns control of it to the connection
    public void Spawn(CustomisationToken token)
    {
        if (!character)
        {
            character = BoltNetwork.Instantiate(BoltPrefabs.Player, token);
        }

        // Server takes control of the char it spawns;
        // client is GIVEN control of the char it spawns.
        if (isServer)
        {
            BoltConsole.Write("Server taking control...");
            character.TakeControl();
        }
        else
        {
            BoltConsole.Write("Assigning control to " + connection);
            character.AssignControl(connection);
        }

        // Just gives a random position.
        character.transform.position = RandomPosition();
    }
Ejemplo n.º 27
0
        public void Spawn()
        {
            var point = SpawnPoint.Get();

            if (!character)
            {
                character = BoltNetwork.Instantiate(BoltPrefabs.Newtorked_Sample_Controller, point.transform.position, Quaternion.identity);

                if (IsServer)
                {
                    character.TakeControl();
                }
                else
                {
                    character.AssignControl(connection);
                }
            }

            // teleport entity to a random spawn position
            var retroController = character.GetComponent <RetroController>();

            retroController.TeleportTo(point.transform.position, true);
        }
    public override void SceneLoadLocalDone(string scene)
    {
        BoltEntity player = BoltNetwork.Instantiate(BoltPrefabs.EthanServerAuth);

        player.TakeControl();
    }
    public override void SceneLoadLocalDone(string scene, IProtocolToken token)
    {
        BoltEntity player = BoltNetwork.Instantiate(BoltPrefabs.EthanServerAuth, new Vector3(0, -1f, 0), Quaternion.identity);

        player.TakeControl();
    }
Ejemplo n.º 30
0
    public override void SceneLoadLocalDone(string scene)
    {
        BoltEntity player = BoltNetwork.Instantiate(BoltPrefabs.ClickToMovePlayer);

        player.TakeControl();
    }
Ejemplo n.º 31
0
        public override void SceneLoadLocalDone(string map)
        {
            BoltEntity player = BoltNetwork.Instantiate(BoltPrefabs.ThirdPersonControllerServerAuth);

            player.TakeControl();
        }