Inheritance: UnityEngine.MonoBehaviour
 void CmdAddPlayer(NetworkIdentity ni)
 {
     if (playerOne == null)
         playerOne = ni;
     else if (playerTwo == null)
         playerTwo = ni;
 }
 private void GetNetworkInformation(GameObject gameObject)
 {
     this.m_Identity = gameObject.GetComponent<NetworkIdentity>();
     if (this.m_Identity != null)
     {
         this.m_Info = new List<NetworkIdentityInfo>();
         this.m_Info.Add(this.GetAssetId());
         this.m_Info.Add(GetString("Scene ID", this.m_Identity.sceneId.ToString()));
         if (Application.isPlaying)
         {
             this.m_Info.Add(GetString("Network ID", this.m_Identity.netId.ToString()));
             this.m_Info.Add(GetString("Player Controller ID", this.m_Identity.playerControllerId.ToString()));
             this.m_Info.Add(GetBoolean("Is Client", this.m_Identity.isClient));
             this.m_Info.Add(GetBoolean("Is Server", this.m_Identity.isServer));
             this.m_Info.Add(GetBoolean("Has Authority", this.m_Identity.hasAuthority));
             this.m_Info.Add(GetBoolean("Is Local Player", this.m_Identity.isLocalPlayer));
             NetworkBehaviour[] components = gameObject.GetComponents<NetworkBehaviour>();
             if (components.Length > 0)
             {
                 this.m_Behaviours = new List<NetworkBehaviourInfo>();
                 foreach (NetworkBehaviour behaviour in components)
                 {
                     NetworkBehaviourInfo item = new NetworkBehaviourInfo {
                         name = new GUIContent(behaviour.GetType().FullName),
                         behaviour = behaviour
                     };
                     this.m_Behaviours.Add(item);
                 }
             }
         }
     }
 }
    public override void OnStartLocalPlayer()
    {
        networkIdentity = GetComponent<NetworkIdentity>();

        GetNetworkIdentity();
        SetNetworkIdentity();
    }
Beispiel #4
0
 void Start()
 {
     
     image = GetComponent<Image>();
     networkIdentity = gameObject.GetComponent<NetworkIdentity>();
     image.fillAmount = 1;
 }
 internal PlayerController(GameObject go, short playerControllerId)
 {
     this.playerControllerId = -1;
     this.gameObject = go;
     this.unetView = go.GetComponent<NetworkIdentity>();
     this.playerControllerId = playerControllerId;
 }
 // Use this for initialization
 void Start()
 {
     currentLocalRot = Quaternion.identity;
     this.transform.localPosition = new Vector3(0, 0, 0);
     owner = transform.parent.GetComponent<NetworkIdentity>();
     cmc = transform.parent.gameObject.GetComponentInChildren<CharacterModelControl>();
 }
    NetworkIdentity playerTwo = null; //to hold the NetworkIdentity of the SECOND to join as Player TWO

    #endregion Fields

    #region Methods

    //Pass in a network id
    public bool checkTurn(NetworkIdentity ni)
    {
        if (ni == currentPlayer)  // if matches currentPlayer variable. returns true.
            return true;
        else
            return false;
    }
Beispiel #8
0
 // Use this for initialization
 public override void Start()
 {
     base.Start();
     shipRigidbody = myShip.GetComponent<Rigidbody>();
     networkidentity = GetComponent<NetworkIdentity>();
     if (networkidentity.hasAuthority)
         shipRigidbody.isKinematic = false;
 }
 internal void AddOwnedObject(NetworkIdentity obj)
 {
     if (this.m_ClientOwnedObjects == null)
     {
         this.m_ClientOwnedObjects = new HashSet<NetworkInstanceId>();
     }
     this.m_ClientOwnedObjects.Add(obj.netId);
 }
