private async void sendButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         var message = Message.Text;
         if (!string.IsNullOrEmpty(message))
         {
             if (int.TryParse(UserId.Text, out int userId))
             {
                 await Sending("Chat.Message", ("message", message), ("userId", userId.ToString()));
             }
             else
             {
                 await Sending("Chat.MessageToAll", ("message", message));
             }
         }
         else
         {
             MessageBox.Show("First enter access token");
         }
     }
     catch (Exception ex)
     {
         messagesList.Items.Add(ex.Message);
     }
 }
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdProduct,IdOrder,IdProvider,IdEmployee,DateDelivery,DateDeparture")] Sending sending)
        {
            if (id != sending.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sending);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SendingExists(sending.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdEmployee"] = new SelectList(_context.Employees, "Id", "Id", sending.IdEmployee);
            ViewData["IdOrder"]    = new SelectList(_context.Order, "Id", "Id", sending.IdOrder);
            ViewData["IdProduct"]  = new SelectList(_context.Products, "Id", "Id", sending.IdProduct);
            ViewData["IdProvider"] = new SelectList(_context.Providers, "Id", "Id", sending.IdProvider);
            return(View(sending));
        }
Beispiel #3
0
        /// <summary>
        /// Does the actual work of sending the <see cref="IFormattedNotificationMessage"/>
        /// </summary>
        /// <param name="message">The <see cref="IFormattedNotificationMessage"/> to be sent</param>
        public override void PerformSend(IFormattedNotificationMessage message)
        {
            if (!message.Recipients.Any())
            {
                return;
            }

            using (var msg = new MailMessage
            {
                From = new MailAddress(message.From),
                Subject = message.Name,
                Body = message.BodyText,
                IsBodyHtml = true
            })
            {
                // REFACTOR update to MultiLogHelper when we control Resolution Freeze
                LogHelper.Info <SmtpNotificationGatewayMethod>("Sending an email to " + string.Join(", ", message.Recipients));

                foreach (var to in message.Recipients)
                {
                    if (!string.IsNullOrEmpty(to))
                    {
                        msg.To.Add(new MailAddress(to));
                    }
                }

                // Event raised to allow further modification to msg (like attachments)
                Sending.RaiseEvent(new ObjectEventArgs <MailMessage>(msg), this);

                this.Send(msg);
            }
        }
Beispiel #4
0
    public static void Died(short Map_Num, byte Index)
    {
        Lists.Structures.NPCs NPC = Lists.NPC[Lists.Map[Map_Num].Temp_NPC[Index].Index];

        // Solta os itens
        for (byte i = 0; i <= Game.Max_NPC_Queda - 1; i++)
        {
            if (NPC.Queda[i].Item_Num > 0)
            {
                if (Game.Aleatório.Next(NPC.Queda[i].Chance, 101) == 100)
                {
                    // Data do item
                    Lists.Structures.Map_Items Item = new Lists.Structures.Map_Items();
                    Item.Index  = NPC.Queda[i].Item_Num;
                    Item.Amount = NPC.Queda[i].Amount;
                    Item.X      = Lists.Map[Map_Num].Temp_NPC[Index].X;
                    Item.Y      = Lists.Map[Map_Num].Temp_NPC[Index].Y;

                    // Solta
                    Lists.Map[Map_Num].Temp_Item.Add(Item);
                }
            }
        }

        // Envia os Data dos itens no chão para o mapa
        Sending.Map_Items(Map_Num);

        // Reseta os Data do NPC
        Lists.Map[Map_Num].Temp_NPC[Index].Vital[(byte)Game.Vital.Life] = 0;
        Lists.Map[Map_Num].Temp_NPC[Index].Appearance_Time = Environment.TickCount;
        Lists.Map[Map_Num].Temp_NPC[Index].Index           = 0;
        Lists.Map[Map_Num].Temp_NPC[Index].Target_Type     = 0;
        Lists.Map[Map_Num].Temp_NPC[Index].Target_Index    = 0;
        Sending.Map_NPC_Died(Map_Num, Index);
    }
Beispiel #5
0
    public static void Entrar(byte Index)
    {
        // Previni que alguém que já está online de logar
        if (IsPlaying(Index))
        {
            return;
        }

        // Defines that the player is inside the Game
        Lists.TempPlayer[Index].Playing = true;

        // Envia todos os dados necessários
        Sending.Entrada(Index);
        Sending.Players_Data_Map(Index);
        Sending.Player_Experience(Index);
        Sending.Player_Inventory(Index);
        Sending.Player_Hotbar(Index);
        Sending.Items(Index);
        Sending.NPCs(Index);
        Sending.Map_Items(Index, Character(Index).Map);

        // Transports the player to his determined position
        Transportar(Index, Character(Index).Map, Character(Index).X, Character(Index).Y);

        // Enter the Game
        Sending.Entrar(Index);
        Sending.Message(Index, Lists.Server_Data.Message, Color.Blue);
    }
    private void Window_DoubleClick(object sender, System.EventArgs e)
    {
        // Events em Jogo
        if (Tools.CurrentWindow == Tools.Windows.Jogo)
        {
            // Use item
            byte Slot = Tools.Inventory_Overlapping();
            if (Slot > 0)
            {
                if (Player.Inventory[Slot].Item_Num > 0)
                {
                    Sending.Inventory_Use(Slot);
                }
            }

            // Use o que estiver na hotbar
            Slot = Tools.Hotbar_Overlapping();
            if (Slot > 0)
            {
                if (Player.Hotbar[Slot].Slot > 0)
                {
                    Sending.Hotbar_Use(Slot);
                }
            }
        }
    }
Beispiel #7
0
        public Task Dispatch(ReactiveRequest request)
        {
            Task<HttpResponseMessage> sendTask = null;
            
            try
            {
                Sending?.Invoke(this, request);

                var httpRequest = Convert(request);
                sendTask = httpClient.SendAsync(httpRequest);
            }
            catch
            {
                //Exception?.Invoke(this, e);
                throw;
            }

            sendTask?.ContinueWith(task =>
            {
                if (task.Exception != null)
                {
                    //Exception?.Invoke(this, task.Exception);
                    throw task.Exception;
                }
                else
                {
                    var response = Convert(task.Result);
                    Receiving?.Invoke(this, response);
                }
            });

            return Task.CompletedTask;
        }
Beispiel #8
0
        public Login()
        {
            InitializeComponent();
            string fileName = @"c:\wimea\wimeas.sdf";

            if (!File.Exists(fileName))
            {
                login.Visibility  = System.Windows.Visibility.Hidden;
                cancel.Visibility = System.Windows.Visibility.Hidden;
                CreateDB();

                if (Sending.IsInternetAvailable())
                {
                    tbProgress.Content = "updating user list.---------";
                    login.Visibility   = System.Windows.Visibility.Hidden;
                    cancel.Visibility  = System.Windows.Visibility.Hidden;
                    syncs(Sending.genUrl + "user/all", "users", "center");
                    Loading_users();

                    tbProgress.Content = "user list upto date---------";
                    login.Visibility   = System.Windows.Visibility.Visible;
                    cancel.Visibility  = System.Windows.Visibility.Visible;
                }

                _UsersList = new ObservableCollection <User>(App.WimeaApp.Users);
            }
            _UsersList   = new ObservableCollection <User>(App.WimeaApp.Users);
            _stationList = new ObservableCollection <Station>(App.WimeaApp.Stations);
        }
Beispiel #9
0
    public static bool GiveItem(byte Index, short Item_Num, short Amount)
    {
        byte Slot_Item  = EncontrarInventory(Index, Item_Num);
        byte Slot_Vazio = EncontrarInventory(Index, 0);

        // Somente se necessário
        if (Item_Num == 0)
        {
            return(false);
        }
        if (Slot_Vazio == 0)
        {
            return(false);
        }
        if (Amount == 0)
        {
            Amount = 1;
        }

        // Stackable
        if (Slot_Item > 0 && Lists.Item[Item_Num].Empilhável)
        {
            Character(Index).Inventory[Slot_Item].Amount += Amount;
        }
        //Non-stackable
        else
        {
            Character(Index).Inventory[Slot_Vazio].Item_Num = Item_Num;
            Character(Index).Inventory[Slot_Vazio].Amount   = Amount;
        }

        //Sends the data to the player
        Sending.Player_Inventory(Index);
        return(true);
    }
Beispiel #10
0
    public static void SoltarItem(byte Index, byte Slot)
    {
        short Map_Num = Character(Index).Map;

        Lists.Structures.Map_Items Map_Item = new Lists.Structures.Map_Items();

        // Somente se necessário
        if (Lists.Map[Map_Num].Temp_Item.Count == Game.Max_Map_Items)
        {
            return;
        }
        if (Character(Index).Inventory[Slot].Item_Num == 0)
        {
            return;
        }
        if (Lists.Item[Character(Index).Inventory[Slot].Item_Num].NãoDropável)
        {
            return;
        }

        // Solta o item no chão
        Map_Item.Index  = Character(Index).Inventory[Slot].Item_Num;
        Map_Item.Amount = Character(Index).Inventory[Slot].Amount;
        Map_Item.X      = Character(Index).X;
        Map_Item.Y      = Character(Index).Y;
        Lists.Map[Map_Num].Temp_Item.Add(Map_Item);
        Sending.Map_Items(Map_Num);

        // Retira o item do Inventory do jogador
        Character(Index).Inventory[Slot].Item_Num = 0;
        Character(Index).Inventory[Slot].Amount   = 0;
        Sending.Player_Inventory(Index);
    }
Beispiel #11
0
    public static void CheckLevel(byte Index)
    {
        byte NumLevel = 0; short ExpSobrando;

        // Previni erros
        if (!IsPlaying(Index))
        {
            return;
        }

        while (Character(Index).Experience >= Character(Index).ExpRequired)
        {
            NumLevel   += 1;
            ExpSobrando = (short)(Character(Index).Experience - Character(Index).ExpRequired);

            // Define os dados
            Character(Index).Level     += 1;
            Character(Index).Points    += 3;
            Character(Index).Experience = ExpSobrando;
        }

        // Envia os dados
        Sending.Player_Experience(Index);
        if (NumLevel > 0)
        {
            Sending.Players_Data_Map(Index);
        }
    }
Beispiel #12
0
    // Update is called once per frame
    void Update()
    {
        var wind = gameObject.GetComponent <WindZone> ();

        if (Input.GetKey(KeyCode.L))
        {
            changeWindModeSound.Play();
            windSound.Play();
            wind.mode     = WindZoneMode.Directional;
            wind.windMain = 1.0f;
            ScoreManager.instance.total = 0;
            estadoVento = true;
            //ProjectileAddForce.instance.windvalue = 1;
            //ffs.instance.valorVento = 1;
            //ProjectileAddForce.instance.rigidbody.AddRelativeForce (Vector3.right * 250);
//			wind.transform.position= new Vector3 (357, -5, 195);
//			wind.transform.rotation= Quaternion.Euler(0,235,0);

            //ArrowWind ();
            Sending.liga();
        }
        if (Input.GetKey(KeyCode.D))
        {
            changeWindModeSound.Play();
            windSound.Stop();
            wind.mode     = WindZoneMode.Directional;
            wind.windMain = 0.0f;
            ScoreManager.instance.total = 0;
            estadoVento = false;
            //ProjectileAddForce.instance.windvalue = 0;
            //ffs.instance.valorVento = 0;
            Sending.desliga();
        }
    }
Beispiel #13
0
        public DailyPage()
        {
            InitializeComponent();
            _StationsList = new ObservableCollection <Station>(App.WimeaApp.Stations);

            stationTxtCbx.Text = Sending.currentstation;
            RefreshUserList();



            if (Sending.IsInternetAvailable())
            {
                internet.Content = "internet connection available";
                bw.RunWorkerAsync();
                bw.WorkerReportsProgress = true;
                //  bw.WorkerSupportsCancellation = true;
                bw.DoWork             += new DoWorkEventHandler(bw_DoWork);
                bw.ProgressChanged    += new ProgressChangedEventHandler(bw_ProgressChanged);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(bw_RunWorkerCompleted);
            }
            else
            {
                internet.Content = "no internet connection";
            }
        }
Beispiel #14
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            int counter             = _elementList.Count(c => c.Sync == "F" || c.Sync == "");

            List <Element> sendies = new List <Element>();

            sendies = _elementList.Where(c => c.Sync == "F" || c.Sync == "").ToList();
            string URL = Sending.genUrl + "api/tasks";

            foreach (Element row in sendies)
            {
                NameValueCollection formData = new NameValueCollection();
                formData["name"]        = row.Name;
                formData["abbrev"]      = row.Abbrev;
                formData["type"]        = row.Type;
                formData["units"]       = row.Units;
                formData["scale"]       = row.Scale;
                formData["limits"]      = row.Limits;
                formData["description"] = row.Description;
                formData["submitted"]   = row.Submitted;


                String results = Sending.send(URL, formData);
                // row.Update(row.Id, "F");
                row.Update(row.Id, results);
                Console.WriteLine(results);
                worker.ReportProgress(((counter--)));
            }


            System.Threading.Thread.Sleep(500);
        }
    public static void Inventory_MouseDown(MouseEventArgs e)
    {
        byte Slot = Inventory_Overlapping();

        // Somente se necessário
        if (Slot == 0)
        {
            return;
        }
        if (Player.Inventory[Slot].Item_Num == 0)
        {
            return;
        }

        // Solta item
        if (e.Button == MouseButtons.Right)
        {
            Sending.SoltarItem(Slot);
            return;
        }
        // Seleciona o item
        else if (e.Button == MouseButtons.Left)
        {
            Player.Inventory_Moving = Slot;
            return;
        }
    }
