using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
namespace Snxxz.UI
|
{
|
[XLua.Hotfix]
|
public static class EquipShowSwitch
|
{
|
static MagicianModel godWeaponModel
|
{
|
get { return ModelCenter.Instance.GetModel<MagicianModel>(); }
|
}
|
|
const int GODWEAPON_EFFECT_STAGE = 3;
|
|
public static bool IsGodWeaponEffectOn(uint value, out Dictionary<int, int> dict)
|
{
|
dict = new Dictionary<int, int>();
|
foreach (var type in godWeaponModel.godWeaponEffectTypes)
|
{
|
var level = 0;
|
if (IsGodWeaponEffectOn(value, type, out level))
|
{
|
dict.Add(type, level);
|
}
|
}
|
return dict.Count > 0;
|
}
|
|
public static bool IsGodWeaponEffectOn(uint value, int type, out int level)
|
{
|
level = 0;
|
if (value == 7)
|
{
|
return false;
|
}
|
for (int i = 0; i < GODWEAPON_EFFECT_STAGE; i++)
|
{
|
var stage = i + 1;
|
var index = GetGodWeaponEquipShowIndex(type, stage);
|
if (MathUtility.GetBitValue(value, index))
|
{
|
level = godWeaponModel.GetGodWeaponStageRequireLevel(type, stage);
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public static byte GetGodWeaponEquipShowIndex(int type, int stage)
|
{
|
EquipShowSwitchType switchType = EquipShowSwitchType.GodWeapon_Life1;
|
switch (type)
|
{
|
case 1:
|
switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Life1 : stage == 2 ?
|
EquipShowSwitchType.GodWeapon_Life2 : EquipShowSwitchType.GodWeapon_Life3;
|
break;
|
case 2:
|
switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Atk1 : stage == 2 ?
|
EquipShowSwitchType.GodWeapon_Atk2 : EquipShowSwitchType.GodWeapon_Atk3;
|
break;
|
case 4:
|
switchType = stage == 1 ? EquipShowSwitchType.GodWeapon_Defend1 : stage == 2 ?
|
EquipShowSwitchType.GodWeapon_Defend2 : EquipShowSwitchType.GodWeapon_Defend3;
|
break;
|
}
|
return (byte)switchType;
|
}
|
|
public static void SendGodWeaponEffectOn(int type, int stage, bool isOn)
|
{
|
var level = 0;
|
var value = PlayerDatas.Instance.baseData.equipShowSwitch;
|
var requireLevel = godWeaponModel.GetGodWeaponStageRequireLevel(type, stage);
|
if (isOn && IsGodWeaponEffectOn(value, type, out level)
|
&& level != requireLevel)
|
{
|
var _stage = 0;
|
if (godWeaponModel.TryGetGodWeaponStage(type, level, out _stage))
|
{
|
var index = GetGodWeaponEquipShowIndex(type, _stage);
|
value = (uint)MathUtility.SetBitValue((int)value, index, false);
|
}
|
}
|
|
{
|
var index = GetGodWeaponEquipShowIndex(type, stage);
|
value = (uint)MathUtility.SetBitValue((int)value, index, isOn);
|
}
|
|
if (value != PlayerDatas.Instance.baseData.equipShowSwitch)
|
{
|
SendPackage(value);
|
}
|
}
|
|
public static bool IsEquipShowSwitchOn(EquipShowSwitchType type, uint value)
|
{
|
if ((int)type >= (int)EquipShowSwitchType.max)
|
{
|
return false;
|
}
|
return MathUtility.GetBitValue(value, (ushort)type);
|
}
|
|
public static void SendPackage(uint value)
|
{
|
C032F_tagCRequestEquipShowHide pak = new C032F_tagCRequestEquipShowHide();
|
pak.EquipShowSwitch = value;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
public enum EquipShowSwitchType : byte
|
{
|
GodWeapon_Life1,//生命
|
GodWeapon_Life2,
|
GodWeapon_Life3,
|
GodWeapon_Atk1,//攻击
|
GodWeapon_Atk2,
|
GodWeapon_Atk3,
|
GodWeapon_Defend1,//护盾
|
GodWeapon_Defend2,
|
GodWeapon_Defend3,
|
max = 32,
|
}
|
}
|
}
|