Beispiel #10
0
 void Start()
 {
     rt = GetComponent<RectTransform>();
     myID = GetComponent<NetworkIdentity>();
     if (!myID.isLocalPlayer)
         return;
     transform.SetParent(Camera.main.GetComponent<ValueAssigner>().ParentTransform, false);
     ReadyButton.interactable = true;
 }
    protected virtual void Awake()
    {
        if (mainCamera == null)
            mainCamera = Camera.main;

        navMeshAgent = GetComponent<NavMeshAgent>();
        networkIdentity = GetComponent<NetworkIdentity>();

        speed = 8.0f;
    }
 internal bool GetNetworkIdentity(NetworkInstanceId netId, out NetworkIdentity uv)
 {
     if (this.m_LocalObjects.ContainsKey(netId) && (this.m_LocalObjects[netId] != null))
     {
         uv = this.m_LocalObjects[netId];
         return true;
     }
     uv = null;
     return false;
 }
Beispiel #13
0
        // Gets spawned in the Tower.Start() methode.
        void Start()
        {
            Debug.Log ("Starting Local Selector for: " + towerUID);
            transform.name = towerUID + ".select";
            tower = GameObject.Find (towerUID).GetComponent<Tower> ();
            tNI = tower.GetComponent<NetworkIdentity> ();

            Button selBtn =  GameObject.Find("SelectButton").GetComponent<Button>();
            selBtn.onClick.AddListener (() => {TriggerSelect();});
        }
Beispiel #14
0
    void Start()
    {
        ni = GetComponent<NetworkIdentity>();

        if (ni.isLocalPlayer)
        {
            Sm = Camera.main.gameObject.GetComponent<ValueAssigner>().Mover;
            Sm.MoveDown();
        }
    }
    public void Respawn(NetworkIdentity ident, NetworkIdentity enemyIdent, Transform transform)
    {
        int num = UnityEngine.Random.Range(0, 3);

        GameObject player = GameObject.Instantiate(playerPrefabs[num], transform.position, Quaternion.identity) as GameObject;
        NetworkServer.ReplacePlayerForConnection(enemyIdent.connectionToClient, player, enemyIdent.playerControllerId);
        playerConn = enemyIdent.connectionToClient;

        player = GameObject.Instantiate(prefabEnemy, Vector3.zero, Quaternion.identity) as GameObject;
        NetworkServer.AddPlayerForConnection(ident.connectionToClient, player, ident.playerControllerId);
    }
Beispiel #16
0
    ///Set new turn based on whos turn it previously was
    public void newTurn(NetworkIdentity ni)
    {
        if (currentPlayer != ni)
        {

            if (playerOne == ni)
                Cmdnewturn(playerTwo);
            else if (playerTwo == ni)
                Cmdnewturn(playerOne);
        }
    }
 private void Init()
 {
   if (this.m_Initialized)
     return;
   this.m_Initialized = true;
   this.m_NetworkIdentity = this.target as NetworkIdentity;
   this.m_ServerOnlyProperty = this.serializedObject.FindProperty("m_ServerOnly");
   this.m_LocalPlayerAuthorityProperty = this.serializedObject.FindProperty("m_LocalPlayerAuthority");
   this.m_ServerOnlyLabel = new GUIContent("Server Only", "True if the object should only exist on the server.");
   this.m_LocalPlayerAuthorityLabel = new GUIContent("Local Player Authority", "True if this object will be controlled by a player on a client.");
   this.m_SpawnLabel = new GUIContent("Spawn Object", "This causes an unspawned server object to be spawned on clients");
 }
    // Use this for initialization
    void Start()
    {
        if (spawnScript == null)
        {
            spawnScript = GameObject.FindGameObjectWithTag("Manager").GetComponent<Spawn>();
        }

        spawnScript.setPlayer(gameObject);
        netIdentity = GetComponent<NetworkIdentity>();

        prefabEye = Resources.Load("Prefabs/eye");
        prefabFist = Resources.Load("Prefabs/fist");
        prefabMustache = Resources.Load("Prefabs/mustache");
    }
        void Awake()
        {
            rb = GetComponent <Rigidbody>();
#if !DISABLE_PHYSICS_2D
            rb2D = GetComponent <Rigidbody2D>();
#endif

#if PUN_2_OR_NEWER
            pv = GetComponent <PhotonView>();
#else
            ni     = GetComponent <NetworkIdentity>();
            unetNI = GetComponent <UnityEngine.Networking.NetworkIdentity>();
#endif
        }
