423 lines
17 KiB
C#
423 lines
17 KiB
C#
//帮会修炼的界面
|
|
|
|
using Games.LogicObj;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.Events;
|
|
using System.Collections;
|
|
using GCGame;
|
|
using Module.Log;
|
|
using Games.GlobeDefine;
|
|
using System.Collections.Generic;
|
|
using System;
|
|
using GCGame.Table;
|
|
using Games.Events;
|
|
|
|
public class GuildXiulianWnd : MonoBehaviour
|
|
{
|
|
public class AttrInfo
|
|
{
|
|
public int attrID;
|
|
public Tab_GuildAttrPractice attrTab;
|
|
public int attrLevel; //-1 表示未开启
|
|
public int attrExp;
|
|
|
|
public AttrInfo()
|
|
{
|
|
Clear();
|
|
}
|
|
|
|
private void Clear()
|
|
{
|
|
attrID = -1;
|
|
attrTab = null;
|
|
attrLevel = -1;
|
|
attrExp = 0;
|
|
}
|
|
}
|
|
|
|
public Toggle m_ToggleCloneBtn;
|
|
public UIContainerSelect m_AttrContainer;
|
|
|
|
public Button OneKeyStudyBtn;
|
|
public GameObject Disable_OneKeyStudyBtn;
|
|
public Text attrName;
|
|
public Text levelMax;
|
|
public Text CurInfo;
|
|
public Text nextInfo;
|
|
public Text studyNeed;
|
|
|
|
public Text costMoney;
|
|
public Image costMoneyIcon;
|
|
public Text haveCost;
|
|
public Image haveCostIcon;
|
|
public Text CostContribute;
|
|
public Text haveContribute;
|
|
public Toggle AutoPay;
|
|
|
|
public Image ContributeIconHas;
|
|
public Image ContributeIconCost;
|
|
|
|
private AttrInfo m_currSelectAttr = null;
|
|
|
|
void Awake()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.AttrStudyInfo, FreshNewInfo);
|
|
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.BuildAttrInfo, AttrInfoSet);
|
|
|
|
Hashtable add2 = new Hashtable();
|
|
add2["name"] = "AttrStudyInfo";
|
|
Games.Events.MessageEventCallBack call2 = UpdateGuildContribute;
|
|
add2["callFun"] = call2;
|
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdateGuildInfo, add2);
|
|
|
|
Hashtable calbackMoveparam3 = new Hashtable();
|
|
calbackMoveparam3["name"] = "GuildXLSetWuFresh";
|
|
MessageEventCallBack fun3 = PayFresh;
|
|
calbackMoveparam3.Add("callFun", fun3);
|
|
EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.FRESHSAMEUSETIP, calbackMoveparam3);
|
|
ContributeIconHas.gameObject.SetActive(false);
|
|
ContributeIconCost.gameObject.SetActive(false);
|
|
}
|
|
|
|
void OnDestroy()
|
|
{
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.AttrStudyInfo, FreshNewInfo);
|
|
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.BuildAttrInfo, AttrInfoSet);
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdateGuildInfo, "AttrStudyInfo");
|
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.FRESHSAMEUSETIP, "GuildXLSetWuFresh");
|
|
}
|
|
|
|
public void UpdateGuildContribute(Hashtable addtable, Hashtable sendtable)
|
|
{
|
|
haveContribute.text = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute.ToString();
|
|
}
|
|
|
|
public void PayFresh(Hashtable addparam, Hashtable sendparam)
|
|
{
|
|
Click_AttrItem(m_currSelectAttr);
|
|
}
|
|
|
|
public void AttrInfoSet(object obj)
|
|
{
|
|
m_AttrContainer.RefreshItems();
|
|
Click_AttrItem(m_currSelectAttr);
|
|
}
|
|
|
|
public void OnEnable()
|
|
{
|
|
if (GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrInfos.Count <= 0 && GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrTypes.Count <= 0)
|
|
{
|
|
var table = TableManager.GetGuildAttrPractice().Values;
|
|
foreach (var attrInfo in table)
|
|
{
|
|
AttrInfo attr = new AttrInfo();
|
|
attr.attrID = attrInfo.Id;
|
|
attr.attrTab = attrInfo;
|
|
GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrInfos[attr.attrID] = attr;
|
|
GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrTypes[attrInfo.TypeId] = attrInfo.TypeName;
|
|
}
|
|
}
|
|
if(m_ToggleCloneBtn!=null && m_ToggleCloneBtn.transform.parent.childCount<=1)
|
|
{
|
|
CloneToggleBtn();
|
|
}
|
|
}
|
|
|
|
public void FreshNewInfo(object obj)
|
|
{
|
|
m_AttrContainer.RefreshItems();
|
|
Click_AttrItem(m_currSelectAttr);
|
|
}
|
|
|
|
public void CloneToggleBtn()
|
|
{
|
|
if (m_ToggleCloneBtn == null)
|
|
return;
|
|
int index = 0;
|
|
Toggle FirstShow = null;
|
|
foreach (var kv in GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrTypes)
|
|
{
|
|
GameObject toggleBtn = UnityEngine.Object.Instantiate(m_ToggleCloneBtn.gameObject) as GameObject;
|
|
if(toggleBtn != null)
|
|
{
|
|
toggleBtn.SetActive(true);
|
|
toggleBtn.transform.SetParent(m_ToggleCloneBtn.transform.parent);
|
|
toggleBtn.transform.localScale = Vector3.one;
|
|
toggleBtn.transform.localPosition = Vector3.zero;
|
|
Text[] titlenames = toggleBtn.GetComponentsInChildren<Text>();
|
|
for(int i = 0;i < titlenames.Length; i++)
|
|
{
|
|
titlenames[i].text = kv.Value;
|
|
}
|
|
Toggle toggle = toggleBtn.GetComponent<Toggle>();
|
|
if(toggle!=null)
|
|
{
|
|
toggle.group = m_ToggleCloneBtn.group;
|
|
int Type = kv.Key;
|
|
toggle.onValueChanged.AddListener(delegate (bool isOn)
|
|
{
|
|
Click_ToggleBtn(isOn, Type);
|
|
});
|
|
}
|
|
|
|
if (index == 0)
|
|
{
|
|
FirstShow = toggle;
|
|
}
|
|
index++;
|
|
}
|
|
}
|
|
if (FirstShow != null)
|
|
FirstShow.isOn = true;
|
|
}
|
|
|
|
public void Click_ToggleBtn(bool isOn, int typeID)
|
|
{
|
|
if (isOn == false)
|
|
return;
|
|
ShowAttrUpdate(typeID);
|
|
}
|
|
|
|
public void ShowAttrUpdate(int typeID)
|
|
{
|
|
List<AttrInfo> shows = new List<AttrInfo>();
|
|
foreach(var attr in GameManager.gameManager.PlayerDataPool.GuildInfo.m_AttrInfos)
|
|
{
|
|
if (attr.Value.attrTab != null && attr.Value.attrTab.TypeId == typeID)
|
|
shows.Add(attr.Value);
|
|
}
|
|
if (shows.Count <= 0)
|
|
return;
|
|
List<AttrInfo> sels = new List<AttrInfo>();
|
|
sels.Add(shows[0]);
|
|
m_AttrContainer.InitSelectContent(shows, sels, Click_AttrItem);
|
|
}
|
|
|
|
public void Click_AttrItem(object objAttr)
|
|
{
|
|
AttrInfo attr = objAttr as AttrInfo;
|
|
if (attr == null)
|
|
return;
|
|
m_currSelectAttr = attr;
|
|
if (m_currSelectAttr.attrTab == null)
|
|
return;
|
|
attrName.text = string.Format("{0}Lv.{1}", m_currSelectAttr.attrTab.Describe, m_currSelectAttr.attrLevel);
|
|
levelMax.text = string.Format("Lv.{0}", m_currSelectAttr.attrTab.getLevelCount());
|
|
OneKeyStudyBtn.gameObject.SetActive(true);
|
|
Disable_OneKeyStudyBtn.SetActive(false);
|
|
if(m_currSelectAttr.attrLevel==-1)
|
|
{
|
|
attrName.text = m_currSelectAttr.attrTab.Describe;
|
|
CurInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{24982}", m_currSelectAttr.attrTab.GuildCollegeLevel);
|
|
nextInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{24982}", m_currSelectAttr.attrTab.GuildCollegeLevel);
|
|
studyNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{24982}", m_currSelectAttr.attrTab.GuildCollegeLevel);
|
|
OneKeyStudyBtn.gameObject.SetActive(false);
|
|
Disable_OneKeyStudyBtn.SetActive(true);
|
|
}
|
|
else if (m_currSelectAttr.attrLevel >= m_currSelectAttr.attrTab.getLevelCount())
|
|
{
|
|
//CurInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25096}");
|
|
CurInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25097}", m_currSelectAttr.attrTab.Describe, m_currSelectAttr.attrTab.GetLevelbyIndex(m_currSelectAttr.attrLevel - 1));
|
|
nextInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25096}");
|
|
studyNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25096}");
|
|
OneKeyStudyBtn.gameObject.SetActive(false);
|
|
Disable_OneKeyStudyBtn.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
if(m_currSelectAttr.attrLevel < 0)
|
|
{
|
|
OneKeyStudyBtn.gameObject.SetActive(false);
|
|
Disable_OneKeyStudyBtn.SetActive(true);
|
|
}
|
|
|
|
if(m_currSelectAttr.attrLevel == 0)
|
|
{
|
|
CurInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25097}", m_currSelectAttr.attrTab.Describe, 0);
|
|
nextInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25097}", m_currSelectAttr.attrTab.Describe, m_currSelectAttr.attrTab.GetLevelbyIndex(m_currSelectAttr.attrLevel));
|
|
studyNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25098}", 0);
|
|
}
|
|
else
|
|
{
|
|
CurInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25097}", m_currSelectAttr.attrTab.Describe, m_currSelectAttr.attrTab.GetLevelbyIndex(m_currSelectAttr.attrLevel - 1));
|
|
nextInfo.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25097}", m_currSelectAttr.attrTab.Describe, m_currSelectAttr.attrTab.GetLevelbyIndex(m_currSelectAttr.attrLevel));
|
|
studyNeed.text = GCGame.Table.StrDictionary.GetClientDictionaryString("#{25098}", m_currSelectAttr.attrTab.GetNeedLevelbyIndex(m_currSelectAttr.attrLevel));
|
|
}
|
|
}
|
|
|
|
haveCost.text = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType((MONEYTYPE)m_currSelectAttr.attrTab.MoneyType).ToString();
|
|
costMoney.text = m_currSelectAttr.attrLevel == -1 ? "0" : m_currSelectAttr.attrTab.MoneyNum.ToString();
|
|
LoadAssetBundle.Instance.SetImageSprite(costMoneyIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)m_currSelectAttr.attrTab.MoneyType));
|
|
LoadAssetBundle.Instance.SetImageSprite(haveCostIcon, UICurrencyItem.GetCurrencySprite((MONEYTYPE)m_currSelectAttr.attrTab.MoneyType));
|
|
CostContribute.text = m_currSelectAttr.attrLevel == -1 ? "0" : m_currSelectAttr.attrTab.ContributeNum.ToString();
|
|
haveContribute.text = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute.ToString();
|
|
LoadAssetBundle.Instance.SetImageSprite(ContributeIconHas, UICurrencyItem.GetScoreSprite(SCORE_TYPE.GUILD_SCORE),delegate(bool isSucess, GameObject obj)
|
|
{
|
|
if(obj)
|
|
{
|
|
ContributeIconHas.gameObject.SetActive(true);
|
|
}
|
|
});
|
|
LoadAssetBundle.Instance.SetImageSprite(ContributeIconCost, UICurrencyItem.GetScoreSprite(SCORE_TYPE.GUILD_SCORE), delegate (bool isSucess, GameObject obj)
|
|
{
|
|
if (obj)
|
|
{
|
|
ContributeIconCost.gameObject.SetActive(true);
|
|
}
|
|
});
|
|
}
|
|
|
|
public bool CheckLevelMax()
|
|
{
|
|
if (m_currSelectAttr == null || m_currSelectAttr.attrTab == null)
|
|
return false;
|
|
if (m_currSelectAttr.attrLevel>=0 && m_currSelectAttr.attrLevel >= m_currSelectAttr.attrTab.getLevelCount())
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
public bool CheckLevelNeed()
|
|
{
|
|
if (m_currSelectAttr==null || m_currSelectAttr.attrTab == null)
|
|
return false;
|
|
if (m_currSelectAttr.attrLevel > m_currSelectAttr.attrTab.getLevelCount())
|
|
return false;
|
|
int needLevel = 0;
|
|
if(m_currSelectAttr.attrLevel > 0)
|
|
needLevel = m_currSelectAttr.attrTab.GetNeedLevelbyIndex(m_currSelectAttr.attrLevel);
|
|
if (Singleton<ObjManager>.Instance.MainPlayer != null && Singleton<ObjManager>.Instance.MainPlayer.BaseAttr.Level >= needLevel)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
//一键修炼
|
|
public void OneKeyStudy()
|
|
{
|
|
if (GameManager.gameManager.m_RunningScene == 658)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
|
|
return;
|
|
}
|
|
if (m_currSelectAttr==null || m_currSelectAttr.attrTab == null)
|
|
return;
|
|
if(m_currSelectAttr.attrLevel < 0)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{24982}",m_currSelectAttr.attrTab.GuildCollegeLevel));
|
|
return;
|
|
}
|
|
if (CheckLevelMax())
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25125}"));
|
|
return;
|
|
}
|
|
int nPracticeMax1 = 99999999;
|
|
int nPracticeMax2 = 99999999;
|
|
int nPracticeCount = 0;
|
|
|
|
if (m_currSelectAttr.attrTab.ContributeNum > GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute)
|
|
{
|
|
// 帮贡不足,不可修炼
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25087}"));
|
|
return;
|
|
}
|
|
nPracticeMax1 = GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute / m_currSelectAttr.attrTab.ContributeNum;
|
|
if (m_currSelectAttr.attrTab.MoneyNum > 0)
|
|
{
|
|
long haveCoin = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN);
|
|
long haveCoinBind = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN_BIND);
|
|
if (AutoPay.isOn)
|
|
haveCoinBind = haveCoin + haveCoinBind;
|
|
nPracticeMax2 = (int)((haveCoinBind) / (long)m_currSelectAttr.attrTab.MoneyNum);
|
|
if (nPracticeMax2 <= 0)
|
|
{
|
|
// 钱不足,不可修炼
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25086}"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
nPracticeCount = Mathf.Min(nPracticeMax1, nPracticeMax2);
|
|
|
|
int nOneKeyCount = m_currSelectAttr.attrTab.GetExpbyIndex(m_currSelectAttr.attrLevel) - m_currSelectAttr.attrExp;
|
|
if (nPracticeCount > nOneKeyCount)
|
|
{
|
|
nPracticeCount = nOneKeyCount;
|
|
}
|
|
|
|
if (nPracticeCount > 0)
|
|
{
|
|
MessageBoxLogic.OpenOKCancelBox(StrDictionary.GetClientDictionaryString("#{25045}", nPracticeCount* m_currSelectAttr.attrTab.ContributeNum,nPracticeCount* m_currSelectAttr.attrTab.MoneyNum), null, delegate ()
|
|
{
|
|
|
|
Xiulian((int)CG_REQ_GUILD_PRACTICE.OPTION_TYPE.PRACTICE_ONEKEY);
|
|
|
|
}, null);
|
|
}
|
|
}
|
|
|
|
private void Xiulian(int type)
|
|
{
|
|
CG_REQ_GUILD_PRACTICE send = (CG_REQ_GUILD_PRACTICE)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_GUILD_PRACTICE);
|
|
send.SetOptiontype(type);
|
|
send.AddPracticeid(m_currSelectAttr.attrID);
|
|
send.IsAllowWithSilver = (AutoPay.isOn ? 1 : 0);
|
|
send.SendPacket();
|
|
}
|
|
|
|
//修炼一次
|
|
public void StudyOneTimes()
|
|
{
|
|
if (GameManager.gameManager.m_RunningScene == 658)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{79512}"));
|
|
return;
|
|
}
|
|
if (m_currSelectAttr == null)
|
|
return;
|
|
if(m_currSelectAttr.attrLevel==-1)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{24982}", m_currSelectAttr.attrTab.GuildCollegeLevel));
|
|
return;
|
|
}
|
|
|
|
if(CheckLevelNeed()==false)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25134}"));
|
|
return;
|
|
}
|
|
|
|
if (CheckLevelMax())
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25125}"));
|
|
return;
|
|
}
|
|
|
|
if (m_currSelectAttr.attrTab == null)
|
|
return;
|
|
|
|
if (m_currSelectAttr.attrTab.ContributeNum > GameManager.gameManager.PlayerDataPool.GuildInfo.GuildContribute)
|
|
{
|
|
// 帮贡不足,不可修炼
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25087}"));
|
|
return;
|
|
}
|
|
|
|
long haveCoin = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN);
|
|
long haveBindCoin = GameManager.gameManager.PlayerDataPool.Money.GetMoneyByType(MONEYTYPE.MONEYTYPE_COIN_BIND);
|
|
bool isEnough = (haveBindCoin >= m_currSelectAttr.attrTab.MoneyNum);
|
|
if(isEnough == false && AutoPay.isOn)
|
|
{
|
|
isEnough = (haveCoin + haveBindCoin > m_currSelectAttr.attrTab.MoneyNum);
|
|
}
|
|
|
|
if(isEnough==false)
|
|
{
|
|
GUIData.AddNotifyData(GCGame.Table.StrDictionary.GetClientDictionaryString("#{25086}"));
|
|
return;
|
|
}
|
|
|
|
Xiulian((int)CG_REQ_GUILD_PRACTICE.OPTION_TYPE.PRACTICE_ONCE);
|
|
}
|
|
|
|
} |