Beispiel #16
0
    private static void Register(byte Index, NetIncomingMessage Data)
    {
        // Lê os Data
        string User     = Data.ReadString().Trim();
        string Password = Data.ReadString();

        // Check if everything is okay
        if (User.Length < Game.Min_Character || User.Length > Game.Max_Character || Password.Length < Game.Min_Character || Password.Length > Game.Max_Character)
        {
            Sending.Alert(Index, "The User name and password must contain " + Game.Min_Character + " and " + Game.Max_Character + " characters.");
            return;
        }
        else if (File.Exists(Directories.Accounts.FullName + User + Directories.Format))
        {
            Sending.Alert(Index, "Already registered with this name.");
            return;
        }

        // Cria a conta
        Lists.Player[Index].User     = User;
        Lists.Player[Index].Password = Password;

        // Salva a conta
        Write.Player(Index);

        // Abre a janela de seleção de personagens
        Sending.Classes(Index);
        Sending.CreateCharacter(Index);
    }
Beispiel #17
0
    private static void Hotbar_Change(byte Index, NetIncomingMessage Data)
    {
        byte Slot_Antigo = Data.ReadByte(), Slot_Novo = Data.ReadByte();

        Lists.Structures.Hotbar Antigo = Player.Character(Index).Hotbar[Slot_Antigo];

        // Somente se necessário
        if (Player.Character(Index).Hotbar[Slot_Antigo].Slot == 0)
        {
            return;
        }
        if (Slot_Antigo == Slot_Novo)
        {
            return;
        }

        // Caso houver um item no novo slot, trocar ele para o velho
        if (Player.Character(Index).Hotbar[Slot_Novo].Slot > 0)
        {
            Player.Character(Index).Hotbar[Slot_Antigo].Slot = Player.Character(Index).Hotbar[Slot_Novo].Slot;
            Player.Character(Index).Hotbar[Slot_Antigo].Type = Player.Character(Index).Hotbar[Slot_Novo].Type;
        }
        else
        {
            Player.Character(Index).Hotbar[Slot_Antigo].Slot = 0;
            Player.Character(Index).Hotbar[Slot_Antigo].Type = 0;
        }

        // Muda o item de slot
        Player.Character(Index).Hotbar[Slot_Novo].Slot = Antigo.Slot;
        Player.Character(Index).Hotbar[Slot_Novo].Type = Antigo.Type;
        Sending.Player_Hotbar(Index);
    }
