public void HandleMsg(string msg) { //Console.Out.WriteLine("msg="+msg); PlayObj pobj = Json.fromJson <PlayObj>(msg); callback?.HandlePlayObject(pobj); }
public void NextMatchBtn() { WinObj.SetActive(false); PlayObj.SetActive(true); PlayerPrefs.SetInt("goal", 0); SceneManager.LoadScene("Play"); }
public override void Exec() { if (Peanut.profile == null && !Peanut.conf.ContainsKey("domainName")) { Dictionary <string, string> _params = new Dictionary <string, string>(); _params["macid"] = PeanutModule.GetMacId(); _params["macType"] = "win32"; using (WebClient webClient = PeanutModule.newWebClient()) { string url = "https://cherry.danoolive.com/api/root/easyreg/check"; string resp = webClient.DownloadString(url + "?macid=" + PeanutModule.GetMacId()); Console.Out.WriteLine("resp=" + resp); EasyCheckResp er = Json.fromJson <EasyCheckResp>(resp); if (er == null) { Console.Out.WriteLine("resp ERROR"); Thread.Sleep(60 * 1000); return; } if (er.easyreg != null) { // 需要注册 var scene_url = er.easyreg["scene_url"].ToString(); Console.Out.WriteLine("scene_url=" + scene_url); PlayObj pobj = new PlayObj(); pobj.type = "play"; pobj.start = -1; pobj.libName = "pic"; pobj._params = new Dictionary <string, object>(); pobj._params["path"] = "https://nutz.cn/qrcode/get?w=256&h=256&data=" + Uri.EscapeUriString(scene_url); pobj._params["height"] = "512"; pobj._params["width"] = "512"; pobj._params["top"] = "100"; pobj._params["left"] = "100"; pobj._params["zIndex"] = 8; Peanut.callback.HandlePlayObject(pobj); Thread.Sleep(15 * 1000); } else if (er.box_conf != null) { Peanut.conf["domainName"] = er.box_conf["domainName"].ToString(); PeanutModule.writeIni("config.ini", Peanut.conf); } } Thread.Sleep(5000); return; } using (WebClient webClient = PeanutModule.newWebClient()) { Console.Out.WriteLine("ping ..."); var tmp = webClient.DownloadString("https://cherry.danoolive.com/ping?ex="); Peanut.pingResp = Json.fromJson <PingResp>(tmp); Console.Out.WriteLine("ping done=" + tmp); } }
public void StopLayout(PlayObj pobj) { object[] tmp = pobj._params["ids"] as object[]; //Console.Out.WriteLine("tmp=" + tmp.GetType()); foreach (string id in tmp) { int zIndex = int.Parse(id); UIElement ele = getByZIndex(zIndex); if (ele != null) { TopCanvas.Children.Remove(ele); TopCanvas.UnregisterName("LV_" + zIndex); } } }
public void HandlePlayObject(object obj) { PlayObj pobj = (PlayObj)obj; if (pobj._params == null) { return; } long start = pobj.start; if (start > 0) { long now = GetTimestamp(DateTime.UtcNow); int sleep = (int)(start - now); if (sleep > 5) { Thread.Sleep(sleep - 5); } } Dispatcher.BeginInvoke(new Action(delegate() { if ("stop" == pobj.type) { StopLayout(pobj); } else if ("play" == pobj.type) { StartLayout(pobj.getIntParam("zIndex"), pobj); } else { Console.Out.WriteLine("what? type=" + pobj.type); } })); }
// Update is called once per frame void Update() { time += Time.deltaTime; print(Mathf.FloorToInt(time)); goal = PlayerPrefs.GetInt("goal", goal); //if (Input.GetKey(KeyCode.LeftArrow)) //{ // float x = Mathf.Clamp(transform.position.x - speed, 50, Screen.width - 50); //to restrict the movement field of Player: pos var to control, min range, max // transform.position = new Vector2(x, transform.position.y); //tranform the pos on key press //} //if (Input.GetKey(KeyCode.RightArrow)) //{ // float x = Mathf.Clamp(transform.position.x + speed, 50, Screen.width - 50); // transform.position = new Vector2(x, transform.position.y); //} //if (Input.GetKey(KeyCode.UpArrow)) //{ // float y = Mathf.Clamp(transform.position.y + speed, 50, Screen.height - 50); // transform.position = new Vector2(transform.position.x, y); //} //if (Input.GetKey(KeyCode.DownArrow)) //{ // float y = Mathf.Clamp(transform.position.y - speed, 50, Screen.height - 50); // transform.position = new Vector2(transform.position.x, y); //} if (Input.GetKey(KeyCode.LeftArrow)) { //Player.velocity = new Vector2(-100, 0); //just on once key press Player will move with speed of 100 in left direction Player.velocity = Vector2.left * velocity; //vector2.left = vector(-1,0) and * velocity means (-1,0)*150 //Player.AddForce(Vector2.left * velocity); //add force in left direction of (-1,0)*velocity which is (-150,0) } if (Input.GetKey(KeyCode.RightArrow)) { //Player.velocity = new Vector2(100, 0); Player.velocity = Vector2.right * velocity; //Player.AddForce(Vector2.right * velocity); } if (Input.GetKey(KeyCode.UpArrow)) { //Player.velocity = new Vector2(0, 100); Player.velocity = Vector2.up * velocity; //Player.AddForce(Vector2.up * velocity); } if (Input.GetKey(KeyCode.DownArrow)) { //Player.velocity = new Vector2(0, -100); Player.velocity = Vector2.down * velocity; //Player.AddForce(Vector2.down * velocity); } //if(Input.GetKeyUp(KeyCode.LeftArrow)) //{ // Player.velocity = Vector2.zero; //on release of key Player will stop & vector2.zero = (0,0) //} //if (Input.GetKeyUp(KeyCode.RightArrow)) //{ // Player.velocity = Vector2.zero; //} //if (Input.GetKeyUp(KeyCode.UpArrow)) //{ // Player.velocity = Vector2.zero; //} //if (Input.GetKeyUp(KeyCode.DownArrow)) //{ // Player.velocity = Vector2.zero; //} //PlayerPrefs.GetInt("goal"); ScoreBoard.text = "GOAlS:" + goal + ""; //PlayerPrefs.GetInt("score"); //ScoreBoard.text = "SCORE:" + score + ""; if (time >= TimeLimit[LevelNo - 1]) { if (goal >= Target[LevelNo - 1]) { can.GetComponent <CanvasGroup>().interactable = false; WinObj.SetActive(true); PlayObj.SetActive(false); print("win"); LevelNo++; } else { can.GetComponent <CanvasGroup>().interactable = false; LossObj.SetActive(true); PlayObj.SetActive(false); print("lose"); } } else { if (goal >= Target[LevelNo - 1]) { can.GetComponent <CanvasGroup>().interactable = false; WinObj.SetActive(true); PlayObj.SetActive(false); print("win"); LevelNo++; } } }
public void StartLayout(int zIndex, PlayObj pobj) { string libName = pobj.libName; UIElement ele = getByZIndex(zIndex); UIElement old = null; if (ele != null && ele is XplayUiEle && ((XplayUiEle)ele).getLibName() != pobj.libName) { old = ele; ele = null; } bool isNew = ele == null; if (ele == null) { switch (libName) { case "text": ele = new TextUiEle(); break; case "video": ele = new VideoUiEle(); break; case "pic": ele = new PicUiEle(); break; } } if (ele == null) { return; } XplayUiEle xe = (XplayUiEle)ele; xe.prepare(pobj); if (libName == "text") { Canvas.SetLeft(ele, pobj.getIntParam("left") * PlayObj.scaling * 96 / PlayObj.dpiX); Canvas.SetTop(ele, pobj.getIntParam("top") * PlayObj.scaling * 96 / PlayObj.dpiY - 20); //Console.Out.WriteLine(""+(pobj.getIntParam("top") * PlayObj.scaling * 96 / PlayObj.dpiY)); } else { Canvas.SetLeft(ele, pobj.getIntParam("left") * PlayObj.scaling); Canvas.SetTop(ele, pobj.getIntParam("top") * PlayObj.scaling); } Canvas.SetZIndex(ele, 0 - zIndex); if (isNew) { TopCanvas.Children.Add(ele); if (old != null) { TopCanvas.Children.Remove(old); TopCanvas.UnregisterName("LV_" + zIndex); } TopCanvas.RegisterName("LV_" + zIndex, ele); } xe.Play(); }