Commit 203fedc8 authored by maxiaoliang's avatar maxiaoliang

Merge branch 'master' of gitlab.huolea.com:shujianhe/tusegamecolor

parents 68a11b53 ac0584ef
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gameSceneAreaGroupHandler : gridView
{
// Start is called before the first frame update
void Start()
{
RectTransform rectTransform = transform.parent.GetComponent<RectTransform>();
utilsTools.DisplaySize = new Vector2(rectTransform.rect.width, rectTransform.rect.height);
float scale = rectTransform.rect.height / 1920;
var scale1 = transform.localScale;
scale1.y *= scale;
transform.localScale = scale1;
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: f061d67e9390d054a91052bab714d5e1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
public class gameSceneLogic : MonoBehaviour, IEventHandler
......@@ -11,14 +13,28 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
public static int maxIdValue = 100;
private int nowSelectGroupId = 4;
public float progress = 0;
public bool showAreaId = true;
private TextMeshProUGUI debugViewObj = null;
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);
}
}
var gridViewList = areaGroupList.GetComponent<gameSceneAreaGroupHandler>();
gridViewList.gameObject.SetActive(true);
gameShowView.GetComponent<mainGameView>().loadTest();
gridViewList.setDataNoGrid(20, 100, 100, 5, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
//gameShowView.GetComponent<mainGameView>().loadTest();
gridViewList.setDataNoGrid(20, 150, 150, 15, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
{
......@@ -47,7 +63,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
{
}
public void onEventHandler(string eventName, List<Object> uobjects, List<object> objects)
public void onEventHandler(string eventName, List<UnityEngine.Object> uobjects, List<System.Object> objects)
{
if (eventName.Equals("switchGameAreaGroupId"))
{
......@@ -80,7 +96,7 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
gridViewList.gameObject.SetActive(true);
var maingameView = gameShowView.GetComponent<mainGameView>();
var ColorInfos = maingameView.getGroups();
gridViewList.setDataNoGrid(ColorInfos.Count, 150, 150, 100, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
gridViewList.setDataNoGrid(ColorInfos.Count, 150, 150, 20, (GameObject gobject, int idx, ListViewBackTypeEnum lvbType) =>
{
if (lvbType == ListViewBackTypeEnum.create || ListViewBackTypeEnum.update == lvbType)
{
......@@ -111,11 +127,37 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
print("切换下表完成" + 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++)
{
s = s + uobjects[i].ToString() + ",";
}
}
if (s.Length == 0) return;
if (utilsTools.IsPhone == false || debugViewObj == null)
{
print(s);
}
else
{
debugViewObj.text = s;
}
}
}
public void onTestTemp1()
{
print("是否卡顿?");
}
}
......@@ -15,6 +15,8 @@ public class mainGameScaleMove : MonoBehaviour
public float OldTouchCurrDis = -1000;
public float minScale = 0.25f;
public float maxScale = 8f;
public List<GameObject> ignoreList = new List<GameObject>();
private List<System.Object> logTempList = null;
public Vector2 NowPos
{
get { return nowPos; }
......@@ -29,6 +31,11 @@ public class mainGameScaleMove : MonoBehaviour
// Start is called before the first frame update
void Start()
{
logTempList = new List<object>();
logTempList.Add("");
logTempList.Add("");
logTempList.Add("");
logTempList.Add("");
setCheckInput();
Vector3 tempVector3;
Quaternion quaternion;
......@@ -50,24 +57,7 @@ public class mainGameScaleMove : MonoBehaviour
{
if (checkInput == null)
{
switch (Application.platform)
{
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
case RuntimePlatform.WebGLPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
checkInput = checkInputByComputer;
break;
case RuntimePlatform.Android:
case RuntimePlatform.IPhonePlayer:
checkInput = checkInputByPhone;
break;
default:
checkInput = checkInputByPhone;
break;
}
checkInput = utilsTools.IsPhone ? checkInputByPhone : checkInputByComputer;
}
}
......@@ -102,9 +92,11 @@ public class mainGameScaleMove : MonoBehaviour
}
else if(touchPhase == TouchPhase.Moved)
{
if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false) return;
onOneTouchMove(oneTouch.position, oneTouch.deltaPosition);
}else if(touchPhase == TouchPhase.Ended)
{
if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false) return;
onOneTouchEnd(oneTouch.position, oneTouch.deltaPosition);
}else if(touchPhase == TouchPhase.Canceled)
{
......@@ -142,6 +134,11 @@ public class mainGameScaleMove : MonoBehaviour
var itemChild = transform.GetChild(i);
itemChild.localScale = nowScale;
}
logTempList[0] = "scale";
logTempList[1] = "";
logTempList[2] = nowScale;
logTempList[3] = nowSize;
utilsTools.sendEventObjects("debugViewLogHandler", logTempList);
}
void clearOneTouchBegin()
{
......@@ -150,24 +147,15 @@ public class mainGameScaleMove : MonoBehaviour
//左键点击 右键缩放
void checkInputByComputer()
{
////0 1 2 鼠标 左中右
//bool RDown = Input.GetMouseButtonDown(2);
//bool LDown = Input.GetMouseButtonDown(0);
//if (RDown == LDown && RDown == true)//当作双指滑动 制造缩放
//float value = 0;
//var mouseScrollDelta = Input.mouseScrollDelta;
//if (mouseScrollDelta.y == 0) return;
//print(mouseScrollDelta.y);
//if (OldTouchCurrDis < -999)
//{
//}else if(RDown != LDown && LDown == true)
//{
// Vector3 mousePosition = Input.mousePosition;
// if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false)
// onOneTouchBegin(new Vector2(mousePosition.x, mousePosition.y));
// else
// {
// }
//}else if(LDown == false){
// if (utilsTools.ContainsKey(gameObject, "oneTouchBegin") == false) return;
// OldTouchCurrDis = 0;
//}
//onDoubleTouchHandler(mouseScrollDelta.y * 200f);
}
private void onOneTouchBegin(Vector2 vector2)
{
......@@ -203,7 +191,11 @@ public class mainGameScaleMove : MonoBehaviour
if (delatPos.x == delatPos.y && delatPos.x == 0) return;//都不用移动就不更新坐标
tempVector3.x += delatPos.x;
tempVector3.y += delatPos.y;
logTempList[0] = "move";
logTempList[1] = tempVector3;
logTempList[2] = nowScale;
logTempList[3] = nowSize;
utilsTools.sendEventObjects("debugViewLogHandler", logTempList);
}
itemChild.SetLocalPositionAndRotation(tempVector3, quaternion);
}
......@@ -226,7 +218,13 @@ public class mainGameScaleMove : MonoBehaviour
}
private void onOneClick(Vector2 nowPos)
{
print("点击>>>>" + nowPos.ToString());
var localPos = utilsTools.ScreenToUILocalPos(transform as RectTransform, nowPos);
logTempList[0] = "click";
logTempList[1] = nowPos;
logTempList[2] = localPos;
utilsTools.sendEventObjects("debugViewLogHandler", logTempList);
//print("点击>>>>" + nowPos.ToString());
}
// Update is called once per frame
void Update()
......
......@@ -99,7 +99,7 @@ public class mainGameView : MonoBehaviour
}
};
int tempsetp = 500;
int tempsetp = 200;
for (int i = 0; i < lineTexture2d.width; i+=tempsetp)
{
System.Object[] objects = { i, tempsetp, lineTexture2d.height };
......@@ -135,7 +135,7 @@ public class mainGameView : MonoBehaviour
onInitDigitMatrix("select");
}
};
int tempsetp = 500;
int tempsetp = 200;
for (int i = 0; i < lowImgTexture2d.width; i += tempsetp)
{
System.Object[] taskParams = { i, tempsetp, lowImgTexture2d.width, lowImgTexture2d.height };
......
......@@ -12,6 +12,46 @@ using UnityEngine.UI;
public class utilsTools
{
private static int isPhone = 0;
private static Vector2 displaySize = new Vector2(0,0);
public static bool IsPhone
{
get {
if(isPhone == 0)
{
switch (Application.platform)
{
case RuntimePlatform.WindowsEditor:
case RuntimePlatform.WindowsPlayer:
case RuntimePlatform.WebGLPlayer:
case RuntimePlatform.OSXEditor:
case RuntimePlatform.OSXPlayer:
isPhone = 2;
break;
case RuntimePlatform.Android:
case RuntimePlatform.IPhonePlayer:
isPhone = 1;
break;
default:
isPhone = 1;
break;
}
}
return isPhone == 1;
}
}
public static Vector2 DisplaySize
{
get
{
return displaySize;
}
set
{
if (displaySize.x > 1) return;
displaySize = value;
}
}
public static Dictionary<String, GameObject> dynamicMount = new Dictionary<string, GameObject>();
public static bool addTimer_Sec(GameObject gameObject, string name, timeEventBack back, double intervalLen, uint loopRepetitionLen = 1)
{
......@@ -336,5 +376,11 @@ public class utilsTools
{
}
public static Vector2 ScreenToUILocalPos(RectTransform transform, Vector2 mousePos, Camera canvasCam = null)
{
Vector2 uiLocalPos;
RectTransformUtility.ScreenPointToLocalPointInRectangle(transform, mousePos, canvasCam, out uiLocalPos);
return uiLocalPos;
}
}
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