Beispiel #18
0
        public ClientConnectionSys(Player me, string ip, int port, string myPassword)
        {
            takenCommands = new List <Sending>();

            this.RecFunctions = new Dictionary <string, RecieveDel>();
            this.myPassword   = myPassword;

            addToEvent("byebye", discFinal);
            addToEvent("Exception", ExceptionF);
            addToEvent("okYouOnline", OkayWeConnected);
            addToEvent("message", messageShow);

            this.me = me;

            ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            ClientSocket.Connect(ip, port);

            listen = new Thread(StartListen);
            listen.IsBackground = true;
            listen.Start();

            Sending s = new Sending();

            s.data = me;
            send(s);

            proccess = new Thread(Processing);
            proccess.IsBackground = true;
            proccess.Start();
        }
    public static void Hotbar_MouseDown(MouseEventArgs e)
    {
        byte Slot = Hotbar_Overlapping();

        // Somente se necessário
        if (Slot == 0)
        {
            return;
        }
        if (Player.Hotbar[Slot].Slot == 0)
        {
            return;
        }

        // Solta item
        if (e.Button == MouseButtons.Right)
        {
            Sending.Hotbar_Add(Slot, 0, 0);
            return;
        }
        // Seleciona o item
        else if (e.Button == MouseButtons.Left)
        {
            Player.Hotbar_Moving = Slot;
            return;
        }
    }
