Esempio n. 1
0
        public void TestHostInfo()
        {
            IWhoIs whoIs = new WhoIs();
            var    resp  = whoIs.GetHostInfo("google.com").Result;

            Assert.IsTrue(resp.Length > 0);
        }
Esempio n. 2
0
        /// <summary>
        /// Метод вызывается для каждой стороны для каждой декорации.
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="s"></param>
        /// <param name="who"></param>
        /// <remarks></remarks>
        public void Update(int x, int y, Side s, WhoIs who)
        {
            //DONE: обновление источников четырех сторон. то есть сюда приходит запрос из источника, и происходит
            //обновление нужной стороны под нужный источник события.

            //сделана зависимость для отмены рисования
            if (GameController.board[x, y].m_Current is Ground)
            {
                return;
            }
            if (GameController.board[x, y].m_Current is Beton)
            {
                return;
            }
            //DONE: сделать зависимость декорации от земли где она применяется. для камня это свои картинки, для песка свои. сча любой тип это песок.
            //DONE: сделать зависимость декорации от бомбы.
            if (GameController.board[x, y].m_Current is Rock)
            {
                CurrentType = DecalType.Rock;
                PrepareSources(who, s);
            }
            if (GameController.board[x, y].m_Current is Sand)
            {
                CurrentType = DecalType.Sand;
                PrepareSources(who, s);
            }


            //UpdateSide(s, x, y)
        }
Esempio n. 3
0
        private void LookObserver_SetDirty(IObserver observer, Action <IObserver> callback)
        {
            WhoIs whois = new WhoIs(WhoIsOption.Stat | WhoIsOption.Costume);

            whois.OnComplete += delegate(Operation op)
            {
                observer.Cache = whois;
                this.Look      = whois.Summary;
                if (this.Client != null)
                {
                    if (!this.lookUpdated && this.ChannelJoined != null)
                    {
                        this.Client.Enter(this.ChannelJoined.Channel, this.InitialPartitionID, this.InitialAction, this.Look);
                        this.lookUpdated = true;
                    }
                    else if (this.Client.Player != null)
                    {
                        this.Client.Player.UpdateLook(this.Look);
                    }
                }
                observer.EndSync(true);
                callback(observer);
            };
            whois.OnFail += delegate(Operation op)
            {
                observer.EndSync(false);
                callback(observer);
            };
            observer.Connection.RequestOperation(whois);
        }
Esempio n. 4
0
        /// <summary>
        /// Interprets the received NetworkCommand message.
        /// </summary>
        /// <param name="data">Deserialized NetworkCommand message.</param>
        /// <param name="id">ClientID of client sending message.</param>
        public void ReceiveSimMessage(string data, int id)
        {
            TcpClient        client = list_clients[id];
            MessageInterface mi     = JsonConvert.DeserializeObject <MessageInterface>(data);

            switch (mi.Type)
            {
            case "AuthRequest":
                // Request connection to server
                break;

            case "WhoIs":
                WhoIs wi = (WhoIs)mi;
                if (connected_clients.ContainsKey(wi.MACAddress))
                {
                    connected_clients.Remove(wi.MACAddress);
                }
                connected_clients.Add(wi.MACAddress, new ClientConnections(wi.IPAddress, wi.MACAddress, id));
                Thread stillAliveThread = new Thread(() => StillAlive(client, wi.MACAddress));
                stillAliveThread.Start();
                break;

            case "KillKey":
                KillKey k = (KillKey)mi;
                OnClientConnect(new ClientConnectEventArgs(2, k.IPAddress, k.MACAddress));
                ClientDisconnects(connected_clients[k.MACAddress].DictionaryID, k.MACAddress);
                break;

            default:
                CmdAdmin.ReceiveCommand(mi);
                break;
            }

            /*NetworkCommand nc = JsonConvert.DeserializeObject<NetworkCommand>(data);
             * switch (nc.Type)
             * {
             *  case NetworkCommand.CommandTypes.AuthRequest:
             *      // Request connection to the server
             *      break;
             *  case NetworkCommand.CommandTypes.WhoIs:
             *      if (connected_clients.ContainsKey(nc.MacAddress))
             *      {
             *          connected_clients.Remove(nc.MacAddress);
             *      }
             *      connected_clients.Add(nc.MacAddress, new ClientConnections(nc.IpAddress, nc.MacAddress, id));
             *      Thread stillAliveThread = new Thread(() => StillAlive(client, nc.MacAddress));
             *      stillAliveThread.Start();
             *      break;
             *  case NetworkCommand.CommandTypes.KillKey:
             *      OnClientConnect(new ClientConnectEventArgs(2, "", nc.MacAddress));
             *      ClientDisconnects(connected_clients[nc.MacAddress].DictionaryID, nc.MacAddress);
             *      break;
             *  default:
             *      CmdAdmin.ReceiveCommand(nc);
             *      break;
             * }*/
        }
