Commit d3f7db1e authored by lijin's avatar lijin

增加注释

parent e269b470
...@@ -16,7 +16,7 @@ public class EffectItem : MonoBehaviour ...@@ -16,7 +16,7 @@ public class EffectItem : MonoBehaviour
MainData md = GameMgr.Ins.md; MainData md = GameMgr.Ins.md;
Transform p = Rect.parent; Transform p = Rect.parent;
Rect.SetParent(md.imgpng.transform); Rect.SetParent(md.imgpng.transform);
Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2); Rect.localPosition = v - new Vector3(md.json.width / 2, md.json.height / 2);
Rect.SetParent(p); Rect.SetParent(p);
MainModule mm = ps.main; MainModule mm = ps.main;
mm.startColor = c; mm.startColor = c;
......
...@@ -21,12 +21,13 @@ public class GameMgr : MonoBehaviour ...@@ -21,12 +21,13 @@ public class GameMgr : MonoBehaviour
void Update() void Update()
{ {
Save();//自动保存逻辑
Click();//点击事件逻辑 Click();//点击事件逻辑
Play();//涂色重播逻辑 Play();//涂色重播逻辑
Save();//自动保存逻辑
} }
//初始化,主逻辑入口 #region 外部接口
//逻辑接口,主逻辑入口,初始化
public void Init(string key, Texture2D png, Sprite jpg, ResJsonData json, DynamicData dynamic, Texture2D map) public void Init(string key, Texture2D png, Sprite jpg, ResJsonData json, DynamicData dynamic, Texture2D map)
{ {
ins = this; ins = this;
...@@ -39,7 +40,6 @@ public class GameMgr : MonoBehaviour ...@@ -39,7 +40,6 @@ public class GameMgr : MonoBehaviour
{ {
gray = _gray; gray = _gray;
} }
//选组接口,传入组ID //选组接口,传入组ID
public void ChooseGroup(int groupId) public void ChooseGroup(int groupId)
{ {
...@@ -63,8 +63,9 @@ public class GameMgr : MonoBehaviour ...@@ -63,8 +63,9 @@ public class GameMgr : MonoBehaviour
{ {
md.AutoClick(); md.AutoClick();
} }
#endregion
#region 点击 #region 点击事件逻辑
public static readonly Vector2 gunSize = new Vector2(3, 10); public static readonly Vector2 gunSize = new Vector2(3, 10);
private float time = 0; private float time = 0;
private Vector2 pos = Vector2.zero; private Vector2 pos = Vector2.zero;
...@@ -99,8 +100,8 @@ public class GameMgr : MonoBehaviour ...@@ -99,8 +100,8 @@ public class GameMgr : MonoBehaviour
isLongPress = -1; isLongPress = -1;
RectTransformUtility.ScreenPointToLocalPointInRectangle(md.rect, Input.mousePosition, Camera.main, out Vector2 v); RectTransformUtility.ScreenPointToLocalPointInRectangle(md.rect, Input.mousePosition, Camera.main, out Vector2 v);
Debug.Log("长按:" + v); Debug.Log("长按:" + v);
v.x += md.png.width / 2; v.x += md.json.width / 2;
v.y += md.png.height / 2; v.y += md.json.height / 2;
v.x = (int)v.x; v.x = (int)v.x;
v.y = (int)v.y; v.y = (int)v.y;
md.OnLongPressPos(v); md.OnLongPressPos(v);
...@@ -140,13 +141,13 @@ public class GameMgr : MonoBehaviour ...@@ -140,13 +141,13 @@ public class GameMgr : MonoBehaviour
//点击由坐标系转图内像素坐标 //点击由坐标系转图内像素坐标
public bool OnClickPixel(Vector2 v) public bool OnClickPixel(Vector2 v)
{ {
v.x += md.png.width / 2; v.x += md.json.width / 2;
v.y += md.png.height / 2; v.y += md.json.height / 2;
return md.OnClickPos(v); return md.OnClickFun(v);
} }
#endregion #endregion
#region 重播逻辑 #region 涂色重播逻辑
private int stepIndex = -1;//重播判断值,-1不处理,0及以上为重播到第几步 private int stepIndex = -1;//重播判断值,-1不处理,0及以上为重播到第几步
private static readonly float delay = 0.5f;//重播延迟 private static readonly float delay = 0.5f;//重播延迟
private static readonly float maxTime = 0.1f;//重播步间隔 private static readonly float maxTime = 0.1f;//重播步间隔
...@@ -174,7 +175,7 @@ public class GameMgr : MonoBehaviour ...@@ -174,7 +175,7 @@ public class GameMgr : MonoBehaviour
} }
#endregion #endregion
#region 保存逻辑 #region 自动保存逻辑
private float saveTime = -1;//保存判断值,由正变负则保存 private float saveTime = -1;//保存判断值,由正变负则保存
//保存接口,点击涂色触发 //保存接口,点击涂色触发
public void SaveTime() public void SaveTime()
...@@ -193,7 +194,7 @@ public class GameMgr : MonoBehaviour ...@@ -193,7 +194,7 @@ public class GameMgr : MonoBehaviour
saveTime -= Time.deltaTime; saveTime -= Time.deltaTime;
if (saveTime <= 0) if (saveTime <= 0)
{ {
md.Save(); SaveManager.Instance.SaveRes(md.key, md.dynamic, md.png);
Debug.Log("自动保存"); Debug.Log("自动保存");
} }
} }
......
This diff is collapsed.
...@@ -58,12 +58,12 @@ public class MaskItem : MonoBehaviour ...@@ -58,12 +58,12 @@ public class MaskItem : MonoBehaviour
//坐标计算 //坐标计算
Transform p = Rect.parent; Transform p = Rect.parent;
Rect.SetParent(md.imgpng.transform); Rect.SetParent(md.imgpng.transform);
Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2); Rect.localPosition = v - new Vector3(md.json.width / 2, md.json.height / 2);
Rect.SetParent(p); Rect.SetParent(p);
Rect.localScale = Vector2.one; Rect.localScale = Vector2.one;
SPRect.SetParent(md.imgpng.transform); SPRect.SetParent(md.imgpng.transform);
SPRect.localPosition = new Vector3(erd.size.x + (erd.size.z + 1 - erd.size.x) / 2 - (md.png.width + 1) / 2, erd.size.y + (erd.size.w + 1 - erd.size.y) / 2 - (md.png.height + 1) / 2, 0); SPRect.localPosition = new Vector3(erd.size.x + (erd.size.z + 1 - erd.size.x) / 2 - (md.json.width + 1) / 2, erd.size.y + (erd.size.w + 1 - erd.size.y) / 2 - (md.json.height + 1) / 2, 0);
SPRect.SetParent(Rect); SPRect.SetParent(Rect);
SPRect.localScale = Vector2.one; SPRect.localScale = Vector2.one;
...@@ -87,7 +87,7 @@ public class MaskItem : MonoBehaviour ...@@ -87,7 +87,7 @@ public class MaskItem : MonoBehaviour
Transform p = Rect.parent; Transform p = Rect.parent;
Rect.SetParent(md.imgpng.transform); Rect.SetParent(md.imgpng.transform);
Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2); Rect.localPosition = v - new Vector3(md.json.width / 2, md.json.height / 2);
Rect.SetParent(p); Rect.SetParent(p);
SPRect.SetParent(Rect); SPRect.SetParent(Rect);
......
...@@ -115,7 +115,7 @@ public class MaskItemMgr : MonoBehaviour ...@@ -115,7 +115,7 @@ public class MaskItemMgr : MonoBehaviour
ExRoomDatas erd = new ExRoomDatas(); ExRoomDatas erd = new ExRoomDatas();
for (int k = 0; k < rd.posIndex.Count; k++) for (int k = 0; k < rd.posIndex.Count; k++)
{ {
erd.AddData(rd.posIndex[k], GameMgr.Ins.md.png.width); erd.AddData(rd.posIndex[k], GameMgr.Ins.md.json.width);
} }
return Create(GameMgr.Ins.md, erd, rd.id, rd.groupId); return Create(GameMgr.Ins.md, erd, rd.id, rd.groupId);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment