|
@@ -2,7 +2,9 @@ using FairyGUI;
|
|
|
using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.Drawing;
|
|
|
using UI.DressUp;
|
|
|
+using UnityEditor;
|
|
|
using UnityEngine;
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
@@ -45,6 +47,7 @@ namespace GFGGame
|
|
|
|
|
|
private Vector3 distance = Vector3.zero;//点击位置和点击物体原点的距离,用于
|
|
|
private Vector2 lastPos = Vector2.zero;//上一次移动后从物体中心到鼠标位置的方向
|
|
|
+ private float lastDistance = 0;//上一次移动后从物体中心到鼠标位置的方向
|
|
|
|
|
|
// private float _startDistance;//从物体中心到缩放按钮的距离
|
|
|
|
|
@@ -132,6 +135,7 @@ namespace GFGGame
|
|
|
_ui.m_loaGuide.enabled = true;
|
|
|
_ui.m_loaGuide1.enabled = false;
|
|
|
}
|
|
|
+ // CreatTex();
|
|
|
Timers.inst.AddUpdate(UpdateToCheckGuide);
|
|
|
}
|
|
|
/************************************************************UI界面*********************************************************/
|
|
@@ -300,13 +304,16 @@ namespace GFGGame
|
|
|
private void OnTouchBtnSizeBegin(EventContext context)
|
|
|
{
|
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
|
+ Vector2 pt0 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
+
|
|
|
Vector2 screenPos = this.viewCom.GlobalToLocal(_ui.m_comSelectBox.m_btnSize.LocalToGlobal(Vector2.zero));
|
|
|
- Vector2 pt = new Vector2(screenPos.x, screenPos.y);
|
|
|
+ Vector2 pt1 = new Vector2(screenPos.x, screenPos.y);
|
|
|
Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
|
|
|
-
|
|
|
+ lastDistance = Vector2.Distance(pt0, pt2);
|
|
|
if (!_equipDistance.ContainsKey(memoryHitGameObj))
|
|
|
{
|
|
|
- float distance = Vector2.Distance(pt, pt2) / memoryHitGameObj.transform.localScale.x;
|
|
|
+ float distance = Vector2.Distance(pt1, pt2) / memoryHitGameObj.transform.localScale.x;
|
|
|
+ Debug.Log("distance:" + distance + " pt1:" + pt1 + " pt2:" + pt2);
|
|
|
_equipDistance.Add(memoryHitGameObj, distance);
|
|
|
}
|
|
|
}
|
|
@@ -314,6 +321,7 @@ namespace GFGGame
|
|
|
{
|
|
|
if (memoryHitGameObj == null) return;
|
|
|
InputEvent inputEvent = (InputEvent)context.data;
|
|
|
+
|
|
|
Vector2 pt1 = this.viewCom.GlobalToLocal(new Vector2(inputEvent.x, inputEvent.y));
|
|
|
Vector2 pt2 = new Vector2(_ui.m_comSelectBox.target.x, _ui.m_comSelectBox.target.y);
|
|
|
Vector2 curPos = pt1 - pt2;
|
|
@@ -324,12 +332,21 @@ namespace GFGGame
|
|
|
lastPos = curPos;
|
|
|
ControllerRotate(angle, memoryHitGameObj);
|
|
|
|
|
|
-
|
|
|
float dist = Vector2.Distance(pt1, pt2);
|
|
|
- float ss = dist / _equipDistance[memoryHitGameObj];
|
|
|
- float newValue = Mathf.Clamp(ss, 0.1f, 2);
|
|
|
+
|
|
|
+ float ss = dist / lastDistance;
|
|
|
+ Debug.Log("dist:" + dist + " lastDistance:" + lastDistance + " ss:" + ss);
|
|
|
+ float newValue = Mathf.Clamp(ss * memoryHitGameObj.transform.localScale.x, 0.1f, 2);
|
|
|
ControllerScale(newValue, memoryHitGameObj);
|
|
|
|
|
|
+ if (newValue <= 0.1f) return;
|
|
|
+ Debug.Log("ss:" + ss + " newValue:" + newValue);
|
|
|
+ lastDistance = dist;
|
|
|
+ Debug.Log("newValue:" + newValue);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
private void OnTouchBtnSizeEnd(EventContext context)
|
|
|
{
|
|
@@ -373,7 +390,8 @@ namespace GFGGame
|
|
|
if (value > MaxScale || value < MinScale) return;
|
|
|
gameObject.transform.localScale = new Vector3(value, value, 1);
|
|
|
Vector2 size = SceneController.GetGameObjectSize(gameObject);
|
|
|
- _ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
|
+ _ui.m_comSelectBox.target.size = size;
|
|
|
+ // _ui.m_comSelectBox.target.SetSize(size.x, size.y);
|
|
|
}
|
|
|
private void ControllerRotate(float value, GameObject gameObject)
|
|
|
{
|
|
@@ -623,6 +641,97 @@ namespace GFGGame
|
|
|
GuideController.TryCompleteGuide(ConstGuideId.PHOTOGRAPH, 7);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ private void CreatTex()
|
|
|
+ {
|
|
|
+ Rect rect = new Rect(-(UnityEngine.Screen.width / 2), -(UnityEngine.Screen.height / 2), UnityEngine.Screen.width, UnityEngine.Screen.height);
|
|
|
+ Texture2D tex = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.ARGB32, false);//新建一个Texture2D对象
|
|
|
+ Transform transform = _sceneObject.transform.Find("Scene/Role");
|
|
|
+ Dictionary<SpriteRenderer, int> data = new Dictionary<SpriteRenderer, int>();
|
|
|
+
|
|
|
+ float width = 0;
|
|
|
+ float height = 0;
|
|
|
+ for (int i = 0; i < transform.childCount; i++)
|
|
|
+ {
|
|
|
+ SpriteRenderer sr = transform.GetChild(i).GetComponent<SpriteRenderer>();
|
|
|
+ if (sr != null)
|
|
|
+ {
|
|
|
+ width = Math.Max(sr.bounds.size.x + sr.transform.position.x, width);
|
|
|
+ height = Math.Max(sr.bounds.size.x + sr.transform.position.x, width);
|
|
|
+
|
|
|
+ data.Add(sr, sr.sortingOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<KeyValuePair<SpriteRenderer, int>> lst = new List<KeyValuePair<SpriteRenderer, int>>(data);
|
|
|
+ lst.Sort(delegate (KeyValuePair<SpriteRenderer, int> s1, KeyValuePair<SpriteRenderer, int> s2) { return s2.Value.CompareTo(s1.Value); });
|
|
|
+ data.Clear();
|
|
|
+
|
|
|
+ for (int i = lst.Count - 1; i >= 0; i--)
|
|
|
+ {
|
|
|
+ SpriteRenderer sr = lst[i].Key;
|
|
|
+ if (sr != null)
|
|
|
+ {
|
|
|
+ // Sprite sprite1 = sr.GetComponent<Sprite>();
|
|
|
+ Texture2D texture2D = sr.sprite.texture;
|
|
|
+ for (int j = 0; j < texture2D.width; j++)
|
|
|
+ {
|
|
|
+ for (int k = 0; k < texture2D.height; k++)
|
|
|
+ {
|
|
|
+ var color = texture2D.GetPixel(j, k);
|
|
|
+ tex.SetPixel(j, k, color);
|
|
|
+ tex.Apply();
|
|
|
+ Debug.Log("color:" + color + " " + j + " " + k);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // var color = texture2D.GetPixel(0, 0);
|
|
|
+
|
|
|
+ // tex.SetPixel(0, 0, color);
|
|
|
+ // tex.Apply();//保存像素信息
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Sprite sprite = Sprite.Create(tex, rect, new Vector2(-(UnityEngine.Screen.width / 2), -(UnityEngine.Screen.height / 2)));
|
|
|
+ GameObject gameObject = _sceneObject.transform.Find("Scene/Role/BodyRes").gameObject;
|
|
|
+ gameObject.AddComponent<SpriteRenderer>();
|
|
|
+ gameObject.GetComponent<SpriteRenderer>().sprite = sprite;
|
|
|
+
|
|
|
+ // // Dictionary<string, int> data = new Dictionary<string, int>();
|
|
|
+ // // for (int i = 0; i < _equipRoleData.Count; i++)
|
|
|
+ // // {
|
|
|
+ // // ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_equipRoleData[i]);
|
|
|
+ // // ItemTypeCfg typeCfg = ItemTypeCfgArray.Instance.GetCfg(itemCfg.subType);
|
|
|
+
|
|
|
+ // // if (itemCfg.resLayer1 > 0)
|
|
|
+ // // {
|
|
|
+ // // data.Add(itemCfg.res, typeCfg.defaultLayer);
|
|
|
+ // // }
|
|
|
+ // // if (itemCfg.resLayer2 > 0)
|
|
|
+ // // {
|
|
|
+ // // data.Add(string.Format("{0}_t", itemCfg.res), typeCfg.defaultLayer);
|
|
|
+ // // }
|
|
|
+ // // }
|
|
|
+ // // List<KeyValuePair<string, int>> lst = new List<KeyValuePair<string, int>>(data);
|
|
|
+ // // lst.Sort(delegate (KeyValuePair<string, int> s1, KeyValuePair<string, int> s2) { return s2.Value.CompareTo(s1.Value); });
|
|
|
+ // // data.Clear();
|
|
|
+ // // for (int i = lst.Count - 1; i >= 0; i--)
|
|
|
+ // // {
|
|
|
+ // // string res = lst[i].Key;
|
|
|
+ // // int sortingOrder = lst[i].Value;
|
|
|
+
|
|
|
+ // // float tx, ty;
|
|
|
+ // // DressUpUtil.LoadSpritePos(res, out tx, out ty);
|
|
|
+ // // string resPath = ResPathUtil.GetDressUpPath(res);
|
|
|
+ // // Bitmap bmp = new Bitmap(resPath);
|
|
|
+
|
|
|
+ // // tex.SetPixel(0, 0, );//读取像素,屏幕左下角为0点
|
|
|
+ // // tex.Apply();//保存像素信息
|
|
|
+ // // }
|
|
|
+ // tex.SetPixel(0, 0, );//读取像素,屏幕左下角为0点
|
|
|
+
|
|
|
+ // tex.Apply();//保存像素信息
|
|
|
+ // return tex;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|