SetPlayer() public method

public SetPlayer ( Player _player ) : void
_player Player
return void
示例#1
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            //Disable player graphics for local player
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            //Create PlayerUI
            playerUIInstance      = Instantiate(playerUIprefab);
            playerUIInstance.name = playerUIprefab.name;

            //Config PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();

            if (ui == null)
            {
                Debug.Log("No playerUI component");
            }

            ui.SetPlayer(GetComponent <PlayerManager>());

            //enable all the components y camara on y todo
            GetComponent <PlayerManager>().SetupPlayer();
        }
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera)
            {
                sceneCamera.gameObject.SetActive(false);
            }

            //create playerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            //configure player UI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (!ui)
            {
                Debug.LogError("No playerUI component on PlayerUI prefab");
            }
            ui.SetController(GetComponent <PlayerController>());
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().Setup();
        }
    }
示例#3
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponent();
            AssignRemotePlayer();
        }
        else
        {
            sceneCamera = Camera.main;
            //if (sceneCamera != null)
            //{
            //    sceneCamera.gameObject.SetActive(false);
            //    Debug.Log("found dup");

            //}



            playerUIInstance      = Instantiate(playerUIprefab);
            playerUIInstance.name = playerUIprefab.name;



            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();
        }
    }
示例#4
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponent();
            AssignRemoteLayer();
        }
        else
        {
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDraw));
            playerUIInstance      = (GameObject)Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.Log("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());
            GetComponent <Player>().SetupPlayer();

            string _username = "******";
            if (UserAccountManager.isLoggedIn)
            {
                _username = UserAccountManager.playerUsername;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUsername(transform.name, _username);
        }

        //RegisterPlayer();
    }
示例#5
0
    private void Start()
    {
        //выключаем компоненты на других игроках,
        //которые мы можем использовать
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            //выключаем графику для локального персонажа
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            //Создаем интерфейс
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            //Настраиваем интерфейс
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui != null)
            {
                ui.SetPlayer(GetComponent <Player>());
            }

            GetComponent <Player>().SetupPlayer();
        }
    }
    void Start()
    {
        // deaktiviert unnötige Komponenten des nicht lokalen Spielers
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        // wenn lokaler Player erzeugt wurde, dann deaktiviere die sceneCamera
        else
        {
            //Cursor-Lock (Cursor unsichtbar machen)
            Cursor.lockState = CursorLockMode.Locked;

            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }

            // PlayerUI erstellen
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // PlayerUI konfigurieren
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("Keine PlayerUI Komponente auf dem PlayerUI Prefab.");
            }
            ui.SetPlayer(GetComponent <Player> ());
        }

        GetComponent <Player>().Setup();
    }
示例#7
0
    void Start()
    {
        menuItems = new List <GameObject>();

        int i = 0;

        foreach (GameObject character in characters)
        {
            GameObject menuItem = Instantiate(menuClassItem, uiParent);
            PlayerUI   uiPlayer = menuItem.GetComponent <PlayerUI>();
            if (uiPlayer != null)
            {
                uiPlayer.SetPlayer(character.name, clr);
            }
            menuItems.Add(menuItem);
        }

        last.onClick.AddListener(LastItem);
        next.onClick.AddListener(NextItem);

        index = 0;
        GoToCharacter();

        Button confirm = btnConfirm.GetComponent <Button>();

        confirm.onClick.AddListener(delegate { ChooseCharacter(); });

        Button cancel = btnCancel.GetComponent <Button>();

        cancel.onClick.AddListener(CancelCharacter);

        ChosenCharacter = false;
    }
示例#8
0
 void Start()
 {
     if (!isLocalPlayer)
     {
         for (int i = 0; i < componentsToDisable.Length; i++)
         {
             componentsToDisable[i].enabled = false;
         }
         AssignRemoteLayer();
     }
     else
     {
         //Disable player graphics for localplayer
         SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));
         sceneCamera = GameObject.Find("Scene Camera");
         if (sceneCamera != null)
         {
             sceneCamera.SetActive(false);
         }
         //Create PlayerUI
         playerUIInstance      = Instantiate(playerUIPrefab);
         playerUIInstance.name = playerUIPrefab.name;
         //Configure PlayerUI
         PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
         if (ui == null)
         {
             Debug.LogError("No playerui component on playerui prefab");
         }
         ui.SetPlayer(GetComponent <Player>());
         GetComponent <Player>().SetupPlayer();
     }
 }
示例#9
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            //Disable player graphics for local player
            Utility.SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            //create PlayerUI for local player
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            //configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();

            if (ui == null)
            {
                Debug.LogError("no player ui component on playerui prefab");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();
        }
    }