Beispiel #20
0
 public void sendToAll(Sending command)
 {
     for (int i = 0; i < chanels.Count; i++)
     {
         send(chanels[i], command);
     }
 }
Beispiel #21
0
    public static void Logic()
    {
        for (byte i = 1; i <= Lists.Map.GetUpperBound(0); i++)
        {
            // Não é necessário fazer todos os cálculos se não houver nenhum jogador no Map
            if (!ThereIsPlayers(i))
            {
                continue;
            }

            // Lógica dos NPCs
            NPC.Logic(i);

            // Faz reaparecer todos os itens do Map
            if (Environment.TickCount > Tie.Score_Map_Items + 300000)
            {
                Lists.Map[i].Temp_Item = new System.Collections.Generic.List <Lists.Structures.Map_Items>();
                Appearance_Items(i);
                Sending.Map_Items(i);
            }
        }

        // Reseta as contagens
        if (Environment.TickCount > Tie.Score_NPC_Reneration + 5000)
        {
            Tie.Score_NPC_Reneration = Environment.TickCount;
        }
        if (Environment.TickCount > Tie.Score_Map_Items + 300000)
        {
            Tie.Score_Map_Items = Environment.TickCount;
        }
    }
Beispiel #22
0
        void RecieveCallback(IAsyncResult result)
        {
            Chanel connection = (Chanel)result.AsyncState;

            if (chanels.Contains(connection))
            {
                //try
                //{
                connection.socket.EndReceive(result);

                Sending a = sendDecode(connection);

                if (a.name != string.Empty && Passwords.ContainsKey(a.name) && Passwords[a.name] == a.password)
                {
                    forceCallEvent(a.operation, a.data);
                }
                else
                {
                    Console.WriteLine("Хм, нам пытаются послать комманду с не корректным паролем. Казнить еретика?");
                }

                connection.socket.BeginReceive(connection.buffer, 0, Sending.SizeOfMessage, SocketFlags.None, new AsyncCallback(RecieveCallback), connection);
                //}

                //catch (Exception ex)
                //{
                //    Console.WriteLine(ex.Message);
                //    removeChanel(connection.who);
                //}
            }
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;
            int counter             = _instrumentList.Count(c => c.Sync == "F" || c.Sync == "");

            List <Instrument> sendies = new List <Instrument>();

            sendies = _instrumentList.Where(c => c.Sync == "F" || c.Sync == "").ToList();
            string URL = Sending.genUrl + "api/tasks";

            foreach (Instrument row in sendies)
            {
                NameValueCollection formData = new NameValueCollection();
                formData["name"]         = row.Name;
                formData["element"]      = row.Element;
                formData["station"]      = row.Station;
                formData["dateRegister"] = row.DateRegister;
                formData["dateExpire"]   = row.DateExpire;
                formData["code"]         = row.Code;
                formData["manufacturer"] = row.Manufacturer;
                formData["description"]  = row.Description;
                formData["submitted"]    = row.Submitted;


                String results = Sending.send(URL, formData);
                // row.Update(row.Id, "F");
                row.Update(row.Id, results);
                Console.WriteLine(results);
                worker.ReportProgress(((counter--)));
            }


            System.Threading.Thread.Sleep(500);
        }
