Commit 3b4b25f7 authored by JiangWanZhi's avatar JiangWanZhi

添加一些备注

parent ac8baf3f
......@@ -24,7 +24,7 @@ public class GameScenUserInfo
//以上是url
public int status = 0;//0 未开始 1 这个id进过游戏 2 至少有一个区域点亮 3完成
public double progress = 0;//0 -- 1 具体自己算百分比
public List<AreaInfoUseData> areaInfoUseData = new List<AreaInfoUseData>();
public List<AreaInfoUseData> areaInfoUseData = new List<AreaInfoUseData>(); //涂的区域的顺序
private string getUrlByLocalPath(string url)
{
if (url.StartsWith("http") == false) return "";
......
......@@ -6,7 +6,7 @@ using UnityEngine;
public class gameAreaGroupItem
{
public short id;
public List<short> roomIds;
public List<short> roomIds; //属于这个组的区域id‘集合
public float R;
public float G;
public float B;
......
......@@ -12,10 +12,10 @@ public class gameAreaItem
public float G;
public float B;
public short id;
public short gid = -1;//id
public short valid;//未知含义 未启用
public short useAreaData;//未知含义 未启用
public bool notPaintCol;//未启用
public short gid = -1;//��id
public short valid;//δ֪���� δ����
public short useAreaData;//δ֪���� δ����
public bool notPaintCol;//���
public string tempExKey = "";
public bool isShow = false;
public int threadHandState = 0;
......
......@@ -3,7 +3,7 @@ using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
public class gameIdJsonData
public class gameIdJsonData //json文件的所有数据
{
public string nowId = "";
public short width = 0;
......
......@@ -17,6 +17,7 @@ class DebugNetHotData
public bool isFile;
public string msg;
}
//初始化、下载、解压
public class gameSceneLogic : MonoBehaviour, IEventHandler
{
// Start is called before the first frame update
......@@ -58,18 +59,18 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
}
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
onEvent("switchGameAreaGroupId",this.onEvent_switchGameAreaGroupId_Handler);
onEvent("gameViewOnInitEnd",this.onEvent_gameViewOnInitEnd_Handler);
onEvent("gameClickPos",this.onEvent_gameClickPos_Handler);
onEvent("inGameLoadingBarEnd",this.onEvent_inGameLoadingBarEnd_Handler);
onEvent("showAreaEventOk", onSelectAreaEvent);
onEvent("initViewShowData", onInitViewShowDataEvent);
onEvent("changeGameUserProgress", onChangeGameUserProgressEvent);
onEvent("tipShowPosMaxScale", onTipShowPosMaxScaleEvent);
onEvent("gamePlayerEndHandler", onGamePlayerEndHandlerEvent);
onEvent("closeGameScene", onCloseGameSceneEvent);
onEvent("removeGroupByGid", onRemoveGroupByGidEvent);
transform.Find("ingameLoad/loadImg").gameObject.SetActive(false);
onEvent("switchGameAreaGroupId",this.onEvent_switchGameAreaGroupId_Handler); //切换组的ID
onEvent("gameViewOnInitEnd",this.onEvent_gameViewOnInitEnd_Handler); //游戏图片初始化完成
onEvent("gameClickPos",this.onEvent_gameClickPos_Handler); //灰色的点击回掉
onEvent("inGameLoadingBarEnd",this.onEvent_inGameLoadingBarEnd_Handler); //进入游戏的进度条加载完成
onEvent("showAreaEventOk", onSelectAreaEvent); //当前组的都涂完了
onEvent("initViewShowData", onInitViewShowDataEvent); //初始化数据完成
onEvent("changeGameUserProgress", onChangeGameUserProgressEvent); //整体进度改变
onEvent("tipShowPosMaxScale", onTipShowPosMaxScaleEvent); // 点提示,当前组随机一个没涂的位置放大
onEvent("gamePlayerEndHandler", onGamePlayerEndHandlerEvent); //整个大图都涂完了
onEvent("closeGameScene", onCloseGameSceneEvent); //关游戏
onEvent("removeGroupByGid", onRemoveGroupByGidEvent); //自动涂gid不一致会调过来
transform.Find("ingameLoad/loadImg").gameObject.SetActive(false);
//gameScenUser
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(false);
......@@ -86,8 +87,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
addHotParams<float>("TUSE_doubleTouchScale", "doubleTouchScale", float.TryParse);
addHotParams<short>("TUSE_areaOutValue", "areaOutValue", short.TryParse);
addHotParams<float>("TUSE_MoveScale", "moveScale", float.TryParse);
addHotParams<float>("TUSE_doubleTouchScale", "doubleTouchScale", float.TryParse);
addHotParams<float>("TUSE_doubleTouchScale", "doubleTouchScale", float.TryParse);
addHotParams<float>("TUSE_dyMinShowFontSize", "dyMinShowFontSize", float.TryParse);
addHotParams<int>("TUSE_PhoneOffsetValue", "PhoneOffsetValue", int.TryParse);
return true;
......@@ -101,7 +100,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
void addHotParams<T>(string netKey,string localKey, StringOutTValue<T> back, NotifyBoolParam notifyBoolParam = null)
{
string url = string.Format("http://www.xn--3-y50c.com:8560/keysOper?key={0}", netKey);
string url = $"http://www.xn--3-y50c.com:8560/keysOper?key={netKey}";
utilsTools.setGDataByKey(url,localKey);
utilsTools.httpGET(this, url, true, (string id, string url, bool isSuccess, System.Object data) =>
{
......@@ -131,6 +130,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
{
ActionManages.update();
}
//创建列表item的时候回调并设置、初始化和刷新
private void onUpdateGroupGridHandler(GameObject gobject, int idx, ListViewBackTypeEnum lvbType,TempGroupInfos group,bool isFirst = false)
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
......@@ -170,6 +171,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
childEventHandlers[eventName](uobjects, objects);
}
}
//切换组的id
private void onEvent_switchGameAreaGroupId_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
Vector3 vector3;
......@@ -203,6 +205,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
}
});
}
//游戏图片初始化完成
private void onEvent_gameViewOnInitEnd_Handler(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
......@@ -364,7 +367,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
//rectTransform2.localPosition = new Vector3(rectTransform2.localPosition.x, transform1.localPosition.y - 10);
}
private void handlerLoadingPosition(Image image)
private void handlerLoadingPosition(Image image) //进度条上面的图缩放一下
{
Debug.Log("handlerLoadingPosition hand endl");
image.gameObject.SetActive(true);
......@@ -427,11 +430,11 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
{
Debug.Log("handlerLoadingPosition hand begin");
string zpath = utilsTools.getWritableByPath("outFiles/" + gameScenUser.id + ".zip");
if (utilsTools.IsPhone == false)
if (utilsTools.IsWin == true)
zpath = zpath.Replace("/", "\\");
gameScenUser.createWorkDirectory();
string outPath = GameScenUserInfo.getAllRoot();
if(utilsTools.IsPhone == false)
if(utilsTools.IsWin == true)
{
outPath = outPath.Replace("/", "\\");
}
......@@ -447,51 +450,14 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
utilsTools.setGDataByKey("downGaoQing", utilsTools.getTotalMillisecond());
gameShowView.GetComponent<mainGameView>().loadGameImgId();
if (utilsTools.IsExistIO(lineImg) == false)
{
//utilsTools.httpDOWNIMG(this, gameScenUser.img, lineImg, (string id, string url, bool isSuccess, System.Object data) =>
//{
// return onDownColorImgHandler(id, url, isSuccess, data, lineImg);
//});
}
else
{
//if (utilsTools.IsExistIO(suoluetu) == false)
//{
// //utilsTools.loadLocalImage(this, image, lineImg, (bool isOk) =>
// //{
// // if (isOk)
// // {
// // Debug.Log("sdfdsfds " + (utilsTools.getTotalMillisecond() - temp1).ToSafeString());
// // image.color = Color.white;
// // handlerLoadingPosition(image);
// // }
// //});
//}
//else
//{
// int temp1 = utilsTools.getTotalMillisecond();
// utilsTools.loadLocalImage(this, image, suoluetu, (bool isOk) =>
// {
// if (isOk)
// {
// Debug.Log("sdfdsfds " + (utilsTools.getTotalMillisecond() - temp1).ToSafeString());
// image.color = Color.white;
// handlerLoadingPosition(image);
// }
// });
//}
}
}
//下载和解压zip 没有下载过就去下载线稿图
void onInitViewShowDataEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
utilsTools.setGDataByKey("firstT", utilsTools.getTotalMillisecond());
GameScenUserInfo gameScenUser = (GameScenUserInfo)objects[0];
string zpath = utilsTools.getWritableByPath("outFiles/" + gameScenUser.id+".zip");
if (utilsTools.IsPhone == false)
if (utilsTools.IsWin == true)
zpath = zpath.Replace("/", "\\");
string suoluetu = gameScenUser.getLocalThumbnailPath();
Image image = transform.Find("ingameLoad/loadImg").GetComponent<Image>();
......@@ -563,6 +529,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
}
}
//整体的进度改变
void onChangeGameUserProgressEvent(List<UnityEngine.Object> uobjects,List<System.Object> objects) {
int pro = (int)objects[0];
transform.Find("ingameLoad").gameObject.SetActive(false);
......@@ -571,6 +538,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
UnityEngine.UI.Slider slider = transform.Find("gameProgress").GetComponent<UnityEngine.UI.Slider>();
slider.value = pro;
}
//点提示,当前组随机一个没涂的位置放大
void onTipShowPosMaxScaleEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
System.Object obj = objects[0];
......@@ -579,6 +547,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
gameAreaItem gameAreaItem1 = obj as gameAreaItem;
gameShowView.GetComponent<mainGameScaleMove>().onTipShowPosMaxScale(gameAreaItem1,width,height);
}
//整个大图都涂完了
void onGamePlayerEndHandlerEvent(List<UnityEngine.Object> uobjects,List<System.Object> objects)
{
//Debug.Log("游戏完成,播放结束动画");
......@@ -597,6 +567,8 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
// return false;
// }, 10);
}
//当前组的都涂完了
void onSelectAreaEvent(List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
gameAreaItem gameArea = (gameAreaItem)objects[0];
......
......@@ -44,7 +44,7 @@ public class replayerBack : MonoBehaviour, IEventHandler
initData();
return false;
}, 5);
//string tuijian = "{\"status\":200,\"msg\":\"请求成功\",\"sign\":\"\",\"result\":{\"data\":[";
//string tuijian = "{\"status\":200,\"msg\":\"����ɹ�\",\"sign\":\"\",\"result\":{\"data\":[";
//for (int i = 0; i < 8; i++)
//{
// tuijian = tuijian + json + ",";
......@@ -132,7 +132,7 @@ public class replayerBack : MonoBehaviour, IEventHandler
keyValuePairs.Add(idx, true );
}
List<Vector2Int> removeLists = new List<Vector2Int>();
foreach (var item in GroupByAreaPtInfos.mapAllDatas)//因为有特意裁处空白保持圆角和长的非1:2
foreach (var item in GroupByAreaPtInfos.mapAllDatas)//��Ϊ������ô��հױ���Բ�Ǻͳ��ķ�1:2
{
for (int i = 0; i < item.Value.Count; i++)
{
......@@ -159,11 +159,11 @@ public class replayerBack : MonoBehaviour, IEventHandler
GameScenUserInfo gameScenUser = (GameScenUserInfo)objects[0];
nowGameScenUser = gameScenUser;
string zpath = utilsTools.getWritableByPath("outFiles/" + gameScenUser.id + ".zip");
if (utilsTools.IsPhone == false)
if (utilsTools.IsWin == true)
zpath = zpath.Replace("/", "\\");
string suoluetu = gameScenUser.getColorImgLocalPath();//gameScenUser.getLocalThumbnailPath();
Image image = mainShowView.GetComponent<Image>();
image.color = new Color(1, 1, 1, 0);//未加载出来时候就透明化
image.color = new Color(1, 1, 1, 0);//δ���س���ʱ���͸����
string key = gameScenUser.id + "_showAd";
showAd = utilsDB.getDBBoolDataByKey(key, showAd);
if (utilsTools.IsExistIO(suoluetu) == false)
......@@ -319,7 +319,7 @@ public class replayerBack : MonoBehaviour, IEventHandler
utilsTools.sendEvent("CloseScenePrve");
utilsTools.addTimer_Update(gameObject, "close", (String name) =>
{
Debug.Log("关闭");
Debug.Log("�ر�");
var gameBackJavaData = utilsTools.getGDataByKey<GameBackJavaData>("gameBackJavaData", null);
gameBackJavaData.name = "replayer";
if (gameBackJavaData == null)
......@@ -499,7 +499,7 @@ public class replayerBack : MonoBehaviour, IEventHandler
{
if (mp4OperNext == 1)
{
Debug.Log("分享中");
Debug.Log("������");
gameObject.transform.Find("inSaveProgress").gameObject.SetActive(false);
utilsTools.share("", gameObject.name,"");
}
......@@ -507,7 +507,7 @@ public class replayerBack : MonoBehaviour, IEventHandler
{
gameObject.transform.Find("inSaveProgress/fore").gameObject.SetActive(false);
gameObject.transform.Find("inSaveProgress/end").gameObject.SetActive(true);
Debug.Log("保存完成");
Debug.Log("�������");
}
}
}
......
......@@ -6,7 +6,7 @@ using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
//这个节点必须在现实的下边
//����ڵ��������ʵ���±�
class PosChecks
{
public Vector2 pos;
......@@ -122,7 +122,7 @@ public class checkRootFirstRun : MonoBehaviour
var an1 = new Vector2(x1, y1);
Debug.Log(an1);
utilsTools.setAnchor(gobject, an1);
if(utilsTools.IsPhone == false){
if(utilsTools.IsWin == true){
gobject.localScale = new Vector2(0.2f, 0.2f);
ActionManages.addMoveByScale(gobject.gameObject, 9, 5f, (GameObject _, int id) =>{
gobject.localScale = new Vector2(0.2f, 0.2f);
......@@ -134,7 +134,7 @@ public class checkRootFirstRun : MonoBehaviour
int i = posChecks[0].isUse == false ? 0 : (posChecks[1].isUse == false ? 1 : -1);
if(i == -1)
{
//先清理一边老的的
//������һ���ϵĵ�
drawBlock(posChecks[0].pos, backColor);
posChecks[0].isUse = false;
drawBlock(posChecks[1].pos, backColor);
......@@ -167,7 +167,7 @@ public class checkRootFirstRun : MonoBehaviour
}
private void LateUpdate()
{
if (utilsTools.IsPhone)
if (utilsTools.IsWin)
{
if (Input.touchCount == 2)
{
......@@ -271,13 +271,13 @@ public class checkRootFirstRun : MonoBehaviour
Vector2 vector = utilsTools.ScreenToUILocalPos(rectTransform, tempPos.pos);
if (rectTransform.rect.Contains(vector))
{
Debug.Log("在区域内");
Debug.Log("��������");
tempPos.pos = vector;
pushDrawPos();
}
else
{
Debug.Log("不在区域内");
Debug.Log("����������");
}
}
}
......
......@@ -7,7 +7,7 @@ using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class mainGameOneImageView : mainGameView
public class mainGameOneImageView : mainGameView //回放上面,回放用的是一张图片
{
// Start is called before the first frame update
public GameObject oneImg = null;
......@@ -169,7 +169,7 @@ public class mainGameOneImageView : mainGameView
});
if (cout == 0)
{
//没有可渲染区域
//û�п���Ⱦ����
removeAids.Add(item.m_aid);
List<Vector2Short> tempLineColors = new List<Vector2Short>();
groupPtInfo.getLineByAid(item.m_aid,ref tempLineColors);
......@@ -207,7 +207,7 @@ public class mainGameOneImageView : mainGameView
if (removeAids.Count > 0)
{
//移除已经播放完成
//�Ƴ��Ѿ��������
foreach (var aid in removeAids)
{
for (int i = 0; i < showAreaAnimationDatas.Count; i++)
......@@ -222,7 +222,7 @@ public class mainGameOneImageView : mainGameView
drawThumbnailByAid(removeAids);
if (showAreaAnimationDatas.Count == 0)
{
//保存一次缩略遮罩
//����һ����������ͼ
if (utilsTools.isEqualByValue(gameScenUseInfo.progress, 1.0, 0.0000002f))
{
TaskManages.getInstance().addTask(this, (System.Object[] parma) =>
......@@ -249,7 +249,7 @@ public class mainGameOneImageView : mainGameView
}, 4);
return;
}
//为缩略图准备
//Ϊ����ͼ׼��
Vector2Short vector2Short = allColorSize["final"];
Vector2Short vector2ShortOut = allColorSize["outColor"];
Color[] colors = new Color[vector2Short.x * vector2Short.y];
......@@ -308,7 +308,7 @@ public class mainGameOneImageView : mainGameView
lineImg.SetActive(false);
return;
}
//显示指定区域
//��ʾָ������
if (GroupByAreaPtInfos.mapAllDatas.ContainsKey((short)areaId))
{
gameAreaItem areaItem1 = gameidJsondata.getAid((short)areaId);
......@@ -329,7 +329,7 @@ public class mainGameOneImageView : mainGameView
allColor2["outColor"][idx] = color;
allColor2["thumbnail"][y * size2.x + x] = color;
}
//边缘怎么弄?
//��Ե��ôŪ?
if (isApply == true)
{
Apply();
......@@ -341,7 +341,7 @@ public class mainGameOneImageView : mainGameView
}
}
//回放使用
//�ط�ʹ��
public void showAreaPrveClear(bool isfirst) {
if(InitEndIsShowLine == false)
{
......@@ -373,7 +373,7 @@ public class mainGameOneImageView : mainGameView
}
public override void resetSize()
{
//怎么保持宽高比
//��ô���ֿ��߱�
if (InitEndIsShowLine == true)
{
float width = gameidJsondata.width;
......@@ -391,7 +391,7 @@ public class mainGameOneImageView : mainGameView
width = utilsTools.DisplaySize.x * 0.65f;
height = width * 2;
}
//确定好宽高后赋
//ȷ���ÿ��ߺ�ֵ
GameObject[] gameObjects = { oneImg, areaIdBase };
Vector3 tempPos = rectTransform.localPosition;
if (width.Equals(height) == false)
......@@ -533,10 +533,11 @@ public class mainGameOneImageView : mainGameView
});
}
}
public void idHashPosToArrayPosEx()
public void idHashPosToArrayPosEx()
{
idHashPosToArrayPos();
//将边缘重复放入周边区域
//����Ե�ظ������ܱ����� 将边缘重复放入周边区域
for (int i = 0; i < allBianLun.Count(); i++)
{
int idx = allBianLun[i];
......@@ -729,13 +730,13 @@ public class mainGameOneImageView : mainGameView
}
utilsTools.setGDataByKey("loadBinBegin", utilsTools.getTotalMillisecond());
string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin";
if (utilsTools.IsPhone == false)
if (utilsTools.IsWin == true)
{
binpath = binpath.Replace("/", "\\");
}
Byte[] bytes = File.ReadAllBytes(binpath);
bytesInitDigitMatrix(bytes);
Debug.Log("bin初始化完成--------------");
Debug.Log("bin��ʼ�����--------------");
int start = 0;
int step = BitConverter.GetBytes((short)2).Length;
int stepInt = BitConverter.GetBytes(65539).Length;
......
......@@ -68,6 +68,8 @@ public class mainGameScaleMove : MonoBehaviour
resetBtn.SetActive(false);
}
}
public void setCheckInput()
{
if (checkInput == null)
......@@ -273,11 +275,17 @@ public class mainGameScaleMove : MonoBehaviour
}
Vector2 diff = new Vector2(Input.mousePosition.x + winPrvePos.x,Input.mousePosition.y + winPrvePos.y);
onOneTouchMove(Input.mousePosition, diff);
}else if(utilsTools.ContainsKey(gameObject, "oneTouchBegin"))
}
else if(utilsTools.ContainsKey(gameObject, "oneTouchBegin"))
{
Vector2 diff = new Vector2(Input.mousePosition.x + winPrvePos.x, Input.mousePosition.y + winPrvePos.y);
onOneTouchEnd(Input.mousePosition, diff);
}
}
private void onOneTouchBegin(Vector2 vector2)
{
......@@ -367,7 +375,7 @@ public class mainGameScaleMove : MonoBehaviour
// Update is called once per frame
void Update()
{
if (checkInput != null)
{
if (utilsTools.getGDataByKey<bool>("enableZoomMove", false))
......@@ -375,7 +383,6 @@ public class mainGameScaleMove : MonoBehaviour
checkInput();
}
}
}
private void updateScaleView()
{
......@@ -406,12 +413,13 @@ public class mainGameScaleMove : MonoBehaviour
Vector3 pos = new Vector3();
float ptx = areaItem.px / width * 1.0f;//百分比
float pty = areaItem.py / height * 1.0f;
for (int i = 0; i < transform.childCount; i++)
{
var itemChild = transform.GetChild(i);
itemChild.localScale = nowScale;
}
Debug.Log(areaItem.ToString());
RectTransform idAreaRectTransform = transform.Find("areaIdBase/" + areaItem.tempExKey).GetComponent<RectTransform>();
pos = idAreaRectTransform.localPosition * -1 * nowScale / initScale;
......
......@@ -13,40 +13,40 @@ using System.Threading;
using TMPro;
using Unity.VisualScripting;
public class mainGameView : MonoBehaviour
public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
{
protected gameIdJsonData gameidJsondata = null;
private string progresName = "";
public GameObject lineImg = null;//线图
public GameObject colorImg = null;//颜色图
public GameObject lowImg = null;//底图
public GameObject areaIdBase = null;
public GameObject areaIdBase = null; //显示的区域数字的父节点
[Header("区域id的预制体")]
public string perfabPath = "";
private GameObject areaIdperfabObj = null;
private GameObject areaIdperfabObj = null; //加载出来的区域的数字预制体
public DigitMatrixShort digitMatrix = null;
public float minShowFontSize = 20f;
public float showFontSizeMax = 30f;
protected Texture2D lineTexture2d = null;
private Texture2D lowImgTexture2d = null;
private Texture2D colorTexure2d = null;
protected short nowSelectgid = -1;
protected bool fillAnimation = true;
private string[] initDigitMatrixs = { "", "","" };
protected Dictionary<short, short> aid2selectOrderIdx = new Dictionary<short, short>();
protected Texture2D lineTexture2d = null; //线
private Texture2D lowImgTexture2d = null; //底
private Texture2D colorTexure2d = null; //彩
protected short nowSelectgid = -1; //当前选中的组id
protected bool fillAnimation = true; //填充动画开关
private string[] initDigitMatrixs = { "", "","" }; //选中图,高清图,线稿图 这个三个都不为空就是初始化完了
protected Dictionary<short, short> aid2selectOrderIdx = new Dictionary<short, short>(); //已经涂的区域 key是aid(区域id),value是json数组的下标
protected GameScenUserInfo gameScenUseInfo = null;
//x,y aid 当前帧向量 起点终点 等宽度计算扩散
protected List<AreaAnimationDiffuse> showAreaAnimationDatas = new List<AreaAnimationDiffuse>();
protected List<AreaAnimationDiffuse> showAreaAnimationDatas = new List<AreaAnimationDiffuse>(); //等待显示动画的区域
protected Dictionary<short, GroupByAreaPtInfos> groupPtInfos = new Dictionary<short, GroupByAreaPtInfos>();
protected Dictionary<short, GroupByAreaPtInfos> groupPtInfos_All = new Dictionary<short, GroupByAreaPtInfos>();//不管是否涂色都会记录
protected short bianlun = -1;
protected short fullShow = -2;
protected Texture2D thumbnailTexture2d = null;
protected short bianlun = -1; //表示这个是线
protected short fullShow = -2; //标记已经涂过的
protected Texture2D thumbnailTexture2d = null; //缩略图,无动画
private bool isDebugTestToEnd = false;
public GameObject clickPosEff = null;
Dictionary<string, Color[]> allColor = new Dictionary<string, Color[]>();
Dictionary<string, Color[]> allColor = new Dictionary<string, Color[]>(); //key: line color thumbnail
[SerializeField]
protected int selectTextureIdx = 1;
protected int selectTextureIdx = 1;
static protected string[] allSelectTexturePaths = {
"scenes/game/cells/grayCell",
"scenes/game/cells/buleCell",
......@@ -106,7 +106,7 @@ public class mainGameView : MonoBehaviour
}
}
}
public void onInitDigitMatrix(string name)
public void onInitDigitMatrix(string name) //判断选中、高清、线稿图有没有初始化完
{
Debug.Log("onInitDigitMatrix >> " + name);
......@@ -195,26 +195,12 @@ public class mainGameView : MonoBehaviour
nowSelectgid = -1;
resetSize();
onInitEndHandler();
if (thumbnailTexture2d != null) {
//utilsTools.addTimer_Update(gameObject, "shouhuThumbnailIsChange", (String _) =>
//{
// if (thumbnailIsChange == true)
// {
// thumbnailIsChange = false;
// thumbnailTexture2d.SetPixels(allColor["thumbnail"]);
// string path = gameScenUseInfo.getLocalThumbnailPath();
// var sltTextureSize = utilsTools.getGDataByKey<Vector2>("sltTextureSize", Vector2.one);
// utilsTools.saveByteToPath(utilsTools.ScaleTexture(thumbnailTexture2d, Convert.ToInt32(sltTextureSize.x), Convert.ToInt32(sltTextureSize.y)).EncodeToJPG(), path);
// utilsTools.saveByteToPath(thumbnailTexture2d.EncodeToJPG(), path);
// }
// return true;
//}, 120, 0);
}
}
protected string getSelectPathByGid(int gid)
{
return gameScenUseInfo.getPathByFormath("groupId_{0}.png",gid);
}
public void saveGroupTexture(int pgid,Texture2D nowGroupIdTexture,bool isDestroy = true)
{
string temppath = getSelectPathByGid(pgid);
......@@ -256,7 +242,6 @@ public class mainGameView : MonoBehaviour
GroupByAreaPtInfos.width = gameidJsondata.width;
GroupByAreaPtInfos.height = gameidJsondata.height;
int t1 = utilsTools.getTotalMillisecond();
Dictionary<short, RectInt> aidByRect = fillAnimation ? new Dictionary<short, RectInt>() : null;
float maxWidth = (float)(gameidJsondata.width + 1f);
float maxHeight = (float)(gameidJsondata.height + 1f);
RectInt model = new RectInt();
......@@ -271,10 +256,6 @@ public class mainGameView : MonoBehaviour
aidToIndex.Add(item, fid);
var temp2 = new List<int>(2400);
AidVersions2.Add(item, temp2);
if (aidByRect != null)
{
aidByRect.Add(item, new RectInt(model));
}
}
groupPtInfos_All.Add(gid, groupByAreaPtInfos);
}
......@@ -295,14 +276,7 @@ public class mainGameView : MonoBehaviour
short aid = (short)(cell - 20);
cout1++;
AidVersions2[aid].Add(y * digitMatrix.RowCount + x);
if(aidByRect != null)
{
RectInt rectInt = aidByRect[aid];
if (rectInt.left > x) rectInt.left = x;
if(rectInt.right < x) rectInt.right = x;
if(rectInt.top > y) rectInt.top = y;
if(rectInt.dowm < y) rectInt.dowm = y;
}
}
}
}
......@@ -320,6 +294,9 @@ public class mainGameView : MonoBehaviour
}
}
}
}
public void onLineColorHandlerEnd()
{
......@@ -333,7 +310,7 @@ public class mainGameView : MonoBehaviour
}
Color[] colors = lineTexture2d.GetPixels(0, 0, lineTexture2d.width, lineTexture2d.height);
List<Vector2Short> temp = null;
foreach (var item in aid2selectOrderIdx)
foreach (var item in aid2selectOrderIdx)//显示已经涂过的区域,将线稿图的对应区域变为彩色
{
var aidData = gameidJsondata.getAid(item.Key);
if (groupPtInfos_All[aidData.gid].getDataByAid(item.Key, ref temp) && temp.Count > 0)
......@@ -368,7 +345,7 @@ public class mainGameView : MonoBehaviour
}
public void onLoadFileOk(int typeId)
{
if (typeId == 1)
if (typeId == 1) // 1(线稿图)、2(彩色图)是一张图片
{
lineTexture2d = lineImg.GetComponent<Image>().sprite.texture;
TaskManages taskManages = TaskManages.getInstance();
......@@ -422,7 +399,7 @@ public class mainGameView : MonoBehaviour
return false;
}, 5, 100000);
}
else if(typeId == 4)
else if(typeId == 4) // 选中的图
{
TaskManages tm = TaskManages.getInstance();
TaskItemBack checkPtNextHandler = null;
......@@ -478,7 +455,7 @@ public class mainGameView : MonoBehaviour
}
}
}
protected void checkAddAreaId()
protected void checkAddAreaId()//显示图上面的数字(区域id)
{
float width = gameidJsondata.width;
float height = gameidJsondata.height;
......@@ -532,14 +509,14 @@ public class mainGameView : MonoBehaviour
}
}
}
public void updateScaleView()
public void updateScaleView() //更新缩放视图大小
{
if (areaIdBase == null) return;
Vector3 vector3 = areaIdBase.transform.localScale;
float dyMinShowFontSize = utilsTools.getGDataByKey<float>("dyMinShowFontSize", minShowFontSize);
if (areaIdBase != null && perfabPath.Equals("") == false)
{
//倍数怎么弄
//倍数怎么弄 ,后面需要根据相机距离和区域大小去调整字体的大小
for (int i = 0; i < gameidJsondata.roomDatas.Count; i++)
{
var item = gameidJsondata.roomDatas[i];
......@@ -689,7 +666,7 @@ public class mainGameView : MonoBehaviour
});
}
}
protected virtual void bytesInitDigitMatrix(Byte[] bytes)
protected virtual void bytesInitDigitMatrix(Byte[] bytes) //转bin文件为二维数组
{
int start = 0;
int step = BitConverter.GetBytes((short)2).Length;
......@@ -740,10 +717,11 @@ public class mainGameView : MonoBehaviour
TaskManages.getInstance().insertTask(this, (System.Object[] _) =>
{
string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin";
if(utilsTools.IsPhone == false)
if(utilsTools.IsWin == true)
{
binpath = binpath.Replace("/", "\\");
}
Byte[] bytes = File.ReadAllBytes(binpath);
bytesInitDigitMatrix(bytes);
Debug.Log("bin初始化完成--------------");
......@@ -834,6 +812,8 @@ public class mainGameView : MonoBehaviour
}
});
}
//
public virtual void showArea(int areaId, OnAreaHandler onAreaHandler = null,bool isApply = true)
{
if (areaId == -1)
......@@ -860,6 +840,7 @@ public class mainGameView : MonoBehaviour
}
}
//切换显示的组
public virtual bool switchShowAreaGroup(short gid, OnAreaHandler onAreaHandler = null)
{
if (gid .Equals(nowSelectgid))
......@@ -1031,7 +1012,7 @@ public class mainGameView : MonoBehaviour
{
if(showBack!= null)
showBack(-1, false);
return -1;
return -1; //还没初始化
}
short oldValue = digitMatrix.Data[x, y];
if (oldValue < 20)
......@@ -1039,7 +1020,7 @@ public class mainGameView : MonoBehaviour
if (showBack != null)
showBack(-1, false);
return oldValue.Equals(bianlun) ? -2 : -3;
return oldValue.Equals(bianlun) ? -2 : -3; //已经涂上色的再点
}
short aid = (short)(oldValue - 20);
foreach (var item in showAreaAnimationDatas)//边界判定 卡顿并且尚未重置中心点时候
......@@ -1047,14 +1028,14 @@ public class mainGameView : MonoBehaviour
if(item.m_aid.Equals(aid))
{
if (showBack != null) showBack(-1, false);
return -3;
return -3; //已经点过了,但还没处理
}
}
var areaItem = gameidJsondata.roomDatas[aid];
if(gameidJsondata.getRoomGroup(nowSelectgid).roomIds.IndexOf(aid) < 0 && ignoreGid.Equals(false))
{
if (showBack != null) showBack(aid, false);
return -4;
return -4; //点的不是这个组的色块
}
if (areaItem.isShow)
{
......@@ -1113,9 +1094,52 @@ public class mainGameView : MonoBehaviour
showBack(aid, true);
return 1;
}
Vector3 mouse_oldpos;
Vector3 mouse_nowpos;
bool flag;
private void Update()
{
baseUpdate();
if (Input.mouseScrollDelta.y < 0) //滚轮向前滚动
{
var scal = new Vector3(transform.localScale.x - Input.mouseScrollDelta.y, transform.localScale.y - Input.mouseScrollDelta.y, 0);
if (scal.x > 5)
scal = Vector3.one * 5;
transform.localScale = scal;
}
if (Input.mouseScrollDelta.y > 0) //滚轮向后滚动
{
var scal = new Vector3(transform.localScale.x - Input.mouseScrollDelta.y, transform.localScale.y - Input.mouseScrollDelta.y, 0);
if (scal.x < 1)
scal = Vector3.one;
transform.localScale = scal;
}
if (Input.GetMouseButton(0)) //暂时先这样实现编辑器里的鼠标拖动
{
if (flag)
{
mouse_nowpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
if (mouse_nowpos != mouse_oldpos)
{
float pos_x = (mouse_oldpos.x - mouse_nowpos.x)*transform.localScale.x;
float pos_y = (mouse_oldpos.y - mouse_nowpos.y)*transform.localScale.x;
transform.localPosition = new Vector3(transform.localPosition.x - pos_x, transform.localPosition.y - pos_y, 0);
}
}
else
{
mouse_oldpos= Camera.main.ScreenToWorldPoint(Input.mousePosition);
}
mouse_nowpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
flag = true;
}
if (Input.GetMouseButtonUp(0))
{
flag = false;
}
}
// Update is called once per frame
protected void baseUpdate()
......@@ -1126,7 +1150,7 @@ public class mainGameView : MonoBehaviour
{
TaskManages.getInstance().updateTask(this);
}
protected virtual void onShowAnimationHandler()
protected virtual void onShowAnimationHandler()//对点击色块区域后的处理
{
if(showAreaAnimationDatas.Count > 0)
......@@ -1140,6 +1164,7 @@ public class mainGameView : MonoBehaviour
short nowCheckId = (short)(item.m_aid + 20);
var groupPtInfo = groupPtInfos[gid];
int cout = 0;
//这儿播放上色的动画效果
utilsTools.Ring(item.m_x, item.m_y, item.m_fpsEnd, item.m_fpsStart, gameidJsondata.width, gameidJsondata.height,(int x, int y, int idx) =>
{
short nowValue = digitMatrix.Data[x, y];
......@@ -1216,7 +1241,6 @@ public class mainGameView : MonoBehaviour
drawThumbnailByAid(removeAids);
if (showAreaAnimationDatas.Count == 0)
{
//保存一次缩略遮罩图
if (utilsTools.isEqualByValue(gameScenUseInfo.progress, 1.0, 0.0000002f))
{
......@@ -1415,8 +1439,6 @@ public class mainGameView : MonoBehaviour
//提示的查找过程
public void onTipHandler()
{
if (isDebugTestToEnd == false)
{
if (nowSelectgid >= 0)
{
var roomGroup = gameidJsondata.getRoomGroup(nowSelectgid);
......@@ -1452,65 +1474,64 @@ public class mainGameView : MonoBehaviour
}
}
}
}
else if (nowSelectgid >= 0)
{
var roomGroup = gameidJsondata.getRoomGroup(nowSelectgid);
if (groupPtInfos.ContainsKey(nowSelectgid) == false)
{
return;
}
var aidpts = groupPtInfos[nowSelectgid];
short[] noshowAids = aidpts.getDataAllKey();
List<short> aids = new List<short>();
if (noshowAids.Length > 0)
{
short aid = -1;
for (int i = 0; i < noshowAids.Length; i++)
{
aid = noshowAids[i];
foreach (var item in showAreaAnimationDatas)
{
if (aid.Equals(item.m_aid))
{
aid = -1;
break;
}
}
if (aid > -1)
{
aids.Add(aid);
}
}
}
if (aids.Count > 0)
{
TaskManages.getInstance().addTask(this, (System.Object[] p) =>
{
List<short> showAids = (List<short>)p[0];
foreach (var item in showAids)
{
var tipAidInfo = gameidJsondata.getAid(item);
showAreaByPos(tipAidInfo.px, tipAidInfo.py, null);
break;
}
utilsTools.addTimer_Update(gameObject, "sdcdvc", (String name) =>
{
utilsTools.setGDataByKey("enableZoomMove", false);
if (lowImg != null) lowImg.SetActive(false);
if (areaIdBase != null) areaIdBase.SetActive(false);
utilsTools.sendEventObjectParams("gamePlayerEndHandler");
return false;
},15);
}, aids);
}
}
else{
utilsTools.setGDataByKey("enableZoomMove", false);
if (lowImg != null) lowImg.SetActive(false);
if (areaIdBase != null) areaIdBase.SetActive(false);
utilsTools.sendEventObjectParams("gamePlayerEndHandler");
}
//else if (nowSelectgid >= 0)
//{
// var roomGroup = gameidJsondata.getRoomGroup(nowSelectgid);
// if (groupPtInfos.ContainsKey(nowSelectgid) == false)
// {
// return;
// }
// var aidpts = groupPtInfos[nowSelectgid];
// short[] noshowAids = aidpts.getDataAllKey();
// List<short> aids = new List<short>();
// if (noshowAids.Length > 0)
// {
// short aid = -1;
// for (int i = 0; i < noshowAids.Length; i++)
// {
// aid = noshowAids[i];
// foreach (var item in showAreaAnimationDatas)
// {
// if (aid.Equals(item.m_aid))
// {
// aid = -1;
// break;
// }
// }
// if (aid > -1)
// {
// aids.Add(aid);
// }
// }
// }
// if (aids.Count > 0)
// {
// TaskManages.getInstance().addTask(this, (System.Object[] p) =>
// {
// List<short> showAids = (List<short>)p[0];
// foreach (var item in showAids)
// {
// var tipAidInfo = gameidJsondata.getAid(item);
// showAreaByPos(tipAidInfo.px, tipAidInfo.py, null);
// break;
// }
// utilsTools.addTimer_Update(gameObject, "sdcdvc", (String name) =>
// {
// utilsTools.setGDataByKey("enableZoomMove", false);
// if (lowImg != null) lowImg.SetActive(false);
// if (areaIdBase != null) areaIdBase.SetActive(false);
// utilsTools.sendEventObjectParams("gamePlayerEndHandler");
// return false;
// },15);
// }, aids);
// }
//}
//else{ //直接进回放
// utilsTools.setGDataByKey("enableZoomMove", false);
// if (lowImg != null) lowImg.SetActive(false);
// if (areaIdBase != null) areaIdBase.SetActive(false);
// utilsTools.sendEventObjectParams("gamePlayerEndHandler"); //直接发送这个事件
//}
}
//加载小的选中图的保存过程,如果需要三合一的方式mainGameOneImageView的处理方式
protected virtual void loadSelectImageTexture(Texture2D nowSelectTexture,NotifyEmptParam notify, int width = 0,int height = 0)
......@@ -1572,7 +1593,7 @@ public class mainGameView : MonoBehaviour
}, objects2);
}
protected void loadSelectImageTextureId(int idx = 0, NotifyEmptParam notify = null)
protected void loadSelectImageTextureId(int idx = 0, NotifyEmptParam notify = null) //加载选中的组对应的区域的颜色块
{
string path = allSelectTexturePaths[idx];
var req = Resources.LoadAsync<Texture2D>(path);
......@@ -1636,4 +1657,5 @@ public class mainGameView : MonoBehaviour
}, 5);
}
}
}
......@@ -5,21 +5,21 @@ using System;
using UnityEngine.UIElements;
using Unity.VisualScripting;
/// <summary>
/// 数字矩阵
/// ���־���
/// </summary>
public class DigitMatrixShort
public class DigitMatrixShort//泛洪算法 颜料桶算法
{
#region 属性
#region ����
public DigitMatrixSetBack back = null;
public DigitMatrixIsEqual<short> isEqualItem = null;
public bool isPause = false;
/// <summary>
/// 行数
/// ����
/// </summary>
public short RowCount { get; private set; }
/// <summary>
/// 列数
/// ����
/// </summary>
public short ColumnCount { get; private set; }
......@@ -72,15 +72,15 @@ public class DigitMatrixShort
}, bianLun, false);
//foreach (var item in tempPts)
//{
// Data[item.Item1, item.Item2] = oldValue;//恢复
// Data[item.Item1, item.Item2] = oldValue;//�ָ�
//}
}
#region FloodFill8WithStack
/// <summary>
/// 漫水填充(基于堆的8邻域填充)
/// ��ˮ���(���ڶѵ�8�������)
/// </summary>
/// <param name="r"></param>
/// <param name="c"></param>
/// <param name="r">��</param>
/// <param name="c">��</param>
/// <param name="newValue"></param>
/// <param name="oldValue"></param>
/// <param name="matrix"></param>
......@@ -135,7 +135,7 @@ public class DigitMatrixShort
CheckNewSeed(r - 1, c + 1);
CheckNewSeed(r + 1, c - 1);
tryValues = tryValues + 1;
if (tryValues > 4096 * 4096 * 10) break;//基本死循环了
if (tryValues > 4096 * 4096 * 10) break;//������ѭ����
}
}
#endregion
......
......@@ -26,7 +26,7 @@ public class AreaAnimationDiffuse
public short m_y;
public short m_aid;
public short m_fpsStart = 1;//r 开始
public short m_fpsEnd = 100;//r 结束
public short m_fpsEnd = 50;//r 结束 这个值调大了可以让动画效果变快,小了就是变慢
//key beginStart 值 value 这个圆环的像素
public ConcurrentDictionary<short, List<short>> m_datas = new ConcurrentDictionary<short, List<short>>();
public int nowState = 0;//0 尚未开始 1 处理中 2 处理完成
......@@ -71,12 +71,12 @@ public class RectInt
dowm = rectInt.dowm;
}
}
public class GroupByAreaPtInfos
public class GroupByAreaPtInfos //把组和大图对应的区域关联起来
{
//public Dictionary<short, List<Vector2Short>> datas = new Dictionary<short, List<Vector2Short>>();
public Dictionary<short, bool> datasBool = new Dictionary<short, bool>();
private Dictionary<short, bool> lines = new Dictionary<short, bool>();
public static Dictionary<short, List<int>> mapAllDatas = new Dictionary<short, List<int>>();
public Dictionary<short, bool> datasBool = new Dictionary<short, bool>(); //key 区域id bool true:没涂
private Dictionary<short, bool> lines = new Dictionary<short, bool>(); //key:区域id true没涂
public static Dictionary<short, List<int>> mapAllDatas = new Dictionary<short, List<int>>(); //key:区域id value:全部的像素点坐标
public static int width;
public static int height;
public bool getDataByAid(short aid, ref List<Vector2Short> data, bool isReBack = false)
......@@ -203,7 +203,7 @@ public class ColorIndexTables
color = new Color(temp.r, temp.g, temp.b, temp.a);
return true;
}
public bool getTiledColor(int x, int y, ref Color color)
public bool getTiledColor(int x, int y, ref Color color) //选中区域整个铺满
{
if (x < 0)
{
......
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