public static void Recv_handler(string msg) { var dao = new DAO(); dao.Deserialize(msg); switch (dao.type) { case "cmd": CommandController commandController = GameObject.Find("GameController").GetComponent <CommandController>(); if (commandController == null) { Debug.Log("YA RI1 !"); } Command cmd = new Command(); cmd.action = dao.action; cmd.args[0] = dao.characters[0]; switch (dao.action) { case "deplacer": cmd.args[1] = dao.world.regions.Length == 0 ? dao.characters[1] : dao.world.regions[0]; break; case "discuter": cmd.args[1] = dao.characters[1]; break; default: Debug.Log("Commande d'action non reconnue"); return; } commandController.NewCommand(cmd); break; case "sys": switch (dao.action) { case "exit": Application.Quit(); //UnityEditor.EditorApplication.isPlaying = false; break; default: Debug.Log("Commande système non reconnue"); break; } break; default: Debug.Log("Commande non reconnue"); break; } }
// Update is called once per frame void Update() { // [UP_ARROW] Go to Up position if (Input.GetKeyDown(KeyCode.UpArrow)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Michel"; cmd.args[1] = "Ugo"; commandeControl.NewCommand(cmd); } // [RIGHT_ARROW] Go to Right position if (Input.GetKeyDown(KeyCode.RightArrow)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Michel"; cmd.args[1] = "Est"; commandeControl.NewCommand(cmd); } // [DOWN_ARROW] Go to Down position if (Input.GetKeyDown(KeyCode.DownArrow)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Michel"; cmd.args[1] = "Sud"; commandeControl.NewCommand(cmd); } // [LEFT_ARROW] Go to Left position if (Input.GetKeyDown(KeyCode.LeftArrow)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Michel"; cmd.args[1] = "Ouest"; commandeControl.NewCommand(cmd); } // [SPACE] Discuss with UGo if (Input.GetKeyDown(KeyCode.Space)) { Command cmd = new Command(); cmd.action = "discuter"; cmd.args[0] = "Michel"; cmd.args[1] = "Ugo"; commandeControl.NewCommand(cmd); } // [UP_ARROW] Go to Up position if (Input.GetKeyDown(KeyCode.Z)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Ugo"; cmd.args[1] = "Michel"; commandeControl.NewCommand(cmd); } // [RIGHT_ARROW] Go to Right position if (Input.GetKeyDown(KeyCode.D)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Ugo"; cmd.args[1] = "Est"; commandeControl.NewCommand(cmd); } // [DOWN_ARROW] Go to Down position if (Input.GetKeyDown(KeyCode.S)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Ugo"; cmd.args[1] = "Sud"; commandeControl.NewCommand(cmd); } // [LEFT_ARROW] Go to Left position if (Input.GetKeyDown(KeyCode.Q)) { Command cmd = new Command(); cmd.action = "deplacer"; cmd.args[0] = "Ugo"; cmd.args[1] = "Ouest"; commandeControl.NewCommand(cmd); } }