Esempio n. 5
0
        public void ReceivedWhoIs(BacNetRawMessage msg)
        {
            WhoIs apdu  = new WhoIs(msg.Apdu);
            uint  devId = BacNetDevice.Instance.DeviceId;

            if ((apdu.LowLimit != null && apdu.HighLimit != null && apdu.LowLimit.Value < devId && apdu.HighLimit.Value > devId) || (apdu.LowLimit == null || apdu.HighLimit == null))
            {
                BacNetDevice.Instance.Services.Unconfirmed.IAm();
            }
        }
Esempio n. 6
0
 public Bullet(Vector2f startPosition, float angleParent, Texture textureBullet, WhoIs isShut)
 {
     WhoIs     = isShut;
     Direction = new Vector2f((float)Math.Cos(angleParent / 180 * 3.14159), (float)Math.Sin(angleParent / 180 * 3.14159));
     Sprite    = new Sprite(textureBullet, new IntRect(0, 0, 22, 22))
     {
         Origin   = new Vector2f(11, 11),
         Position = new Vector2f(startPosition.X + Direction.X * 110, startPosition.Y + Direction.Y * 110),
         Rotation = angleParent
     };
 }
Esempio n. 7
0
 public void Remove(int x, int y, Side s, WhoIs who)
 {
     //DONE: удаляет с канваса все images.     Вызывается когда какой то объект разрушен.
     GameObject.Destroy(LeftImage);
     GameObject.Destroy(RightImage);
     GameObject.Destroy(UpImage);
     GameObject.Destroy(DownImage);
     //PoleG.Children.Remove(DownImage);
     //PoleG.Children.Remove(LeftImage);
     //PoleG.Children.Remove(RightImage);
     //PoleG.Children.Remove(UpImage);
     return;
 }
Esempio n. 8
0
 private void RemoveDecalSub(int x1, int y1, Side s, WhoIs w)
 {
     if (x1 >= GameController.MinXInt & y1 >= GameController.MinYInt & x1 <= GameController.MaxXInt & y1 <= GameController.MaxYInt)
     {
         if ((GameController.DecalLayer[x1, y1] == null))
         {
         }
         else
         {
             ((IDecal)GameController.DecalLayer[x1, y1]).Remove(x1, y1, s, w);
             GameController.DecalLayer[x1, y1] = null;
         }
     }
 }
Esempio n. 9
0
        private void UpdateDecalSub(int x1, int y1, Side s, WhoIs w)
        {
            bool f = false;

            //DONE: сделать декорацию для бомб. декорация для бомб сделана только для случаев, когда не происходит разрушения. то есть для начальных случаев.
            //например: когда рядом целый песок или целая скала. если при врзрыве скала меняет состояние, то декорация будет под ней. так как понятно почему.
            //adddamage у объекта бомбы, происходит для всех участвков под бомбой. это происходит слева направ сверх вниз. и так как я тестировал , когда скала разрушалась
            //снизу, то разрушение затирало декорацию.

            if (x1 >= GameController.MinXInt & y1 >= GameController.MinYInt & x1 < GameController.MaxXInt & y1 < GameController.MaxYInt)
            {
                if ((GameController.DecalLayer[x1, y1] == null))
                {
                    if ((GameController.board[x1, y1] == null))
                    {
                        return;
                    }

                    if (GameController.board[x1, y1].Current is Rock)
                    {
                        GameController.DecalLayer[x1, y1] = new SandDecal(x1, y1);
                        f = true;
                    }
                    if (GameController.board[x1, y1].Current is Sand)
                    {
                        GameController.DecalLayer[x1, y1] = new SandDecal(x1, y1);
                        f = true;
                    }
                    if (!f)
                    {
                        return;
                    }
                }

                if (GameController.board[x1, y1].Current is Rock)
                {
                    f = true;
                }

                if (GameController.board[x1, y1].Current is Sand)
                {
                    f = true;
                }
                ((IDecal)GameController.DecalLayer[x1, y1]).Update(x1, y1, s, w);
            }
        }
