SetPlayer() public static method

public static SetPlayer ( IPlayer, player ) : void
player IPlayer,
return void
Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (!running)
        {
            return;
        }
        //a strange roundabout way to find the server player, but it works so shut up
        if (!localPlayerSet)
        {
            if (GameManager.instance.CurrentPlayer != null)
            {
                controlledPlayers.Add(GameManager.instance.CurrentPlayer);
                PlayerRegistry.SetPlayer(GameManager.instance.CurrentPlayer);
                localPlayerSet = true;
                Debug.Log("Local player set!");
            }
        }

        //if all players have passed control back to the server
        if (controlledPlayers.Count == lobby.PlayerCount)
        {
            Finished();
            return;
        }
        timer += Time.deltaTime;
        if (timer > CONTROL_TIMEOUT)  //the timeout has expired
        {
            KickAllNonCompliantPlayers();
            Finished();
        }
    }
Example #2
0
 //once each player has finished loading the scene and spawning their players, they must give control back to the server
 //to indicate that they're ready and compliant.  this function will be called when they do.  Due to timing issues, this method
 //cannot be used for the server's local player, so that one is handled in Update()
 public override void ControlOfEntityGained(BoltEntity entity)
 {
     if (entity.prefabId == BoltPrefabs.PlayerPrefab && !entity.isOwner)  //first ensure that its a player that this event is being called on
     {
         IPlayer player = entity.gameObject.GetComponentInChildren <AbstractPlayer>();
         controlledPlayers.Add(player);    //add them to the list
         PlayerRegistry.SetPlayer(player); //add them to the PlayerRegistry, if this is the server's player, it will be done elsewhere
     }
 }
Example #3
0
    public override void Attached()
    {
        if (entity.isOwner)
        {
            GameObject prefab = Instantiate(OwnerPrefab);
            state.Transform.SetTransforms(prefab.transform);
            prefabTransform = prefab.transform;
            if (BoltNetwork.isServer)
            {
                entity.TakeControl();
            }
            else
            {
                entity.AssignControl(BoltNetwork.server);
            }
        }
        else
        {
            GameObject prefab = Instantiate(ProxyPrefab);
            state.Transform.SetTransforms(prefab.transform);
            prefabTransform = prefab.transform;
        }
        prefabTransform.parent        = this.transform;
        prefabTransform.localPosition = Vector3.zero;
        prefabTransform.localRotation = Quaternion.identity;
        Player = prefabTransform.GetComponent <IPlayer>();
        ((AbstractPlayer)Player).SetState(this);
        if (entity.isOwner)
        {
            state.Name = GameManager.instance.CurrentUserName;
        }

        //if this is the server's player we have to do some special stuff
        if (BoltNetwork.isServer && entity.isOwner)
        {
            PlayerRegistry.SetPlayer(Player);
        }
    }