public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.stateHash = (int) reader.ReadPackedUInt32();
     this.normalizedTime = reader.ReadSingle();
     this.parameters = reader.ReadBytesAndSize();
 }
    void RpcSetWeaponTarget(NetworkInstanceId target)
    {
        //Prende la transform del veicolo per settare la mira correttamente.  Trovare un altro sistema!!!

        targetIk.solver.target = ClientScene.FindLocalObject(target).transform.GetComponent<ControllerWheels>().CentralPoint.transform;

    }
        /// <summary>
        /// Attribue un item à un slot déjà existant
        /// </summary>
        /// <param name="name"></param>
        /// <param name="type"></param>
        /// <param name="spritePath"></param>
        public static void AddItem(Item itemToAdd, NetworkInstanceId _go)
        {
            itemToAdd.go = _go;
            int slotId = 0;
            InventorySlot currentSlot;

            // Initialisation du numéro de slot à remplir
            while (slotId < slots.Count())
            {
                if (slotId >= SLOTS_NBR)
                {
                    return;
                }

                currentSlot = slots[slotId];
                if (currentSlot.IsEmpty)
                    break;
                else if (currentSlot.Item.Name.Equals(itemToAdd.Name) && currentSlot.Amount < 100)
                {
                    currentSlot.Amount += 1;       // Si un ojet du même type a été trouvé, on incrémente juste la quantité
                    return;
                }
                slotId++;
            }
            slots[slotId].FillSlot(itemToAdd);
        }
Esempio n. 4
0
    void GetNetIdentity()
    {
        //NetworkIdentityのNetID取得
        playerNetID = GetComponent<NetworkIdentity>().netId;

        CmdTellServerMyIdentity(MakeUniqueIdentity());
    }
 public PlayerInfoPacket(string name, string team, NetworkInstanceId networkID, int score = 0)
 {
     this.playerName = name;
     this.playerTeam = team;
     this.networkID = networkID;
     this.score = score;
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.payload = reader.ReadBytesAndSize();
     this.teleport = reader.ReadBoolean();
     this.time = (int) reader.ReadPackedUInt32();
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.sceneId = reader.ReadSceneId();
     this.position = reader.ReadVector3();
     this.payload = reader.ReadBytesAndSize();
 }
    public void StopDragging(NetworkInstanceId netId)
    {
        //draggingHelper = playerTransform.GetComponent<DraggingHelper>();

        //draggingHelper.CmdSetDraggedBody(netId);
        StopDragging();
    }
Esempio n. 9
0
 public void registerKill(NetworkInstanceId netId, int playerKilledId, int playerKillerId)
 {
     KillPlayer kp = new KillPlayer();
     kp.netId = netId;
     nm.client.Send(Msgs.killPlayer, kp);
     pom.killPlayerLocal(playerKilledId, playerKillerId);
     Debug.Log("Player " + playerKilledId + " died");
 }
 public void CmdUnspawnUnit(NetworkInstanceId objID)
 {
     GameObject unspawnedObj = NetworkServer.FindLocalObject(objID);
     //NetworkServer.UnSpawn(unspawnedObj);
     NetworkServer.Destroy(unspawnedObj);
     //For the server we don't want to see it, but it will stil exists, because we need the reference to the old object due to buttons listeners.
     unspawnedObj.GetComponent<MeshRenderer>().enabled = false;
 }
Esempio n. 11
0
	void GetNETID()
	{
		NET_ID = this.GetComponent<NetworkIdentity> ().netId;

		CmdSayMyID(myID());


	}
