Files
Main/Assets/Code/Logic/_Required/Lua/LogicAdaptor.cs

106 lines
3.3 KiB
C#
Raw Normal View History

2025-01-25 04:38:09 +08:00
using Thousandto.Code.Center;
using System;
using System.Collections.Generic;
using UnityEngine;
using Thousandto.Code.Logic.LocalPlayerBT;
namespace Thousandto.Code.Logic
{
//Logic适配器用于Lua端的调用
public class LogicAdaptor
{
//设置数量输入框Info数据
public static void SetNumInputInfoParam(int maxCount, int price, int haveCoin, int iconId)
{
Global.NumInputInfoParam param = new Global.NumInputInfoParam();
param.MaxCount = maxCount;
param.Price = price;
param.HaveCoin = haveCoin;
param.IconId = iconId;
GameCenter.PushFixEvent(Global.LogicEventDefine.EID_EVENT_SHOW_NUMINPUTINFO, param);
}
//获取当前攻击的怪物ID
public static int GetCurAttackMonsterCfgId()
{
int ret = 0;
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
if (lp != null)
{
var target = lp.GetCurSelectedTarget();
if (target != null && target is Monster)
{
Monster monster = target as Monster;
ret = monster.PropMoudle.CfgID;
}
}
return ret;
}
////获取好友信息
//public static MSG_Friend.CommonInfo GetFriend(long id)
//{
// return GameCenter.LuaSystem.Adaptor.GetFriendInfo((ulong)id);
//}
//获取当前平台类型
public static RuntimePlatform GetRuntimePlatform()
{
return Application.platform;
}
//获取当前画质等级
public static int GetQualityLevel()
{
return GameSettingCore.Get(GameSettingKeyCode.QualityLevel);
}
//获取当前游戏状态id
public static int GetCurGameStateId()
{
var curState = GameCenter.GameStateSystem.GetCurState();
if (curState == null)
{
return - 1;
}
return curState.GetStateId();
}
//获取当前网络状态
public static int GetCurInternetReachability()
{
return (int)Application.internetReachability;
}
//生成64位唯一id
public static ulong GenGUID()
{
//根据GUID获取19位的唯一数字序列
byte[] buffer = Guid.NewGuid().ToByteArray();
return BitConverter.ToUInt64(buffer, 0);
}
//返回任务地图参数
public static List<float> GetTaskMapPosParams(int type, int id)
{
List<float> retList = null;
TaskBD.TaskTargetType taskType = (TaskBD.TaskTargetType)type;
var pos = LocalPlayerBT.PlayerBT.Task.GetTaskPos(taskType, id);
if (pos != null)
{
retList = new List<float>();
retList.Add(pos.MapId);
retList.Add(pos.Pos.x);
retList.Add(pos.Pos.z);
}
return retList;
}
//发送玩家坐标
public static void SendPlayerPos(int channel, int param)
{
ChatChanelType chatChannel = (ChatChanelType)channel;
GameCenter.ChatSystem.SendPos(chatChannel, param);
}
}
}