Beispiel #20
0
    void Start()
    {
        networkId = GetComponent<NetworkIdentity>();

        // enable-disable controller
        if (!networkId.isLocalPlayer)
        {
            GetComponent<CarController>().enabled = false;
        }
        else
        {
            GetComponent<CarController>().enabled = true;
        }
    }
Beispiel #21
0
    void CmdRandomTurn()
    {
        if (currentPlayer != null && playerOne == null && playerTwo == null)
            return;

        else
        {
            int rand = Random.Range(1, 2);

            if (rand == 1)
                currentPlayer = playerOne;
            if (rand == 2)
                currentPlayer = playerTwo;
        }
    }
        private void Awake()
        {
#if PUN_2_OR_NEWER
            pv = GetComponent <Photon.Pun.PhotonView>();
#else
            ni     = GetComponent <NetworkIdentity>();
            unetNI = GetComponent <UnityEngine.Networking.NetworkIdentity>();
#endif
            var itc = transform.root.GetComponent <IHasTransformCrusher>();

            if (itc != null)
            {
                tc = itc.TC;
            }
        }
    void Start()
    {
        //on client, this isn't required but is nice for testing.
        Application.runInBackground = true;

        var globals = FindObjectOfType<GlobalAssets>();

        _networkStateEntityProtoType = globals.NetworkEntityStatePrototype.GetComponent<NetworkIdentity>();

        ClientScene.RegisterSpawnHandler(_networkStateEntityProtoType.assetId, OnSpawnEntity, OnDespawnEntity);

        _client = new NetworkClient();
        _client.Connect("localhost", 7777);
        _client.RegisterHandler(MsgType.Connect, OnClientConnected);

    }
