//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, October 28, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
//关于PK战斗状态改变面板
|
|
namespace Snxxz.UI
|
{
|
|
public class CombatModeWin : Window
|
{
|
public float headings = 20f;
|
public float height = 60f;
|
[SerializeField]
|
RectTransform _Viewport;
|
[SerializeField]
|
ScrollerController m_ScrollerController;
|
[SerializeField]
|
Button _CloseBtn;
|
private Dictionary<int, string> _dic = new Dictionary<int, string>();
|
private int _PkType = 0;
|
private int[] AtkTypeList;
|
#region Built-in
|
BuffModel m_BuffModel;
|
BuffModel Buffmodel { get { return m_BuffModel ?? (m_BuffModel = ModelCenter.Instance.GetModel<BuffModel>()); } }
|
PKModel m_PKModel;
|
PKModel pKModel { get { return m_PKModel ?? (m_PKModel = ModelCenter.Instance.GetModel<PKModel>()); } }
|
PlayerMainDate m_MainModel;
|
PlayerMainDate onMainModel { get { return m_MainModel ?? (m_MainModel = ModelCenter.Instance.GetModel<PlayerMainDate>()); } }
|
protected override void BindController()
|
{
|
string PkStr = FuncConfigConfig.Get("PKText").Numerical1;
|
_dic = ConfigParse.GetDic<int, string>(PkStr);
|
}
|
|
protected override void AddListeners()
|
{
|
_CloseBtn.AddListener(CloseBtn);
|
}
|
|
protected override void OnPreOpen()
|
{
|
int MapID = PlayerDatas.Instance.baseData.MapID;
|
var config = MapConfig.Get(MapID);
|
AtkTypeList = pKModel.GetArea(config.AtkType).ToArray();
|
|
_PkType = Buffmodel.PkType;//获取当前PK状态
|
if (_PkType != 2)
|
{
|
_dic.Remove(2);
|
}
|
m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
|
OnCreateGridLineCell(m_ScrollerController);
|
_Viewport.sizeDelta = _Viewport.sizeDelta.SetY(AtkTypeList.Length * height + headings);
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
}
|
|
protected override void OnPreClose()
|
{
|
m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
|
|
void CloseBtn()
|
{
|
|
Close();
|
}
|
private void OnCreateGridLineCell(ScrollerController gridCtrl)
|
{
|
gridCtrl.Refresh();
|
for (int i = 0; i < AtkTypeList.Length; i++)
|
{
|
gridCtrl.AddCell(ScrollerDataType.Header, AtkTypeList[i]);
|
}
|
gridCtrl.Restart();
|
}
|
private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
|
{
|
PKButton _PkButton = cell.GetComponent<PKButton>();
|
if (_PkType == cell.index)
|
_PkButton.ElectImage.SetActive(true);
|
else
|
_PkButton.ElectImage.SetActive(false);
|
TextSwitch(cell.index, _PkButton.Model, _PkButton.ContentText);
|
_PkButton.StateSelection.RemoveAllListeners();
|
bool IsBossBool = MapArea.IsInMapArea(PlayerDatas.Instance.hero.CurMapArea, MapArea.E_Type.Boss);//是否在Boss区域
|
_PkButton.StateSelection.AddListener(() =>
|
{
|
DTCA202_tagMCAttackMode.Send_SwitchAttackMode((E_AttackMode)cell.index);
|
Close();
|
});
|
// throw new NotImplementedException();
|
}
|
|
|
void TextSwitch(int _EnumType, Image _imge, Text _text)
|
{
|
switch (_EnumType)
|
{
|
case 0:
|
|
_imge.SetSprite("Atk_Peace");//和平
|
_text.text = _dic[0];
|
break;
|
case 1:
|
|
_imge.SetSprite("Atk_All");//全体
|
_text.text = _dic[1];
|
break;
|
case 2:
|
_imge.SetSprite("Atk_Defence");//防卫
|
_text.text = _dic[2];
|
break;
|
case 3:
|
|
DebugEx.LogError("集团");
|
break;
|
case 4:
|
|
DebugEx.LogError("组队");
|
break;
|
case 5:
|
|
_imge.SetSprite("Atk_Force");//强制
|
_text.text = _dic[5];
|
break;
|
case 6:
|
break;
|
case 7:
|
_imge.SetSprite("Atk_Scramble");
|
_text.text = _dic.ContainsKey(7) ? _dic[7] : string.Empty;
|
break;
|
default:
|
break;
|
}
|
}
|
}
|
|
|
|
|
|
}
|