Esempio n. 12
0
 public void CmdAddDeath(NetworkInstanceId attacker)
 {
     deaths++;
     var attackerObj = ClientScene.FindLocalObject(attacker);
     if (attackerObj) {
         attackerObj.GetComponent<Player>().kills++;
     }
 }
 public override void Deserialize(NetworkReader reader)
 {
     m_id = reader.ReadNetworkId();
     m_parentId = reader.ReadNetworkId();
     m_childId = reader.ReadInt32();
     m_position = reader.ReadVector3();
     m_payload = reader.ReadBytesAndSize();
 }
 void RpcPickUp(NetworkInstanceId id)
 {
     if (pc == null)
         pc = ClientScene.FindLocalObject (id).GetComponent<PlayerControls> ();
     GetComponent<SpriteRenderer> ().enabled = false;
     GetComponent<CircleCollider2D> ().enabled = false;
     if (pc.isLocalPlayer)
         MainGUI.GUI.SetPowerUpIcon (Icon);
 }
    // Logs deaths in the scoreboard and kills where applicable
    public static void LogKill(NetworkInstanceId killerId, NetworkInstanceId victimId)
    {
        PlayerStats[victimId]["deaths"]++;

        // Not a suicide or environmental death, so log a kill
        if (!killerId.IsEmpty () && killerId != victimId) {
            PlayerStats[killerId]["kills"]++;
        }
    }
 public void Reset()
 {
     Life = MAX_PLAYER_LIFE;
     ExplosionRange = MIN_EXPLOSION_RANGE;
     MaxBombsNum = MIN_BOMB_NUM;
     Speed = MIN_SPEED * 2;
     NetId = NetworkInstanceId.Invalid;
     KickSkill = false;
 }
 public void CmdEquipItem(NetworkInstanceId netId, int handIndex)
 {
     var go = NetworkServer.FindLocalObject(netId);
     go.transform.SetParent(handIndex == -1 ? playerLeftHand : playerRightHand);
     go.transform.position = Vector3.zero;
     go.transform.localPosition = Vector3.zero;
     go.transform.rotation = Quaternion.identity;
     go.SetActive(true);
     RpcEquipItem(netId, handIndex);
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 private void CmdShoot(NetworkInstanceId id, bool explosion)
 {
     GameObject player = NetworkServer.FindLocalObject(id);
     var healthScript = player.GetComponent<NetworkHealth>();
     if(healthScript == null) {
         Debug.LogError("no healthScripts attached to player");
         return;
     }
     healthScript.TakeDamage(damage, explosion);
 }
Esempio n. 20
0
 internal GameObject FindLocalObject(NetworkInstanceId netId)
 {
   if (this.m_LocalObjects.ContainsKey(netId))
   {
     NetworkIdentity localObject = this.m_LocalObjects[netId];
     if ((Object) localObject != (Object) null)
       return localObject.gameObject;
   }
   return (GameObject) null;
 }
Esempio n. 21
0
 private void CmdShoot(NetworkInstanceId id)
 {
     GameObject player = NetworkServer.FindLocalObject(id);
     var healthScript = player.GetComponent<NetworkHealth>();
     if (healthScript == null)
     {
         Debug.LogError("no hleathscript attached to player");
         return;
     }
     healthScript.GetShot(damage);
 }
 public override void Deserialize(NetworkReader reader)
 {
     this.netId = reader.ReadNetworkId();
     this.assetId = reader.ReadNetworkHash128();
     this.position = reader.ReadVector3();
     this.payload = reader.ReadBytesAndSize();
     uint num = 0x10;
     if ((reader.Length - reader.Position) >= num)
     {
         this.rotation = reader.ReadQuaternion();
     }
 }
Esempio n. 23
0
 public void RpcChangeLightStatus(NetworkInstanceId id, int status)
 {
     foreach (GameObject player in players)
     {
         if (player.GetComponent<NetworkIdentity>().netId == id)
         {
             FlashlightScript theirLight = player.GetComponentInChildren<FlashlightScript>();
             if (theirLight != null)
                 theirLight.changeStatus(status);
         }
     }
 }
Esempio n. 24
0
    public void RpcSyncPlayer(NetworkInstanceId[] hId)
    {
        for (int i = 0; i < hId.Count(); i++)
        {
            Actor hActor = ClientScene.FindLocalObject(hId[i]).GetComponent<Actor>();
            if (!scores.ContainsKey(hActor))
                scores.Add(hActor, 0);

            if(hActor.gameObject != Radar.Player)
                Radar.Add(hActor.gameObject);
        }
    }
Esempio n. 25
0
    public static int CheckPlayerBombCount(NetworkInstanceId playerId)
    {
        int count = 0;
        foreach (var obj in ClientScene.objects)
        {
            Bomb bomb = obj.Value.GetComponent<Bomb>();
            if (bomb != null && bomb.PuttingPlayer.PlayerData.NetId == playerId)
                ++count;
        }

        return count;
    }
Esempio n. 26
0
 internal GameObject FindLocalObject(NetworkInstanceId netId)
 {
     if (this.m_LocalObjects.ContainsKey(netId))
     {
         NetworkIdentity identity = this.m_LocalObjects[netId];
         if (identity != null)
         {
             return identity.gameObject;
         }
     }
     return null;
 }
 public void AddScore(NetworkInstanceId id, int newScore)
 {
     if(playerDetails.ContainsKey(id)) {
         playerDetails[id] = new PlayerInfoPacket( // This doesn't feel right..
             playerDetails[id].playerName,
             playerDetails[id].playerTeam,
             playerDetails[id].networkID,
             playerDetails[id].score + newScore
         );
         RpcUdateScore(playerDetails[id]);
     }
 }
 protected void updateParentId(NetworkInstanceId id)
 {
     this.parentId = id;
     GameObject parentObject = ClientScene.FindLocalObject(id);
     if(parentObject != null) {
         transform.parent = parentObject.transform;
         if (setPositionAndRotation) {
             transform.localPosition = positionAndRotation.position;
             transform.localEulerAngles = positionAndRotation.rotation;
         }
     }
 }
Esempio n. 29
0
    //private UnitOwner parent = null;

    public void setOwnerShip( UnitOwner owner)
    {

        if (owner != null)
        {
            //parent = owner;
            this.playerName = owner.playerName;
            //this.playerIndex = owner.playerIndex;
            this.playerNetId = owner.playerNetId;
            this.teamIndex = owner.teamIndex;
        }
    }
 public void CmdSpawnPlayer()
 {
     if (ClientScene.FindLocalObject(spawnedCharacterID) == null)
     {
         var go = (GameObject)Instantiate(characterPrefab, Vector3.up, Quaternion.identity);
         NetworkServer.AddPlayerForConnection(GetComponent<NetworkIdentity>().connectionToClient, go, 1);
         spawnedCharacterID = go.GetComponent<NetworkIdentity>().netId;
     }
     else
     {
         Debug.LogWarning("Server: Can't spawn two character for the same player");
     }
 }
Esempio n. 31
0
        internal static void HandleChildTransform(NetworkMessage netMsg)
        {
            NetworkInstanceId netId = netMsg.reader.ReadNetworkId();
            uint index = netMsg.reader.ReadPackedUInt32();

            NetworkDetailStats.IncrementStat(NetworkDetailStats.NetworkDirection.Incoming, 0x10, "16:LocalChildTransform", 1);
            GameObject obj2 = NetworkServer.FindLocalObject(netId);

            if (obj2 == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleChildTransform no gameObject");
                }
            }
            else
            {
                NetworkTransformChild[] components = obj2.GetComponents <NetworkTransformChild>();
                if ((components == null) || (components.Length == 0))
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("HandleChildTransform no children");
                    }
                }
                else if (index >= components.Length)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("HandleChildTransform childIndex invalid");
                    }
                }
                else
                {
                    NetworkTransformChild child = components[index];
                    if (child == null)
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("HandleChildTransform null target");
                        }
                    }
                    else if (!child.localPlayerAuthority)
                    {
                        if (LogFilter.logError)
                        {
                            Debug.LogError("HandleChildTransform no localPlayerAuthority");
                        }
                    }
                    else if (!netMsg.conn.clientOwnedObjects.Contains(netId))
                    {
                        if (LogFilter.logWarn)
                        {
                            Debug.LogWarning("NetworkTransformChild netId:" + netId + " is not for a valid player");
                        }
                    }
                    else
                    {
                        child.UnserializeModeTransform(netMsg.reader, false);
                        child.m_LastClientSyncTime = Time.time;
                        if (!child.isClient)
                        {
                            child.m_Target.localPosition = child.m_TargetSyncPosition;
                            child.m_Target.localRotation = child.m_TargetSyncRotation3D;
                        }
                    }
                }
            }
        }
