392 lines
13 KiB
C#
392 lines
13 KiB
C#
|
using UnityEngine;
|
|||
|
using System.Collections;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections.Generic;
|
|||
|
using GCGame.Table;
|
|||
|
using System;
|
|||
|
|
|||
|
public class MainMissionCopySceneItem : MonoBehaviour {
|
|||
|
|
|||
|
#region
|
|||
|
public Image copySceneIcon;
|
|||
|
public Text copySceneName;
|
|||
|
public GameObject copySceneItemMarkIcon;
|
|||
|
|
|||
|
public List<Image> rewItemIconList;
|
|||
|
public List<Text> rewItemCountList;
|
|||
|
public List<Image> rewItemQualityList;
|
|||
|
public Image copyScoreIcon; //s ss sss a b c
|
|||
|
|
|||
|
public Image firstRewItemIcon;
|
|||
|
public Image firstRewItemQuality;
|
|||
|
public Text firstRewItemCount;
|
|||
|
public GameObject gainFirstRewMarkIcon;
|
|||
|
|
|||
|
public Text canSweepRemainTimeText;
|
|||
|
public Text todayRemainTimesText;
|
|||
|
|
|||
|
public Text lockDesc;
|
|||
|
public GameObject funBtnPanel;
|
|||
|
public GameObject lockPanel;
|
|||
|
|
|||
|
public List<Sprite> scoreIconList;
|
|||
|
public GameObject _CanReiveObj;
|
|||
|
#endregion
|
|||
|
|
|||
|
private List<int> rewdIdList = new List<int>();
|
|||
|
public int curBaseId = 0;
|
|||
|
|
|||
|
public bool canNormalSweep = false;
|
|||
|
|
|||
|
private int remainCanSweepDays; //还有几天可以开启扫荡
|
|||
|
public int remainCanChallengeTimes; //剩余挑战次数
|
|||
|
private Tab_NewCopyBase copyBase = null;
|
|||
|
public bool isPassOnce = false;
|
|||
|
public void InitItem(MainMissionCopyitemInfo info)
|
|||
|
{
|
|||
|
curBaseId = info.fubenId;
|
|||
|
copyBase = TableManager.GetNewCopyBaseByID(info.fubenId, 0);
|
|||
|
if(copyBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(copySceneIcon, copyBase.Icon);
|
|||
|
Tab_Fuben fuben = TableManager.GetFubenByID(info.fubenId, 0);
|
|||
|
if(fuben == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
copySceneName.text = fuben.Name;
|
|||
|
|
|||
|
SetNormalPassRew(copyBase.NormalPassRewardId);
|
|||
|
SetFirstPassRew(copyBase.FirstPassRewardId, info._RewState);
|
|||
|
SetRemainChallengeimes(info.remainTimes);
|
|||
|
SetCanSweepState();
|
|||
|
SetScoreIcon(info.score);
|
|||
|
SetLockState(copyBase.UnLockLevel);
|
|||
|
}
|
|||
|
|
|||
|
private int _RewState = -1; //未通关 不能领取
|
|||
|
|
|||
|
public void SetLockState(int needLevel)
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level >= needLevel)
|
|||
|
{
|
|||
|
funBtnPanel.SetActive(true);
|
|||
|
lockPanel.SetActive(false);
|
|||
|
} else
|
|||
|
{
|
|||
|
funBtnPanel.SetActive(false);
|
|||
|
lockPanel.SetActive(true);
|
|||
|
lockDesc.text = StrDictionary.GetClientDictionaryString("#{44011}", needLevel);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetScoreIcon(int score)
|
|||
|
{
|
|||
|
if(score < 1)
|
|||
|
{
|
|||
|
copyScoreIcon.gameObject.SetActive(false);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
copyScoreIcon.gameObject.SetActive(true);
|
|||
|
copyScoreIcon.overrideSprite = scoreIconList[score - 1];
|
|||
|
copyScoreIcon.SetNativeSize();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetCanSweepState()
|
|||
|
{
|
|||
|
if(remainCanSweepDays > 0 || remainCanChallengeTimes == 0)
|
|||
|
{
|
|||
|
canNormalSweep = false;
|
|||
|
}else
|
|||
|
{
|
|||
|
canNormalSweep = true;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void SetRemainChallengeimes(int times)
|
|||
|
{
|
|||
|
if(times == -1)//不限制次数
|
|||
|
{
|
|||
|
todayRemainTimesText.text = StrDictionary.GetClientDictionaryString("#{44013}", StrDictionary.GetClientDictionaryString("#{43036}"));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
todayRemainTimesText.text = StrDictionary.GetClientDictionaryString("#{44013}", times);
|
|||
|
}
|
|||
|
|
|||
|
remainCanChallengeTimes = times;
|
|||
|
}
|
|||
|
|
|||
|
public void SetCanSweepTime()
|
|||
|
{
|
|||
|
Tab_NewCopyBase newCopyBase = TableManager.GetNewCopyBaseByID(curBaseId, 0);
|
|||
|
if(newCopyBase == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//int sweepNeedOpenServerDay = copyBase.NormalSweepPram; //固定为开服所需天数
|
|||
|
int openServerDay = (int)GlobalData.OpenServerDays;
|
|||
|
|
|||
|
//if (openServerDay < sweepNeedOpenServerDay)
|
|||
|
//{
|
|||
|
// remainCanSweepDays = sweepNeedOpenServerDay - openServerDay;
|
|||
|
// canSweepRemainTimeText.gameObject.SetActive(true);
|
|||
|
// canSweepRemainTimeText.text = StrDictionary.GetClientDictionaryString("#{44014}", sweepNeedOpenServerDay - openServerDay);
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// remainCanSweepDays = 0;
|
|||
|
// canSweepRemainTimeText.gameObject.SetActive(false);
|
|||
|
//}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void ShowMarkIcon(bool isShow)
|
|||
|
{
|
|||
|
copySceneItemMarkIcon.SetActive(isShow);
|
|||
|
}
|
|||
|
|
|||
|
private int _CurRewId = -1;
|
|||
|
public void SetNormalPassRew(int rewId)
|
|||
|
{
|
|||
|
if(_CurRewId == rewId)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
_CurRewId = rewId;
|
|||
|
Tab_CopySceneReward rewardTab = TableManager.GetCopySceneRewardByID(rewId, 0);
|
|||
|
if (rewardTab == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//第一个奖励
|
|||
|
if (rewardTab.GetRewardItemIDbyIndex(0) > 0)
|
|||
|
{
|
|||
|
rewdIdList.Add(rewardTab.GetRewardItemIDbyIndex(0));
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(rewardTab.GetRewardItemIDbyIndex(0), 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(rewItemIconList[0], commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(rewItemQualityList[0], GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, rewItemIconList[0].transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, rewItemIconList[0].transform);
|
|||
|
}
|
|||
|
|
|||
|
rewItemCountList[0].text = rewardTab.GetRewardCountbyIndex(0).ToString();
|
|||
|
}
|
|||
|
|
|||
|
//第二个
|
|||
|
if (rewardTab.GetRewardItemIDbyIndex(1) > 0)
|
|||
|
{
|
|||
|
rewdIdList.Add(rewardTab.GetRewardItemIDbyIndex(1));
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(rewardTab.GetRewardItemIDbyIndex(1), 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(rewItemIconList[1], commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(rewItemQualityList[1], GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
rewItemCountList[1].text = rewardTab.GetRewardCountbyIndex(1).ToString();
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, rewItemIconList[1].transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, rewItemIconList[1].transform);
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
private int _CurFirstGainRewId = -1;
|
|||
|
public void SetFirstPassRew(int rewId, int _State)
|
|||
|
{
|
|||
|
_RewState = _State;
|
|||
|
_CanReiveObj.SetActive(_RewState == 1);
|
|||
|
|
|||
|
if(_CurFirstGainRewId == rewId)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
_CurFirstGainRewId = rewId;
|
|||
|
|
|||
|
Tab_CopySceneReward rewardTab = TableManager.GetCopySceneRewardByID(rewId, 0);
|
|||
|
if (rewardTab == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//首通奖励
|
|||
|
if (rewardTab.GetRewardItemIDbyIndex(0) > 0)
|
|||
|
{
|
|||
|
rewdIdList.Add(rewardTab.GetRewardItemIDbyIndex(0));
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(rewardTab.GetRewardItemIDbyIndex(0), 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(firstRewItemIcon, commonItem.Icon);
|
|||
|
LoadAssetBundle.Instance.SetImageSprite(firstRewItemQuality, GCGame.Utils.GetItemQualityFrame(commonItem.Quality));
|
|||
|
if (commonItem.QualityEffect > 0)
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, firstRewItemIcon.transform);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, firstRewItemIcon.transform);
|
|||
|
}
|
|||
|
|
|||
|
firstRewItemCount.text = rewardTab.GetRewardCountbyIndex(0).ToString();
|
|||
|
}
|
|||
|
|
|||
|
gainFirstRewMarkIcon.SetActive(_State == 2);
|
|||
|
isPassOnce = (_State != 0);
|
|||
|
}
|
|||
|
|
|||
|
public void RefreshFirstRewState(int _State)
|
|||
|
{
|
|||
|
_RewState = _State;
|
|||
|
gainFirstRewMarkIcon.SetActive(_State == 2);
|
|||
|
_CanReiveObj.SetActive(_RewState == 1);
|
|||
|
isPassOnce = (_State != 0);
|
|||
|
}
|
|||
|
|
|||
|
public void OnFindTeamBtnClick()
|
|||
|
{
|
|||
|
if (false == GameManager.gameManager.PlayerDataPool.IsHaveTeam() &&
|
|||
|
null != Singleton<ObjManager>.GetInstance().MainPlayer) //创建队伍
|
|||
|
{
|
|||
|
Tab_TeamTarget teamTarget = TableManager.GetTeamTargetByID(copyBase.TeamTargetId, 0);
|
|||
|
if(teamTarget == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(teamTarget.Id, teamTarget.MinLV, teamTarget.MaxLv);
|
|||
|
UIManager.ShowUI(UIInfo.TeamInfoRoot, delegate(bool bSucess, object param) {
|
|||
|
if(bSucess)
|
|||
|
{
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.ChangeTeamDest(teamTarget.Id, teamTarget.MinLV, teamTarget.MaxLv);
|
|||
|
if(TeamInfoWindow.Instance())
|
|||
|
{
|
|||
|
//TeamInfoWindow.Instance().RefreshDest();
|
|||
|
|
|||
|
//开始自动匹配
|
|||
|
//TeamInfoWindow.Instance().OnBtnAuto();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}else
|
|||
|
{
|
|||
|
//在队伍中要判断是不是队长
|
|||
|
//.是否是队长
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain() == false)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44024}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnChallengeBtnClick()
|
|||
|
{
|
|||
|
if(remainCanChallengeTimes < 1)
|
|||
|
{
|
|||
|
if (!CopyCtrBase.GetInstance().CanBuyCopyChallengeTimes(curBaseId))
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
//.是否组队
|
|||
|
Tab_Fuben fuben = TableManager.GetFubenByID(curBaseId, 0);
|
|||
|
if(fuben == null)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(fuben.PlayerDemandMin > 1)
|
|||
|
{
|
|||
|
if (false == GameManager.gameManager.PlayerDataPool.IsHaveTeam() &&
|
|||
|
null != Singleton<ObjManager>.GetInstance().MainPlayer)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44023}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//.是否是队长
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.IsCaptain() == false)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44024}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//.玩家人数大于等于3
|
|||
|
if (GameManager.gameManager.PlayerDataPool.TeamInfo.GetTeamMemberCount() < fuben.PlayerDemandMin)
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{44025}", fuben.PlayerDemandMin));
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//CG_REQ_ENTER_COPY req = (CG_REQ_ENTER_COPY)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_ENTER_COPY);
|
|||
|
//req.SetCopyid(curBaseId);
|
|||
|
//req.SendPacket();
|
|||
|
MessageBoxLogic.ShowEnterCopySceneEnsureMessageBox(curBaseId, 999);
|
|||
|
}
|
|||
|
|
|||
|
public void OnItemClick()
|
|||
|
{
|
|||
|
if(MainMissionCopySceneRootCtr.Instance)
|
|||
|
{
|
|||
|
MainMissionCopySceneRootCtr.Instance.OnItemClick(curBaseId);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void OnRewItemClick(int index)
|
|||
|
{
|
|||
|
if(index == 0)
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(rewdIdList[index], ItemTooltipsLogic.ShowType.Info, rewItemIconList[0].gameObject.transform.position);
|
|||
|
}
|
|||
|
else if(index == 1)
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(rewdIdList[index], ItemTooltipsLogic.ShowType.Info, rewItemIconList[1].gameObject.transform.position);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if(_RewState == 1)
|
|||
|
{
|
|||
|
//领取奖励
|
|||
|
CG_GET_COPY_BASE_FIRST_REWARD req = (CG_GET_COPY_BASE_FIRST_REWARD)PacketDistributed.CreatePacket(MessageID.PACKET_CG_GET_COPY_BASE_FIRST_REWARD);
|
|||
|
req.SetCopyBaseId(curBaseId);
|
|||
|
req.SendPacket();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ItemTooltipsLogic.ShowItemTooltip(rewdIdList[index], ItemTooltipsLogic.ShowType.Info, firstRewItemIcon.gameObject.transform.position);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
}
|