示例#10
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            for (int i = 0; i < componentsToDisable.Length; i++)
            {
                componentsToDisable[i].enabled = false;
            }
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }

            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            playerUIInstance = Instantiate(playerUIPrefab);

            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            ui.SetPlayer(GetComponent <Player>());
        }
    }
示例#11
0
    void Start()
    {
        // Disable components that should only be
        // active on the player that we control
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            // Disable player graphics for local player
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Create PlayerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();
        }
    }
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }

            playerUIInstance      = Instantiate(playerUIPrefab, transform);
            playerUIInstance.name = gameObject.name + "UI";

            playerInventoryInstance      = Instantiate(playerInventoryPrefab, transform);
            playerInventoryInstance.name = gameObject.name + "Inventory";

            //Configure player UIU
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No Player UI!!!");
            }
            ui.SetPlayer(GetComponent <PlayerManager>());
        }

        GetComponent <PlayerManager>().Setup();
    }
示例#13
0
    void Start()
    {
        if (!isLocalPlayer)  // if not the local palyer
        {
            DisableComponents();
            AssignRemoteLayer();
        }

        else //if local player
        {
            //disable graphics for local palyer
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            //create player UI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            //configure player UI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI Prefab");
            }
            ui.SetControllerType(1);
            ui.SetPlayer(GetComponent <Player>());

            //this part was moved here to fix the bug
            GetComponent <Player>().Setup();
        }
    }
示例#14
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            //Disable local player graphics on cam
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));
            //CreationUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No UI Component found");
            }
            else
            {
                ui.SetPlayer(GetComponent <Player>());
            }
            GetComponent <Player>().SetupPlayer();
        }
    }
示例#15
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            //remoteplayer
            Disablecomponents();
            Assignlayer();
        }
        else
        {
            //localplayer

            // Disable player graphics for local player
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Create PlayerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();

            CmdSetUsername(transform.name, GameManager.playerName);
        }
    }
示例#16
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
            // Disable player graphics for remote player
            Util.SetLayerRecursively(_remoteGraphics, LayerMask.NameToLayer(_dontDrawLayerName));
        }
        else
        {
            // Disable player graphics for local player
            Util.SetLayerRecursively(_playerGraphics, LayerMask.NameToLayer(_dontDrawLayerName));
            // Create player ui
            playerUIInstance      = Instantiate(_playerUIPrefab);
            playerUIInstance.name = _playerUIPrefab.name;

            // Configure player ui
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab");
            }

            ui.SetPlayer(GetComponent <Player>());
            GetComponent <Player>().SetupPlayer();
        }
    }
示例#17
0
    private void OnEnable()
    {
        // create PlayerUI
        if (playerUIInstance == null)
        {
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;
        }
        // enable PlayerUI
        else
        {
            playerUIInstance.SetActive(true);
        }

        // configure PlayerUI
        PlayerUI playerUI = playerUIInstance.GetComponent <PlayerUI>();

        if (playerUI == null)
        {
            Debug.LogError("No PlayerUI component on PlayerUI prefab.");
        }
        playerUI.SetPlayer(GetComponent <Entity>());

        // hide and lock cursor
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Confined;
    }
示例#18
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComonents();
            AssignRemotePlayer();
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }

            playerUIInstance      = Instantiate(playerUIPreafb);
            playerUIInstance.name = playerUIPreafb.name;

            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No ui for playerui prefab");
            }
            ui.SetPlayer(GetComponent <Player>());
        }

        GetComponent <Player>().Setup();
    }
示例#19
0
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            sceneCamera = Camera.main;
            if (sceneCamera != null)
            {
                sceneCamera.gameObject.SetActive(false);
            }
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            Player player = GetComponent <Player>();
            player.CmdUpdateUsername(((InputField)sceneCamera.gameObject.GetComponentInChildren(typeof(InputField))).text);
            ui.SetPlayer(player);
        }

        GetComponent <Player>().Setup();
    }
示例#20
0
 private void SpawnPlayers()
 {
     for (int i = 0; i < this.players.Length; ++i)
     {
         this.players[i] = Instantiate(this.playerPrefab, this.transform);
         PlayerUI playerUI = Instantiate(this.playerUIPrefab, this.uiParent);
         playerUI.SetPlayer(this.players[i]);
         this.players[i].playerNumber = i;
     }
     this.RespawnPlayers();
 }
