Commit 16669b22 authored by Ever's avatar Ever

去除灰圖僅使用mask

parent 42e43354
......@@ -102,7 +102,7 @@ public class MainData : MonoBehaviour
GameMgr.Ins.giMgr.CircleId(id);
GameMgr.Ins.tiMgr.CircleId(id);
GameMgr.Ins.miMgr.Create(this, erd, v);
GameMgr.Ins.miMgr.Play(v, id);
EventDispatcher.Dispatch(EventName.Event.Event_GropuItemChange, json.roomGroupsData[i]);
SaveManager.Instance.SaveRes(key, json, png);
return true;
......@@ -150,7 +150,7 @@ public class MainData : MonoBehaviour
}
for (int i = 0; i < list.Count; i++)
{
GameMgr.Ins.giMgr.Create(this, dic[list[i]], list[i]);
GameMgr.Ins.miMgr.Create(this, dic[list[i]], list[i]);
}
}
......
......@@ -6,6 +6,7 @@ using UnityEngine.UI;
public class MaskItem : MonoBehaviour
{
public int id = -1;
public float IsUse = -1;
public Image SP;
public RectTransform Rect;
......@@ -15,7 +16,7 @@ public class MaskItem : MonoBehaviour
// Update is called once per frame
void Update()
{
if (IsUse == -1)
if (IsUse < 0)
{
return;
}
......@@ -28,8 +29,10 @@ public class MaskItem : MonoBehaviour
}
}
public void FunDo(MainData md, ExRoomDatas erd, Vector3 v)
public void FunDo(MainData md, ExRoomDatas erd, int _id)
{
Vector3 v = Vector3.zero;
id = _id;
//创建图片
Texture2D te = new Texture2D((int)(erd.size.z - erd.size.x + 1), (int)(erd.size.w - erd.size.y + 1), TextureFormat.RGBA32, false);
Color[] colors = te.GetPixels();
......@@ -69,6 +72,21 @@ public class MaskItem : MonoBehaviour
Rect.sizeDelta = Vector2.zero;
float a = Math.Max(erd.size.z - v.x, v.x - erd.size.x);
float b = Math.Max(erd.size.w - v.y, v.y - erd.size.y);
IsUse = Math.Max(a, b) * 2;
IsUse = -Math.Max(a, b) * 2;
}
internal void Play(Vector3 v)
{
MainData md = GameMgr.Ins.md;
SPRect.SetParent(md.imgpng.transform);
Transform p = Rect.parent;
Rect.SetParent(md.imgpng.transform);
Rect.localPosition = v - new Vector3(md.png.width / 2, md.png.height / 2);
Rect.SetParent(p);
SPRect.SetParent(Rect);
IsUse *= -1;
}
}
using DG.Tweening;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
......@@ -27,9 +28,20 @@ public class MaskItemMgr : MonoBehaviour
poolList.Add(temp);
}
}
public void Create(MainData md, ExRoomDatas erd, Vector3 v)
public void Create(MainData md, ExRoomDatas erd, int id)
{
MaskItem temp = Get();
temp.FunDo(md, erd, v);
temp.FunDo(md, erd, id);
}
}
public void Play(Vector3 v, int id)
{
for (int i = 0; i < useList.Count; i++)
{
if (useList[i].id == id)
{
useList[i].Play(v);
}
}
}
}
\ No newline at end of file
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