Beispiel #24
0
    // Update is called once per frame
    void Update()
    {
        float a = Mathf.Round(transform.position.x * 1000.0f) / 1000.0f;
        float b = Mathf.Round((transform.position.y - 0.251f) * 1000.0f) / 1000.0f;
        float c = Mathf.Round(transform.position.z * 1000.0f) / 1000.0f;

        Sending.sendXYZ(a, b, c);
    }
Beispiel #25
0
    void Start()
    {
        mainCamera   = Camera.main;
        camTransform = mainCamera.transform;
        mainCamera.gameObject.AddComponent <PhysicsRaycaster>();

        sending = GetComponent <Sending>();
    }
Beispiel #26
0
        private void Refresh_Click(object sender, RoutedEventArgs e)
        {
            if (Sending.IsInternetAvailable())
            {
                string urls = "";

                try
                {
                    if (stationTxtCbx.Text != "")
                    {
                        if (dailyChk.IsChecked == true)
                        {
                            urls = Sending.genUrl + "api/tasks/station/" + stationTxtCbx.Text + "/format/json";
                            syncs(urls, "daily");
                            validate("daily");
                        }

                        if (metarChk.IsChecked == true)
                        {
                            urls = Sending.genUrl + "apimetar/metar/station/" + stationTxtCbx.Text + "/format/json";
                            syncs(urls, "metar");
                            validate("metar");
                        }
                        if (synopticChk.IsChecked == true)
                        {
                            urls = Sending.genUrl + "apisynoptic/synoptic/station/" + stationTxtCbx.Text + "/format/json";
                            syncs(urls, "synoptic");
                            validate("synoptic");
                        }
                        if (rainChk.IsChecked == true)
                        {
                            urls = Sending.genUrl + "api/tasks/station/" + stationTxtCbx.Text + "/format/json";
                            syncs(urls, "rain");
                        }
                        if (stationChk.IsChecked == true)
                        {
                            urls = Sending.genUrl + "api/tasks/station/" + stationTxtCbx.Text + "/format/json";
                            syncs(urls, "station");
                        }
                        RefreshStationList();
                    }
                    else
                    {
                        MessageBox.Show("Please select a station");
                    }
                }
                catch
                {
                    MessageBox.Show("no data for specified station");
                }
            }
            else
            {
                internet.Content = "no internet connection";
                MessageBox.Show("no internet connection");
            }
        }