Beispiel #24
0
    // Use this for initialization
    void Start()
    {
        points = 0;
        _timer = 2;
        _timeout = false;
        nIdent = GetComponent<NetworkIdentity> ();
        _hunter = (nIdent.netId.Value <= 2);
        isFirstplayer = _hunter;
        red = new Color(255,0,0,1);
        blue = new Color(0,0,255,1);

        gameObjectRenderer = this.gameObject.GetComponent<MeshRenderer>();

        Material newMaterial = new Material(Shader.Find("Diffuse"));
        if (_hunter)
            newMaterial.color = red;
        else
            newMaterial.color = blue;
        gameObjectRenderer.material = newMaterial ;
    }
 internal void AssignAuthorityCallback(NetworkConnection conn, NetworkIdentity uv, bool authorityState)
 {
     PeerAuthorityMessage msg = new PeerAuthorityMessage {
         connectionId = conn.connectionId,
         netId = uv.netId,
         authorityState = authorityState
     };
     if (LogFilter.logDebug)
     {
         Debug.Log("AssignAuthorityCallback send for netId" + uv.netId);
     }
     for (int i = 0; i < NetworkServer.connections.Count; i++)
     {
         NetworkConnection connection = NetworkServer.connections[i];
         if (connection != null)
         {
             connection.Send(0x12, msg);
         }
     }
 }
    public override void OnStartClient(){
        base.OnStartClient();
        Debug.Log("DictID is " + dictId);
        nIdentity = GetComponent<NetworkIdentity>();
        nm = (PlanetsNetworkManager)NetworkManager.singleton;
        ppi = PersonalPlayerInfo.singleton;
        pm = PlayerManager.singleton;
        rb = GetComponent<Rigidbody>();
        invertControls = nm.isSplitScreen();
        reflectionMatrix = genRefMatrix(90 * Mathf.Deg2Rad);
        roundEvents = GameObject.Find("RoundEvents").GetComponent<RoundEvents>(); //Sets reference to RoundEvents object
        resourcePowerUpManager = GameObject.FindGameObjectWithTag("Planet").GetComponent<ResourcePowerUpManager>();
        needsReflection = gameObject.CompareTag("PlayerSuperCorp");
        //Debug.Log("Player + " + PlayerManager.singleton.getPlayer(dictId));

            if (pm.checkIfExists(dictId)) {
            playerDetails.setPlayerDetails(dictId, pm.getPlayer(dictId));
        } else {
            playerDetails.setPlayerDetails(dictId, ppi.getPlayer());
        }
        Debug.Log("Setting teardrop id to " + playerDetails.getObsId().ToString()); //BUG
        tearDropId.text = playerDetails.getObsId().ToString();
    }
 internal void AddToVisList(NetworkIdentity uv)
 {
     this.m_VisList.Add(uv);
     NetworkServer.ShowForConnection(uv, this);
 }
 public void RespawnEnemy(NetworkIdentity ident)
 {
     GameObject player = GameObject.Instantiate(prefabEnemy, Vector3.zero, Quaternion.identity) as GameObject;
     NetworkServer.ReplacePlayerForConnection(ident.connectionToClient, player, ident.playerControllerId);
 }
 internal void OnStartServer()
 {
     if (this.m_IsServer)
     {
         return;
     }
     this.m_IsServer = true;
     if (this.m_LocalPlayerAuthority)
     {
         this.m_HasAuthority = false;
     }
     else
     {
         this.m_HasAuthority = true;
     }
     this.m_Observers           = new List <NetworkConnection>();
     this.m_ObserverConnections = new HashSet <int>();
     this.CacheBehaviours();
     if (this.netId.IsEmpty())
     {
         this.m_NetId = NetworkIdentity.GetNextNetworkId();
         if (LogFilter.logDev)
         {
             Debug.Log(string.Concat(new object[]
             {
                 "OnStartServer ",
                 base.gameObject,
                 " GUID:",
                 this.netId
             }));
         }
         NetworkServer.instance.SetLocalObjectOnServer(this.netId, base.gameObject);
         for (int i = 0; i < this.m_NetworkBehaviours.Length; i++)
         {
             NetworkBehaviour networkBehaviour = this.m_NetworkBehaviours[i];
             try
             {
                 networkBehaviour.OnStartServer();
             }
             catch (Exception ex)
             {
                 Debug.LogError("Exception in OnStartServer:" + ex.Message + " " + ex.StackTrace);
             }
         }
         if (NetworkClient.active && NetworkServer.localClientActive)
         {
             ClientScene.SetLocalObject(this.netId, base.gameObject);
             this.OnStartClient();
         }
         if (this.m_HasAuthority)
         {
             this.OnStartAuthority();
         }
         return;
     }
     if (LogFilter.logError)
     {
         Debug.LogError(string.Concat(new object[]
         {
             "Object has non-zero netId ",
             this.netId,
             " for ",
             base.gameObject,
             " !!1"
         }));
     }
 }
Beispiel #30
0
 private void Start()
 {
     instance = this;
     netIdentity = GetComponent<NetworkIdentity>();
 }
 internal void AddToVisList(NetworkIdentity uv)
 {
     this.m_VisList.Add(uv);
     NetworkServer.ShowForConnection(uv, this);
 }
 void CmdChangeColor(GameObject go, Color c)
 {
     objNetId = go.GetComponent<NetworkIdentity>();
     objNetId.AssignClientAuthority(connectionToClient);
     RpcUpdateTower(go, c);
     objNetId.RemoveClientAuthority(connectionToClient);
 }
 public void Write(NetworkIdentity value)
 {
   if ((UnityEngine.Object) value == (UnityEngine.Object) null)
     this.WritePackedUInt32(0U);
   else
     this.Write(value.netId);
 }
 void Start()
 {
     angularVelocity = gameObject.GetComponent<Rigidbody2D>().angularVelocity;
     netIdentity = GetComponent<NetworkIdentity>();
 }
 internal PlayerController(GameObject go, short playerControllerId)
 {
     this.gameObject         = go;
     this.unetView           = go.GetComponent <NetworkIdentity>();
     this.playerControllerId = playerControllerId;
 }