private static void ClickEvent(GamePicture picture, Rect rect, int ms, Action action) { List <bool> check = new List <bool>() { false, false }; while (true) { var point = FindGamePicture(rect, picture); if (!IsFind(point)) { if (check[0] == true && check[1] == false) { MainWindow.mainWindow.WriteLog(picture + "확인"); action(); return; } MainWindow.mainWindow.WriteLog(picture + "서치 실패"); Thread.Sleep(ms); check.Add(false); check.RemoveAt(0); continue; } check.Add(true); check.RemoveAt(0); MouseHooker.LeftClick(point); Thread.Sleep(ms); } }
/// <summary> /// 231 显示图片 /// 图片编号 /// 图片名 /// 坐标x /// 坐标y /// opacity 0~255 /// rotation 0~360 /// </summary> /// <returns></returns> public bool command_showPic() { int num = int.Parse(this.currentParam[0]); string picName = this.currentParam[1]; int x = int.Parse(this.currentParam[2]); int y = int.Parse(this.currentParam[3]); int opacity = 255; int rotation = 0; if (this.currentParam.Length > 4 && !"".Equals(this.currentParam[4])) { opacity = int.Parse(this.currentParam[4]); } if (this.currentParam.Length > 5 && !"".Equals(this.currentParam[5])) { rotation = int.Parse(this.currentParam[5]); } // 生成数据和精灵 GamePicture picture = new GamePicture(num, picName, x, y); picture.opacity = opacity; picture.rotation = rotation; GameTemp.gameScreen.showPicture(picture); return(true); }
public static Point FindGamePictureDuring(Rect rect, GamePicture picture, int ms, int maxcount) { var path = GetPicturePath(picture); if (!File.Exists(path)) { return(new Point(-2, -2)); } int count = 0; while (count < maxcount) { string[] search = ImageSearcher.Search(path); if (search == null) { count++; Thread.Sleep(ms); continue; } int[] search_ = new int[search.Length]; for (int j = 0; j < search.Length; j++) { search_[j] = Convert.ToInt32(search[j]); } return(new Point(search_[1], search_[2])); } return(new Point(-1, -1)); }
public bool contanes(GamePicture gp) { return((transform.position.x - wUnitsField / 2 <= gp.transform.position.x - gp.wUnitsPicture / 2) && (transform.position.x + wUnitsField / 2 >= gp.transform.position.x + gp.wUnitsPicture / 2) && (transform.position.y - hUnitsField / 2 <= gp.transform.position.y - gp.hUnitsPicture / 2) && (transform.position.y + hUnitsField / 2 >= gp.transform.position.y + gp.hUnitsPicture / 2)); }
/// <summary> /// 显示图片 /// </summary> /// <param name="picture"></param> public void attachPicImage(GamePicture picture) { Debug.Log(string.Format("attach pic {0}", picture.picName)); GameObject picImage = new GameObject(); Image img = picImage.AddComponent <Image>(); Sprite sprite = Resources.Load <Sprite>(string.Format("graphics/pictures/{0}", picture.picName)); img.sprite = sprite; Debug.Log(string.Format("pic size: {0}, {1}", sprite.textureRect.width, sprite.textureRect.height)); img.GetComponent <RectTransform>().sizeDelta = new Vector2(sprite.textureRect.width, sprite.textureRect.height); img.transform.position = new Vector3(picture.x, picture.y, picture.num); img.color = new Color( 1.0f, 1.0f, 1.0f, picture.opacity / 255.0f ); img.transform.rotation = Quaternion.Euler(new Vector3(0, 0, picture.rotation)); picImage.transform.SetParent(GameObject.Find("Pics").transform); if (this.pictures.ContainsKey(picture.num)) { // 已存在 GameObject.Destroy(this.pictures[picture.num]); this.pictures.Remove(picture.num); } this.pictures.Add(picture.num, img); }
void pictureDroped(DraggableObject obj, Vector3 position) { GamePicture gp = (GamePicture)obj; setCurrentPicture(gp); if (gp != null) { //Перемещение в карзину Collider2D[] colliders = Physics2D.OverlapCircleAll(new Vector2(basket.position.x, basket.position.y), 0.2f); if (contanes(colliders, gp.gameObject)) { gp.reset(); setCurrentPicture(null); return; } //Перемешение на поле if (field.contanes(gp)) { noObjectsOnFieldError.active = false; return; } } gp.returnToPreviousPosition(); }
/// <summary> /// 232 移动图片 /// 编号 /// 时间 /// x /// y /// opacity /// rotation /// zoomX /// zoomY /// </summary> /// <returns></returns> public bool command_transPic() { int num = int.Parse(this.currentParam[0]); int wait = int.Parse(this.currentParam[1]); int x = int.Parse(this.currentParam[2]); int y = int.Parse(this.currentParam[3]); GamePicture currPic = GameTemp.gameScreen.getPicture(num); Debug.Log(string.Format("trans pic {0}", num)); if (currPic == null) { Debug.Log(string.Format("return for pic is null")); return(true); } currPic.setAnimDuration(wait); currPic.moveTo(x, y); if (this.currentParam.Length > 4 && !"".Equals(this.currentParam[4])) { int opacity = int.Parse(this.currentParam[4]); currPic.fadeTo(opacity); } if (this.currentParam.Length > 5 && !"".Equals(this.currentParam[5])) { int rotation = int.Parse(this.currentParam[5]); currPic.rotateTo(rotation); } if (this.currentParam.Length > 7) { float zoomX = float.Parse(this.currentParam[6]); float zoomY = float.Parse(this.currentParam[7]); currPic.zoomTo(zoomX, zoomY); } return(true); }
void pictureDroped(DraggableObject obj, Vector3 position) { const float R = 0.01F; // Радиус зоны попадания на картинку GamePicture gp = (GamePicture)obj; if (gp != null) { GamePicture target = gameField.onTargetPositon(gp); if (target != null) { //картинка сопоставлена правильно (музыка, эфекты) audioController.playBubblesSound(); //gamePicturePlaces.Remove(gp); //Destroy (gp.gameObject); target.setTrueColor(); gp.reset(); checkForGameOver(); return; } else { misstakes++; } } gp.returnToPreviousPosition(); }
/// <summary> /// el: : Picture EraseRect /// num "integer" /// </summary> static void PictureErase() { GamePicture picture = MakeCommand.Command("num").ToPicture(); if (picture != null) { picture.Erase(); } }
/// <summary> /// el: Picture rotate /// num "integer" /// [speed "integer"] /// [angle "integer"] /// </summary> static void PictureRotate() { GamePicture picture = MakeCommand.Command("num").ToPicture(); int speed = 0; if (MakeCommand.Optional("speed")) { speed = MakeCommand.Command("speed").ToInteger(); } if (picture != null) { picture.Rotate(speed); } }
public static string GetPicturePath(GamePicture picture) { if (Directory.Exists(ImagesDirectory) == false) { return(string.Empty); } if (picture == GamePicture.Fail) { return(ImagesDirectory + "\\Fail.PNG"); } else if (picture == GamePicture.Success) { return(ImagesDirectory + "\\Success.PNG"); } else if (picture == GamePicture.SuccessFairy) { return(ImagesDirectory + "\\SuccessFairy.PNG"); } else if (picture == GamePicture.FullFish) { return(ImagesDirectory + "\\FullFish.PNG"); } else if (picture == GamePicture.FullFish_SellAll) { return(ImagesDirectory + "\\FullFish_SellAll.PNG"); } else if (picture == GamePicture.FullFish_SellAllOk) { return(ImagesDirectory + "\\FullFish_SellAllOk.PNG"); } else if (picture == GamePicture.FullFish_SellCheck) { return(ImagesDirectory + "\\FullFish_SellCheck.PNG"); } else if (picture == GamePicture.Back) { return(ImagesDirectory + "\\Back.PNG"); } else if (picture == GamePicture.BigMonster) { return(ImagesDirectory + "\\BigMonster.PNG"); } else { return(ImagesDirectory + "\\Numbers\\" + (int)picture + ".PNG"); } }
/// <summary> /// el: start Picture tone change /// num "integer" /// tone red:"0-255" green:"0-255" blue:"0-255" gray:"0-255" /// duration "integer" /// </summary> static void StartPictureToneChange() { GamePicture picture = MakeCommand.Command("num").ToPicture(); MakeCommand.Category("tone"); int red = MakeCommand.Parameter("red").ToInteger(); int green = MakeCommand.Parameter("green").ToInteger(); int blue = MakeCommand.Parameter("blue").ToInteger(); int gray = MakeCommand.Parameter("gray").ToInteger(); int duration = MakeCommand.Parameter("duration").ToInteger(); if (picture != null) { picture.StartToneChange(new Tone(red, green, blue, gray), duration); } }
public GamePicture onTargetPositon(GamePicture gp, float esp = 1f) { foreach (GamePicture gamePicture in gamePictures) { float a = Mathf.Abs(gamePicture.transform.position.x - gp.transform.position.x); float b = Mathf.Abs(gamePicture.transform.position.y - gp.transform.position.y); if (Mathf.Sqrt(a * a + b * b) < esp) { if (gp.GamePictureInfo.equals(gamePicture.GamePictureInfo)) { return(gamePicture); } } } return(null); }
/// <summary> /// el: Picture move /// num "integer" /// duration "integer" /// position x:"integer" y:"integer" /// [Size zoom_x:"integer" zoom_y:"integer"] /// [opacity "0-255"] /// [blend_type "normaladd|sub"] /// [angle "0-360"] /// </summary> static void PictureMove() { GamePicture picture = MakeCommand.Command("num").ToPicture(); int duration = MakeCommand.Command("duration").ToInteger(); MakeCommand.Category("position"); int x = MakeCommand.Parameter("x").ToInteger(); int y = MakeCommand.Parameter("y").ToInteger(); float zoom_x = 100f; float zoom_y = 100f; byte opacity = 255; int blend_type = 0; if (picture != null) { zoom_x = picture.ZoomX; zoom_y = picture.ZoomY; opacity = picture.Opacity; blend_type = picture.BlendType; } if (MakeCommand.Optional("size")) { MakeCommand.Category("size"); zoom_x = MakeCommand.Parameter("zoom_x").ToInteger(); zoom_y = MakeCommand.Parameter("zoom_y").ToInteger(); } if (MakeCommand.Optional("blend_type")) { blend_type = MakeCommand.Command("blend_type").ToBlendType(); } int angle = 0; if (MakeCommand.Optional("opacity")) { opacity = (byte)MakeCommand.Command("opacity").ToInteger(); } if (MakeCommand.Optional("angle")) { angle = MakeCommand.Command("angle").ToInteger(); } if (picture != null) { picture.Move(duration, picture.Origin, x, y, zoom_x, zoom_y, opacity, blend_type, angle); } }
/* * private void openLevel (string path){ * string name = ""; * string description = ""; * FileWorker.readLevelFromFileForEdition (path, ref field, ref pictures, ref name, ref description); * }*/ public void setCurrentPicture(GamePicture gp) { if (gp == null) { currentPcture.resetCurrent(); return; } if (currentPcture != gp) { if (currentPcture != null) { currentPcture.resetCurrent(); } currentPcture = gp; currentPcture.setCurrent(); sizeSlider.value = (currentPcture.getSize()); rotationSlider.value = (currentPcture.getRotationAngle()); } }
private static void ClickThread(ref int count, GamePicture picture, Rect rect) { try { List <bool> check = new List <bool>() { false, false }; while (true) { var point = FindGamePicture(rect, picture); if (!IsFind(point)) { if (check[0] == true && check[1] == false) { count++; if (picture == GamePicture.Fail) { MainWindow.mainWindow.ModifyGetFail("실패 : " + count.ToString() + "(" + (++StackFailCount) + ")"); } else if (picture == GamePicture.Success) { MainWindow.mainWindow.ModifyGetSuccess("성공 : " + count.ToString() + "(" + (++StackSuccessCount) + ")"); } else if (picture == GamePicture.BigMonster) { MainWindow.mainWindow.ModifyBigMosnter("괴수 등장 : " + count.ToString() + "(" + (++StackBigMonsterCount) + ")"); } } Thread.Sleep(1000); check.Add(false); check.RemoveAt(0); continue; } check.Add(true); check.RemoveAt(0); MouseHooker.LeftClick(point); Thread.Sleep(1000); } } catch { } }
public static Point FindGamePicture(GamePicture picture) { var path = GetPicturePath(picture); if (!File.Exists(path)) { return(new Point(-2, -2)); } string[] search = ImageSearcher.Search(path); if (search == null) { return(new Point(-1, -1)); } int[] search_ = new int[search.Length]; for (int j = 0; j < search.Length; j++) { search_[j] = Convert.ToInt32(search[j]); } return(new Point(search_[1], search_[2])); }
private static void ClickThreadOnce(ref int count, GamePicture picture, Rect rect) { try { List <bool> check = new List <bool>() { false, false }; while (count == 0) { var point = FindGamePicture(rect, picture); if (!IsExist(point)) { MainWindow.mainWindow.WriteLog(picture + "경로에 없음"); throw new Exception(""); } if (!IsFind(point)) { if (check[0] == true && check[1] == false) { count++; MainWindow.mainWindow.WriteLog(picture + "확인"); } MainWindow.mainWindow.WriteLog(picture + "서치 실패"); Thread.Sleep(1000); check.Add(false); check.RemoveAt(0); continue; } check.Add(true); check.RemoveAt(0); MouseHooker.LeftClick(point); Thread.Sleep(1000); } } catch { } }
/* * public GamePicture createPicture (string url, Vector3 position, float size, float angle, bool flipX = false, bool flipY = false, bool shadow = true) { * GamePicture gp = Instantiate (gamePicturePrefab, position, transform.rotation, transform) as GamePicture; * gamePictures.Add (gp); * gp.setPicture (url); * gp.setSize (size); * gp.setRotation (angle); * gp.setFlipX (flipX); * gp.setFlipY (flipY); * if (shadow) * gp.setSpriteColor (pictureShadowColor); * return gp; * }*/ public GamePicture createPicture(GamePictureInfo gpi, int type = 2) { GamePicture gp = Instantiate(gamePicturePrefab, new Vector3(gpi.Position.x, gpi.Position.y, -1f), transform.rotation, transform) as GamePicture; gp.transform.localPosition = new Vector3(gpi.Position.x, gpi.Position.y, -1); gamePictures.Add(gp); gp.setPicture(gpi); gp.setSize(gpi.Size); gp.setRotation(gpi.Angle); gp.setFlipX(gpi.FlipX); gp.setFlipY(gpi.FlipY); if (type == 1) { gp.setSpriteColor(pictureShadowColor); } else if (type == 0) { gp.setSpriteColor(pictureHalfColor); } gp.activate(false); return(gp); }
/// <summary> /// Constructor /// </summary> /// <param Name="port">viewport on which the sprite is displayed</param> /// <param Name="Picture">associated GamePicture</param> public SpritePicture(Viewport port, GamePicture picture) : base(port) { this.picture = picture; Update(); }
public static void FullFishCheckingThread(ref int fullFishCount, GamePicture fullFish, Rect rect) { List <bool> check = new List <bool>() { false, false }; List <Thread> FinderThreadList = new List <Thread>(); try { while (true) { AA :; var point = FindGamePicture(rect, fullFish); if (!IsFind(point)) { if (check[0] == true && check[1] == false) { if (MacroThread != null) { MacroThread.Abort(); } MainWindow.mainWindow.WriteLog("어망 진입완료"); MainWindow.mainWindow.ModifySellFullFish("어망 풀 : " + (++fullFishCount).ToString() + "(" + (++StackFullFishCount) + ")"); int a = 0; int b = 0; int NoFish = 0; try { FinderThreadList.Add(new Thread(() => ClickThreadOnce( ref a, GamePicture.FullFish_SellAll, AppSetting.RectList[( int )RectEnum.FullFishContinue] ))); FinderThreadList.Add(new Thread(() => ClickThreadOnce( ref b, GamePicture.FullFish_SellAllOk, AppSetting.RectList[( int )RectEnum.FullFishContinue] ))); StartList(FinderThreadList); } catch (Exception e) { MainWindow.mainWindow.WriteLog("문제1 : " + e); } try { while (true) { var Clear어망 = FindGamePicture(AppSetting.RectList[( int )RectEnum.FullFishContinue], GamePicture.FullFish_SellCheck); if (IsFind(Clear어망)) { NoFish++; MainWindow.mainWindow.WriteLog(GamePicture.FullFish_SellCheck + "확인"); break; } Thread.Sleep(500); } } catch (Exception e) { MainWindow.mainWindow.WriteLog("문제2 : " + e); } try { if (NoFish > 0) { AbortList(FinderThreadList); FinderThreadList.Clear(); ClickEvent(GamePicture.Back, AppSetting.RectList[( int )RectEnum.FullFishContinue], 1000, new Action(() => { MouseHooker.MoveTo(new Point(0, 0)); MainWindow.mainWindow.WriteLog("낚시터로 이동완료"); MacroThread = new Thread(MacroThreadFunction); MacroThread.Start(); })); check[0] = false; check[1] = false; goto AA; } else { MainWindow.mainWindow.WriteLog("어망 비우기 실패"); goto AA; } } catch (Exception e) { MainWindow.mainWindow.WriteLog("문제3 : " + e); } } Thread.Sleep(1000); check.Add(false); check.RemoveAt(0); continue; } check.Add(true); check.RemoveAt(0); MouseHooker.LeftClick(point); Thread.Sleep(1000); } } catch { AbortList(FinderThreadList); } }