Esempio n. 1
0
    public void Delete(int tabIndex)
    {
        if (!this.PreCheck())
        {
            return;
        }
        MonoBehaviour.print("Deleted " + tabIndex);
        if (this.Deleting)
        {
            MsgController.ShowMsg(SFST.T.Sharing_Wait_Request);
            return;
        }
        this.Deleting = true;
        DeletePacket toSend = new DeletePacket
        {
            Target = this.pagesIDS[tabIndex]
        };

        GameTracker.Tracker.client.AuthedRequest(toSend, delegate(DefaultPacket r)
        {
            SyncContext.RunOnUI(delegate
            {
                if (r.Success)
                {
                    MsgController.ShowMsg("Rocket deleted");
                    this.ReloadPage(null);
                }
                else
                {
                    MsgController.ShowMsg("Could not delete rocket because:\n" + r.Error);
                }
                this.Deleting = false;
            });
        });
    }
Esempio n. 2
0
    public void DeleteNetworkedObject(int obj_net_id)
    {
        DeletePacket packet = new DeletePacket("D_Delete");

        packet.item_net_id = obj_net_id;

        clientNetworker.SendPacketToServer(packet);
    }
Esempio n. 3
0
    public override void Update()
    {
        base.Update();


        if (isServer)
        {
            if (health <= 0)
            {
                DeletePacket packet = new DeletePacket("D_Delete");
                packet.item_net_id = GetComponent <ScapeNet_Network_ID>().object_id;

                server.SendPacketToAll(packet);
                Destroy(gameObject);
            }
        }
    }
Esempio n. 4
0
        private void AddDefaultPacketReceives()
        {
            Packet_Register.Instance.serverPacketReceivedRegister.Add("D_Connection", packetObj =>
            {
                ConnectionPacket connectionPacket = (ConnectionPacket)packetObj[0];
                NetConnection senderConnection    = (NetConnection)packetObj[2];

                //Register Player
                int newID = GetNextPlayerID();
                playersConnection.Add(senderConnection, newID);
                players.Add(newID, senderConnection);
                connectionPacket.player_id = newID;

                SendPacketToExistingConnection(connectionPacket, senderConnection, -1);

                return(false);
            });

            Packet_Register.Instance.serverPacketReceivedRegister.Add("D_OnConnect", packetObj =>
            {
                OnConnectPacket instantiate = (OnConnectPacket)packetObj[0];
                int playerId       = (int)packetObj[1];
                NetConnection conn = (NetConnection)packetObj[2];


                foreach (PacketWithId <InstantiationPacket> ip in registers)
                {
                    SendPacketToExistingConnection(ip.packet, conn, ip.playerId);
                }

                if (funcOnNewConnection != null)
                {
                    funcOnNewConnection.Invoke(packetObj);
                }

                return(false);
            });


            Packet_Register.Instance.serverPacketReceivedRegister.Add("D_Instantiate", packetObj =>
            {
                InstantiationPacket instantiate = (InstantiationPacket)packetObj[0];
                int playerId = (int)packetObj[1];

                instantiate.item_net_id = GetNextItemID();
                registers.Add(new PacketWithId <InstantiationPacket>(instantiate, playerId));

                SendPacketToAll(instantiate, playerId);

                return(false);
            });

            Packet_Register.Instance.serverPacketReceivedRegister.Add("D_Delete", packetObj =>
            {
                DeletePacket instantiate = (DeletePacket)packetObj[0];
                int playerId             = (int)packetObj[1];
                NetConnection conn       = (NetConnection)packetObj[2];

                int idToRemove = -1;

                for (int i = 0; i < registers.Count; i++)
                {
                    //Found packet we need to delete
                    if (registers[i].packet.item_net_id == instantiate.item_net_id)
                    {
                        idToRemove = i;
                        break;
                    }
                }

                registers.RemoveAt(idToRemove);
                SendPacketToAll(instantiate, playerId);
                return(false);
            });

            Packet_Register.Instance.serverPacketReceivedRegister.Add("D_PositionRotation", packetObj =>
            {
                PositionRotation packet = (PositionRotation)packetObj[0];
                int playerId            = (int)packetObj[1];
                NetConnection conn      = (NetConnection)packetObj[2];

                SendPacketToAll(packet, playerId);
                return(false);
            });
        }