Esempio n. 10
0
        /////////////////////////////////////////////////////////////////////
        ///  Client System
        /////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Connects this client to the server detected from the beacon listener.
        /// </summary>
        /// /// <param name="ipInput">IP address of the server retrieved from the beacon listener.</param>
        private void ConnectToServer(string ipInput)
        {
            try
            {
                IPAddress ip = IPAddress.Parse(ipInput);
                tcpConn = new TcpClient();
                tcpConn.Connect(ip, commPort);

                clientNS     = tcpConn.GetStream();
                clientThread = new Thread(o => ReceiveData((TcpClient)o));
                clientThread.Start();
                hasConnection = true;
                clientMAC     = GetMACAddress();
                //string establishConnMsg = commands[1] + "~" + GetInternalIP() + "~" + clientMAC;
                WhoIs wi = new WhoIs(clientMAC, GetInternalIP());
                //NetworkCommand nc = new NetworkCommand(NetworkCommand.CommandTypes.WhoIs, "", "");
                //nc.MacAddress = clientMAC;
                //nc.IpAddress = GetInternalIP();
                //byte[] buffer = Encoding.ASCII.GetBytes(establishConnMsg);
                //byte[] buffer = Encoding.ASCII.GetBytes(nc.ToJson());
                byte[] buffer = Encoding.ASCII.GetBytes(wi.ToJson());
                clientNS.Write(buffer, 0, buffer.Length);
                EntryOutput("Connected to the console.");
                OnConnectionEstablished(new ConnectionEstablishedArgs(true));
                if (beaconSearch != null)
                {
                    beaconSearch.Abort();
                }
            }
            catch (SocketException e)
            {
                tcpConn = null;
                if (clientThread != null)
                {
                    clientThread.Abort();
                }
                EntryOutput("Connection failed. Unable to connect to IP " + ipInput + ".");
                Console.WriteLine(e.StackTrace);
            }
        }
Esempio n. 11
0
 public WhoIsReceivedEventArgs(WhoIs whoIsResponse)
 {
     WhoIsResponse = whoIsResponse;
 }
