Commit f3192eda authored by shujianhe's avatar shujianhe

1 缩放和移动后正常点击区域并逐渐填充,点击后气泡扩散暂未实现

parent a3463f7f
......@@ -794,6 +794,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 593691933}
- component: {fileID: 593691934}
m_Layer: 0
m_Name: areaIdBase
m_TagString: Untagged
......@@ -821,6 +822,51 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 950, y: 1280}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!61 &593691934
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 593691932}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IncludeLayers:
serializedVersion: 2
m_Bits: 0
m_ExcludeLayers:
serializedVersion: 2
m_Bits: 0
m_LayerOverridePriority: 0
m_ForceSendLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ForceReceiveLayers:
serializedVersion: 2
m_Bits: 4294967295
m_ContactCaptureLayers:
serializedVersion: 2
m_Bits: 4294967295
m_CallbackLayers:
serializedVersion: 2
m_Bits: 4294967295
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0, y: 0}
oldSize: {x: 0, y: 0}
newSize: {x: 0, y: 0}
adaptiveTilingThreshold: 0
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 950, y: 1280}
m_EdgeRadius: 0
--- !u!1 &706874198
GameObject:
m_ObjectHideFlags: 0
......@@ -897,142 +943,6 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 706874198}
m_CullTransparentMesh: 1
--- !u!1 &759592344
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 759592345}
- component: {fileID: 759592347}
- component: {fileID: 759592346}
m_Layer: 0
m_Name: debugView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &759592345
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 759592344}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1474894691}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -5.9033203, y: -1559.2}
m_SizeDelta: {x: -74.776, y: 136.63}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &759592346
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 759592344}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 0
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_text: this is a testtextxfx zdfzsdfdsfdsfdsfffffffff ffffffffffffff ffffffffffffffffffffffffffffffffffffffffff
ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffffff5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffssssssssssssssssssssssssssssssssssssffffffhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4287981311
m_fontColor: {r: 1, g: 0.40060285, b: 0.58431375, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 2
m_VerticalAlignment: 512
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 3
m_linkedTextComponent: {fileID: 0}
parentLinkedComponent: {fileID: 0}
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_IsTextObjectScaleStatic: 0
m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_hasFontAssetChanged: 0
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!222 &759592347
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 759592344}
m_CullTransparentMesh: 1
--- !u!1 &859724157
GameObject:
m_ObjectHideFlags: 0
......@@ -1536,7 +1446,6 @@ RectTransform:
- {fileID: 1656126341}
- {fileID: 1013381886}
- {fileID: 133508485}
- {fileID: 759592345}
m_Father: {fileID: 297775248}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -1761,6 +1670,7 @@ MonoBehaviour:
lowImg: {fileID: 303685715}
areaIdBase: {fileID: 593691932}
perfabPath: perfabs/areaGroupId
lowImgTexture2ds: []
--- !u!114 &1656126344
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -1780,7 +1690,9 @@ MonoBehaviour:
- {fileID: 1893464095}
- {fileID: 1755905471}
- {fileID: 133508484}
- {fileID: 759592344}
- {fileID: 0}
- {fileID: 0}
DebugSprites: []
--- !u!222 &1656126346
CanvasRenderer:
m_ObjectHideFlags: 0
......@@ -2085,7 +1997,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 1977147924}
m_Direction: 0
m_Value: 1
m_Size: 1
m_Size: 0.9999999
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
......
......@@ -5,11 +5,22 @@ using UnityEngine;
[System.Serializable]
public class gameAreaGroupItem
{
public double gid;
public List<short> areaIds;
public List<UInt16> RGB;
public short id;
public List<short> roomIds;
public float R;
public float G;
public float B;
public bool isComplete = false;
public void getRGB(out Color color)
{
color = new Color(RGB[0] / 255, RGB[1] / 255, RGB[2] / 255, 1);
color = new Color(R / 255f, G / 255f, B / 255f, 1);
}
public static int sortByIsComplete(gameAreaGroupItem a, gameAreaGroupItem b)
{
if(a.isComplete == b.isComplete)
{
return a.id - b.id;
}
return a.isComplete ? 1 : -1;
}
}
......@@ -5,9 +5,17 @@ using UnityEngine;
[System.Serializable]
public class gameAreaItem
{
public short x;
public short y;
public ushort id;
public short gid;
public short px;
public short py;
public short pr;
public float R;
public float G;
public float B;
public short id;
public short gid = -1;//组id
public short valid;//未知含义 未启用
public short useAreaData;//未知含义 未启用
public bool notPaintCol;//未启用
public string tempExKey = "";
public bool isShow = false;
}
......@@ -7,6 +7,6 @@ public class gameIdJsonData
public string nowId = "";
public short width = 0;
public short height = 0;
public List<gameAreaItem> centers = new List<gameAreaItem>();
public List<gameAreaGroupItem> groups = new List<gameAreaGroupItem>();
public List<gameAreaItem> roomDatas = new List<gameAreaItem>();
public List<gameAreaGroupItem> roomGroupsData = new List<gameAreaGroupItem>();
}
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
public class gameSceneLogic : MonoBehaviour, IEventHandler
{
......@@ -10,58 +12,51 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
public GameObject gameShowView = null;
public GameObject areaGroupList = null;
public static int maxIdValue = 100;
private int nowSelectGroupId = 4;
private int nowidx = 4;
public float progress = 0;
public bool showAreaId = true;
private TextMeshProUGUI debugViewObj = null;
private List<TempGroupInfos> groupInfos = null;
private Vector2 pos1 = new Vector2(-10000, -10000);
private int rvalue = -1;
void Start()
{
//GetComponent<TextMeshProUGUI>()
utilsTools.onEvent(this, "switchGameAreaGroupId");
utilsTools.onEvent(this, "gameViewOnInitEnd");
utilsTools.onEvent(this, "debugViewLogHandler");
var debugTran = transform.Find("debugView");
if(debugTran != null)
{
debugViewObj = debugTran.GetComponent<TextMeshProUGUI>();
if (debugViewObj == null) debugTran.gameObject.SetActive(false);
else
{
debugTran.gameObject.SetActive(utilsTools.IsPhone);
}
}
utilsTools.onEvent(this, "gameClickPos");
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(true);
gridViewList.gameObject.SetActive(false);
gameShowView.GetComponent<mainGameView>().loadTest();
//gridViewList.setDataNoGrid(20, 150, 150, 15, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
//{
// if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
// {
// var item = gobject.GetComponent<colorItem>();
// bool isSelect = idx == nowSelectGroupId;
// item.IsSelect = isSelect;
// Vector3 vector3;
// Quaternion quaternion;
// gobject.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
// vector3.y = -95f;
// if (isSelect)
// {
// vector3.y = vector3.y + 14;
// }
// gobject.transform.SetLocalPositionAndRotation(vector3, quaternion);
// item.IdName = idx.ToString();
// float idxf = idx;
// item.UseColor = new Color(idxf * 10 / 255f, 0.5f, (22 - idxf) * 10 / 255f, 1.0f);
// item.NowProgress = idx < 4 ? 0.0f : (idx < 15 ? idx / 13f : 1.0f);
// }
//}, false);
}
// Update is called once per frame
void Update()
{
}
private void onUpdateGroupGridHandler(GameObject gobject, int idx, ListViewBackTypeEnum lvbType,TempGroupInfos group)
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
{
var item = gobject.GetComponent<colorItem>();
bool isSelect = idx == nowidx;
item.IsSelect = isSelect;
Vector3 vector3;
Quaternion quaternion;
gobject.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = -95f;
if (isSelect)
{
vector3.y = vector3.y + 14;
}
gobject.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.IdName = (group.gid).ToString();
item.index = idx;
item.UseColor = group.rgb;
item.NowProgress = group.jindu;
}
}
public void onEventHandler(string eventName, List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
if (eventName.Equals("switchGameAreaGroupId"))
......@@ -70,94 +65,68 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
Quaternion quaternion;
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
colorItem item = null;
if (nowSelectGroupId >= 0)
if (nowidx >= 0)
{
item = gridViewList.getObjectById(nowSelectGroupId).GetComponent<colorItem>();
item = gridViewList.getObjectById(nowidx).GetComponent<colorItem>();
item.IsSelect = false;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = vector3.y - 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
}
var maingameView = gameShowView.GetComponent<mainGameView>();
nowSelectGroupId = (int)objects[0];
item = gridViewList.getObjectById(nowSelectGroupId).GetComponent<colorItem>();
int idx = (int)objects[0];
nowidx = idx;
var nowSelectGroupId = groupInfos[idx].gid;
item = gridViewList.getObjectById(idx).GetComponent<colorItem>();
item.IsSelect = true;
item.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = vector3.y + 14;
item.transform.SetLocalPositionAndRotation(vector3, quaternion);
print("切换下表开始" + nowSelectGroupId.ToString());
Debug.Log("切换下标开始" + nowSelectGroupId.ToString());
maingameView.switchShowAreaGroup((short)nowSelectGroupId, (int id, bool isOk) => {
print("切换下表完成" + id.ToString());
Debug.Log("切换下标完成" + id.ToString());
});
}else if (eventName.Equals("gameViewOnInitEnd"))
{
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(true);
var maingameView = gameShowView.GetComponent<mainGameView>();
var ColorInfos = maingameView.getGroups();
gridViewList.setDataNoGrid(ColorInfos.Count, 150, 150, 20, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
groupInfos = maingameView.getGroups();
int cout = 0;
for (int i = 0; i < groupInfos.Count; i++)
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
{
var item = gobject.GetComponent<colorItem>();
bool isSelect = idx == nowSelectGroupId;
item.IsSelect = isSelect;
Vector3 vector3;
Quaternion quaternion;
gobject.transform.GetLocalPositionAndRotation(out vector3, out quaternion);
vector3.y = -95f;
if (isSelect)
{
vector3.y = vector3.y + 14;
}
gobject.transform.SetLocalPositionAndRotation(vector3, quaternion);
item.IdName = (idx + 1).ToString();
item.index = idx;
float idxf = idx;
item.UseColor = new Color(idxf * 10 / 255f, 0.5f, (22 - idxf) * 10 / 255f, 1.0f);
item.NowProgress = 0;
if(groupInfos[i].jindu == 1) {
break;
}
cout++;
}
gridViewList.setDataNoGrid(cout, 150, 150, 20, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
{
this.onUpdateGroupGridHandler(gobject, idx, lvbType, groupInfos[idx]);
}, false);
if(nowSelectGroupId > 0)
if(nowidx > 0)
{
print("切换下表开始" + nowSelectGroupId.ToString());
maingameView.switchShowAreaGroup((short)(nowSelectGroupId), (int id,bool isOk) => {
print("切换下表完成" + id.ToString());
//Debug.Log("切换下标开始" + nowSelectGroupId.ToString());
maingameView.switchShowAreaGroup((short)(groupInfos[nowidx].gid), (int id,bool isOk) => {
Debug.Log("切换下标完成" + id.ToString());
});
}
}else if (eventName.Equals("debugViewLogHandler"))
}else if (eventName.Equals("gameClickPos"))
{
string s = "";
if (objects != null)
{
for (int i = 0; i < objects.Count; i++)
{
s = s + objects[i].ToString() + ",";
}
}
if(uobjects != null)
{
for (int i = 0; i < uobjects.Count; i++)
{
s = s + uobjects[i].ToString() + ",";
}
}
if (s.Length == 0) return;
print(s);
//if (utilsTools.IsPhone == false || debugViewObj == null)
//{
// print(s);
//}
//else
//{
// debugViewObj.text = s;
//}
short x = (short)objects[0];
short y = (short)objects[1];
var maingameView = gameShowView.GetComponent<mainGameView>();
maingameView.showAreaByPos(x,y, (int id,bool isOk) => {
Debug.Log("点击区域" + id.ToSafeString() + " 显示" + isOk.ToSafeString());
return;
});
//groupInfos = maingameView.getGroups();
}
}
public void onTestTemp1()
{
print("是否卡顿?");
Debug.Log("---->>>");
}
}
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Assertions;
public class gameUserInfos : MonoBehaviour, IEventHandler
{
......@@ -17,16 +19,21 @@ public class gameUserInfos : MonoBehaviour, IEventHandler
}
public void startId(string id)
{
gameSaveKey = "gameUserData_" + id.ToString();
string defvalue = "";
string oldGameInfo = utilsDB.getDBJsonDataByKey(gameSaveKey, defvalue);
if (oldGameInfo.Equals(defvalue))
GameScenUserInfo gameScenUser = utilsTools.getGameScenUserInfo(id);
if(gameScenUser == null)
{
return;
}
List<short> shorts = new List<short>();
for (int i = 0; i < gameScenUser.areaInfoUseData.Count; i++)
{
shorts.Add(gameScenUser.areaInfoUseData[i].id);
}
GetComponent<mainGameView>().loadGameImgId(gameScenUser.img, gameScenUser.finishImg, gameScenUser.json,"",shorts);
}
void IEventHandler.onEventHandler(string eventName, List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
}
}
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
delegate void CheckInput();
public class mainGameScaleMove : MonoBehaviour
{
......@@ -14,10 +17,11 @@ public class mainGameScaleMove : MonoBehaviour
private bool skipDoubleScale = false;
public float OldTouchCurrDis = -1000;
public float minScale = 0.25f;
public float maxScale = 8f;
public float maxScale = 1.25f;//8f;
public List<GameObject> ignoreList = new List<GameObject>();
private List<System.Object> logTempList = null;
private Vector2 winPrvePos = new Vector2(-90000, -90000);
public List<Sprite> DebugSprites = new List<Sprite>();
public Vector2 NowPos
{
get { return nowPos; }
......@@ -89,18 +93,18 @@ public class mainGameScaleMove : MonoBehaviour
TouchPhase touchPhase = oneTouch.phase;
if(touchPhase == TouchPhase.Began)
{
MyPrint("one Click begin");
Debug.Log("one Click begin");
onOneTouchBegin(oneTouch.position);
}
else if(touchPhase == TouchPhase.Moved)
{
if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false) return;
MyPrint("one Click move");
Debug.Log("one Click move");
onOneTouchMove(oneTouch.position, oneTouch.deltaPosition);
}else if(touchPhase == TouchPhase.Ended)
{
if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false) return;
MyPrint("one Click end");
Debug.Log("one Click end");
onOneTouchEnd(oneTouch.position, oneTouch.deltaPosition);
}else if(touchPhase == TouchPhase.Canceled)
{
......@@ -138,25 +142,24 @@ public class mainGameScaleMove : MonoBehaviour
var itemChild = transform.GetChild(i);
itemChild.localScale = nowScale;
}
MyPrint("scale", "", nowScale, nowSize);
}
void clearOneTouchBegin()
{
MyPrint("one Click clear");
Debug.Log("one Click clear");
utilsTools.delUserDataByKey(gameObject, "oneTouchBegin");
}
bool checkMouseInIgnoreList(Vector2 vector)
{
for (int i = 0; i < ignoreList.Count; i++)
{
if (ignoreList[i] == null) continue;
RectTransform checkRectTransform = ignoreList[i].transform.GetComponent<RectTransform>();
var newLocalPos = utilsTools.ScreenToUILocalPos(checkRectTransform, vector);
if (checkRectTransform.rect.Contains(newLocalPos)) return true;
}
return false;
}
//左键点击 右键缩放
//左键点击 右键缩放
void checkInputByComputer()
{
if (Input.GetMouseButtonDown(0))
......@@ -212,85 +215,91 @@ public class mainGameScaleMove : MonoBehaviour
{
delatPos.y = 0;
}
if (delatPos.x == delatPos.y && delatPos.x == 0) return;//都不用移动就不更新坐标
if (delatPos.x == delatPos.y && delatPos.x == 0) return;//都不用移动就不更新坐标
tempVector3.x += delatPos.x;
tempVector3.y += delatPos.y;
MyPrint("move", tempVector3, nowScale, nowSize);
Debug.Log("move"+tempVector3.ToSafeString()+ nowScale.ToSafeString()+ nowSize.ToSafeString());
}
itemChild.SetLocalPositionAndRotation(tempVector3, quaternion);
}
//更新坐标 应该记录当前显示的位置
}
private void MyPrint(System.Object param1,System.Object param2 = null,System.Object param3 = null,System.Object param4 = null)
{
logTempList[0] = param1;
if (param2 == null) logTempList[1] = "";
else logTempList[1] = param2;
if (param3 == null) logTempList[2] = "";
else logTempList[1] = param3;
if (param4 == null) logTempList[3] = "";
else logTempList[1] = param4;
utilsTools.sendEventObjects("debugViewLogHandler", logTempList);
//更新坐标 应该记录当前显示的位置
}
private void onOneTouchEnd(Vector2 nowPos, Vector2 delatPos)
{
utilsTools.getUserData<Vector2>(gameObject, "oneTouchBegin", out tempVector, defvalueVector);
if (tempVector.Equals(defvalueVector))//说明之前已经移除了
if (tempVector.Equals(defvalueVector))//说明之前已经移除了
{
return;
}
float sqrMagnitude = (nowPos - tempVector).SqrMagnitude();
clearOneTouchBegin();
if (sqrMagnitude > 20f) {//按下和抬起距离太远就不算点击
MyPrint("begin end diff big ", sqrMagnitude);
if (sqrMagnitude > 20f) {//按下和抬起距离太远就不算点击
Debug.Log("begin end diff big "+ sqrMagnitude);
return;
}
onOneClick(nowPos);
}
//获取图片和屏幕交集的区域 //屏幕坐标系
//获取图片和屏幕交集的区域 //屏幕坐标系
Rect ImageToSceneJiao()
{
//将四个点转成屏幕坐标系
//将四个点转成屏幕坐标系
RectTransform firstRectTransform = transform.GetChild(0).GetComponent<RectTransform>();
Rect rect = firstRectTransform.rect;
//Vector2 localtemp;
//Vector2 worldtemp;
//Vector2 pingtemp;
//Vector2 pingtemp2;
//localtemp = new Vector2(rect.xMin, rect.yMin);
//worldtemp = firstRectTransform.TransformPoint(localtemp);
//pingtemp = Camera.main.WorldToScreenPoint(worldtemp);
//MyPrint(localtemp, worldtemp, pingtemp);
//localtemp = new Vector2(rect.xMax, rect.yMax);
//worldtemp = firstRectTransform.TransformPoint(localtemp);
//pingtemp2 = Camera.main.WorldToScreenPoint(worldtemp);
//Rect wuti = new Rect(pingtemp.x, pingtemp.y, pingtemp2.x, pingtemp2.y);
//Rect pingRect = new Rect(0, 0, utilsTools.DisplaySize.x, utilsTools.DisplaySize.y);
//Rect ret = new Rect(0, 0, 0, 0);
//if (wuti.x < pingRect.x)
// ret.x = pingRect.x;
//else
// ret.x = wuti.x;
//if (wuti.y < pingRect.y)
// ret.y = pingRect.y;
//MyPrint(localtemp, worldtemp, pingtemp);
return rect;
}
private Vector3 GetNativePosition(Vector3 screenPos)
{
// 将屏幕坐标转换为世界坐标
screenPos.z = 10000f;
Vector3 worldPos = Camera.main.ScreenToWorldPoint(screenPos);
Ray2D ray = new Ray2D(worldPos, Vector2.right);
RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction);
if(hit.collider != null)
{
Debug.Log("有碰撞 ....");
}
else
{
Debug.Log("没有碰撞 ");
}
// 获取节点的缩放信息
Vector3 scale = transform.localScale;
// 获取节点的位置信息
Vector3 position = transform.localPosition;
// 计算节点的逆变换矩阵
Matrix4x4 inverseTransform = Matrix4x4.TRS(-position, Quaternion.identity, Vector3.one).inverse;
inverseTransform *= Matrix4x4.Scale(new Vector3(1 / scale.x, 1 / scale.y, 1 / scale.z));
// 将世界坐标转换为节点内的原生坐标
Vector3 nativePos = inverseTransform.MultiplyPoint(worldPos);
return nativePos;
}
private void onOneClick(Vector2 nowPos)
{
RectTransform firstRectTransform = transform.GetChild(0).GetComponent<RectTransform>();
var localPos = utilsTools.ScreenToUILocalPos(firstRectTransform, nowPos);
if (firstRectTransform.rect.Contains(localPos))//首先要区域内
Vector3 temp = new Vector3(nowPos.x,nowPos.y);
mainGameView mainView = GetComponent<mainGameView>();
int width;
int height;
if (mainView.getSize(out width, out height) == false) return;
var lineTransform = transform.Find("low").GetComponent<RectTransform>();
Vector2 vector = utilsTools.ScreenToUILocalPos(lineTransform, nowPos);
if (lineTransform.rect.Contains(vector))
{
Vector2 localPos1 = (localPos - (nowPos * nowScale * 3f));
MyPrint("click", nowPos, localPos, localPos1);
Vector2 scaleVector = new Vector2(width / lineTransform.rect.width, height / lineTransform.rect.height);
Vector2 pos1 = vector * scaleVector;
short x = Convert.ToInt16(pos1.x + width / 2);
short y = Convert.ToInt16(pos1.y + height / 2);
List<System.Object> senddata = new List<System.Object>() {x,y};
utilsTools.sendEventObjects("gameClickPos", senddata);
}
else
{
MyPrint("click", nowPos, localPos, "noRect");
print("2");
}
//nowPos = GetNativePosition(temp);
//Debug.Log("当前点击位置到图片对应"+temp.ToSafeString());
}
// Update is called once per frame
void Update()
......
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
......@@ -11,27 +12,53 @@ using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
public class TempGroupInfos
{
public Color rgb;
public int gid;
public float jindu;
}
class AreaAnimationDiffuse
{
public short m_x;
public short m_y;
public short m_aid;
public short m_fpsStart = 1;//r 开始
public short m_fpsEnd = 20;//r 结束
public AreaAnimationDiffuse(short x,short y,short aid)
{
m_x = x;
m_y = y;
m_aid = aid;
}
}
public class mainGameView : MonoBehaviour
{
private gameIdJsonData gameidJsondata = null;
private string progresName = "";
public GameObject lineImg = null;//线图
public GameObject colorImg = null;//颜色图
public GameObject lowImg = null;//底图
public GameObject lineImg = null;//线图
public GameObject colorImg = null;//颜色图
public GameObject lowImg = null;//底图
public GameObject areaIdBase = null;
[Header("区域id的预制体")]
[Header("区域id的预制体")]
public string perfabPath = "";
private GameObject areaIdperfabObj = null;
public DigitMatrixShort digitMatrix = null;
protected Texture2D lineTexture2d = null;
protected List<Texture2D> lowImgTexture2ds = new List<Texture2D>();
public List<Texture2D> lowImgTexture2ds = new List<Texture2D>();
protected short nowSelectgid = -1;
private string[] initDigitMatrixs = { "", "" };
private string runGameDatas = "runGameDatas";
private List<short> nowSelectInfos = null;
private Vector2 pos1 = new Vector2(-1000, -1000);
//x,y aid 当前帧向量 起点终点 等宽度计算扩散
private List<AreaAnimationDiffuse> showAreaAnimationDatas = new List<AreaAnimationDiffuse>();
private int rvalue = -1;
public void onInitDigitMatrix(string name)
{
print("onInitDigitMatrix >> " + name);
Debug.Log("onInitDigitMatrix >> " + name);
if (lowImg == null && name.Equals("select") == false)
onInitDigitMatrix("select");
for (int i = 0; i < initDigitMatrixs.Count(); i++)
......@@ -53,9 +80,83 @@ public class mainGameView : MonoBehaviour
utilsTools.CreateDirectory(savepath);
return savepath + "/temp_" + gid.ToString() + ".png";
}
public void saveGroupTexture(int pgid,Texture2D nowGroupIdTexture)
{
string temppath = getSelectPathByGid(pgid);
utilsTools.saveByteToPath(nowGroupIdTexture.EncodeToPNG(), temppath);
utilsTools.saveImageDefaultMetaInfoToPath(temppath);
GameObject.Destroy(nowGroupIdTexture);
nowGroupIdTexture = null;
}
public bool addTaskInMakeGroupMap(int i, Texture2D lowImgTexture2dFirst,bool isNowShow)
{
var tm = TaskManages.getInstance();
var group = gameidJsondata.roomGroupsData[i];
short pgid = group.id;
if (group.isComplete) return false;
string temppath = getSelectPathByGid(pgid);
if (utilsTools.IsExistIO(temppath))
{
Debug.Log("已经存在所以跳过 " + pgid.ToSafeString());
return false;
}
Texture2D nowGroupIdTexture = null;
Tuple<bool, int, Texture2D> tuple = new Tuple<bool, int, Texture2D>(isNowShow, i, nowGroupIdTexture);
for (int i1 = 0; i1 < gameidJsondata.roomGroupsData[i].roomIds.Count(); i1++)
{
var aid1 = gameidJsondata.roomGroupsData[i].roomIds[i1];
System.Object[] taskParams = { aid1, pgid,isNowShow, temppath };
tm.addTask(this, (System.Object[] listparam) =>
{
bool isGameShow = (bool)listparam[2];
if(isGameShow == true && utilsTools.IsExistIO(temppath) == true)
{
if(nowGroupIdTexture != null)
{
GameObject.Destroy(nowGroupIdTexture);
nowGroupIdTexture = null;
}
return;
}
if (nowGroupIdTexture == null)
{
nowGroupIdTexture = new Texture2D(lowImgTexture2dFirst.width, lowImgTexture2dFirst.height, lowImgTexture2dFirst.format, false);
nowGroupIdTexture.LoadRawTextureData(lowImgTexture2dFirst.GetRawTextureData());
}
int aid = (short)listparam[0];
var areaInfo = gameidJsondata.roomDatas[aid];
short tempgid = (short)listparam[1];
int setcout = 0;
digitMatrix.PeekFloodFill8WithStack(areaInfo.px, areaInfo.py, -5, (short)(aid + 20), (short x1, short y1, short c) =>
{
nowGroupIdTexture.SetPixel(x1, y1, Color.white);
setcout = setcout + 1;
return true;
});
}, taskParams);
}
System.Object[] param1 = { pgid,isNowShow};
tm.addTask(this, (System.Object[] listparam) =>
{
bool isGameShow = (bool)listparam[1];
if (isGameShow == true && utilsTools.IsExistIO(temppath) == true)
{
if (nowGroupIdTexture != null)
{
GameObject.Destroy(nowGroupIdTexture);
nowGroupIdTexture = null;
}
return;
}
if(nowGroupIdTexture != null)
saveGroupTexture((short)listparam[0],nowGroupIdTexture);
}, param1);
return true;
}
public void onLoadFileOk(int typeId)
{
if (typeId == 1)
{
Debug.Log("begin init lunkuo");
......@@ -67,7 +168,7 @@ public class mainGameView : MonoBehaviour
int x = (int)datas[0];
int setp = (int)datas[1];
int height = (int)datas[2];
print("执行任务参数列表 typeid 1 " + (x + setp).ToSafeString());
Debug.Log("执行任务参数列表 typeid 1 " + (x + setp).ToSafeString());
for (int i = x; i < (x + setp); i++)
{
for (int j = 0; j < height; j++)
......@@ -93,14 +194,14 @@ public class mainGameView : MonoBehaviour
TaskItemBack taskItemBack1 = (System.Object[] param) =>
{
gameAreaItem gai = (gameAreaItem)param[0];
print("area reset id " + (gai.id + 20).ToString());
digitMatrix.FloodFill8WithStack(gai.x, gai.y, (short)(gai.id + 20), 0, null);
Debug.Log("area reset id " + (gai.id + 20).ToString());
digitMatrix.FloodFill8WithStack(gai.px, gai.py, (short)(gai.id + 20), 0, null);
};
//给每一个空白设置 区域id
for (int i = 0; i < gameidJsondata.centers.Count; i++)
//给每一个空白设置 区域id
for (int i = 0; i < gameidJsondata.roomDatas.Count; i++)
{
var item = gameidJsondata.centers[i];
if (digitMatrix.Data[item.x,item.y] == 0){
var item = gameidJsondata.roomDatas[i];
if (digitMatrix.Data[item.px,item.py] == 0){
System.Object[] temps = { item };
taskManages.addTask(this, taskItemBack1, temps);
}
......@@ -126,8 +227,6 @@ public class mainGameView : MonoBehaviour
TaskManages tm = TaskManages.getInstance();
var lowImgTexture2dFirst = lowImgTexture2ds[0];
Texture2D nowGroupIdTexture = null;
//lowImgTexture2ds = new List<Texture2D>();
Action<int> tempSaveTexture = (int nowgid) =>
{
string temppath = getSelectPathByGid(nowgid);
......@@ -137,134 +236,46 @@ public class mainGameView : MonoBehaviour
nowGroupIdTexture = null;
return;
};
TaskItemBack onUpdataeColor = (System.Object[] listparam) =>
{
int start = (int)listparam[0];
int setp = (int)listparam[1];
int maxWidth = (int)listparam[2];
int height = (int)listparam[3];
int gid = (int)listparam[4];
Color oldColor1 = new Color(1,1,1,0);
Color oldColor2 = new Color(1, 1, 1, 1);
List<short> shorts = gameidJsondata.groups[gid].areaIds;
for (int col = start; col < (start + setp); col++)
{
for (int line = 0; line < height; line++)
{
short flg = digitMatrix.Data[col, line];
if (flg >= 20 && shorts.IndexOf((short)(flg - 20f)) >= 0)
{
nowGroupIdTexture.SetPixel(col, line, oldColor2);
}
else
{
nowGroupIdTexture.SetPixel(col, line, oldColor1);
}
}
}
};
//for (int i = 0;i < gameidJsondata.groups.Count; i++)
//{
// tm.addTask(this, (System.Object[] listparams) =>
// {
// Texture2D newTextureByRawData = new Texture2D(lowImgTexture2dFirst.width, lowImgTexture2dFirst.height, lowImgTexture2dFirst.format, false);
// newTextureByRawData.LoadRawTextureData(lowImgTexture2dFirst.GetRawTextureData());
// lowImgTexture2ds.Add(newTextureByRawData);
// });
//}
TaskItemBack checkPtNextHandler = null;
checkPtNextHandler = (System.Object[] listparam) =>
{
var checkPt = gameidJsondata.centers[gameidJsondata.centers.Count-1];
float flg = digitMatrix.Data[checkPt.x,checkPt.y];
var checkPt = gameidJsondata.roomDatas[gameidJsondata.roomDatas.Count-1];
float flg = digitMatrix.Data[checkPt.px,checkPt.py];
if(flg == 0)
{
tm.addTask(this, checkPtNextHandler);
return;
}
print("开始生成组图片");
int tempsetp = 200;
for (int i = 0;i < gameidJsondata.groups.Count; i++)
Debug.Log("开始生成组图片");
gameidJsondata.roomGroupsData.Sort(gameAreaGroupItem.sortByIsComplete);
int j = 0;
int i = 0;
while (j < 11 && i < gameidJsondata.roomGroupsData.Count)
{
string temppath = getSelectPathByGid(i);
tm.addTask(this, (System.Object[] listparam) => {
nowGroupIdTexture = new Texture2D(lowImgTexture2dFirst.width, lowImgTexture2dFirst.height, lowImgTexture2dFirst.format, false);
Color colorstemp = Color.yellow;
colorstemp.a = 0;
nowGroupIdTexture.LoadRawTextureData(lowImgTexture2dFirst.GetRawTextureData());
});
for (int i1 = 0; i1 < gameidJsondata.groups[i].areaIds.Count(); i1++)
if(addTaskInMakeGroupMap(i, lowImgTexture2dFirst, false) == true)
{
System.Object[] taskParams = { gameidJsondata.groups[i].areaIds[i1], i };
tm.addTask(this, (System.Object[] listparam) =>
{
int aid = (short)listparam[0];
var areaInfo = gameidJsondata.centers[aid];
int tempgid = (int)listparam[1];
int setcout = 0;
digitMatrix.PeekFloodFill8WithStack(areaInfo.x, areaInfo.y, -5, (short)(aid + 20), (short x1, short y1, short c) =>
{
nowGroupIdTexture.SetPixel(x1, y1, Color.white);
setcout = setcout + 1;
return true;
});
print(listparam[0].ToSafeString() + ">>" + tempgid.ToSafeString() + " end " + setcout.ToString());
}, taskParams);
j++;
}
System.Object[] param1 = { i };
tm.addTask(this, (System.Object[] listparam) =>
{
tempSaveTexture((int)listparam[0]);
}, param1);
i++;
}
tm.addTask(this, (System.Object[] _) =>
if (areaIdBase != null && perfabPath.Equals("") == false)
{
if (areaIdBase != null && perfabPath.Equals("") == false)
{
//创建一堆节点
TaskItemBack onUpdateByIdNode = (System.Object[] listparam) =>
{
checkAddAreaId();
onInitDigitMatrix("select");
};
tm.addTask(this, onUpdateByIdNode);
}
else
//创建一堆节点
TaskItemBack onUpdateByIdNode = (System.Object[] listparam) =>
{
checkAddAreaId();
onInitDigitMatrix("select");
}
});
//for (int i1 = 0; i1 < lowImgTexture2dFirst.width; i1 += tempsetp)
//{
// System.Object[] taskParams = { i1, tempsetp, lowImgTexture2dFirst.width, lowImgTexture2dFirst.height };
// if (i1 + tempsetp + tempsetp > lowImgTexture2dFirst.width)
// {
// taskParams[1] = lowImgTexture2dFirst.width - i1;
// tm.addTask(this, onUpdataeColor, taskParams);
// tm.addTask(this, (System.Object[] _) =>
// {
// if (areaIdBase != null && perfabPath.Equals("") == false)
// {
// //创建一堆节点
// TaskItemBack onUpdateByIdNode = (System.Object[] listparam) =>
// {
// checkAddAreaId();
// onInitDigitMatrix("select");
// };
// tm.addTask(this, onUpdateByIdNode);
// }
// else
// {
// onInitDigitMatrix("select");
// }
// });
// break;
// }
// tm.addTask(this, onUpdataeColor, taskParams);
//}
};
tm.addTask(this, onUpdateByIdNode);
}
else
{
onInitDigitMatrix("select");
}
for(; i < gameidJsondata.roomGroupsData.Count(); i++)
{
addTaskInMakeGroupMap(i, lowImgTexture2dFirst, true);
}
};
tm.addTask(this, checkPtNextHandler);
......@@ -272,12 +283,12 @@ public class mainGameView : MonoBehaviour
{
TaskManages tm = TaskManages.getInstance();
TaskItemBack firstHandlGid = (System.Object[] temp) => {
for (int i = 0; i < gameidJsondata.groups.Count; i++)
for (int i = 0; i < gameidJsondata.roomGroupsData.Count; i++)
{
var group = gameidJsondata.groups[i];
for (int i1 = 0; i1 < group.areaIds.Count(); i1++)
var group = gameidJsondata.roomGroupsData[i];
for (int i1 = 0; i1 < group.roomIds.Count(); i1++)
{
gameidJsondata.centers[group.areaIds[i1]].gid = (short)(i + 1);
gameidJsondata.roomDatas[group.roomIds[i1]].gid = group.id;
}
}
return;
......@@ -294,14 +305,14 @@ public class mainGameView : MonoBehaviour
Vector3 localPosTemp = new Vector3();
Quaternion quaternion = new Quaternion();
var areaIdBaseTransform = areaIdBase.transform.GetComponent<RectTransform>();
for (int i = 0; i < gameidJsondata.centers.Count; i++)
for (int i = 0; i < gameidJsondata.roomDatas.Count; i++)
{
var item = gameidJsondata.centers[i];
if (digitMatrix.Data[item.x, item.y] >= 20)
var item = gameidJsondata.roomDatas[i];
if (digitMatrix.Data[item.px, item.py] >= 20)
{
item.tempExKey = "idFlg_" + j.ToSafeString();
j++;
//转成物体坐标系?
//转成物体坐标系?
Transform idValueTran = areaIdBase.transform.Find(item.tempExKey);
if (idValueTran == null)
{
......@@ -314,16 +325,16 @@ public class mainGameView : MonoBehaviour
idValueTran.parent = areaIdBase.transform;
idGameObject.name = item.tempExKey;
}
//怎么转换坐标
//怎么转换坐标
RectTransform rectTransform = areaIdBase.transform.parent.GetComponent<RectTransform>();
//坐标怎么设置?
//坐标怎么设置?
idValueTran.GetLocalPositionAndRotation(out localPosTemp, out quaternion);
//严格居中 字体大小等问题 需要调整json的生成脚本生成逻辑后才能继续
localPosTemp.x = (float)item.x / (float)width * rectTransform.rect.width - (rectTransform.rect.width / 2);
localPosTemp.y = (float)item.y / (float)height * rectTransform.rect.height - (rectTransform.rect.height / 2);
//严格居中 字体大小等问题 需要调整json的生成脚本生成逻辑后才能继续
localPosTemp.x = (float)item.px / (float)width * rectTransform.rect.width - (rectTransform.rect.width / 2);
localPosTemp.y = (float)item.py / (float)height * rectTransform.rect.height - (rectTransform.rect.height / 2);
idValueTran.SetLocalPositionAndRotation(localPosTemp, quaternion);
idValueTran.gameObject.SetActive(false);
idValueTran.GetComponent<TextMeshProUGUI>().text = item.gid.ToString();
idValueTran.GetComponent<TextMeshProUGUI>().text = (item.gid).ToString();
}
}
for (int i = j; i < short.MaxValue; i++)
......@@ -336,38 +347,8 @@ public class mainGameView : MonoBehaviour
}
protected void onInitEndHandler()
{
//for (int i = 0; i < gameidJsondata.centers.; i++)
//{
// var item = gameidJsondata.centers[i];
// System.Object[] temp1 = { item };
// TaskManages.getInstance().addTask(this, (System.Object[] param) =>
// {
// gameAreaItem areaItem = (gameAreaItem)param[0];
// showArea(areaItem.id);
// }, temp1);
// //shorts.Add(item.id);
//}
//utilsTools.addTimer_Sec(gameObject, "test auto add Color", (string name1) =>
//{
// int idx = Random.Range(0, shorts.Count);
// showArea(shorts[idx]);
// return true;
//}, 2.0, (uint)(shorts.Count + 20));
//switchShowAreaGroup(3);
//for(int i = 0;i < 20; i++)
//{
// showArea(i);
//}
utilsTools.sendEvent("gameViewOnInitEnd");
for (int i = 0; i < 0; i++)
{
showArea(i);
}
utilsTools.sendEvent("gameViewOnInitEnd");
}
//typeId 1 == line
//typeId 2 == color
//typeId 3 == json
public void loadFileInfo(string url,string localpath,int typeId)
{
if (typeId == 1 || typeId == 2)
......@@ -399,15 +380,15 @@ public class mainGameView : MonoBehaviour
image.sprite = Sprite.Create(texture2d, new Rect(0, 0, texture2d.width, texture2d.height), new Vector2(0.5f, 0.5f));
if(lowImg != null && typeId == 2)
{
//添加底图
//添加底图
string dir = utilsTools.getWritableByPath(runGameDatas);
string lowPath = dir + "/"+texture2d.width.ToSafeString() + "X" + texture2d.height.ToSafeString()+".png";
print(lowPath);
Debug.Log(lowPath);
if(utilsTools.IsExistIO(lowPath) == false)
{
Texture2D lowTexture = new Texture2D(texture2d.width, texture2d.height, TextureFormat.RGBA32, false);
Color color = new Color(1, 1, 1, 0);
print("tttttttttttttttt **** create select img");
Debug.Log("tttttttttttttttt **** create select img");
for (int x = 0; x < texture2d.width; x++)
{
for(int y = 0;y < texture2d.height; y++)
......@@ -415,15 +396,13 @@ public class mainGameView : MonoBehaviour
lowTexture.SetPixel(x, y, color);
}
}
print("tttttttttttttttt **** create select img 1");
utilsTools.saveByteToPath(lowTexture.EncodeToPNG(), lowPath);
utilsTools.saveImageDefaultMetaInfoToPath(lowPath);
print("tttttttttttttttt **** create select img 2");
}
Image lowImgView = lowImg.GetComponent<Image>();
print(lowPath);
Debug.Log(lowPath);
utilsTools.loadLocalImage(this, lowImgView, lowPath, (bool isOk) => {
print("lowImgTexture2d isOk " + isOk.ToSafeString());
Debug.Log("lowImgTexture2d isOk " + isOk.ToSafeString());
if (isOk)
{
var lowImgTexture2d = lowImgView.sprite.texture;
......@@ -454,13 +433,40 @@ public class mainGameView : MonoBehaviour
{
string jsondata = data as string;
this.gameidJsondata = JsonUtility.FromJson<gameIdJsonData>(jsondata);
if(this.nowSelectInfos != null)
{
int centerSize = gameidJsondata.roomDatas.Count();
for (int i = 0; i < this.nowSelectInfos.Count(); i++)
{
int aid = this.nowSelectInfos[i];
if(aid < 0 || aid >= centerSize)
{
Debug.LogError("本地db错误,或者json错误,超出范围");
return 0;
}
gameidJsondata.roomDatas[aid].isShow = true;
}
for(int i = 0;i < gameidJsondata.roomGroupsData.Count(); i++)
{
var group = gameidJsondata.roomGroupsData[i];
group.isComplete = true;
for (int j = 0; j < group.roomIds.Count(); j++)
{
if (gameidJsondata.roomDatas[group.roomIds[j]].isShow == false)
{
group.isComplete = false;
break;
}
}
}
}
onLoadFileOk(typeId);
return 0;
}
});
}
}
public bool loadGameImgId(string lineUrl,string colorUrl,string jsonUrl)
public bool loadGameImgId(string lineUrl,string colorUrl,string jsonUrl,string gid,List<short> selectIds = null)
{
if (lowImg != null) lowImg.SetActive(false);
if (lineUrl.EndsWith(".png") == false)
......@@ -510,26 +516,19 @@ public class mainGameView : MonoBehaviour
{
utilsTools.CreateDirectory(progresNameDir);
}
this.nowSelectInfos = selectIds;
loadFileInfo(jsonUrl, runGameDatas+"/" + jsonLocalName + ".json", 3);
loadFileInfo(colorUrl, runGameDatas+"/" + colorLocalName + ".png", 2);
loadFileInfo(lineUrl, runGameDatas+"/" + lineLocalName + ".png", 1);
return true;
}
//恢复之前的已经显示进度
public void showAreaList(int[] areaids,OnAreaHandler onAreaHandler = null)
{
for (int i = 0; i < areaids.Count(); i++)
{
showArea(areaids[i], onAreaHandler);
}
}
public void showArea(int areaId, OnAreaHandler onAreaHandler = null)
{
//显示指定区域
if(digitMatrix !=null && lineTexture2d != null && gameidJsondata != null && areaId >= 0 && areaId < gameidJsondata.centers.Count)
//显示指定区域
if(digitMatrix !=null && lineTexture2d != null && gameidJsondata != null && areaId >= 0 && areaId < gameidJsondata.roomDatas.Count)
{
gameAreaItem areaItem1 = gameidJsondata.centers[areaId];
short oldValue = digitMatrix.Data[areaItem1.x, areaItem1.y];
gameAreaItem areaItem1 = gameidJsondata.roomDatas[areaId];
short oldValue = digitMatrix.Data[areaItem1.px, areaItem1.py];
if (oldValue == -2)
{
if(onAreaHandler != null)
......@@ -541,15 +540,16 @@ public class mainGameView : MonoBehaviour
var nowIdNode = areaIdBase.transform.Find(areaItem1.tempExKey);
nowIdNode.SetParent(null);
GameObject.Destroy(nowIdNode.gameObject);
areaItem1.tempExKey = "";
}
TaskManages task = TaskManages.getInstance();
TaskItemBack taskItemBack = (System.Object[] param) =>
{
Color color = new Color(0, 0, 0, 0);
gameAreaItem areaItem = (gameAreaItem)param[0];
short oldValue1 = digitMatrix.Data[areaItem.x, areaItem.y];
var lowImgTexture2d = lowImgTexture2ds[0];
digitMatrix.FloodFill8WithStack(areaItem.x, areaItem.y, -2, oldValue1, (short x1, short y1, short v) => {
short oldValue1 = digitMatrix.Data[areaItem.px, areaItem.py];
var lowImgTexture2d = lowImg.GetComponent<Image>().sprite.texture;// lowImgTexture2ds[0];
digitMatrix.FloodFill8WithStack(areaItem.px, areaItem.py, -2, oldValue1, (short x1, short y1, short v) => {
color = lineTexture2d.GetPixel(x1, y1);
color.a = 0;
lineTexture2d.SetPixel(x1, y1, color);
......@@ -568,7 +568,6 @@ public class mainGameView : MonoBehaviour
utilsTools.saveByteToPath(lowImgTexture2d.EncodeToPNG(), groupPath);
};
task.addTask(this, taskItemBack, areaItem1);
}
else if (onAreaHandler != null)
{
......@@ -581,8 +580,7 @@ public class mainGameView : MonoBehaviour
if (gid == nowSelectgid)
{
if(onAreaHandler != null)
onAreaHandler(gid, true);
onAreaHandler(gid, true);
return true;
}
if (lowImg == null)
......@@ -591,7 +589,7 @@ public class mainGameView : MonoBehaviour
onAreaHandler(gid, false);
return false;
}
if (!(digitMatrix != null && lineTexture2d != null && gameidJsondata != null && gid >= 0 && gid < gameidJsondata.groups.Count))
if (!(digitMatrix != null && lineTexture2d != null && gameidJsondata != null && gid >= 0 && gid < gameidJsondata.roomGroupsData.Count))
{
if (onAreaHandler != null)
onAreaHandler(gid, false);
......@@ -600,70 +598,414 @@ public class mainGameView : MonoBehaviour
lowImg.SetActive(true);
string groupPath = getSelectPathByGid(gid);
Image image = lowImg.GetComponent<Image>();
utilsTools.loadLocalImage(this, image, groupPath,(bool isOk) => {
if (isOk)
if (utilsTools.IsExistIO(groupPath))
{
if (nowSelectgid >= 0) {
for (int i = 0; i < gameidJsondata.roomGroupsData[nowSelectgid-1].roomIds.Count(); i++)
{
short aid = gameidJsondata.roomGroupsData[nowSelectgid-1].roomIds[i];
string key = gameidJsondata.roomDatas[aid].tempExKey;
if(key.Equals("") == false)
{
areaIdBase.transform.Find(key).gameObject.SetActive(false);
}
}
}
nowSelectgid = gid;
utilsTools.loadLocalImage(this, image, groupPath, (bool isOk) =>
{
if (isOk)
{
lowImgTexture2ds[0] = image.sprite.texture;
lowImgTexture2ds[0].Apply();
for (int i = 0; i < gameidJsondata.roomGroupsData[nowSelectgid-1].roomIds.Count(); i++)
{
short aid = gameidJsondata.roomGroupsData[nowSelectgid-1].roomIds[i];
string key = gameidJsondata.roomDatas[aid].tempExKey;
if (key.Equals("") == false)
{
var node = areaIdBase.transform.Find(key);
if(node == null)
{
gameidJsondata.roomDatas[aid].tempExKey = "";
continue;
}
node.gameObject.SetActive(true);
}
}
}
if (onAreaHandler != null)
onAreaHandler(gid, isOk);
});
}
else
{
// 需要添加一个紧急插队的操作
var group = gameidJsondata.roomGroupsData[nowSelectgid-1];
var tm = TaskManages.getInstance();
Texture2D texture2D = new Texture2D(image.sprite.texture.width, image.sprite.texture.height);
texture2D.LoadRawTextureData(image.sprite.texture.GetRawTextureData());
TaskItemBack taskItemBack = (System.Object[] param) => {
gameAreaItem item = (gameAreaItem)param[0];
bool isShow = (bool)param[1];
if (item.tempExKey.Equals("") == false)
{
this.areaIdBase.transform.Find(item.tempExKey).gameObject.SetActive(isShow);
}
Color color = new Color();
digitMatrix.PeekFloodFill8WithStack(item.px, item.py, (short)(0 - item.id), (short)item.id, (short x, short y, short c) =>
{
color = texture2D.GetPixel(x, y);
color.a = isShow ? 1 : 0;
texture2D.SetPixel(x, y,color);
return false;
});
};
//倒排列的顺序
tm.insertTask(this, (System.Object[] param) =>
{
lowImgTexture2ds[0] = image.sprite.texture;
lowImgTexture2ds[0].Apply();
short pgid = (short)param[0];
Sprite sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));
image.sprite = sprite;
saveGroupTexture(pgid, texture2D);
image.sprite.texture.Apply();
OnAreaHandler onAreaHandler1 = (OnAreaHandler)param[1];
if (onAreaHandler1 != null) onAreaHandler1(pgid,true);
},gid,onAreaHandler);
for (int i = 0; i < group.roomIds.Count(); i++)
{
var area = gameidJsondata.roomDatas[group.roomIds[i]];
if(area.isShow == false)
{
tm.insertTask(this, taskItemBack, area, false);
}
}
if (onAreaHandler != null)
onAreaHandler(gid, isOk);
});
//var lowImgTexture2d = lowImgTexture2ds[gid];
//var sprite = Sprite.Create(lowImgTexture2d, new Rect(0, 0, lowImgTexture2d.width, lowImgTexture2d.height), new Vector2(0.5f, 0.5f));
//lowImg.GetComponent<Image>().sprite = sprite;
//sprite.texture.Apply();
var group2 = gameidJsondata.roomGroupsData[gid];
for (int i = 0; i < group2.roomIds.Count(); i++)
{
var area = gameidJsondata.roomDatas[group2.roomIds[i]];
if (area.isShow == false)
{
tm.insertTask(this, taskItemBack, area, true);
}
}
nowSelectgid = gid;
}
return true;
}
public List<Color> getGroups()
public List<TempGroupInfos> getGroups()
{
List<Color> colors = new List<Color>();
List<TempGroupInfos> ret = new List<TempGroupInfos>();
if (digitMatrix != null && lineTexture2d != null && gameidJsondata != null)
{
foreach (var item in gameidJsondata.groups)
foreach (var item in gameidJsondata.roomGroupsData)
{
Color color = new Color();
item.getRGB(out color);
colors.Add(color);
TempGroupInfos tempGroupInfos = new TempGroupInfos();
item.getRGB(out tempGroupInfos.rgb);
tempGroupInfos.gid = item.id;
if (item.isComplete) tempGroupInfos.jindu = 1;
else
{
short cout = 0;
for (int i = 0; i < item.roomIds.Count(); i++)
{
if (gameidJsondata.roomDatas[item.roomIds[i]].isShow)
{
cout++;
}
}
//防止出现 整数 2/5 ==> 0
tempGroupInfos.jindu = (float)cout / (float)item.roomIds.Count();
}
ret.Add(tempGroupInfos);
}
}
return colors;
return ret;
}
int getAreaByPos(int x,int y)
{
if (digitMatrix == null || lineTexture2d == null || gameidJsondata == null || x >= digitMatrix.RowCount || y >= digitMatrix.ColumnCount)
return -1;
short oldValue = digitMatrix.Data[x, y];
if (oldValue == -2) return -1;//已经显示
if (oldValue == 0) return -1;//请稍后尚未初始化完成
if (oldValue == -1) return -1;//这是轮廓上
if (oldValue == -2) return -1;//已经显示
if (oldValue == 0) return -1;//请稍后尚未初始化完成
if (oldValue == -1) return -1;//这是轮廓上
return oldValue - 20;
}
public bool showAreaByPos(short x,short y,OnAreaHandler showBack)
{
if (x >= digitMatrix.RowCount || y >= digitMatrix.ColumnCount || this.nowSelectgid < 0 || x < 0 || y < 0)
{
if(showBack!= null)
showBack(-1, false);
return false;
}
short oldValue = digitMatrix.Data[x, y];
if (oldValue < 20)
{
if (showBack != null)
showBack(-1, false);
return false;
}
short aid = (short)(oldValue - 20);
var areaItem = gameidJsondata.roomDatas[aid];
if(gameidJsondata.roomGroupsData[nowSelectgid-1].roomIds.IndexOf(aid) < 0)
{
if (showBack != null) showBack(aid, false);
return false;
}
if (areaItem.isShow)
{
if (showBack != null)
showBack(-1, false);
return false;
}
areaItem.isShow = true;
//showArea(aid);
if (areaItem.tempExKey.Equals("") == false)
{
var node = areaIdBase.transform.Find(areaItem.tempExKey);
if (node != null)
{
node.SetParent(null);
GameObject.Destroy(node.gameObject);
}
areaItem.tempExKey = "";
}
AreaAnimationDiffuse areaAnimationDiffuse = new AreaAnimationDiffuse(x, y, aid);
areaAnimationDiffuse.m_fpsStart = 0;
showAreaAnimationDatas.Add(areaAnimationDiffuse);
return true;
}
public void loadTest()
{
loadGameImgId(
"http://192.168.124.160:8795/srcImgs/temp1/testImgline.png",
"http://192.168.124.160:8795/srcImgs/temp1/testImg.png",
"http://192.168.124.160:8795/srcImgs/temp1/testImg.json"
);
"http://192.168.124.160:8795/srcImgs/colorFan/tuline.png",
"http://192.168.124.160:8795/srcImgs/colorFan/tucolor.png",
"http://192.168.124.160:8795/srcImgs/colorFan/tu.json",
"tu");
}
// Start is called before the first frame update
void Start()
{
//utilsTools.HideView(gameObject);
utilsTools.addTimer_Update(gameObject, "tempNext", (string name) =>
{
//loadTest();
return false;
});
//Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
}
private void showColorByPos(int x,int y,short aid,Texture2D lowImgTexture2d)
{
digitMatrix.Data[(short)x, (short)y] = -2;
Color color = lineTexture2d.GetPixel(x, y);
color.a = 0;
lineTexture2d.SetPixel(x, y, color);
color = lowImgTexture2d.GetPixel(x, y);
color.a = 0;
lowImgTexture2d.SetPixel(x, y, color);
}
// Update is called once per frame
void Update()
{
TaskManages.getInstance().updateTask(this);
onShowAnimationHandler();
}
//暂时不支持 不同组在同一帧率填充过程
void onShowAnimationHandler()
{
if (showAreaAnimationDatas.Count > 0)
{
int cout = 0;
int width = lineTexture2d.width;
int height = lineTexture2d.height;
Texture2D selectTexture = null;
if(lowImg != null)
{
selectTexture = lowImg.GetComponent<Image>().sprite.texture;
}
List<short> removeAids = new List<short>();
foreach (var item in showAreaAnimationDatas)
{
float setp = 0.35f;
int cout1 = 0;
if(item.m_fpsStart > 10)
{
setp = 1 / (item.m_fpsStart / 5f);
}
short nowcheckAid = (short)(item.m_aid + 20);
bool isChange = nowSelectgid.Equals(gameidJsondata.roomDatas[item.m_aid].gid);
for (float angle = 0; angle < 360; angle += setp) {
Vector2 direct = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle));
for (short r = item.m_fpsStart; r < item.m_fpsEnd; r++)
{
//下标0就只需要一个点就可以了,不需要360都算一遍
if (r == 0 && utilsTools.isEqualByValue(angle, 0.0f, 0.000003f) == false) continue;
Vector2 scale = direct * r;
short x = Convert.ToInt16(scale.x+ item.m_x);
short y = Convert.ToInt16(scale.y + item.m_y);
if (x < 0 || y < 0 || x >= width || y >= height) continue;
short nowDataValue = digitMatrix.Data[x, y];
if (nowDataValue.Equals(nowcheckAid) == false) {
continue;
}
string key = x.ToString() + "_" + y.ToString();
digitMatrix.Data[x, y] = -1;
Color color = lineTexture2d.GetPixel(x, y);
color.a = 0;
lineTexture2d.SetPixel(x, y, color);
cout++;
cout1++;
if (selectTexture != null)
{
color = selectTexture.GetPixel(x, y);
color.a = 0;
selectTexture.SetPixel(x, y, color);
}
}
}
if(cout1 == 0)
{
//没有可渲染区域
removeAids.Add(item.m_aid);
Debug.Log("没有找到填充的颜色像素"+item.m_aid.ToString());
}
else
{
short diff = (short)(item.m_fpsEnd - item.m_fpsStart);
item.m_fpsStart = item.m_fpsEnd;
item.m_fpsEnd += diff;
}
}
if(cout == 0)
{
showAreaAnimationDatas.Clear();
return;
}
if(selectTexture != null)
{
selectTexture.Apply();
}
lineTexture2d.Apply();
if(removeAids.Count > 0)
{
//移除已经播放完成
foreach (var aid in removeAids)
{
for (int i = 0; i < showAreaAnimationDatas.Count; i++)
{
if (showAreaAnimationDatas[i].m_aid.Equals(aid) == true)
{
showAreaAnimationDatas.RemoveAt(i);
break;
}
}
}
}
}
}
void testFunByMousePtShowYuanAnimation()
{
if (Input.GetMouseButtonDown(0))
{
RectTransform rectTransform = lineImg.GetComponent<RectTransform>();
Vector2 pos = utilsTools.ScreenToUILocalPos(rectTransform, Input.mousePosition);
rvalue = 1;
if (lowImgTexture2ds.Count == 0)
{
Texture2D texture2D = lineImg.GetComponent<Image>().sprite.texture;
Texture2D texture = new Texture2D(texture2D.width, texture2D.height, texture2D.format, false);
texture.LoadRawTextureData(texture.GetRawTextureData());
lowImgTexture2ds.Add(texture);
texture = new Texture2D(texture2D.width, texture2D.height, texture2D.format, false);
texture.LoadRawTextureData(texture.GetRawTextureData());
lowImgTexture2ds.Add(texture);
}
else
{
Texture2D texture2D = lowImgTexture2ds[1];
Texture2D texture = new Texture2D(texture2D.width, texture2D.height, texture2D.format, false);
texture.LoadRawTextureData(texture.GetRawTextureData());
GameObject.Destroy(lowImgTexture2ds[0]);
lowImgTexture2ds[0] = texture;
}
Vector2 scaleVector = new Vector2(1, 1);
scaleVector.x = lowImgTexture2ds[0].width / rectTransform.rect.width;
scaleVector.y = lowImgTexture2ds[0].height / rectTransform.rect.height;
pos1 = pos * scaleVector;
}
else if (rvalue > 0)
{
Dictionary<String, bool> keyValues = new Dictionary<string, bool>();
mainGameView gameView = this;
Texture2D texture2D = null;
RectTransform rectTransform = gameView.lineImg.GetComponent<RectTransform>();
float setp = 5f;
if (rvalue > 5)
{
setp = 2 / ((float)rvalue / 8);
}
for (float angle = 0; angle < 360; angle += setp)
{
float radians = angle * Mathf.Deg2Rad;
Vector2 direction = new Vector2(Mathf.Cos(radians), Mathf.Sin(radians));
for (float r = 0; r < 10; r++)
{
if (r + rvalue > 100) break;
Vector2 temp = direction * (r + rvalue);
int x = Convert.ToInt32(pos1.x + temp.x);
int y = Convert.ToInt32(pos1.y + temp.y);
if (rectTransform.rect.Contains(new Vector2(x, y)) == false) continue;
string key = x.ToString() + "_" + y.ToString();
if (keyValues.ContainsKey(key)) continue;
keyValues.Add(key, true);
if (texture2D == null)
{
texture2D = gameView.lowImgTexture2ds[0];
}
//需要尺寸缩放
x = Convert.ToInt32(x + texture2D.width / 2);//x + Convert.ToInt32(rectTransform.rect.width / 2);
y = Convert.ToInt32(y + texture2D.height / 2);
if (x < 0 || y < 0 || x > texture2D.width || y > texture2D.height) continue;
Color color = texture2D.GetPixel(x, y);
color.a = 0;
texture2D.SetPixel(x, y, color);
}
}
if (texture2D == null)
{
rvalue = 0;
utilsTools.addTimer_Sec(gameObject, "tempTest_1", (string name) =>
{
texture2D = gameView.lowImgTexture2ds[1];
Sprite sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));
gameView.lineImg.GetComponent<Image>().sprite = sprite;
sprite.texture.Apply();
return false;
}, 3);
}
else
{
Sprite sprite = Sprite.Create(texture2D, new Rect(0, 0, texture2D.width, texture2D.height), new Vector2(0.5f, 0.5f));
gameView.lineImg.GetComponent<Image>().sprite = sprite;
sprite.texture.Apply();
rvalue += 10;
}
}
}
public bool getSize(out int width,out int height)
{
width = -1;
height = -1;
if (lineTexture2d == null)
return false;
width = lineTexture2d.width;
height = lineTexture2d.height;
return true;
}
public void debugPos(int x,int y)
{
}
}
......@@ -118,7 +118,7 @@ public class nodeNetProxy : MonoBehaviour
{
if (request.isNetworkError || request.isHttpError) //���������󣬻��ߵ�ַ����
{
print("error" + request.error + url); //����������
Debug.Log("error" + request.error + url); //����������
back("", wurl, false, null);
}
else //���û��
......@@ -138,16 +138,16 @@ public class nodeNetProxy : MonoBehaviour
//��������Ѿ����
if (request.isDone)
{
print("load end " + url);
Debug.Log("load end " + url);
if (request.isNetworkError || request.isHttpError) //���������󣬻��ߵ�ַ����
{
print(request.error); //����������
Debug.Log(request.error); //����������
back("", wurl, false, null);
}
else //���û��
{
print("load end ok " + url);
Debug.Log("load end ok " + url);
String data1 = DownloadHandlerBuffer.GetContent(request);
back("", wurl, true, data1);
}
......@@ -164,7 +164,7 @@ public class nodeNetProxy : MonoBehaviour
}
else
{
print("jar:file://" + abspath);
Debug.Log("jar:file://" + abspath);
StartCoroutine(loadLocalTextFileData("jar:file://" + abspath, url, back));
}
......@@ -204,7 +204,7 @@ public class nodeNetProxy : MonoBehaviour
StartCoroutine(loadLocalFileData("file://" + abspath, url, back));
else
{
print("jar:file://" + abspath);
Debug.Log("jar:file://" + abspath);
StartCoroutine(loadLocalFileData("jar:file://" + abspath, url, back));
}
return;
......@@ -214,8 +214,8 @@ public class nodeNetProxy : MonoBehaviour
back("", url, false, null);
return;
}
print("no find path " + localpath + " >> " + abspath);
print(url);
Debug.Log("no find path " + localpath + " >> " + abspath);
Debug.Log(url);
nodeNetProxyItem newItem = new nodeNetProxyItem();
newItem.url = url;
newItem.back = back;
......@@ -235,9 +235,9 @@ public class nodeNetProxy : MonoBehaviour
yield return unityWebRequest.SendWebRequest();
if (unityWebRequest.error != null)
{
print("DonLoadText error");
print(unityWebRequest.error);
print(unityWebRequest.ToString());
Debug.Log("DonLoadText error");
Debug.Log(unityWebRequest.error);
Debug.Log(unityWebRequest.ToString());
item.back("", url, false, null);
yield return unityWebRequest;
}
......@@ -288,8 +288,17 @@ public class nodeNetProxy : MonoBehaviour
string path1 = path;
string expath = Path.GetExtension(path1);
path1 = path1.Substring(0, path1.Length - expath.Length);
print(path1);
item.back("", url, true, Resources.Load<Texture>(path1));
if (utilsTools.IsPhone == false)
StartCoroutine(loadLocalFileData("file://" + path1, url, item.back));
else
{
Debug.Log("jar:file://" + path1);
StartCoroutine(loadLocalFileData("jar:file://" + path1, url, item.back));
}
//Debug.Log(path1);
//var texture = Resources.Load<Texture>(path1);
//item.back("", url, true, texture);
}
yield return null;
......
......@@ -59,8 +59,8 @@ public class MouseDragSelect : MonoBehaviour
if (!draggingMouse)
{
mousePositions[0] = Input.mousePosition;
print("x start:" + mousePositions[0].x);
print("y start:" + mousePositions[0].y);
Debug.Log("x start:" + mousePositions[0].x);
Debug.Log("y start:" + mousePositions[0].y);
}
draggingMouse = true;
}
......@@ -73,12 +73,12 @@ public class MouseDragSelect : MonoBehaviour
float height = Math.Abs(mousePositions[1].y - mousePositions[0].y);
float x = mousePositions[0].x;
float y = mousePositions[0].y;
// print("width:" + width);
// print("height:" + height);
print("x end:" + mousePositions[1].x);
print("y end:" + mousePositions[1].y);
// Debug.Log("width:" + width);
// Debug.Log("height:" + height);
Debug.Log("x end:" + mousePositions[1].x);
Debug.Log("y end:" + mousePositions[1].y);
position = new Rect(x, y, width, height);
// print("Got last mouse position!");
// Debug.Log("Got last mouse position!");
drawRect = true;
}
}
......
......@@ -77,7 +77,7 @@ public class tempzhangs : MonoBehaviour
////void clearFlgs(int startx, int starty, int w, int h, short val)
////{
//// Color tempColor = new Color();
//// print("开始尝试循环赋值");
//// Debug.Log("开始尝试循环赋值");
//// int nobai = 0;
//// for (int i = 0; i < clickTexture2D.width; i++)
//// {
......@@ -104,7 +104,7 @@ public class tempzhangs : MonoBehaviour
//// setColor(i, j, tempColor);
//// }
//// }
//// print("结束循环赋值 nobai = " + nobai);
//// Debug.Log("结束循环赋值 nobai = " + nobai);
//// updateUIMask();
////}
////void clearAllData()
......@@ -136,7 +136,7 @@ public class tempzhangs : MonoBehaviour
////private void CaculateVector2(int x, int y)
////{
//// if (dm.Data[x, y] != 1) return;
//// print("开始绘制圆形");
//// Debug.Log("开始绘制圆形");
//// operColorSize = 0;
//// lastOperX = -1;
//// dm.FloodFill8WithStack((short)x, (short)y, -100, 1, (short x1, short y1, short value) =>
......@@ -154,7 +154,7 @@ public class tempzhangs : MonoBehaviour
////}
////private void updateUIMask()
////{
//// print("替换纹理");
//// Debug.Log("替换纹理");
//// Sprite sprite = Sprite.Create(clickTexture2D, new Rect(0, 0, clickTexture2D.width, clickTexture2D.height), new Vector2(0.5f, 0.5f));
//// sprite.name = "rand__temp__text_localFile";
//// image0.sprite = sprite;
......@@ -164,7 +164,7 @@ public class tempzhangs : MonoBehaviour
// Byte[] bytes1 = Encoding.UTF8.GetBytes("fileFormatVersion: 2\r\nguid: 54ac8b67ea1f6f14892bd14ea1caab62\r\nTextureImporter:\r\n internalIDToNameTable: []\r\n externalObjects: {}\r\n serializedVersion: 12\r\n mipmaps:\r\n mipMapMode: 0\r\n enableMipMap: 0\r\n sRGBTexture: 1\r\n linearTexture: 0\r\n fadeOut: 0\r\n borderMipMap: 0\r\n mipMapsPreserveCoverage: 0\r\n alphaTestReferenceValue: 0.5\r\n mipMapFadeDistanceStart: 1\r\n mipMapFadeDistanceEnd: 3\r\n bumpmap:\r\n convertToNormalMap: 0\r\n externalNormalMap: 0\r\n heightScale: 0.25\r\n normalMapFilter: 0\r\n flipGreenChannel: 0\r\n isReadable: 0\r\n streamingMipmaps: 0\r\n streamingMipmapsPriority: 0\r\n vTOnly: 0\r\n ignoreMipmapLimit: 0\r\n grayScaleToAlpha: 0\r\n generateCubemap: 6\r\n cubemapConvolution: 0\r\n seamlessCubemap: 0\r\n textureFormat: 1\r\n maxTextureSize: 2048\r\n textureSettings:\r\n serializedVersion: 2\r\n filterMode: 1\r\n aniso: 1\r\n mipBias: 0\r\n wrapU: 1\r\n wrapV: 1\r\n wrapW: 1\r\n nPOTScale: 0\r\n lightmap: 0\r\n compressionQuality: 50\r\n spriteMode: 1\r\n spriteExtrude: 1\r\n spriteMeshType: 1\r\n alignment: 0\r\n spritePivot: {x: 0.5, y: 0.5}\r\n spritePixelsToUnits: 1\r\n spriteBorder: {x: 0, y: 0, z: 0, w: 0}\r\n spriteGenerateFallbackPhysicsShape: 1\r\n alphaUsage: 1\r\n alphaIsTransparency: 1\r\n spriteTessellationDetail: -1\r\n textureType: 8\r\n textureShape: 1\r\n singleChannelComponent: 0\r\n flipbookRows: 1\r\n flipbookColumns: 1\r\n maxTextureSizeSet: 0\r\n compressionQualitySet: 0\r\n textureFormatSet: 0\r\n ignorePngGamma: 0\r\n applyGammaDecoding: 0\r\n swizzle: 50462976\r\n cookieLightType: 0\r\n platformSettings:\r\n - serializedVersion: 3\r\n buildTarget: DefaultTexturePlatform\r\n maxTextureSize: 2048\r\n resizeAlgorithm: 0\r\n textureFormat: -1\r\n textureCompression: 1\r\n compressionQuality: 50\r\n crunchedCompression: 0\r\n allowsAlphaSplitting: 0\r\n overridden: 0\r\n ignorePlatformSupport: 0\r\n androidETC2FallbackOverride: 0\r\n forceMaximumCompressionQuality_BC6H_BC7: 0\r\n - serializedVersion: 3\r\n buildTarget: Standalone\r\n maxTextureSize: 2048\r\n resizeAlgorithm: 0\r\n textureFormat: -1\r\n textureCompression: 1\r\n compressionQuality: 50\r\n crunchedCompression: 0\r\n allowsAlphaSplitting: 0\r\n overridden: 0\r\n ignorePlatformSupport: 0\r\n androidETC2FallbackOverride: 0\r\n forceMaximumCompressionQuality_BC6H_BC7: 0\r\n - serializedVersion: 3\r\n buildTarget: Server\r\n maxTextureSize: 2048\r\n resizeAlgorithm: 0\r\n textureFormat: -1\r\n textureCompression: 1\r\n compressionQuality: 50\r\n crunchedCompression: 0\r\n allowsAlphaSplitting: 0\r\n overridden: 0\r\n ignorePlatformSupport: 0\r\n androidETC2FallbackOverride: 0\r\n forceMaximumCompressionQuality_BC6H_BC7: 0\r\n - serializedVersion: 3\r\n buildTarget: Android\r\n maxTextureSize: 2048\r\n resizeAlgorithm: 0\r\n textureFormat: -1\r\n textureCompression: 1\r\n compressionQuality: 50\r\n crunchedCompression: 0\r\n allowsAlphaSplitting: 0\r\n overridden: 0\r\n ignorePlatformSupport: 0\r\n androidETC2FallbackOverride: 0\r\n forceMaximumCompressionQuality_BC6H_BC7: 0\r\n spriteSheet:\r\n serializedVersion: 2\r\n sprites: []\r\n outline: []\r\n physicsShape: []\r\n bones: []\r\n spriteID: 5e97eb03825dee720800000000000000\r\n internalID: 0\r\n vertices: []\r\n indices: \r\n edges: []\r\n weights: []\r\n secondaryTextures: []\r\n nameFileIdTable: {}\r\n mipmapLimitGroupName: \r\n pSDRemoveMatte: 0\r\n userData: \r\n assetBundleName: \r\n assetBundleVariant: \r\n");
// utilsTools.saveByteToPath(bytes1, "Resources/rand__temp__text_localFile.png.meta");
//// utilsTools.loadLocalImage(this, image0, "Resources/rand__temp__text_localFile.png");
//// print("替换纹理End");
//// Debug.Log("替换纹理End");
////}
////private Vector2 ScreenToUILocalPos(RectTransform transform, Vector2 mousePos, Camera canvasCam = null)
////{
......
......@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static UnityEngine.ParticleSystem;
public class TaskManages
{
......@@ -14,6 +15,22 @@ public class TaskManages
{
return instance;
}
//priorityStack
//内部是栈维护 当栈空的时候才会继续执行队列Queue中的任务
public void insertTask(MonoBehaviour monoBehaviour,TaskItemBack taskItemBack, System.Object[] allparams)
{
Stack<Tuple<TaskItemBack, System.Object[]>> taskInfos;
if (utilsTools.ContainsKey(monoBehaviour.gameObject, "PriorityStack") == false)
utilsTools.getUserData<Stack<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "PriorityStack", out taskInfos, new Stack<Tuple<TaskItemBack, System.Object[]>>());
else
utilsTools.getUserData<Stack<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "PriorityStack", out taskInfos, null);
utilsTools.setUserData(monoBehaviour.gameObject, "PriorityStack", taskInfos);
}
public void insertTask(MonoBehaviour monoBehaviour, TaskItemBack taskItemBack, System.Object param1 = null,System.Object param2 = null)
{
System.Object[] allparams = { param1,param2 };
insertTask(monoBehaviour, taskItemBack, allparams);
}
public void addTask(MonoBehaviour monoBehaviour, TaskItemBack taskItemBack, System.Object param = null)
{
System.Object[] allparams = { param };
......@@ -29,17 +46,37 @@ public class TaskManages
taskInfos.Enqueue(new Tuple<TaskItemBack, object[]>(taskItemBack, allparams));
utilsTools.setUserData(monoBehaviour.gameObject, "TaskList", taskInfos);
}
private Tuple<TaskItemBack, System.Object[]> getTask(MonoBehaviour monoBehaviour)
{
Tuple<TaskItemBack, System.Object[]> ret = null;
if (utilsTools.ContainsKey(monoBehaviour.gameObject, "PriorityStack") == true)
{
Stack<Tuple<TaskItemBack, System.Object[]>> taskStackInfos = null;
utilsTools.getUserData<Stack<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "PriorityStack", out taskStackInfos, null);
if(taskStackInfos.Count > 0)
{
ret = taskStackInfos.Pop();
utilsTools.setUserData(monoBehaviour.gameObject, "PriorityStack", taskStackInfos);
}
}
if (ret == null)
{
Queue<Tuple<TaskItemBack, System.Object[]>> taskInfos;
if (utilsTools.ContainsKey(monoBehaviour.gameObject, "TaskList") == false)
return null;
else
utilsTools.getUserData<Queue<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "TaskList", out taskInfos, null);
if (taskInfos.Count == 0) return null;
ret = taskInfos.Dequeue();
utilsTools.setUserData(monoBehaviour.gameObject, "TaskList", taskInfos);
}
return ret;
}
public bool updateTask(MonoBehaviour monoBehaviour)
{
Queue<Tuple<TaskItemBack, System.Object[]>> taskInfos;
if (utilsTools.ContainsKey(monoBehaviour.gameObject, "TaskList") == false)
return false;
else
utilsTools.getUserData<Queue<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "TaskList", out taskInfos, null);
if (taskInfos.Count == 0) return false;
var first = taskInfos.Dequeue();
utilsTools.setUserData(monoBehaviour.gameObject, "TaskList", taskInfos);
first.Item1(first.Item2);
var task = getTask(monoBehaviour);
if (task == null) return false;
task.Item1(task.Item2);
return true;
}
public int taskSize(MonoBehaviour monoBehaviour)
......
......@@ -477,7 +477,6 @@ public class utilsTools
{
Directory.CreateDirectory(path1);
}
}
}
}
Base path: 'C:/Program Files/Unity/Hub/Editor/2022.3.1f1c1/Editor/Data', plugins path 'C:/Program Files/Unity/Hub/Editor/2022.3.1f1c1/Editor/Data/PlaybackEngines'
Cmd: initializeCompiler
Cmd: shutdown
Quitting shader compiler process
......@@ -15,11 +15,11 @@ MonoBehaviour:
m_PixelRect:
serializedVersion: 2
x: 7.2000003
y: 50.4
y: 104.8
width: 2033.6
height: 1054.4
height: 1000
m_ShowMode: 4
m_Title: "\u6E38\u620F"
m_Title: Game
m_RootView: {fileID: 9}
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
......@@ -40,9 +40,9 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 387.2
width: 507.20007
height: 617.2
y: 619.2
width: 317.6001
height: 330.8
m_MinSize: {x: 232, y: 271}
m_MaxSize: {x: 10002, y: 10021}
m_ActualView: {fileID: 13}
......@@ -67,14 +67,14 @@ MonoBehaviour:
- {fileID: 2}
m_Position:
serializedVersion: 2
x: 1197.6
x: 1463.2
y: 0
width: 507.20007
height: 1004.4
width: 317.6001
height: 950
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 8096, y: 16192}
vertical: 1
controlID: 142
controlID: 63
--- !u!114 &4
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -85,23 +85,23 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: SceneHierarchyWindow
m_Name: ConsoleWindow
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 0
y: 0
width: 507.20007
height: 387.2
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 15}
width: 317.6001
height: 619.2
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 17}
m_Panes:
- {fileID: 15}
- {fileID: 17}
m_Selected: 0
m_LastSelected: 1
m_Selected: 1
m_LastSelected: 0
--- !u!114 &5
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -117,10 +117,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 711.2
x: 569.6
y: 0
width: 486.39996
height: 1004.4
width: 893.6
height: 950
m_MinSize: {x: 202, y: 221}
m_MaxSize: {x: 4002, y: 4021}
m_ActualView: {fileID: 16}
......@@ -148,12 +148,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1704.8
height: 1004.4
width: 1780.8
height: 950
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 45
controlID: 62
--- !u!114 &7
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -174,11 +174,11 @@ MonoBehaviour:
x: 0
y: 30
width: 2033.6
height: 1004.4
height: 950
m_MinSize: {x: 400, y: 100}
m_MaxSize: {x: 32384, y: 16192}
vertical: 0
controlID: 44
controlID: 61
--- !u!114 &8
MonoBehaviour:
m_ObjectHideFlags: 52
......@@ -194,10 +194,10 @@ MonoBehaviour:
m_Children: []
m_Position:
serializedVersion: 2
x: 1704.8
x: 1780.8
y: 0
width: 328.79993
height: 1004.4
width: 252.79993
height: 950
m_MinSize: {x: 276, y: 71}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 14}
......@@ -226,7 +226,7 @@ MonoBehaviour:
x: 0
y: 0
width: 2033.6
height: 1054.4
height: 1000
m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000}
m_UseTopView: 1
......@@ -271,7 +271,7 @@ MonoBehaviour:
m_Position:
serializedVersion: 2
x: 0
y: 1034.4
y: 980
width: 2033.6
height: 20
m_MinSize: {x: 0, y: 0}
......@@ -293,8 +293,8 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 711.2
height: 1004.4
width: 569.6
height: 950
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_ActualView: {fileID: 18}
......@@ -317,15 +317,15 @@ MonoBehaviour:
m_MinSize: {x: 230, y: 250}
m_MaxSize: {x: 10000, y: 10000}
m_TitleContent:
m_Text: "\u9879\u76EE"
m_Text: Project
m_Image: {fileID: -5179483145760003458, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1204.8
y: 468
width: 505.20007
height: 596.2
x: 1470.4
y: 754.4
width: 315.6001
height: 309.8
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -341,8 +341,6 @@ MonoBehaviour:
m_ClassNames: []
m_AssetLabels: []
m_AssetBundleNames: []
m_VersionControlStates: []
m_SoftLockControlStates: []
m_ReferencingInstanceIDs:
m_SceneHandles:
m_ShowAllHits: 0
......@@ -365,7 +363,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: f0660000
m_LastClickedID: 26352
m_ExpandedIDs: 00000000386400003a6400003c6400003e6400004064000042640000446400004664000048640000
m_ExpandedIDs: 00000000126300003263000030640000326400003464000036640000386400003a6400003c6400003e64000040640000426400004464000046640000486400004a640000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
......@@ -390,10 +388,10 @@ MonoBehaviour:
m_Icon: {fileID: 0}
m_ResourceFile:
m_AssetTreeState:
scrollPos: {x: 0, y: 0}
scrollPos: {x: 0, y: 1216.2}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: ffffffff00000000386400003a6400003c6400003e640000406400004264000044640000466400004864000088640000
m_ExpandedIDs: ffffffff00000000126300003263000030640000326400003464000036640000386400003a6400003c6400003e64000040640000426400004464000046640000486400004a640000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
......@@ -464,15 +462,15 @@ MonoBehaviour:
m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: "\u68C0\u67E5\u5668"
m_Text: Inspector
m_Image: {fileID: -440750813802333266, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1712
y: 80.8
width: 327.79993
height: 983.4
x: 1788
y: 135.2
width: 251.79993
height: 929
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -511,15 +509,15 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: "\u5C42\u7EA7"
m_Text: Hierarchy
m_Image: {fileID: -3734745235275155857, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1204.8
y: 80.8
width: 505.20007
height: 366.2
x: 1470.4
y: 135.2
width: 315.6001
height: 598.2
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -535,7 +533,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 78efffff7aefffff7cefffff84efffff86f5ffff8ef5ffff9cf5ffffb0f5fffff8f9ffff4c620000ba620000ce620000
m_ExpandedIDs: 34dbfeff7cdbfeffe8ddfeff02defeff36defeff8adefeff92defeffa0defeffb2defeffe6f9ffff
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
......@@ -574,15 +572,15 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: "\u573A\u666F"
m_Text: Scene
m_Image: {fileID: 8634526014445323508, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 718.4
y: 80.8
width: 484.39996
height: 983.4
x: 576.8
y: 135.2
width: 891.6
height: 929
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -928,9 +926,9 @@ MonoBehaviour:
m_PlayAudio: 0
m_AudioPlay: 0
m_Position:
m_Target: {x: 434.2745, y: 673.83057, z: -0.014899037}
m_Target: {x: 458.518, y: 1234.1746, z: -0.11622809}
speed: 2
m_Value: {x: 434.2745, y: 673.83057, z: -0.014899037}
m_Value: {x: 458.518, y: 1234.1746, z: -0.11622809}
m_RenderMode: 0
m_CameraMode:
drawMode: 0
......@@ -980,9 +978,9 @@ MonoBehaviour:
speed: 2
m_Value: {x: 0, y: 0, z: 0, w: 1}
m_Size:
m_Target: 551.76074
m_Target: 576.71204
speed: 2
m_Value: 551.76074
m_Value: 576.71204
m_Ortho:
m_Target: 1
speed: 2
......@@ -1022,15 +1020,15 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: "\u63A7\u5236\u53F0"
m_Text: Console
m_Image: {fileID: -4950941429401207979, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 1204.8
y: 80.8
width: 505.20007
height: 366.2
x: 1470.4
y: 135.2
width: 315.6001
height: 598.2
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -1056,15 +1054,15 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: "\u6E38\u620F"
m_Text: Game
m_Image: {fileID: 4621777727084837110, guid: 0000000000000000d000000000000000, type: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 7.2000003
y: 80.8
width: 710.2
height: 983.4
y: 135.2
width: 568.6
height: 929
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
......@@ -1107,7 +1105,7 @@ MonoBehaviour:
m_VAllowExceedBaseRangeMin: 1
m_VAllowExceedBaseRangeMax: 1
m_ScaleWithWindow: 0
m_HSlider: 1
m_HSlider: 0
m_VSlider: 1
m_IgnoreScrollWheelUntilClicked: 0
m_EnableMouseInput: 1
......@@ -1119,23 +1117,23 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 21
width: 710.2
height: 962.4
m_Scale: {x: 1.2576778, y: 1.2576778}
m_Translation: {x: 331.5816, y: 536.33826}
width: 568.6
height: 908
m_Scale: {x: 0.525463, y: 0.525463}
m_Translation: {x: 284.3, y: 453.99997}
m_MarginLeft: 0
m_MarginRight: 0
m_MarginTop: 0
m_MarginBottom: 0
m_LastShownAreaInsideMargins:
serializedVersion: 2
x: -263.6459
y: -426.45123
width: 564.6915
height: 765.21985
x: -541.04663
y: -863.9999
width: 1082.0933
height: 1727.9999
m_MinimalGUI: 1
m_defaultScale: 0.55694443
m_LastWindowPixelSize: {x: 887.75, y: 1229.25}
m_defaultScale: 0.525463
m_LastWindowPixelSize: {x: 710.75, y: 1161.25}
m_ClearInEditMode: 1
m_NoCameraWarning: 1
m_LowResolutionForAspectRatios: 01000000000000000000
......
No preview for this file type
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