virtual public void CopyMoveTo(int currentTargetX, int currentTargetY, int startX, int startY, int endX, int endY, float movetime, int direct) { if (_object != null) { var currentTargetPos = _zeropos + new Vector3(currentTargetX * Constant.TileSize.x, -currentTargetY * Constant.TileSize.y, 0); var copycurrentpos = _zeropos + new Vector3(startX * Constant.TileSize.x, -startY * Constant.TileSize.y, 0); var targetpos = _zeropos + new Vector3(endX * Constant.TileSize.x, -endY * Constant.TileSize.y, 0); //_copyobject = GameObject.Instantiate(_object) as GameObject; _copyobject_target = GameObject.Instantiate(Resources.Load("Prefabs/MaskTiles/" + _name)) as GameObject; _copyobject_target.SetActive(true); var gridctrl_target = _copyobject_target.gameObject.GetComponent <GridMotionController>(); //add by wwh if (gridctrl_target == null) { gridctrl_target = _copyobject_target.gameObject.AddComponent <GridMotionController>(); } gridctrl_target.transform.position = copycurrentpos; var sortorder = startY * 2; gridctrl_target.transform.GetChild(0).GetComponent <SpriteRenderer>().sortingOrder = sortorder; gridctrl_target?.MoveToPosition(targetpos, movetime); _maskobject_copy = _maskModule?.GetMaskTile(); if (_maskobject_copy) { _maskobject_copy.InitMask(TileSize, sortorder, direct, false); _maskobject_copy.gameObject.transform.position = copycurrentpos; } } }
virtual public void MoveTo(int x, int y, float movetime, int direct, bool usecopy = false) { var targetpos = _zeropos + new Vector3(x * Constant.TileSize.x, -y * Constant.TileSize.y, 0); if (_object == null) { return; } if (usecopy) { _copyobject_ori = GameObject.Instantiate(Resources.Load("Prefabs/MaskTiles/" + _name)) as GameObject; _copyobject_ori.SetActive(true); var gridctrl_ori = _copyobject_ori.gameObject.GetComponent <GridMotionController>(); if (gridctrl_ori == null) { gridctrl_ori = _copyobject_ori.gameObject.AddComponent <GridMotionController>(); } gridctrl_ori.transform.position = _object.transform.position; var sordorder = _object.transform.GetChild(0).GetComponent <SpriteRenderer>().sortingOrder; gridctrl_ori.transform.GetChild(0).GetComponent <SpriteRenderer>().sortingOrder = sordorder; gridctrl_ori?.MoveToPosition(targetpos, movetime); _maskobject_ori = _maskModule?.GetMaskTile(); if (_maskobject_ori) { _maskobject_ori.InitMask(TileSize, sordorder, direct, true); _maskobject_ori.gameObject.transform.position = targetpos; } _object?.SetActive(false); return; } var gridctrl = _object.gameObject.GetComponent <GridMotionController>(); gridctrl?.MoveToPosition(targetpos, movetime); }