示例#21
0
    void Start()
    {
        //Disable components that should only be active on the player that we control
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();

            /*  for (int i = 0; i < componentsToDisable.Length; i++){
             *    componentsToDisable[i].enabled = false;
             * }*/
        }
        else
        {
            //we are the local palyer, disable the scence camera
            //sceneCamera = Camera.main;
            //if (sceneCamera != null)
            //{
            //    sceneCamera.gameObject.SetActive(false);
            //}
            // Disable player graphics for local player
            // SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(DonotDrawName));

            //Create PlayerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();

            string _username = "******";

            if (UserAccountManager.IsLoggedIn)
            {
                _username = UserAccountManager.playerUsername;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUsername(transform.name, _username);
        }
    }
示例#22
0
    private void Start()
    {
        anim  = GetComponent <Animator>();
        motor = GetComponent <PlayerMotor>();
        joint = GetComponent <ConfigurableJoint>();
        SetJointSettings(jointSpring);

        if (!isLocalPlayer)
        {
            //disable les components des autres joueur pour pas controler les autres joueurs)
            gameObject.layer = LayerMask.NameToLayer(remoteLayerName);
            for (int i = 0; i < ComponenetToDiseable.Length; i++)
            {
                ComponenetToDiseable[i].enabled = false;
            }
        }
        else
        {
            //on désactive le layer de l'armure pour le joueur local
            Util.SetLayerRecursiv(playerGraphics, LayerMask.NameToLayer(layer));
            //créer l'UI (crossair)
            playerUIInstance = Instantiate(playerUIPrefab);
            //configuration de l'UI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.Log("pas de PlayerUI");
            }
            else
            {
                ui.SetPlayer(GetComponent <Player>());
            }

            GetComponent <Player>().SetUp();

            string _username = "******";

            if (UserAccountManager.IsLoggedIn)
            {
                _username = UserAccountManager.LoggedIn_Username;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUsername(transform.name, _username);
        }
    }
示例#23
0
    //Camera sceneCamera;

    void Start()
    {
        //If we don't control the player, disable these components
        if (!isLocalPlayer)
        {
            DisableComponenets();
            AssignRemoteLayer();
        }
        else
        {
            //Commented to add death cam
            // sceneCamera = Camera.main;
            // if (sceneCamera != null)
            // {
            //     sceneCamera.gameObject.SetActive(false);
            // }

            // Disable Local Player Graphics
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Create Player UI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            //Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI> ();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();

            string _username = "******";
            if (UserAccountManager.IsLoggedIn)
            {
                _username = UserAccountManager.LoggedIn_Username;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUserName(transform.name, _username);
        }
    }
示例#24
0
        /*
         * Checks is we are the local player
         * if we are not the local player we diable components
         * components: controller, motor, camera and audiolistener
         * Obviously the player is always local to themselves, so this is to avoid a player
         * from controlling multiple players with ASWD or mouse
         *
         * if we are the local player, we set the scene camera to inactive.
         * because we only want to deactive the scene camera for the local player once.
         *
         * Calls Setup on Player script.
         */
        private void Start()
        {
            var player      = GetComponent <Player>();
            var playerNetId = player.PlayerName + "-" + GetComponent <NetworkBehaviour>().netId.ToString();

            Debug.Log("Player name : " + player.PlayerName);
            Debug.Log("PlayerSetup: Start(): Player: " + this.name + " NetId: " + playerNetId);
            GameManager.RegisterPlayer(playerNetId, player);

            if (!isLocalPlayer)
            {
                Debug.Log("NOT LOCAL PLAYER");
                DisableComponents();
                AssignRemoteLayer();
            }
            else
            {
                Debug.Log("IS LOCAL PLAYER");
                GameManager.SetLocalPlayerReference(player);
                //Disable model of player in PoV camera. only done once
                SetLayerRecursively(_graphics, LayerMask.NameToLayer(DontDrawLayer));
                SetLayerRecursively(_namePlatesAndSpeedBarCanvas, LayerMask.NameToLayer(DontDrawLayer));
                //create player UI, like crosshair for example.
                _playerUiInstance      = Instantiate(_playerUiPrefab);
                _playerUiInstance.name = transform.name + "GUI";
                //Link the ui to the player
                PlayerUI ui = _playerUiInstance.GetComponent <PlayerUI>();
                ui.SetPlayer(GetComponent <Player>());
                GetComponent <PlayerGUI>().HitMarker = _playerUiInstance.GetComponent <Images>().HitMarker;
            }

            if (GetComponent <NetworkIdentity>().isServer)
            {
                Debug.Log("PlayerSetup: Start(): Player is HOST.");
            }
            else
            {
                Debug.Log("PlayerSetup: Start(): Player is CLIENT.");
            }


            _head.transform.name = player.name;

            GetComponent <Player>().SetupPlayer();
        }
示例#25
0
    void Start()
    {
        // Disable components that should only be
        // active on the player that we control
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            // Disable player graphics for local player
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Create PlayerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();

            string _username = "******";
            if (UserAccountManager.IsLoggedIn)
            {
                _username = UserAccountManager.LoggedIn_Username;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUsername(transform.name, _username);
            CmdSetColor(transform.name, UserAccountManager.LoggedIn_color);
        }
        //  Debug.Log(GetComponent<NetworkIdentity>().netId.ToString()+" "+colorHolder.playerColor+" "+isLocalPlayer);
    }
示例#26
0
    void SetupClientOnlyObjects()
    {
        Player player = GetComponent <Player>();

        // Create Player UI
        GameObject playerUIObject = Instantiate(playerUIPrefab);

        playerUIObject.name = playerUIPrefab.name;
        playerUIInstance    = playerUIObject.GetComponent <PlayerUI>();
        playerUIInstance.SetPlayer(player);

        // Create Terrain Generator
        GameObject       terrainObject    = Instantiate(terrainGeneratorPrefab);
        TerrainGenerator terrainGenerator = terrainObject.GetComponent <TerrainGenerator>();

        terrainGenerator.viewer = gameObject.transform;
        terrainGenerator.SetPlayer(player);
        terrainGenerator.enabled = true;
    }
示例#27
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            // Désactiver la partie graphique du joueur local
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Création du UI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configuration du UI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("Problème detecté : Pas de component PlayerUI sur playerUIinstance.");
            }
            else
            {
                ui.SetPlayer(GetComponent <Player>());
            }

            GetComponent <Player>().SetupPlayer();

            string _username = "******";
            if (UserAccountManager.IsLoggedIn)
            {
                _username = UserAccountManager.LoggedIn_Username;
            }
            else
            {
                _username = transform.name;
            }

            CmdSetUsername(transform.name, _username);
        }
    }
