Example #1
0
        internal void Jump(string data)
        {
            MoveMessage j2 = JsonConvert.DeserializeObject <MoveMessage>(data);
            //objects[]
            Player2 onb2 = (Player2)simulator.users[j2.client].player;

            // Simulation.Awakener.AwakenBody(ob.bodyHandle);
            onb2.Jump(j2);
        }
Example #2
0
 public void Jump(MoveMessage message)
 {
     if (!Agent.IsLocked())
     {
         QuixConsole.Log("Jump");
         Agent.ChangeState(jumpState);
         Agent.Lock(130);
     }
 }
Example #3
0
 public override void Move(MoveMessage message)
 {
     base.Move(message);
     moveMessage = message;
     if (Agent.ActualState() != notSnappedState)
     {
         Agent.ChangeState(notSnappedState);
         Agent.Lock(20);
     }
 }
Example #4
0
 public virtual void Move(MoveMessage message)
 {
 }
Example #5
0
        internal void ReadCommand()
        {
            //Console.WriteLine("Read command: {0}", v);

            try
            {
                foreach (var item in commandsList)
                {
                    JsonSerializerSettings setting = new JsonSerializerSettings();
                    setting.CheckAdditionalContent = false;

                    Newtonsoft.Json.Linq.JObject message = JsonConvert.DeserializeObject <Newtonsoft.Json.Linq.JObject>((string)item, setting);
                    string type = (string)message["type"];
                    switch (type)
                    {
                    case "create":

                        // Console.WriteLine(message);

                        if (message["data"]["halfSize"] != null)
                        {
                            BoxState ob = JsonConvert.DeserializeObject <BoxState>(((object)message["data"]).ToString());
                            simulator.Create(ob);
                        }

                        if (message["data"]["radius"] != null)
                        {
                            SphereState ob = JsonConvert.DeserializeObject <SphereState>(((object)message["data"]).ToString());
                            simulator.Create(ob);
                            break;
                        }

                        break;

                    case "createBoxes":
                        //Console.WriteLine("Create boxes");
                        // simulator.boxToCreate = 10;
                        simulator.createObjects();
                        break;

                    case "gauntlet":

                        UseGauntlet(((object)message["data"]).ToString());
                        break;

                    case "move":

                        MoveMessage j = JsonConvert.DeserializeObject <MoveMessage>(((object)message["data"]).ToString());
                        //objects[]
                        Player2 onb = (Player2)simulator.users[j.client].player;
                        // Simulation.Awakener.AwakenBody(ob.bodyHandle);
                        onb.Move(j);

                        break;

                    case "rotate":
                        MoveMessage j2 = JsonConvert.DeserializeObject <MoveMessage>(((object)message["data"]).ToString());
                        //objects[]
                        Player2 onb2 = (Player2)simulator.users[j2.client].player;
                        // Simulation.Awakener.AwakenBody(ob.bodyHandle);
                        onb2.Rotate(j2);
                        break;

                    case "jump":
                        Jump(((object)message["data"]).ToString());
                        break;

                    case "shoot":
                        Shoot(((object)message["data"]).ToString());
                        break;

                    case "swipe":
                        Swipe(((object)message["data"]).ToString());
                        break;

                    case "generateMap":

                        var map = this.simulator.server.dataBase.GetMap((string)message["data"]);
                        this.simulator.map = map;

                        foreach (var obj in map.objects)
                        {
                            //obj.ToJson();
                            if (obj.Contains("halfSize"))
                            {
                                obj["halfSize"].AsBsonDocument.Remove("__refId");
                                obj.Remove("_id");
                                var stri = JsonConvert.DeserializeObject <BoxState>(obj.ToJson());
                                stri.quaternion = JsonConvert.DeserializeObject <Quaternion>(obj["quat"].ToJson());

                                this.simulator.Create(stri);
                            }
                            if (obj.Contains("radius"))
                            {
                                // obj["radius"].AsBsonDocument.Remove("__refId");
                                obj.Remove("_id");
                                var stri = JsonConvert.DeserializeObject <SphereState>(obj.ToJson());
                                stri.quaternion = JsonConvert.DeserializeObject <Quaternion>(obj["quat"].ToJson());

                                this.simulator.Create(stri);
                            }
                        }
                        break;

                    case "close":
                        //Console.WriteLine("Close");
                        simulator.Close();

                        break;

                    default:
                        QuixConsole.WriteLine("Command not registred " + type);
                        break;
                    }
                }

                commandsList.Clear();
            }
            catch (InvalidOperationException e)
            {
                QuixConsole.Log("Collection was modifieded", e);
            }
            catch (JsonReaderException e)
            {
                QuixConsole.Log("Json Problem ", e);
            }
            catch (Exception e) {
                QuixConsole.WriteLine(e);
            }
        }
Example #6
0
 public void Rotate(MoveMessage message)
 {
     rotateMessage = message;
 }