Esempio n. 32
0
        public static void HandleTransform(NetworkMessage netMsg)
        {
            NetworkInstanceId networkInstanceId = netMsg.reader.ReadNetworkId();
            GameObject        gameObject        = NetworkServer.FindLocalObject(networkInstanceId);

            if (gameObject == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleTransform no gameObject");
                }
                return;
            }
            NetworkTransform component = gameObject.GetComponent <NetworkTransform>();

            if (component == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleTransform null target");
                }
            }
            else if (!component.localPlayerAuthority)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleTransform no localPlayerAuthority");
                }
            }
            else if (netMsg.conn.clientOwnedObjects == null)
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("HandleTransform object not owned by connection");
                }
            }
            else if (netMsg.conn.clientOwnedObjects.Contains(networkInstanceId))
            {
                switch (component.transformSyncMode)
                {
                case TransformSyncMode.SyncNone:
                    return;

                case TransformSyncMode.SyncTransform:
                    component.UnserializeModeTransform(netMsg.reader, initialState: false);
                    break;

                case TransformSyncMode.SyncRigidbody3D:
                    component.UnserializeMode3D(netMsg.reader, initialState: false);
                    break;

                case TransformSyncMode.SyncRigidbody2D:
                    component.UnserializeMode2D(netMsg.reader, initialState: false);
                    break;

                case TransformSyncMode.SyncCharacterController:
                    component.UnserializeModeCharacterController(netMsg.reader, initialState: false);
                    break;
                }
                component.m_LastClientSyncTime = Time.time;
            }
            else if (LogFilter.logWarn)
            {
                Debug.LogWarning("HandleTransform netId:" + networkInstanceId + " is not for a valid player");
            }
        }