Beispiel #27
0
    public static void Leave(byte Index)
    {
        // Salva os dados do jogador
        Write.Player(Index);
        Clean.Player(Index);

        // Sends everyone the player disconnect
        Sending.Player_Exited(Index);
    }
Beispiel #28
0
        public void send(Player who, Sending command)
        {
            Chanel chan = chanels.Where(c => c.who == who).FirstOrDefault();

            if (chan != null)
            {
                send(chan, command);
            }
        }
Beispiel #29
0
    public static void Attack_Player(byte Index, byte Victim)
    {
        short Dano;
        short x = Character(Index).X, y = Character(Index).Y;

        // Define o azujelo a frente do jogador
        Map.NextTile(Character(Index).Direction, ref x, ref y);

        // Verifica se a Victim pode ser atacada
        if (!IsPlaying(Victim))
        {
            return;
        }
        if (Lists.TempPlayer[Victim].GettingMap)
        {
            return;
        }
        if (Character(Index).Map != Character(Victim).Map)
        {
            return;
        }
        if (Character(Victim).X != x || Character(Victim).Y != y)
        {
            return;
        }
        if (Lists.Map[Character(Index).Map].Moral == (byte)Map.Morais.Pacific)
        {
            Sending.Message(Index, "This is a peaceful area.", Color.White);
            return;
        }

        // Demonstra o ataque aos outros jogadores
        Sending.Player_Attack(Index, Victim, (byte)Game.Target.Player);

        // Tempo de ataque
        Character(Index).Attack_Time = Environment.TickCount;

        // Cálculo de dano
        Dano = (short)(Character(Index).Damage - Character(Victim).Player_Defense);

        // Dano não fatal
        if (Dano <= Character(Victim).MaxVital((byte)Game.Vital.Life))
        {
            Character(Victim).Vital[(byte)Game.Vital.Life] -= Dano;
            Sending.Player_Vital(Victim);
        }
        // FATALITY
        else
        {
            // Dá 10% da experiência da Victim ao atacante
            Character(Index).Experience += (short)(Character(Victim).Experience / 10);

            // Mata a Victim
            Died(Victim);
        }
    }
