コード例 #1
0
        static void Main(string[] args)
        {
            string s = JsonConvert.SerializeObject(new List <Object> ()
            {
                new Vector2()
                {
                    X = 1
                }, new Vector2(), 5, new Vector2[] { new Vector2()
                                                     {
                                                         X = 6
                                                     } }
            });
            var val = JsonConvert.DeserializeObject <List <Object> >(s);

            TCPHelper.Initialize(5000);
            Console.WriteLine("Enter blbl to exit, or type a command.");
            State state = new State();

            Console.WriteLine(state.SetShipPosition(0, new Vector2()
            {
                X = 5, Y = 3
            }));
            Console.WriteLine(state.GetShipPosition(0));
            Console.WriteLine(state.SetShipPosition(0, new Vector2()
            {
                X = 2, Y = 8
            }));
            Console.WriteLine(state.GetShipPosition(0));

            /*while(true)
             * {
             *  Console.Write("Clank.Client #> ");
             *  string cmd = Console.ReadLine();
             *  if (cmd == "blbl")
             *      break;
             *  TCPHelper.Send(cmd);
             *  Console.WriteLine("[Debug] Sent bytes.");
             *  string resp = TCPHelper.Receive();
             *  Console.WriteLine(resp);
             * }*/

            TCPHelper.Close();
            Console.ReadLine();
        }
コード例 #2
0
ファイル: Generated.cs プロジェクト: Scriptopathe/codinsa2015
        public bool SetShipPosition(int index, Vector2 position)
        {
            // Send
            List <object> args = new List <object>()
            {
                index, position
            };
            int           funcId = 2;
            List <object> obj    = new List <object>()
            {
                funcId, args
            };

            TCPHelper.Send(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
            // Receive
            string str = TCPHelper.Receive();

            Newtonsoft.Json.Linq.JArray o = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(str);
            return(o.Value <bool>(0));
        }
コード例 #3
0
ファイル: Generated.cs プロジェクト: Scriptopathe/codinsa2015
        public Vector2 GetShipPosition(int index)
        {
            // Send
            List <object> args = new List <object>()
            {
                index
            };
            int           funcId = 1;
            List <object> obj    = new List <object>()
            {
                funcId, args
            };

            TCPHelper.Send(Newtonsoft.Json.JsonConvert.SerializeObject(obj));
            // Receive
            string str = TCPHelper.Receive();

            Newtonsoft.Json.Linq.JArray o = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(str);
            return((Vector2)o[0].ToObject(typeof(Vector2)));
        }