Esempio n. 33
0
 private static void ApplySpawnPayload(NetworkIdentity uv, Vector3 position, byte[] payload, NetworkInstanceId netId, GameObject newGameObject)
 {
     uv.transform.position = position;
     if (payload != null && payload.Length > 0)
     {
         NetworkReader reader = new NetworkReader(payload);
         uv.OnUpdateVars(reader, true);
     }
     if (newGameObject == null)
     {
         return;
     }
     newGameObject.SetActive(true);
     uv.SetNetworkInstanceId(netId);
     ClientScene.SetLocalObject(netId, newGameObject);
     if (ClientScene.s_IsSpawnFinished)
     {
         uv.OnStartClient();
         ClientScene.CheckForOwner(uv);
     }
 }
Esempio n. 34
0
 internal void OnStartServer(bool allowNonZeroNetId)
 {
     if (!this.m_IsServer)
     {
         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();
         }
         else if (!allowNonZeroNetId)
         {
             if (LogFilter.logError)
             {
                 Debug.LogError(string.Concat(new object[]
                 {
                     "Object has non-zero netId ",
                     this.netId,
                     " for ",
                     base.gameObject
                 }));
             }
             return;
         }
         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();
         }
     }
 }
Esempio n. 35
0
 public void SetAttributes(int _damage, float _timer, UnityEngine.Networking.NetworkInstanceId _id)
 {
 }