Beispiel #30
0
        public void send(Sending x)
        {
            x.name     = me.name;
            x.password = myPassword;

            MemoryStream data = new MemoryStream();

            binFormat.Serialize(data, x);
            ClientSocket.Send(data.GetBuffer());
        }
Beispiel #31
0
 private void SendingToggle(bool stop=false)
 {
     if (sending == Sending.Run || stop==true)
     {
         startToolStripMenuItemStartStop.Text = "Start";
         startToolStripMenuItemStartStop.Image = Properties.Resources.start;
         toolStripButtonStart.Text = "Start";
         toolStripButtonStart.Image = Properties.Resources.start;
         timerSender.Stop();
         toolStripStatusLabelStatus.Image = Properties.Resources.offline;
         sending = Sending.Stopped;
     }
     else if (sending == Sending.Stopped)
     {
         startToolStripMenuItemStartStop.Text = "Stop";
         startToolStripMenuItemStartStop.Image = Properties.Resources.stop;
         toolStripButtonStart.Text = "Stop";
         toolStripButtonStart.Image = Properties.Resources.stop;
         timerSender.Start();
         toolStripStatusLabelStatus.Image = Properties.Resources.online;
         sending = Sending.Run;
     }
 }
        public static void PacketHandler1(Packet packet)
        {
            byte[] packet_bytes = new byte[packet.Length];
            packet_bytes = packet.Buffer;
            packet_string = BitConverter.ToString(packet_bytes);
            string[] asdasd = packet_string.Split('-');
            packet_string = string.Join("", asdasd);
            String text = "\r\n" + packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") + " length:" + packet.Length + "\r\n" + "\r\n" + packet_string + "\r\n";

            get_Info.find_data(packet_string, d1_index, mac_table, dataGridView1);

            if (!get_Info.Filtration.filtration(get_Info, filters_class, d1_index, "in", get_Info.Find_value))
            {
                string smac2 = get_Info.SourceMAC2;
                string dmac2 = get_Info.DestinationMAC2;
                string smac = get_Info.SourceMAC;
                bool print = true;
                foreach (var item in get_Info.SwitchMAC) // kontrola ci ramec nepatri switch-u
                {
                    if (smac2 == item || dmac2 == item)
                    {
                        print = false;
                        break;
                    }
                }
                if (print)
                {
                    richTextBox1.BeginInvoke(new Action(() => richTextBox1.SelectionColor = Color.Red));
                    richTextBox1.BeginInvoke(new Action(() => richTextBox1.AppendText("Zablokované z: " + smac + "\n")));
                }
                    return;
            }
            get_Info.fill_mac_table_dict();
            get_Info.get_statistics(packet_string, statistics_d1_I);
            dataGridView2.BeginInvoke(new Action(() => dataGridView2.DataSource = statistics_table.fill_statistics_table(statistics_d1_I, statistics_d1_O, statistics_d2_I, statistics_d2_O)));

            int PnumberSend;
            if (get_Info.Mac_table.ContainsKey(get_Info.DestinationMAC)){
                if(get_Info.Mac_table[get_Info.DestinationMAC].Item2 == d1_index)
                {
                    return;
                }
                PnumberSend = get_Info.Mac_table[get_Info.DestinationMAC].Item2; //cislo portu na ktorz sa ma paket odoslat
            }
            else
            {
                PnumberSend = d2_index;
            }

            if (!get_Info.Filtration.filtration(get_Info, filters_class, PnumberSend, "out", get_Info.Find_value)) // kontrola filtrov
            {
                bool print = true;
                foreach (var item in get_Info.SwitchMAC) // kontrola ci ramec nepatri switch-u
                {
                    if (get_Info.SourceMAC2 == item || get_Info.DestinationMAC2 == item)
                    {
                        print = false;
                        break;
                    }
                }
                if (print)
                {
                    richTextBox1.BeginInvoke(new Action(() => richTextBox1.SelectionColor = Color.Red));
                    richTextBox1.BeginInvoke(new Action(() => richTextBox1.AppendText("Zablokované na: " + get_Info.SourceMAC + "\n")));
                }
                return;
            }
            Sending s = new Sending(packet, device2);
            get_Info.get_statistics(packet_string, statistics_d2_O);
            s.send(communicator2);

            richTextBox1.BeginInvoke(new Action(() => richTextBox1.AppendText(text)));
            dataGridView2.BeginInvoke(new Action(() => dataGridView2.DataSource = statistics_table.fill_statistics_table(statistics_d1_I, statistics_d1_O, statistics_d2_I, statistics_d2_O)));
        }
