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) =>
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
groupInfos = maingameView.getGroups();
int cout = 0;
for (int i = 0; i < groupInfos.Count; i++)
{
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;
if(groupInfos[i].jindu == 1) {
break;
}
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;
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"))
{
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++)
}else if (eventName.Equals("gameClickPos"))
{
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 void onOneClick(Vector2 nowPos)
private Vector3 GetNativePosition(Vector3 screenPos)
{
RectTransform firstRectTransform = transform.GetChild(0).GetComponent<RectTransform>();
var localPos = utilsTools.ScreenToUILocalPos(firstRectTransform, nowPos);
if (firstRectTransform.rect.Contains(localPos))//首先要区域内
// 将屏幕坐标转换为世界坐标
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)
{
Vector2 localPos1 = (localPos - (nowPos * nowScale * 3f));
MyPrint("click", nowPos, localPos, localPos1);
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)
{
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 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()
......
This diff is collapsed.
......@@ -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);
}
public bool updateTask(MonoBehaviour monoBehaviour)
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 false;
return null;
else
utilsTools.getUserData<Queue<Tuple<TaskItemBack, System.Object[]>>>(monoBehaviour.gameObject, "TaskList", out taskInfos, null);
if (taskInfos.Count == 0) return false;
var first = taskInfos.Dequeue();
if (taskInfos.Count == 0) return null;
ret = taskInfos.Dequeue();
utilsTools.setUserData(monoBehaviour.gameObject, "TaskList", taskInfos);
first.Item1(first.Item2);
}
return ret;
}
public bool updateTask(MonoBehaviour monoBehaviour)
{
var task = getTask(monoBehaviour);
if (task == null) return false;
task.Item1(task.Item2);
return true;
}
public int taskSize(MonoBehaviour monoBehaviour)
......
......@@ -479,5 +479,4 @@ public class utilsTools
}
}
}
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
This diff is collapsed.
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