提交项目

This commit is contained in:
2026-05-28 15:23:36 +08:00
commit 3cfc77d12b
5726 changed files with 554351 additions and 0 deletions
+374
View File
@@ -0,0 +1,374 @@
using System;
using System.Collections.Generic;
using ZooMatch;
using DG.Tweening;
using FGUI.ZM_Common_01;
using UnityEngine;
using FairyGUI;
public class AdRedeemManager
{
public static readonly AdRedeemManager Instance = new AdRedeemManager();
AdRedeemManager()
{
}
public const string buy_one = "com.rainforestworld.space.24.99";
// public const string buy_gold_1 = "com.rainforestworld.shop.1.99";
// public const string buy_gold_2 = "com.rainforestworld.shop.3.99";
// public const string buy_gold_3 = "com.rainforestworld.shop.19.99";
// public const string buy_gold_4 = "com.rainforestworld.shop.39.99";
public const string remove_ad = "com.rainforestworld.remove.2.99";
public const string battle_pass = "com.rainforestworld.pass.9.99";
public const string pack_reward = "com.rainforestworld.reward.1.99";
public const string fail_pack = "com.rainforestworld.fail.1.99";
public const string three_days_gift = "com.rainforestworld.three.1.99";
public void Redeem(AdRedeemData _data)
{
if (Time.time - SaveData.redeem_time < 5)
{
GameHelper.ShowTips("Clicks are too frequent");
return;
}
SaveData.redeem_time = Time.time;
int myAdNum = GetLookRewardADNum();
if (myAdNum >= _data.ad_count)
{
SetLookRewardADNum(myAdNum - _data.ad_count);
SendEventClickByName(_data.type, "success");
DOVirtual.DelayedCall(0.1f, () =>
{
GameDispatcher.Instance.Dispatch(GameMsg.apple_pay_success, _data.type);
});
}
else
{
GameHelper.ShowTips("Your AD count is insufficient!");
}
}
public void ShowVideoAd(string adName, Action _action)
{
GameHelper.ShowVideoAd(adName, isSuccess =>
{
if (isSuccess)
{
_action?.Invoke();
}
});
}
// private btn_watchAd btn_WatchAd = null;
private Dictionary<string, btn_watchAd> btn_WatchAd = new Dictionary<string, btn_watchAd>();
private Dictionary<string, Action> ActionSetText = new Dictionary<string, Action>(); //广告数量的显示
public void SetWatchAd(string key, btn_watchAd _btn, Action action)
{
if (!btn_WatchAd.ContainsKey(key))
{
btn_WatchAd.Add(key, _btn);
}
else
{
btn_WatchAd[key] = _btn;
}
if (!ActionSetText.ContainsKey(key))
{
ActionSetText.Add(key, action);
}
else
{
ActionSetText[key] = action;
}
}
private void removeWatchAd()
{
btn_WatchAd.Clear();
}
private int ad_cool_down = ConfigSystem.GetConfig<CommonModel>().exchangeCD;
private void updateWatchCD()
{
var lastTimes = SaveData.GetSaveobject()._watch_ad_cd;
foreach (var item in btn_WatchAd)
{
bool is_get = item.Key == pack_reward && SaveData.GetSaveobject().is_get_packreward;
bool is_get1 = item.Key == remove_ad && SaveData.GetSaveobject().is_get_removead;
(item.Value.GetChild("img_saveingpot") as GImage).visible = false;
if (is_get || is_get1)
{
item.Value.enabled = false;
}
else if (GameHelper.GetNowTime() < lastTimes && !checkIsCanReceive(item.Key))
{
item.Value.enabled = false;
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_cd;
item.Value.btn_text.text = CommonHelper.TimeFormat(lastTimes - Convert.ToInt32(GameHelper.GetNowTime()), CountDownType.Hour);
}
else
{
// stopAction();
item.Value.enabled = true;
item.Value.can_buy.selectedIndex = btn_watchAd.Can_buy_can;
checkBtnState(item.Value, item.Key);
}
}
}
private CommonModel config = ConfigSystem.GetConfig<CommonModel>();
private List<Paidgift> packdata = ConfigSystem.GetConfig<PaidgiftModel>().dataList;
public int GetCeilingNeedAds(string name)
{
int needAds = -1;
switch (name)
{
case buy_one:
double addspace = config.addspace;
needAds = (int)Math.Ceiling(addspace);
break;
case battle_pass:
double Passportgift = config.Passportgift;
needAds = (int)Math.Ceiling(Passportgift);
break;
case pack_reward:
double Paid_price = packdata[0].Paid_price;
needAds = (int)Math.Ceiling(Paid_price);
break;
case remove_ad:
double move_price = packdata[1].Paid_price;
needAds = (int)Math.Ceiling(move_price);
break;
case three_days_gift:
double three_price = ConfigSystem.GetConfig<MultigiftModel>().dataList[0].Paid_price;
needAds = (int)Math.Ceiling(three_price);
break;
// case buy_gold_1:
// double gold_price1 = coinList[1].Payment_amount;
// needAds = (int)Math.Ceiling(gold_price1);
// break;
// case buy_gold_2:
// double gold_price2 = coinList[2].Payment_amount;
// needAds = (int)Math.Ceiling(gold_price2);
// break;
// case buy_gold_3:
// double gold_price3 = coinList[3].Payment_amount;
// needAds = (int)Math.Ceiling(gold_price3);
// break;
// case buy_gold_4:
// double gold_price4 = coinList[4].Payment_amount;
// needAds = (int)Math.Ceiling(gold_price4);
// break;
}
if (name.StartsWith("buy_gold"))
{
List<Paidcoins> coinList = ConfigSystem.GetConfig<PaidcoinsModel>().dataList;
int startIndex = "buy_gold".Length;
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
int suffix_num = int.Parse(suffix);
double gold_price = coinList[suffix_num].Payment_amount;
needAds = (int)Math.Ceiling(gold_price);
}
return needAds;
}
private bool checkIsCanReceive(string name)
{
int myAd = GetLookRewardADNum();
return myAd >= GetCeilingNeedAds(name);
}
private void checkBtnState(btn_watchAd item, string key)
{
// stopAction();
// foreach (var item in btn_WatchAd)
// {
item.SetClick(() => { });
if (checkIsCanReceive(key))
{
item.buy_state.selectedIndex = btn_watchAd.Buy_state_buy;
item.SetClick(() =>
{
item.enabled = false;
AdRedeemData adRedeemData = new AdRedeemData()
{
type = key,
ad_count = GetCeilingNeedAds(key)
};
Redeem(adRedeemData);
});
}
else
{
item.buy_state.selectedIndex = btn_watchAd.Buy_state_ad;
if (GameHelper.IsGiftSwitch() && ConfigSystem.GetConfig<CommonModel>().PiggyBankSwitch == 1) (item.GetChild("img_saveingpot") as GImage).visible = true;
bool is_get = key == pack_reward && SaveData.GetSaveobject().is_get_packreward;
bool is_get1 = key == remove_ad && SaveData.GetSaveobject().is_get_removead;
if (is_get || is_get1)
{
item.enabled = false;
item.SetClick(() => { });
}
else
{
item.SetClick(() =>
{
SendEventClickByName(key, "click");
ShowVideoAd("buy_add_one", () =>
{
RunAllAction();
item.enabled = false;
TimerHelper.mEasy.AddTimer(0.1f, () =>
{
var ad_times = Convert.ToInt32(GameHelper.GetNowTime());
SaveData.GetSaveobject()._watch_ad_cd = ad_times + ad_cool_down;
startAction();
});
});
});
}
// }
}
}
private void RunAllAction()
{
foreach (var item in ActionSetText)
{
item.Value?.Invoke();
}
}
private void startAction()
{
stopAction();
HallManager.Instance.UpdateSecondEvent += updateWatchCD;
}
private void stopAction()
{
HallManager.Instance.UpdateSecondEvent -= updateWatchCD;
}
public int GetLookRewardADNum()
{
int nums = PlayerPrefs.GetInt("get_look_reward_ad_num", 0);
return nums;
}
public void SetLookRewardADNum(int nums)
{
PlayerPrefs.SetInt("get_look_reward_ad_num", nums);
}
public void Start()
{
startAction();
updateWatchCD();
}
public void Destroy()
{
stopAction();
removeWatchAd();
ActionSetText.Clear();
}
public void SendEventClickByName(string name, string type)
{
string eventClickName = "";
string eventSuccName = "";
switch (name)
{
case pack_reward:
eventClickName = BuriedPointEvent.pack_click;
eventSuccName = BuriedPointEvent.pack_success;
break;
case remove_ad:
eventClickName = BuriedPointEvent.remove_ad_click;
eventSuccName = BuriedPointEvent.remove_ad_success;
break;
// case buy_gold_1:
// eventClickName = BuriedPointEvent.gold_click_1;
// eventSuccName = BuriedPointEvent.gold_success_1;
// break;
// case buy_gold_2:
// eventClickName = BuriedPointEvent.gold_click_2;
// eventSuccName = BuriedPointEvent.gold_success_2;
// break;
// case buy_gold_3:
// eventClickName = BuriedPointEvent.gold_click_3;
// eventSuccName = BuriedPointEvent.gold_success_3;
// break;
// case buy_gold_4:
// eventClickName = BuriedPointEvent.gold_click_4;
// eventSuccName = BuriedPointEvent.gold_success_4;
// break;
case battle_pass:
eventClickName = BuriedPointEvent.pass_click;
eventSuccName = BuriedPointEvent.pass_success;
break;
case buy_one:
eventClickName = BuriedPointEvent.buy_one_click;
eventSuccName = BuriedPointEvent.buy_one_success;
break;
}
if (name.StartsWith("buy_gold"))
{
int startIndex = "buy_gold".Length;
string suffix = name[startIndex..]; // 截取 "gold" 后的所有字符
eventClickName = $"gold_click_{suffix}";
eventSuccName = $"gold_success_{suffix}";
}
if (type == "success" && eventSuccName != "")
{
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_AD_event, eventSuccName, 1);
}
else if (type == "click" && eventClickName != "")
{
NetworkKit.BuriedPoint(BuriedPointEvent.Apple_AD_event, eventClickName, 1);
}
}
}
public class AdRedeemData
{
public string type;
public int ad_count;
}
public class orderState
{
public string order_id;
public int status;
}
public class orderData
{
public string order_id;
public string pay_url;
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33ed44012dd51724bbb822265db9b931
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+32
View File
@@ -0,0 +1,32 @@
namespace ZooMatch
{
public static class App
{
private static SApplication _sCurrSApplication = null;
public static void InitApplication(SApplication sApplication)
{
_sCurrSApplication = sApplication;
_sCurrSApplication.Init();
_sCurrSApplication.Enable();
}
private static float LoadingProgressDelayTime = 0f;
public static void DisplayLoadingUI()
{
AppDispatcher.Instance.Dispatch(AppMsg.UI_DisplayLoadingUI);
}
public static void HideLoadingUI(bool isDelay = false)
{
if (!isDelay)
{
AppDispatcher.Instance.Dispatch(AppMsg.UI_HideLoadingUI);
return;
}
TimerHelper.mEasy.AddTimer(0.5f, () => { AppDispatcher.Instance.Dispatch(AppMsg.UI_HideLoadingUI); });
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 670d339b2f75a144e8ba207f951e51bd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cc47593d8a04d3147a05e47aa376b7b8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+52
View File
@@ -0,0 +1,52 @@
namespace ZooMatch
{
public class AsyncDealData
{
public delegate void DealMethod();
private float _currentTime;
public float DelayTime = 1f;
public DealMethod dealMethod;
public int RepeatCount = 1;
public bool IsComplete => RepeatCount == 0;
public void PassTime(float time)
{
_currentTime += time;
if (!(_currentTime >= DelayTime))
{
return;
}
_currentTime -= DelayTime;
Run();
}
private void Run()
{
if (RepeatCount == -1)
{
dealMethod?.Invoke();
}
else
{
if (RepeatCount > 0)
{
dealMethod?.Invoke();
RepeatCount--;
}
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4e51ff91679a44d1b1efe3438d508e74
timeCreated: 1682577036
@@ -0,0 +1,92 @@
namespace ZooMatch
{
using System;
using UnityEngine;
using System.Collections.Generic;
internal class AsyncKitUnityBehaviour : SingletonUnity<AsyncKitUnityBehaviour>
{
private readonly Dictionary<string, AsyncDealData> _asyncDataDict = new Dictionary<string, AsyncDealData>();
private readonly Dictionary<string, AsyncDealData> _updateActionDict = new Dictionary<string, AsyncDealData>();
private readonly List<string> _keyClean = new List<string>();
private void Update()
{
foreach (var temp in _asyncDataDict.Values)
{
temp.PassTime(Time.deltaTime);
}
try
{
foreach (var temp in _updateActionDict.Values)
{
temp?.dealMethod?.Invoke();
}
}
catch (Exception)
{
}
ClearFinished();
ClearUpdateActionFinished();
}
private void ClearFinished()
{
_keyClean.Clear();
foreach (var dealData in _asyncDataDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_asyncDataDict.Remove(key);
}
}
public void AddAsyncData(string key, AsyncDealData asyncDealData)
{
RemoveAsyncData(key);
_asyncDataDict.Add(key, asyncDealData);
}
public void RemoveAsyncData(string key)
{
if (_asyncDataDict.ContainsKey(key))
{
_asyncDataDict.Remove(key);
}
}
public void ClearUpdateActionFinished()
{
_keyClean.Clear();
foreach (var dealData in _updateActionDict)
{
if (dealData.Value.IsComplete)
{
_keyClean.Add(dealData.Key);
}
}
foreach (var key in _keyClean)
{
_updateActionDict.Remove(key);
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 984d18c5a4974e729d72276896426930
timeCreated: 1682577036
+63
View File
@@ -0,0 +1,63 @@
namespace ZooMatch
{
using UnityEngine;
using System.Collections;
public static class CrazyAsyKit
{
private static AsyncKitUnityBehaviour sAsyncKitUnityBehaviour;
private static readonly object SynClock = new object();
private static AsyncKitUnityBehaviour mAsyncKitUnityBehaviour
{
get
{
if (sAsyncKitUnityBehaviour != null)
{
return sAsyncKitUnityBehaviour;
}
lock (SynClock)
{
if (sAsyncKitUnityBehaviour != null)
{
return sAsyncKitUnityBehaviour;
}
sAsyncKitUnityBehaviour = AsyncKitUnityBehaviour.Instance;
if (sAsyncKitUnityBehaviour != null)
{
sAsyncKitUnityBehaviour.name = "[ CrazyAsyKit ]";
}
}
return sAsyncKitUnityBehaviour;
}
}
public static Coroutine StartCoroutine(IEnumerator enumerator)
{
return mAsyncKitUnityBehaviour.StartCoroutine(enumerator);
}
public static void StopCoroutine(Coroutine enumerator)
{
mAsyncKitUnityBehaviour.StopCoroutine(enumerator);
}
public static void StartAction(string key, AsyncDealData.DealMethod method, float delayTime, int repeat = 1)
{
var temp = new AsyncDealData { dealMethod = method, DelayTime = delayTime, RepeatCount = repeat };
mAsyncKitUnityBehaviour.AddAsyncData(key, temp);
}
public static void StopAction(string key)
{
mAsyncKitUnityBehaviour.RemoveAsyncData(key);
}
}
}
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 93122ca4429e463aba586a345558ed8e
timeCreated: 1682577036
+29
View File
@@ -0,0 +1,29 @@
namespace ZooMatch
{
public abstract class BaseScene
{
public abstract int SceneIdx { get; }
public void Enter()
{
App.DisplayLoadingUI();
OnEnter();
}
public void Leave()
{
OnLeave();
}
public void SwitchSceneComplete(object param)
{
OnSwitchSceneComplete(param);
}
protected abstract void OnEnter();
protected abstract void OnLeave();
protected abstract void OnSwitchSceneComplete(object param);
public abstract void Dispose();
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b8bdd23fc1e10e744a00b9cd6e28eae3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+29
View File
@@ -0,0 +1,29 @@
namespace ZooMatch
{
public abstract class BaseSystem
{
public virtual void Init()
{
}
public virtual void InitLate()
{
}
public virtual void Dispose()
{
}
public virtual void Update()
{
}
public virtual void LateUpdate()
{
}
public virtual void FixedUpdate()
{
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d09f140354146564aa23e2896d940db2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+59
View File
@@ -0,0 +1,59 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Runtime.InteropServices;
using UnityEditor;
public class BrigdeIOS
{
[DllImport("__Internal")]
public static extern void OpenWebview(string url);
[DllImport("__Internal")]
public static extern void CloseWebview();
[DllImport("__Internal")]
public static extern void showDarkWebview();
[DllImport("__Internal")]
public static extern void SetFullScreen();
[DllImport("__Internal")]
public static extern void addH5Field(int field1, int field2, int field3, int field4, int field5, string field6, string field7, string dark_url, string light_url, bool is_gift, string web_through_str, string click_add_time);
// [DllImport("__Internal")]
// public static extern void SetTouchWebview(bool flag, bool force = false);
// [DllImport("__Internal")]
// public static extern void ScrollWebview(float dx, float dy);
[DllImport("__Internal")]
public static extern void SetPadding(float left, float top, float right, float bottom);
[DllImport("__Internal")]
public static extern void SetDarkThough(bool though);
[DllImport("__Internal")]
public static extern void SetBtn(int left, int top, int right, int bottom);
[DllImport("__Internal")]
public static extern void SetCTEnable(bool flag);
[DllImport("__Internal")]
public static extern void ShowH5View(bool flag);
[DllImport("__Internal")]
public static extern void SetIconProgress(float val);
[DllImport("__Internal")]
public static extern void SetClickView();
[DllImport("__Internal")]
public static extern void ShowFlyBtn(bool flag);
[DllImport("__Internal")]
public static extern void setInH5View(bool flag);
[DllImport("__Internal")]
public static extern void upDataH5times(string weblink, int times, bool is_dark);
[DllImport("__Internal")]
public static extern void setFlyBtnTag(bool flag);
[DllImport("__Internal")]
public static extern void setRewardBtnTag(bool flag);
[DllImport("__Internal")]
public static extern void SetOffset(int offset_y ,int offset_y2);
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fde3fa242120540b0b362a4fdf2ca946
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+256
View File
@@ -0,0 +1,256 @@
using System;
using System.Collections.Generic;
using Spine.Unity;
using UnityEngine;
using ZooMatch;
public class CreatAnimalCard : MonoBehaviour
{
private GameObject card_item;
public static CreatAnimalCard instance;
private List<Sprite> img_list;
public Camera orthoCamera; // 这个变量应该被设置为您想要调整大小的正交相机
private void Awake()
{
instance = this;
card_item = Resources.Load<GameObject>("card/card_item/card_");
img_list = new List<Sprite>();
// img_list = Resources.LoadAll<Sprite>("card/card_sprite").ToList();
// img_list.Sort((x, y) => String.Compare(x.name, y.name));
for (int i = 0; i < 16; i++)
{
img_list.Add(Resources.Load<Sprite>("card/card_sprite/" + i));
}
orthoCamera = GameObject.Find("GameCamera").GetComponent<Camera>();
float size = 52.4f;
string type = SystemInfo.deviceModel.ToLower().Trim();
Debug.Log($"barry device type========={type} == {type.Substring(0, 3)}");
if (type.Substring(0, 3) == "iph")
{//iPad机型
size = (float)Math.Round(28.125f / ((float)Screen.width / Screen.height), 4);
}
#if UNITY_EDITOR
size = (float)Math.Round(28.125f / ((float)Screen.width / Screen.height), 4);
#endif
orthoCamera.orthographicSize = size;
}
public void SetCameraVisible(bool visible)
{
orthoCamera.SetActive(visible);
GameHelper.ShowSheepPlayUI(visible);
}
// Start is called before the first frame update
public List<List<Card_item>> card_item_list = new List<List<Card_item>>();
public List<List<Card_item>> CreatCardNew(int all_card_numbers, int card_type_max, int card_layer, int extra_max, List<List<Vector2>> map_list, List<Vector2> left_extra_list,
List<Vector2> right_extra_list)
{
//all_card_numbers *= 3;
int money_rate = ConfigSystem.GetConfig<CommonModel>().rewardrate;
List<int> type_list = new List<int>();
List<int> this_timetype_list = new List<int>();
// Debug.Log(card_layer);
card_item_list.Clear();
// if (card_layer < extra_max)
// {
// card_layer = extra_max;
// }
for (int i = 0; i < all_card_numbers; i++)
{
int type = 0;
if (GameHelper.IsGiftSwitch() && UnityEngine.Random.Range(0, 100) < money_rate) type = 15;
else type = UnityEngine.Random.Range(0, card_type_max);
if (!GameHelper.IsGiftSwitch() && type == 15){
type = UnityEngine.Random.Range(0, card_type_max-1);
}
type_list.Add(type);
type_list.Add(type);
type_list.Add(type);
if (!this_timetype_list.Contains(type)) this_timetype_list.Add(type);
}
SaveData.GetSaveobject().this_time_cardtype = this_timetype_list.Count;
for (int i = 0; i < card_layer; i++)
{
card_item_list.Add(new List<Card_item>());
}
if (left_extra_list.Count > 0 || right_extra_list.Count > 0)
{
for (int i = 0; i < left_extra_list.Count; i++)
{
Card_item _tempObject = new()
{
pos_x = left_extra_list[i].x,
pos_y = left_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject);
}
for (int i = 0; i < right_extra_list.Count; i++)
{
Card_item _tempObject1 = new()
{
pos_x = right_extra_list[i].x,
pos_y = right_extra_list[i].y,
_layer = i
};
card_item_list[i].Add(_tempObject1);
}
}
var nums = 0;
for (int i = 0; i < map_list.Count; i++)
{
nums += map_list[i].Count;
}
for (int i = 0; i < nums; i++)
{
Card_item _tempObject = new();
int layer = getMaplayer(map_list);//确定层数
int pos = UnityEngine.Random.Range(0, map_list[layer].Count);
_tempObject.pos_x = map_list[layer][pos].x;
_tempObject.pos_y = map_list[layer][pos].y;
_tempObject._layer = layer;
card_item_list[layer].Add(_tempObject);
map_list[layer].RemoveAt(pos);
}
for (int i = 0; i < card_item_list.Count; i++)
{
card_item_list[i].Sort((x, y) => y.pos_y.CompareTo(x.pos_y));
}
int index = 0;
for (int i = 0; i < card_item_list.Count; i++)
{
float z_offset = 0;//用来微调每层之间的z值,让下层盖住上层
float last_posy = 0;
for (int j = 0; j < card_item_list[i].Count; j++)
{
if (last_posy != card_item_list[i][j].pos_y)
{
z_offset += 0.05f;
last_posy = card_item_list[i][j].pos_y;
}
GameObject temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer - z_offset), Quaternion.identity, gameObject.transform);
index = UnityEngine.Random.Range(0, type_list.Count);
temp.GetComponent<SpriteRenderer>().sprite = img_list[type_list[index]];
card_item_list[i][j].sheep_card = temp;
card_item_list[i][j].card_type = type_list[index];
temp.gameObject.name = i + "-" + j;
type_list.RemoveAt(index);
}
}
return card_item_list;
}
public void creatSaveCard(List<List<Card_item>> card_item_list)
{
this.card_item_list = card_item_list;
for (int i = 0; i < card_item_list.Count; i++)
{
for (int j = 0; j < card_item_list[i].Count; j++)
{
GameObject temp;
// if (card_item_list[i][j].is_out)
// {
// temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j].out_layer), Quaternion.identity, gameObject.transform);
// }
// else
temp = Instantiate(card_item, new Vector3(card_item_list[i][j].pos_x, card_item_list[i][j].pos_y, 400 - card_item_list[i][j]._layer), Quaternion.identity, gameObject.transform);
temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
card_item_list[i][j].sheep_card = temp;
if (card_item_list[i][j].in_slot || card_item_list[i][j].is_out) temp.transform.localScale = new Vector3(4.628f, 4.628f, 1);
temp.gameObject.name = i + "-" + j;
}
}
}
private GameObject Popup;
#if UNITY_EDITOR || UNITY_IOS
void Update()
{
if (Input.GetMouseButtonDown(0))
{
if (Popup == null) Popup = GameObject.Find("Popup");
if (Popup.transform.childCount != 0) return;
Ray ray = orthoCamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
int layerMask = 1 << 6; // 只与第8层的碰撞器碰撞
// 如果射线与layerMask指定层的碰撞器发生碰撞
if (Physics.Raycast(ray, out hit, Mathf.Infinity, layerMask))
{
// Debug.Log("Hit " + hit.collider.gameObject.name);
GameDispatcher.Instance.Dispatch(GameMsg.card_click, hit.collider.gameObject.name);
// 在此处添加点击物体后的逻辑
}
else
{
// Debug.Log("No hit");
}
}
}
#endif
private GameObject disappear01;
private GameObject disappear02;
public void creatSpine(int type, Vector3 vec3)
{
if (disappear01 == null) disappear01 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_1");
if (disappear02 == null) disappear02 = Resources.Load<GameObject>("card/bg_img/fx_disaappear_2");
if (type == 1)
{
SkeletonAnimation temp = Instantiate(disappear01, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear01", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
if (type == 2)
{
SkeletonAnimation temp = Instantiate(disappear02, new Vector3(vec3.x, vec3.y, 110), Quaternion.identity, gameObject.transform).GetComponent<SkeletonAnimation>();
temp.AnimationState.SetAnimation(0, "disappear02", true);
temp.AnimationState.Complete += (trackEntry) =>
{
Destroy(temp.gameObject);
};
}
// temp.GetComponent<SpriteRenderer>().sprite = img_list[card_item_list[i][j].card_type];
}
int getMaplayer(List<List<Vector2>> map_list)
{
int layer = UnityEngine.Random.Range(0, map_list.Count);//确定层数
if (map_list[layer].Count == 0)
{
layer = getMaplayer(map_list);
}
return layer;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9fb9475b4182b354b84f97ae3ed0a002
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: be8781ff9378e5345a9f6188e990a359
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e7146600e94b62843b388e234c8ce824
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
namespace ZooMatch
{
public static class AnimConst
{
public const float AnimFrameRate = 30;
public const float SecondRateUnit = 1 / AnimFrameRate;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db177b3a2887ce0498712919fed1ee4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,56 @@
using UnityEngine;
using System.Collections.Generic;
namespace ZooMatch
{
public static class AppConst
{
#region Field
#if ZooMatchRelease
public static bool IsEnabledEngineLog = false;
#else
public static bool IsEnabledEngineLog = true;
#endif
public const LogType EnabledFilterLogType =
LogType.Log | LogType.Warning | LogType.Error | LogType.Assert |
LogType.Exception;
public const bool IsRunInBG = true;
public const int SleepTimeoutMode = SleepTimeout.NeverSleep;
public const int AntiAliasing = 0;
public const int HighFrameRate = 60;
public const int LowFrameRate = 45;
public const float HDHighViewScale = 1f;
public const float HDLowViewScale = 0.9f;
public const float PixelsPerUnit = 100f;
public static Vector2Int StandardResolution = new Vector2Int(1080, 1920);
public static Vector2Int UIResolution = new Vector2Int(1080, 1920);
public static bool UseInternalSetting = true;
public static bool IsMultiLangue = true;
public static string CurrMultiLangue = "en";
public static string DefaultLangue = "en";
public static string InternalLangue = "en";
public static string DeviceLangue = "en";
public static List<string> CtrlDisableList = new List<string>();
#endregion
public static bool isPt()
{
if (CurrMultiLangue == "pt") return true;
return false;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5e2daa6b68221ec4f8e0b643de38afd1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,38 @@
using UnityEngine;
namespace ZooMatch
{
public static class AppObjConst
{
public const string FrameGoName = "[ Jarvis ]";
public static GameObject FrameGo;
public const string LauncherGoName = "[Launcher]";
public const string EngineEventSystemGoName = "[EngineEventSystem]";
public static GameObject EngineEventSystemGo;
public const string ApplicationGoName = "[ Application ]";
public static GameObject ApplicationGo;
public const string EngineSingletonGoName = "[EngineSingleton]";
public static GameObject EngineSingletonGo;
public const string MonoManagerGoName = "[MonoManager]";
public static GameObject MonoManagerGo;
public const string DispatcherGoName = "[Dispatcher]";
public static GameObject DispatcherGo;
public const string LoaderGoName = "[Loader]";
public static GameObject LoaderGo;
public const string CameraGoName = "[Camera]";
public static GameObject CameraGo;
public const string UIGoName = "[UI]";
public static GameObject UIGo;
public const string UICacheGoName = "[UICache]";
public static GameObject UICacheGo;
public const string DOTweenGoName = "[DOTween]";
public const string SuperInvokeGoName = "[SuperInvoke]";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ce9826ccd786f9e46a1fb245b9fe4a04
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,19 @@
namespace ZooMatch
{
public static class AudioConst
{
public const string UIButtonDefault = "ui_ButtonDefault";
public const string DailyBonusCollect = "dailyBonus_collect";
public const string CoinFly = "coinfly";
public const string MainBg = "hall_bgm";
public const string GameBg = "game_bgm";
public const string dissolve = "dissolve";
public const string fellshort = "fellshort";
public const string Victoriously = "Victoriously";
public const string MakeupDone = "makupdone";
public const string wheel_spin = "wheel_spin";
public const string game_open = "game_open";
public const string banma = "banma";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dbb65f81bcb66ff48abc55f1c1150765
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,17 @@
using UnityEngine;
namespace ZooMatch
{
public static class CameraConst
{
public const int MainDepth = 0;
public const int UICameraDepth = 10;
public const int MainCameraPosValue = 100;
public const int MainCameraZPos = 0;
public const int UICameraPosValue = 10000;
public static Vector3 MainCameraPos = new Vector3(MainCameraPosValue, MainCameraPosValue, MainCameraZPos);
public static Vector3 UICameraPos = new Vector3(UICameraPosValue, UICameraPosValue, MainCameraZPos);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e2555d38a702f494ca13aaf957846be9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
namespace ZooMatch
{
public static class LayerMaskConst
{
public const string Default_Name = "Default";
public const string UI_Name = "UI";
public readonly static int Default = LayerMask.NameToLayer(Default_Name);
public readonly static int UI = LayerMask.NameToLayer(UI_Name);
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8f53446f031c27d4eae9f0ff7d3e4565
timeCreated: 1530670154
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace ZooMatch
{
public static class PrefsConst
{
public const bool BoolDefault = false;
public const int IntDefault = 0;
public const int IntTrue = 1;
public const int IntFalse = 2;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6cb940cabfde0ad4c8a849ca893d686c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,21 @@
namespace ZooMatch
{
public static class PrefsKeyConst
{
public const string Application_isHDMode = "Application_isHDMode";
public const string Application_isHFRMode = "Application_isHFRMode";
public const string UIMgr_switchLanguage = "UIMgr_switchLanguage";
public const string AudioMgr_isOpenBGM = "AudioMgr_isOpenBGM";
public const string AudioMgr_isOpenEffect = "AudioMgr_isOpenEffect";
public const string App_isNewInstall = "App_isNewInstall";
public const string JarvisToken = "JarvisToken";
public const string C_ThroughMaxToday = "C_ThroughMaxToday";
public const string C_ThroughPop = "C_ThroughPop";
public const string C_ThroughOnline = "C_ThroughOnline";
public const string C_ThroughHide = "C_ThroughHide";
public const string C_ThroughFly = "C_ThroughFly";
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bec1a938462feda4eba6b162b9a387e0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
using UnityEngine;
namespace ZooMatch
{
public static class ScreenConst
{
public static Vector2 StandardResolution = new(AppConst.StandardResolution.x, AppConst.StandardResolution.y);
public static float StandardWidth => AppConst.StandardResolution.x;
public static float StandardHeight => AppConst.StandardResolution.y;
public static Vector2 RawResolution = new(Screen.width, Screen.height);
public static Vector2 CurrResolution = new(Screen.width, Screen.height);
public static float OrthographicSize_1280H = StandardHeight / 2 / AppConst.PixelsPerUnit;
public static float StandardAspectRatio = StandardHeight / StandardWidth;
public static float CurrAspectRatio = (float)Screen.height / Screen.width;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 76e7d3de03bd12a44b19e935ea71697a
timeCreated: 1534935298
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,41 @@
namespace ZooMatch
{
public static class UILayerConst
{
public const string Background = "Background";
public const string Bottom = "Bottom";
public const string Normal = "Normal";
public const string Top = "Top";
public const string FullScreen = "FullScreen";
public const string Popup = "Popup";
public const string Highest = "Highest";
public const string Animation = "Animation";
public const string Tips = "Tips";
public const string Loading = "Loading";
public const string System = "System";
public const string NetworkError = "NetworkError";
public static readonly string[] AllUILayer = {
Background,
Bottom,
Normal,
Top,
FullScreen,
Popup,
Highest,
Animation,
Tips,
Loading,
System,
NetworkError
};
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a1cfef99d74aac943a6872498ec8fb4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using UnityEngine;
namespace ZooMatch
{
public static class VectorConst
{
public static Vector3 One = Vector3.one;
public static Vector3 PPUOne = One * AppConst.PixelsPerUnit;
public static Vector3 Half = new(0.5f, 0.5f, 0.5f);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ae89e346ddf1a584382a1deb4b78193a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,13 @@
using UnityEngine;
namespace ZooMatch
{
public static class YieldConst
{
public const float Time10ms = 0.01f;
public const float Time100ms = 0.1f;
public static WaitForEndOfFrame WaitForEndOfFrame = new WaitForEndOfFrame();
public static WaitForSeconds WaitFor100ms = new WaitForSeconds(Time100ms);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6248774d8e1b69d46a89ad1ea46081ac
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f14f42c47ff29474bb4170a49c3bc8c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
namespace ZooMatch
{
public static partial class CtrlMsg
{
public const string NAME = "CtrlMsg";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
public static readonly uint Login_Succeed = ++Cursor_BASE;
public static readonly uint Game_StartReady = ++Cursor_BASE;
public static readonly uint Game_Start = ++Cursor_BASE;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19bfc133c0819ad4486cceca51c8a2e3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
namespace ZooMatch
{
public static partial class GameMsg
{
public const string NAME = "GameMsg";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d7b577419d940f468e1a95a9afb1dd9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
namespace ZooMatch
{
public static partial class UICtrlMsg
{
public const string NAME = "UICtrlMsg";
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb50862938136744db6a10a950ab4a27
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 05068ae3f93705047a7ad62030047667
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,18 @@
namespace ZooMatch
{
public class ChangeValue<T>
{
public T oldValue;
public T newValue;
public ChangeValue()
{
}
public ChangeValue(T oldValue, T newValue)
{
this.oldValue = oldValue;
this.newValue = newValue;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c53b34a8fdfa77143b24d0660057d5a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f185af0ac6ec3f548bed55863e2f65e8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 10e424129050f3a4ab3fdc991bf91318
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,132 @@
using System;
using UnityEngine;
using System.Collections.Generic;
namespace ZooMatch
{
public abstract class BaseDispatcher<T, Msg, Param> : IDisposable where T : class, new() where Param : class
{
private static T m_instance;
public static T Instance
{
get
{
if (m_instance == null)
{
m_instance = new T();
}
return m_instance;
}
}
private Dictionary<Msg, List<Action<Param>>> m_msgPriorityDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgFinallyDict = new();
private Dictionary<Msg, List<Action<Param>>> m_msgOnceDict = new();
public void AddListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = ListPool<Action<Param>>.Get();
list.Add(listener);
m_msgDict.Add(msgId, list);
}
}
public void AddOnceListener(Msg msgId, Action<Param> listener)
{
if (m_msgOnceDict.TryGetValue(msgId, out var value))
{
value.Add(listener);
}
else
{
var list = ListPool<Action<Param>>.Get();
list.Add(listener);
m_msgOnceDict.Add(msgId, list);
}
}
public void RemoveListener(Msg msgId, Action<Param> listener)
{
if (m_msgDict.TryGetValue(msgId, out var list))
{
if (list.Contains(listener))
{
list.Remove(listener);
if (list.Count == 0)
{
ListPool<Action<Param>>.Release(list);
m_msgDict.Remove(msgId);
}
}
}
}
public void Dispatch(Msg msgId, Param param = null)
{
InvokeMethods(m_msgPriorityDict, msgId, param);
InvokeMethods(m_msgDict, msgId, param);
InvokeMethods(m_msgFinallyDict, msgId, param);
InvokeMethods(m_msgOnceDict, msgId, param);
if (m_msgOnceDict.ContainsKey(msgId))
{
ListPool<Action<Param>>.Release(m_msgOnceDict[msgId]);
m_msgOnceDict.Remove(msgId);
}
}
private void InvokeMethods(Dictionary<Msg, List<Action<Param>>> msgDict, Msg msgId, Param param)
{
if (!msgDict.ContainsKey(msgId)) return;
var rawList = msgDict[msgId];
int funcCount = rawList.Count;
if (funcCount == 1)
{
Action<Param> onEvent = rawList[0];
onEvent(param);
return;
}
var invokeFuncs = ListPool<Action<Param>>.Get();
invokeFuncs.AddRange(rawList);
for (var i = 0; i < funcCount; i++)
{
try
{
var onEvent = invokeFuncs[i];
onEvent(param);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
ListPool<Action<Param>>.Release(invokeFuncs);
}
public void Dispose()
{
m_instance = null;
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgFinallyDict.Clear();
m_msgOnceDict.Clear();
m_msgPriorityDict = null;
m_msgDict = null;
m_msgFinallyDict = null;
m_msgOnceDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c4b55125cefc9754888cccfc76bee4c9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace ZooMatch
{
public class BaseMainThreadDispatcher<T, Msg, Param> : SingletonUnity<T>
where T : SingletonUnity<T>
where Param : class
{
private class MainThreadMsgClass
{
public Msg currMsgId;
public Param currParam;
}
private Queue<MainThreadMsgClass> m_msgQueue = new Queue<MainThreadMsgClass>();
private Dictionary<Msg, List<Action<Param>>> m_msgPriorityDict = new Dictionary<Msg, List<Action<Param>>>();
private Dictionary<Msg, List<Action<Param>>> m_msgDict = new Dictionary<Msg, List<Action<Param>>>();
private Dictionary<Msg, List<Action<Param>>> m_msgOnceDict = new Dictionary<Msg, List<Action<Param>>>();
private object m_queueLock = new object();
private void Update()
{
if (m_msgQueue.Count <= 0) return;
while (m_msgQueue.Count > 0)
{
MainThreadMsgClass msg;
lock (m_queueLock)
{
msg = m_msgQueue.Dequeue();
}
AutoDispatch(msg.currMsgId, msg.currParam);
}
}
public void Dispatch(Msg msgId, Param param = null)
{
if (!m_msgPriorityDict.ContainsKey(msgId)
&& !m_msgDict.ContainsKey(msgId)
&& !m_msgOnceDict.ContainsKey(msgId))
return;
MainThreadMsgClass msg = new MainThreadMsgClass
{
currMsgId = msgId,
currParam = param,
};
lock (m_queueLock)
{
m_msgQueue.Enqueue(msg);
}
}
private void AutoDispatch(Msg msgId, Param param)
{
InvokeMethods(m_msgPriorityDict, msgId, param);
InvokeMethods(m_msgDict, msgId, param);
InvokeMethods(m_msgOnceDict, msgId, param);
if (m_msgOnceDict.ContainsKey(msgId))
{
ListPool<Action<Param>>.Release(m_msgOnceDict[msgId]);
m_msgOnceDict.Remove(msgId);
}
}
private void InvokeMethods(Dictionary<Msg, List<Action<Param>>> msgDict, Msg msgId, Param param)
{
if (!msgDict.ContainsKey(msgId)) return;
List<Action<Param>> rawList = msgDict[msgId];
int funcCount = rawList.Count;
if (funcCount == 1)
{
Action<Param> onEvent = rawList[0];
onEvent(param);
return;
}
List<Action<Param>> invokeFuncs = ListPool<Action<Param>>.Get();
invokeFuncs.AddRange(rawList);
for (int i = 0; i < funcCount; i++)
{
try
{
Action<Param> onEvent = invokeFuncs[i];
onEvent(param);
}
catch (Exception e)
{
Debug.LogError(e);
}
}
ListPool<Action<Param>>.Release(invokeFuncs);
}
protected override string ParentRootName
{
get { return AppObjConst.DispatcherGoName; }
}
protected override void OnDestroy()
{
base.OnDestroy();
m_msgPriorityDict.Clear();
m_msgDict.Clear();
m_msgOnceDict.Clear();
m_msgPriorityDict = null;
m_msgDict = null;
m_msgOnceDict = null;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e02321e1c5d556b4484a914fec6eafbd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7926ab78fe6049f3bff905262b9b4695
timeCreated: 1682307945
@@ -0,0 +1,4 @@
namespace ZooMatch
{
public class AppDispatcher : BaseDispatcher<AppDispatcher, uint, object> { }
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 38ec268add4ac6743a27b7167bdcb36a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class CtrlDispatcher : BaseDispatcher<CtrlDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f627301519ad9ac43ba05e525564d3a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class DataDispatcher : BaseDispatcher<DataDispatcher, string, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 080dce14c0be15a448f7a6f1d316700f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class GameDispatcher : BaseDispatcher<GameDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ab8a1624eafed174385147056385f287
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class MainThreadDispatcher : BaseMainThreadDispatcher<MainThreadDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cc759fa7eaebc574da1d3990ca6acfa5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class ModelDispatcher : BaseDispatcher<ModelDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 730ba6382f4f49444a8219f08543f431
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class NetworkDispatcher : BaseDispatcher<NetworkDispatcher, uint, object>
{
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 81a02ff4d9ca458aa70fe26ab514bb99
timeCreated: 1681977441
@@ -0,0 +1,12 @@
namespace ZooMatch
{
public class PreferencesDispatcher<T> : BaseDispatcher<PreferencesDispatcher<T>, string, ChangeValue<T>>
{
public ChangeValue<T> changeValue;
public PreferencesDispatcher()
{
changeValue = new ChangeValue<T>();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9387267f575e6bb4ca279738a461ad61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,6 @@
namespace ZooMatch
{
public class UICtrlDispatcher : BaseDispatcher<UICtrlDispatcher, uint, object>
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1a26910085caa349b769e0be54a023a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 29aecd4f55584cddae5eb19c86727362
timeCreated: 1682308355
@@ -0,0 +1,26 @@
public static class AppMsg
{
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
public static readonly uint App_Quit = ++Cursor_BASE;
public static readonly uint App_Focus_False = ++Cursor_BASE;
public static readonly uint App_Pause_True = ++Cursor_BASE;
public static readonly uint App_GamePause = ++Cursor_BASE;
public static readonly uint App_GameResume = ++Cursor_BASE;
public static readonly uint App_SwitchLanguage = ++Cursor_BASE;
public static readonly uint UI_DisplayLoadingUI = ++Cursor_BASE;
public static readonly uint UI_HideLoadingUI = ++Cursor_BASE;
public static readonly uint UI_LoadingInitAsset = ++Cursor_BASE;
public static readonly uint AppManagerRegister = ++Cursor_BASE;
public static readonly uint InitUIMgr = ++Cursor_BASE;
public static readonly uint UIEvent_UIOpen = ++Cursor_BASE;
public static readonly uint UIEvent_UIClose = ++Cursor_BASE;
public static readonly uint UIEvent_UIDisplay = ++Cursor_BASE;
public static readonly uint UIEvent_UIHide = ++Cursor_BASE;
public static readonly uint KeyCode_Home = ++Cursor_BASE;
public static readonly uint KeyCode_Escape = ++Cursor_BASE;
public static readonly uint TimeScale_Change = ++Cursor_BASE;
public static readonly uint WorldRaycast_EnableChange = ++Cursor_BASE;
public static readonly uint App_Focus_True = ++Cursor_BASE;
public static readonly uint LoginInit = ++Cursor_BASE;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2b87eaa2cadb1da4f8dba83b0b9d3731
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
public static class MainThreadMsg
{
public const uint BASE = 0;
private static uint Cursor_BASE = BASE;
public static readonly uint App_Focus_True = ++Cursor_BASE;
public static readonly uint App_Pause_False = ++Cursor_BASE;
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0061a4ff521ce154c8ca284f91d1cf8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+53
View File
@@ -0,0 +1,53 @@
using UnityEngine;
using System.Collections.Generic;
using ZooMatch;
public class ErrorLogger : MonoBehaviour
{
// 用于存储报错信息的列表
private List<string> errorLogs = new List<string>();
void OnEnable()
{
// 注册事件处理函数
Application.logMessageReceived += HandleLog;
}
void OnDisable()
{
// 注销事件处理函数
Application.logMessageReceived -= HandleLog;
}
// 事件处理函数
void HandleLog(string logString, string stackTrace, LogType type)
{
// 只处理错误和异常类型的日志
if (type == LogType.Error || type == LogType.Exception)
{
// 将报错信息和堆栈跟踪添加到列表中
errorLogs.Add(logString);
errorLogs.Add(stackTrace);
// 这里可以添加代码将报错信息发送给服务器
SendErrorToServer(logString, stackTrace);
}
}
// 如何将报错信息发送给服务器
void SendErrorToServer(string error, string stackTrace)
{
// Debug.Log($"SendErrorToServer-----------error\n{error}");
// Debug.Log($"SendErrorToServer-----------stackTrace\n{stackTrace}");
// 这里填写将报错信息发送到服务器的代码
var reqData = new RespDebugData
{
level = "error",
message = error,
stacktrace = stackTrace
};
NetworkKit.SendLogToServer(reqData);
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 09f1ea8ad17232b42b0cf5073edbaec0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b5af2e719d8d8cd4891e2098b3dad9e8
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+24
View File
@@ -0,0 +1,24 @@
namespace ZooMatch
{
public static class StringExtend
{
public static double ToDouble(this string str)
{
double temp = 0d;
double.TryParse(str, out temp);
return temp;
}
public static float ToFloat(this string str)
{
float temp = 0;
float.TryParse(str, out temp);
return temp;
}
public static bool IsNullOrWhiteSpace(this string str)
{
return string.IsNullOrWhiteSpace(str);
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 79592f013fcf6dc439f2a2940770a250
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+3
View File
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 07cf9660c4614ccca70ef0f5889aae92
timeCreated: 1682316629
@@ -0,0 +1,24 @@
using UnityEngine;
namespace ZooMatch
{
public static class GameObjectExtend
{
public static void SetParent(this GameObject gameObject, GameObject parentGo, bool worldPositionStays = false)
{
if (parentGo)
{
gameObject.transform.SetParent(parentGo.transform, worldPositionStays);
}
}
public static void SetLayer(this GameObject gameObject, string layerName)
{
Transform[] transArr = gameObject.transform.GetComponentsInChildren<Transform>();
for (int i = 0; i < transArr.Length; i++)
{
transArr[i].gameObject.layer = LayerMask.NameToLayer(layerName);
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f33a4adea56c7dc41944ee83d4ef3f84
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 291877299927e1d48b21ef2f54bba0eb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 45a53fe4413ebe44dbf670faf8651e3b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+114
View File
@@ -0,0 +1,114 @@
namespace ZooMatch
{
public abstract class BaseCtrl
{
public string ctrlName;
public bool isEnable = true;
public bool IsNew { get; private set; }
protected ModuleManager moduleManager;
protected ModelDispatcher modelDispatcher;
protected CtrlDispatcher ctrlDispatcher;
protected UICtrlDispatcher uiCtrlDispatcher;
protected DataDispatcher dataDispatcher;
protected GameDispatcher gameDispatcher;
public void New()
{
if (!isEnable) return;
OnNew();
IsNew = true;
}
public virtual void Init()
{
if (!isEnable) return;
Assignment();
AddListener();
AddServerListener();
OnInit();
}
public virtual void StartUp()
{
if (!isEnable) return;
OnStartUp();
}
public virtual void GameStart()
{
if (!isEnable) return;
OnGameStart();
}
public virtual void Dispose()
{
if (!isEnable) return;
RemoveListener();
RemoveServerListener();
OnDispose();
UnAssignment();
IsNew = false;
}
protected virtual void Assignment()
{
moduleManager = ModuleManager.Instance;
modelDispatcher = ModelDispatcher.Instance;
ctrlDispatcher = CtrlDispatcher.Instance;
uiCtrlDispatcher = UICtrlDispatcher.Instance;
dataDispatcher = DataDispatcher.Instance;
gameDispatcher = GameDispatcher.Instance;
}
protected virtual void UnAssignment()
{
moduleManager = null;
modelDispatcher = null;
ctrlDispatcher = null;
uiCtrlDispatcher = null;
dataDispatcher = null;
gameDispatcher = null;
}
protected virtual void OnNew()
{
}
protected abstract void OnInit();
protected virtual void OnStartUp()
{
}
protected virtual void OnGameStart()
{
}
protected abstract void OnDispose();
protected virtual void AddListener()
{
}
protected virtual void RemoveListener()
{
}
protected virtual void AddServerListener()
{
}
protected virtual void RemoveServerListener()
{
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b81051b63111ae24091f178cd25ab0a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+33
View File
@@ -0,0 +1,33 @@
namespace ZooMatch
{
public abstract class BaseUICtrl : BaseCtrl
{
public virtual uint GetOpenUIMsg(string uiName)
{
return 0;
}
public virtual uint GetCloseUIMsg(string uiName)
{
return 0;
}
public void DispatchCloseUI(string uiName = null, object args = null)
{
uint msgId = GetCloseUIMsg(uiName);
if (msgId == 0)
{
CloseUI(args);
return;
}
if (uiCtrlDispatcher != null)
{
uiCtrlDispatcher.Dispatch(msgId, args);
}
}
public abstract void OpenUI(object args = null);
public abstract void CloseUI(object args = null);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17086b56b8ce86e44a2a0e0f23b0f5ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: eeb97e2ef9396894d8e09b5ac644433e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More