示例#28
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();//the player on other machines or ur opponents
        }
        else
        {
            GameManager.instance.SetSceneCamera(false);

            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(DontDrawLayerName));

            //setting up crosshair
            playerGUIInstance      = Instantiate(playerGUIPrefab);
            playerGUIInstance.name = playerGUIPrefab.name;

            PlayerUI ui = playerGUIInstance.GetComponent <PlayerUI>();

            if (ui == null)
            {
                Debug.LogError("No PlayerUI script found on player UI prefab");
            }

            ui.SetPlayer(GetComponent <Player>());

            GetComponent <Player>().SetupPlayer();//calling setup function
        }

        string _username = "******";

        if (UserAccountManager.IsLoggedIn)
        {
            _username = UserAccountManager.PlayerUsername;
        }

        else
        {
            _username = transform.name;
        }
        CmdSetUSername(transform.name, _username);
    }
示例#29
0
    // Use this for initialization
    void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemoteLayer();
        }
        else
        {
            // Disable player graphics for local player
            SetLayerRecursively(playerGraphics, LayerMask.NameToLayer(dontDrawLayerName));

            // Create PlayerUI
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;

            // Configure PlayerUI
            PlayerUI ui = playerUIInstance.GetComponent <PlayerUI>();
            if (ui == null)
            {
                Debug.LogError("No PlayerUI component on PlayerUI prefab.");
            }
            ui.SetPlayer(GetComponent <Player> ());
            //ui.SetController (GetComponent<PlayerController>());

            GetComponent <Player>().SetupPlayer();

            string _username = "******";
            if (UserAccountManager.isLoggedIn)
            {
                _username = UserAccountManager.loggedInUsername;
            }
            else
            {
                _username = transform.name;
            }


            CmdSetUsername(transform.name, _username);
        }
    }
示例#30
0
    private void Start()
    {
        if (!isLocalPlayer)
        {
            DisableComponents();
            AssignRemotePlayer();
        }
        else
        {
            SetLayerRecursively(physicGraphics, LayerMask.NameToLayer(DontDrawLayerName));
            playerUIInstance      = Instantiate(playerUIPrefab);
            playerUIInstance.name = playerUIPrefab.name;


            PlayerUI playerUI = playerUIInstance.GetComponent <PlayerUI>();

            playerUI.SetPlayerController(GetComponent <PlayerController>());
            playerUI.SetPlayer(GetComponent <Player>());
            GetComponent <Player>().Setup();
        }
    }