Esempio n. 12
0
        public void PrepareSources(WhoIs w, Side s)
        {
            if (CurrentType == DecalType.Rock && w == WhoIs.Ground)
            {
                Vector3 v3 = new Vector3();
                switch (s)
                {
                //x и -y указывают на ячейку Sand левый верхний угол
                case Side.Down:

                    //rght h=hor t=top

                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    DownImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    DownImage.name = x + "_" + y + "DecalDownImage_";
                    DownImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[29];
                    DownImage.GetComponent <SpriteRenderer>().sortingOrder = 1;

                    break;

                case Side.Left:
                    //rgvl v=vert l=left
                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    LeftImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    LeftImage.name = x + "_" + y + "DecalLeftImage_";

                    LeftImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[37];
                    LeftImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Right:
                    //rgvr
                    v3.x            = (float)x / 10 + 0.06f;
                    v3.y            = (float)-y / 10;
                    v3.z            = 0;
                    RightImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    RightImage.name = x + "_" + y + "DecalRightImage_";
                    RightImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[28];
                    RightImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Up:
                    //rghd
                    v3.x         = (float)x / 10;
                    v3.y         = (float)-y / 10 - 0.07f;
                    v3.z         = 0;
                    UpImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    UpImage.name = x + "_" + y + "DecalUpImage_";
                    UpImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[34];
                    UpImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;
                }
            }
            if (CurrentType == DecalType.Sand && w == WhoIs.Ground)
            {
                Vector3 v3 = new Vector3();
                switch (s)
                {
                //x и -y указывают на ячейку Sand левый верхний угол
                case Side.Down:

                    //gght h=hor t=top

                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    DownImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    DownImage.name = x + "_" + y + "DecalDownImage_";
                    DownImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[36];
                    DownImage.GetComponent <SpriteRenderer>().sortingOrder = 1;

                    break;

                case Side.Left:
                    //ggvl v=vert l=left
                    v3.x           = (float)x / 10;
                    v3.y           = (float)-y / 10;
                    v3.z           = 0;
                    LeftImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    LeftImage.name = x + "_" + y + "DecalLeftImage_";

                    LeftImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[35];
                    LeftImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Right:
                    //ggvr
                    v3.x            = (float)x / 10 + 0.06f;
                    v3.y            = (float)-y / 10;
                    v3.z            = 0;
                    RightImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    RightImage.name = x + "_" + y + "DecalRightImage_";
                    RightImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[25];
                    RightImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;

                case Side.Up:
                    //gghd
                    v3.x         = (float)x / 10;
                    v3.y         = (float)-y / 10 - 0.07f;
                    v3.z         = 0;
                    UpImage      = (GameObject)MonoBehaviour.Instantiate(prefab, v3, Quaternion.identity);
                    UpImage.name = x + "_" + y + "DecalUpImage_";
                    UpImage.GetComponent <SpriteRenderer>().sprite       = StaticSpriteCache.sprites[26];
                    UpImage.GetComponent <SpriteRenderer>().sortingOrder = 1;
                    break;
                }
            }
            //switch (CurrentType)
            //{
            //    case DecalType.Rock & w == WhoIs.Bomb:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(18, 4);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(18, 5);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(18, 6);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(18, 3);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesRockBlack()
            //    case DecalType.Sand && w == WhoIs.Bomb:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(18, 2);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 10);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(18, 1);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 9);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesSandBlack()
            //    case DecalType.Rock & w == WhoIs.Ground:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(17, 5);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 6);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(17, 7);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 4);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesRock()
            //    case DecalType.Sand & w == WhoIs.Ground:
            //        switch (s)
            //        {
            //            case Side.Down:
            //                DownImage.Source = ResCache.Brick(17, 3);
            //                break;
            //            case Side.Left:
            //                LeftImage.Source = ResCache.Brick(17, 1);
            //                break;
            //            case Side.Right:
            //                RightImage.Source = ResCache.Brick(17, 2);
            //                break;
            //            case Side.Up:
            //                UpImage.Source = ResCache.Brick(17, 0);
            //                break;
            //        }
            //        break;
            //    //SetUpImagesSand()
            //}
        }
Esempio n. 13
0
        public void WhoIs_GetData()
        {
            WhoIs who = new WhoIs(new MarketShareDataSource());

            who.GetData(who.Context);
        }
Esempio n. 14
0
        //public void Update2(GameObject go)
        //{

        //    go.GetComponent<SpriteRenderer>().sprite = m_Current.Base;
        //}
        public void PreUpdateDecals(WhoIs w)
        {
            Who = w;
            UpdateDecals();
        }
Esempio n. 15
0
 internal WhoIsReceivedEventArgs(WhoIs whoIsResponse)
 {
     WhoIsResponse = whoIsResponse;
 }
Esempio n. 16
0
 public void DoIncrementDamage(int elapsedTime, int damage)
 {
     Who = WhoIs.Ground;
     DoDamage(0, damage);
 }
Esempio n. 17
0
 internal WhoIsReceivedEventArgs(WhoIs whoIsResponse)
 {
     WhoIsResponse = whoIsResponse;
 }
Esempio n. 18
0
 public WhoIsReceivedEventArgs(WhoIs whoIsResponse)
 {
     WhoIsResponse = whoIsResponse;
 }