コード例 #1
0
    /// <summary>
    /// Creates the player.
    /// </summary>
    public void CreatePlayer()
    {
        if (_hasAlreadySpawned)
        {
            Debug.Log("Trying to create a player I already had");
            return;
        }
        Cursor.visible     = false;
        _chat              = GameObject.Find("ChatManager").GetComponent <Chat>();
        _chat.InMenu       = false;
        _hasAlreadySpawned = true;
        GameObject.Find("ChatManager").GetComponent <Chat>().enabled = true;
        updateReferences();
        Vector3 spawnPosition = _map.transform.Find("BoxPrefab").transform.position + Vector3.up * 15;

        spawnPosition.x = UnityEngine.Random.Range(-9f, 9f);
        spawnPosition.z = UnityEngine.Random.Range(-9f, 9f);
        _localPlayer    = PhotonNetwork.Instantiate(Constants.ROBOT_NAMES[(int)_robotID], spawnPosition, Quaternion.identity, 0);
        _localPlayer.transform.Find("Canvas").gameObject.SetActive(true);
        _localPlayer.GetComponent <CrosshairUI>().enabled = true;
        _localPhotonView = _localPlayer.GetComponent <PhotonView>();
// _localPlayer.transform.Find("bottom").Find("Canvas").Find("Text").GetComponent<Text>().text = PhotonNetwork.playerName;
        _localPlayer.GetComponentInChildren <PlayerController>().enabled = true;
        _localPlayer.GetComponent <ShooterB>().enabled = true;
        _shooterB = _localPlayer.GetComponent <ShooterB>();
        _localPlayer.GetComponent <UI>().enabled = true;
        _localPlayer.GetComponentInChildren <LookTowardCamera>().enabled = true;
        _localPlayer.GetComponentInChildren <CameraControl>().enabled    = true;
        _flyingCamera.gameObject.SetActive(false);
        _camera = _localPlayer.transform.Find("TPScamera/firstCamera").gameObject;
        _camera.GetComponent <AudioListener>().enabled = true;

        if (!PhotonNetwork.isMasterClient)
        {
            NetworkEventHandlers.Broadcast(Constants.EVENT_IDS.PLAYER_SPAWNED);
        }
        else
        {
            GameObject.Instantiate(Resources.Load("PowerupManager"));
        }

        if (!GameObject.Find("SettingsManager").GetComponent <Settings>().OnlineMode)
        {
            spawnAI(Constants.NUMBER_OF_AI);
        }
    }
コード例 #2
0
ファイル: UI.cs プロジェクト: FreeForFall/FreeForFall
    void Start()
    {
        _localPlayer = GameObject.Find("NetworkManager").GetComponent <Networking>().Player;
        _pController = _localPlayer.GetComponentInChildren <PlayerController>();
        _shooterB    = _localPlayer.GetComponentInChildren <ShooterB>();

        GameObject launchLabel = _localPlayer.transform.Find("Canvas/Rockets/Filled").gameObject;
        GameObject jumpLabel   = _localPlayer.transform.Find("Canvas/Jump/Filled").gameObject;
        GameObject hookLabel   = _localPlayer.transform.Find("Canvas/GrapplingHook/Filled").gameObject;

        launcher            = launchLabel.GetComponent <Image>();
        jump                = jumpLabel.GetComponent <Image>();
        hook                = hookLabel.GetComponent <Image>();
        launcher.fillAmount = 1f;
        jump.fillAmount     = 1f;
        hook.fillAmount     = 1f;
        lastGrip            = 0f;
        lastJump            = 0f;
    }