Beispiel #33
0
 public Main()
 {
     InitializeComponent();
     LoadCreditials();
     if (Properties.Settings.Default.mode == "standard")
     {
         mode = Mode.Standard;
     }
     else if (Properties.Settings.Default.mode == "expert")
     {
         mode = Mode.Expert;
     }
     mutex = new Mutex(true, Application.ProductName, out is_single_instance);   //Create Mutex
     if (!is_single_instance)    //If second instance of application is running
     {
         this.Close();   //Close current application
         return;
     }
     this.Hide();    //Hide window
     cpu = new PerformanceCounter(); //Create CPU usage counter object
     ram = new PerformanceCounter(); //Create RAM usage counter object
     harddisk_read = new PerformanceCounter();   //Create harddisk read usage counter object
     harddisk_write = new PerformanceCounter();  //Create harddisk write usage couter object
     network_interface = new PerformanceCounterCategory("Network Interface");    //Create network interface
     network_instances = network_interface.GetInstanceNames();   //Get all instances from network interface
     network_download = new PerformanceCounter[network_instances.Length];    //Get number of all network instances (download)
     server_uptime = new PerformanceCounter();
     for (int instance = 0; instance < network_download.Length; instance++)  //For all network instances (download)
     {
         network_download[instance] = new PerformanceCounter();  //Add network instance (download) to an array
     }
     network_upload = new PerformanceCounter[network_instances.Length];  //Get number of all network instances (upload)
     for (int instance = 0; instance < network_upload.Length; instance++)  //For all network instances (upload)
     {
         network_upload[instance] = new PerformanceCounter(); //Add network instance (upload) to an array
     }
     harddisk_read.CategoryName = "PhysicalDisk";  //Get Harddisk counter category
     harddisk_read.CounterName = "Disk Read Bytes/sec";  //Get Harddisk counter name
     harddisk_read.InstanceName = "_Total"; //Get Harddisk counter instance name
     if (login_showed == false)  //If login dialog was not showed
     {
         //If values in registry is null or values are default
         if (server_petname == null || contact_email == null || secret_key == null || server_petname == "server_petname" || contact_email == "*****@*****.**" || secret_key == "secret_key")
         {
             Form login = new Settings();   //Create form Login
             login.ShowDialog(); //Show login
         }
         login_showed = true;    //Set Login dialog was showed
     }
     if(login_showed==true)
     {
         timerSender.Start(); //Start timer update
     }
     hostname = Dns.GetHostName();
     ip_host_entry = Dns.GetHostEntry(hostname);
     ip_addresses = ip_host_entry.AddressList;
     startToolStripMenuItemStartStop.Text = "Stop";
     startToolStripMenuItemStartStop.Image = Properties.Resources.stop;
     sending = Sending.Run;
     updater = Process.GetProcessesByName("Cloudiff updater");
     if (updater.Length != 0)
     {
         foreach (Process process in updater)
         {
             process.Kill();
         }
     }
     if (Environment.Is64BitOperatingSystem)
     {
         operation_system_32_64bit = "64bit";
     }
     else
     {
         operation_system_32_64bit = "32bit";
     }
     cpu_cores = Environment.ProcessorCount;
     RegistryKey cpu_32_64bit_key = Registry.LocalMachine.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
     if (cpu_32_64bit_key.GetValue("Identifier").ToString().IndexOf("64") > 0)
     {
         cpu_32_64bit = "64bit";
     }
     else
     {
         cpu_32_64bit = "32bit";
     }
     cpu_architecture = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
     power = SystemInformation.PowerStatus;
     power_line_status = power.PowerLineStatus;
 }