Exemplo n.º 1
0
        public void NetSpawn()
        {
            if (!JNet.IsServer)
            {
                Debug.LogError("Cannot network spawn auto destroy effect when not on server.");
                return;
            }

            ushort  id  = NetSpawnID;
            Vector2 pos = transform.position;

            var msg = JNet.CreateCustomMessage(true, CustomMsg.AUTO_DESTROY_SPAWN, 14);

            msg.Write(id);
            msg.Write(pos);
            JNet.SendCustomMessageToAll(JNet.GetServer().LocalClientConnection, msg, Lidgren.Network.NetDeliveryMethod.Unreliable, 0);
        }
Exemplo n.º 2
0
        // SPAWNING & NETWORKING

        public static Projectile Spawn(Vector2 position, Vector2 direction, float speed)
        {
            if (!JNet.IsServer)
            {
                Debug.LogError("Cannot spawn projectile when not on server.");
                return(null);
            }

            int seed    = Random.Range(0, int.MaxValue);
            var spawned = SpawnLocal(position, direction, speed, seed);

            var msg = JNet.CreateCustomMessage(true, CustomMsg.PROJECTILE_SPAWN, 32);

            msg.Write(position);
            msg.Write(direction);
            msg.Write(speed);
            msg.Write(spawned.Seed);
            JNet.SendCustomMessageToAll(JNet.GetServer().LocalClientConnection, msg, Lidgren.Network.NetDeliveryMethod.ReliableUnordered, 0);

            return(spawned);
        }