179 lines
6.5 KiB
C#
179 lines
6.5 KiB
C#
|
|
|||
|
using Thousandto.Cfg.Data;
|
|||
|
using Thousandto.Code.Center;
|
|||
|
using Thousandto.Code.Global;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Thousandto.Code.Logic
|
|||
|
{
|
|||
|
//变量系统,用于判断某些条件是否达成
|
|||
|
public class VariableSystem
|
|||
|
{
|
|||
|
private static Dictionary<int, int> _valueTable = new Dictionary<int, int>();
|
|||
|
|
|||
|
public static void SendGetMsg()
|
|||
|
{
|
|||
|
MSG_Backend.ReqFuncOpenRoleInfo msg = new MSG_Backend.ReqFuncOpenRoleInfo();
|
|||
|
msg.Send();
|
|||
|
}
|
|||
|
public static void ResFuncOpenRoleInfo(MSG_Backend.ResFuncOpenRoleInfo result)
|
|||
|
{
|
|||
|
_valueTable.Clear();
|
|||
|
for (int i = 0; i < result.infolist.Count; ++i)
|
|||
|
{
|
|||
|
_valueTable[result.infolist[i].id] = result.infolist[i].state;
|
|||
|
}
|
|||
|
|
|||
|
GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_CLIENTVARIABLERETURN);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取某个条件的展示字符串
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static string GetVariableShowText(int type, int value, bool simplifyValue = false)
|
|||
|
{
|
|||
|
int curValue = GetVariableValue(type);
|
|||
|
switch (type)
|
|||
|
{
|
|||
|
case FunctionVariableIdCode.PlayerTaskID:
|
|||
|
return GameCenter.TaskManager.IsMainTaskOver(value) ? "1/1" : "0/1";
|
|||
|
default:
|
|||
|
return GameCenter.LuaSystem.Adaptor.GetVariableShowText( type, curValue, value, simplifyValue );
|
|||
|
//if (simplifyValue)
|
|||
|
//{
|
|||
|
// var curText = string.Empty;
|
|||
|
// if (curValue > 1000000)
|
|||
|
// {
|
|||
|
// if(curValue % 1000000 == 0)
|
|||
|
// {
|
|||
|
// curText = string.Format("{0}M", curValue / 1000000);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// curText = string.Format("{0:F2}M", curValue / 1000000f);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else if (curValue > 1000)
|
|||
|
// {
|
|||
|
// if(curValue % 1000 == 0)
|
|||
|
// {
|
|||
|
// curText = string.Format("{0}K", curValue / 1000);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// curText = string.Format("{0:F2}K", curValue / 1000f);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// curText = curValue.ToString();
|
|||
|
// }
|
|||
|
|
|||
|
// var valueText = string.Empty;
|
|||
|
// if (value > 1000000)
|
|||
|
// {
|
|||
|
// if(value % 1000000 == 0)
|
|||
|
// {
|
|||
|
// valueText = string.Format("{0}M", value / 1000000);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// valueText = string.Format("{0:F2}M", value / 1000000f);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else if (value > 1000)
|
|||
|
// {
|
|||
|
// if(value % 1000 == 0)
|
|||
|
// {
|
|||
|
// valueText = string.Format("{0}K", value / 1000);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// valueText = string.Format("{0:F2}K", value / 1000f);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// valueText = value.ToString();
|
|||
|
// }
|
|||
|
// return string.Format("{0}/{1}", curText, valueText);
|
|||
|
//}
|
|||
|
//return string.Format("{0}/{1}", curValue, value);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取某个条件的展示进度条
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static float GetVariableShowProgress(int type, int value)
|
|||
|
{
|
|||
|
int curValue = GetVariableValue(type);
|
|||
|
switch (type)
|
|||
|
{
|
|||
|
case FunctionVariableIdCode.PlayerTaskID:
|
|||
|
return GameCenter.TaskManager.IsMainTaskOver(value) ? 1f : 0f;
|
|||
|
default:
|
|||
|
return GameCenter.LuaSystem.Adaptor.GetVariableShowProgress( type, curValue, value );
|
|||
|
//return (float)curValue / value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 判断某个变量是否已经达成条件
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool IsVariableReach(int type, int value)
|
|||
|
{
|
|||
|
int curValue = GetVariableValue(type);
|
|||
|
switch (type)
|
|||
|
{
|
|||
|
case FunctionVariableIdCode.PlayerTaskID:
|
|||
|
return GameCenter.TaskManager.IsMainTaskOver(value);
|
|||
|
default:
|
|||
|
return GameCenter.LuaSystem.Adaptor.IsVariableReach( type, curValue, value );
|
|||
|
//return curValue >= value;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取变量值,返回-1表示此变量值不能被获取
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
public static int GetVariableValue(int code)
|
|||
|
{
|
|||
|
if (_valueTable.ContainsKey(code))
|
|||
|
{
|
|||
|
return _valueTable[code];
|
|||
|
}
|
|||
|
|
|||
|
var lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
|||
|
if (lp == null)
|
|||
|
return 0;
|
|||
|
|
|||
|
switch (code)
|
|||
|
{
|
|||
|
case FunctionVariableIdCode.PlayerLevel://玩家等级
|
|||
|
return lp.Level;
|
|||
|
case FunctionVariableIdCode.PlayerTaskID://玩家任务ID
|
|||
|
return -1;
|
|||
|
case FunctionVariableIdCode.PlayerPower://玩家战力到达多少
|
|||
|
return (int)lp.FightPower;
|
|||
|
case FunctionVariableIdCode.ChangeJob: //转职到XX
|
|||
|
return 0;
|
|||
|
default:
|
|||
|
return GameCenter.LuaSystem.Adaptor.GetVariableValue( code );
|
|||
|
}
|
|||
|
|
|||
|
//return -1;
|
|||
|
}
|
|||
|
|
|||
|
private static int GetZhangChangXunXian()
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|