424 lines
15 KiB
C#
424 lines
15 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using Games.LogicObj;
|
|||
|
using GCGame.Table;
|
|||
|
using Games.GlobeDefine;
|
|||
|
using Module.Log;
|
|||
|
|
|||
|
public class ActivePresious : MonoBehaviour
|
|||
|
{
|
|||
|
public Text title;
|
|||
|
public Text TeamNeed;
|
|||
|
public Text BossName;
|
|||
|
public UICameraTexture ModelTexture;
|
|||
|
public GameObject cloneItem;
|
|||
|
public GameObject cloneAwardItem;
|
|||
|
public Text KillOverTip;
|
|||
|
|
|||
|
public struct sceneBossInfo
|
|||
|
{
|
|||
|
public int sceneID;
|
|||
|
public int insID; //分线ID
|
|||
|
public int ServerID;
|
|||
|
public int PosX;
|
|||
|
public int PosY;
|
|||
|
public ulong GuildGuid;
|
|||
|
|
|||
|
public void Clear()
|
|||
|
{
|
|||
|
sceneID = -1;
|
|||
|
insID = -1;
|
|||
|
ServerID = -1;
|
|||
|
PosX = -1;
|
|||
|
PosY = -1;
|
|||
|
GuildGuid = GlobeVar.INVALID_GUID;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private ActivityDataManager.Activity_Type activeType = ActivityDataManager.Activity_Type.ACTIVITY_INVALID;
|
|||
|
private List<GameObject> m_Items = new List<GameObject>();
|
|||
|
private List<GameObject> itemPrefabList = new List<GameObject>();
|
|||
|
private Dictionary<int, List< sceneBossInfo>> m_bossInfo = new Dictionary<int, List<sceneBossInfo>>();
|
|||
|
private int m_CurrentBossRoleID = -1;
|
|||
|
void Awake()
|
|||
|
{
|
|||
|
Hashtable add = new Hashtable();
|
|||
|
add["name"] = "ActivePresious";
|
|||
|
Games.Events.MessageEventCallBack call = UpdateData;
|
|||
|
add["callFun"] = call;
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.UpdateActivePresiousWnd, add);
|
|||
|
|
|||
|
Hashtable add1 = new Hashtable();
|
|||
|
add1["name"] = "OpenActiveWnd";
|
|||
|
Games.Events.MessageEventCallBack call1 = OpenActiveWnd;
|
|||
|
add1["callFun"] = call1;
|
|||
|
Games.Events.EventDispatcher.Instance.AddMessageEvent(Games.Events.EventId.OpenActivePresiousWnd, add1);
|
|||
|
}
|
|||
|
|
|||
|
public void OpenActiveWnd(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
if (sendparam.Contains("ActiveType") == false)
|
|||
|
return;
|
|||
|
int type = (int)sendparam["ActiveType"];
|
|||
|
activeType = (ActivityDataManager.Activity_Type)type;
|
|||
|
|
|||
|
Tab_ActivityBase activityBase = null;
|
|||
|
var activityBases = TableManager.GetActivityBase().Values;
|
|||
|
foreach (var activity in activityBases)
|
|||
|
{
|
|||
|
if (activity != null && activity.ActivityServerType == (int)activeType)
|
|||
|
{
|
|||
|
activityBase = activity;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
if (activityBase == null)
|
|||
|
return;
|
|||
|
|
|||
|
Ask_Info();
|
|||
|
|
|||
|
title.text = activityBase.ActivityName;
|
|||
|
|
|||
|
if (activityBase.ActivityServerType == 8)
|
|||
|
{
|
|||
|
TeamNeed.text = StrDictionary.GetClientDictionaryString("#{22019}");
|
|||
|
}else if (activityBase.ActivityServerType == 4)
|
|||
|
{
|
|||
|
TeamNeed.text = StrDictionary.GetClientDictionaryString("#{22020}");
|
|||
|
}else if (activityBase.ActivityServerType == 10)
|
|||
|
{
|
|||
|
TeamNeed.text = StrDictionary.GetClientDictionaryString("#{22021}");
|
|||
|
}else if (activityBase.ActivityServerType == 9)
|
|||
|
{
|
|||
|
TeamNeed.text = StrDictionary.GetClientDictionaryString("#{22022}");
|
|||
|
}else
|
|||
|
TeamNeed.text = StrDictionary.GetClientDictionaryString("#{22019}");
|
|||
|
|
|||
|
var misers = TableManager.GetActivityMiser().Values;
|
|||
|
foreach (var miser in misers)
|
|||
|
{
|
|||
|
if (miser.ActivityType == (int)activeType)
|
|||
|
{
|
|||
|
Tab_RoleBaseAttr role = TableManager.GetRoleBaseAttrByID(miser.NpcId, 0);
|
|||
|
if (role != null)
|
|||
|
{
|
|||
|
m_CurrentBossRoleID = miser.NpcId;
|
|||
|
BossName.text = role.Name;
|
|||
|
Tab_CharModel model = TableManager.GetCharModelByID(role.CharModelID, 0);
|
|||
|
if (model != null)
|
|||
|
{
|
|||
|
ModelTexture.InitModelPath(model.ResPath,model, LoadAssetBundle.BUNDLE_PATH_PET, true);
|
|||
|
}
|
|||
|
}
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
void OnDestroy()
|
|||
|
{
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.UpdateActivePresiousWnd, "ActivePresious");
|
|||
|
Games.Events.EventDispatcher.Instance.RemoveMessage(Games.Events.EventId.OpenActivePresiousWnd, "OpenActiveWnd");
|
|||
|
}
|
|||
|
|
|||
|
public void UpdateData(Hashtable addparam, Hashtable sendparam)
|
|||
|
{
|
|||
|
if (sendparam.ContainsKey("packet") == false)
|
|||
|
return;
|
|||
|
int RobberTotle = (sendparam.ContainsKey("RobberTotle") ? ((int)sendparam["RobberTotle"]) : 0);
|
|||
|
List <ActivePresious.sceneBossInfo> sceneBosss = (List<ActivePresious.sceneBossInfo>)sendparam["packet"];
|
|||
|
|
|||
|
Tab_ActivityBase activityBase = null;
|
|||
|
var activityBases = TableManager.GetActivityBase().Values;
|
|||
|
foreach (var activity in activityBases)
|
|||
|
{
|
|||
|
if (activity != null && activity.ActivityServerType == (int)activeType)
|
|||
|
{
|
|||
|
activityBase = activity;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (activityBase == null)
|
|||
|
return;
|
|||
|
string[] m_itemId = activityBase.Reward.Split('|');
|
|||
|
ClearPrefab();
|
|||
|
for (int index = 0; index < m_itemId.Length; index++)
|
|||
|
{
|
|||
|
int DataID = -1;
|
|||
|
int.TryParse(m_itemId[index],out DataID);
|
|||
|
Tab_CommonItem commonItem = TableManager.GetCommonItemByID(DataID, 0);
|
|||
|
if (commonItem == null)
|
|||
|
{
|
|||
|
continue;
|
|||
|
}
|
|||
|
GameObject m_ItemPrefab = GameObject.Instantiate(cloneAwardItem);
|
|||
|
m_ItemPrefab.SetActive(true);
|
|||
|
m_ItemPrefab.transform.SetParent(cloneAwardItem.transform.parent);
|
|||
|
m_ItemPrefab.transform.localScale = Vector3.one;
|
|||
|
m_ItemPrefab.transform.localRotation = Quaternion.Euler(Vector3.zero);
|
|||
|
|
|||
|
m_ItemPrefab.GetComponent<RewardInfoItemController>().initItem(DataID);
|
|||
|
itemPrefabList.Add(m_ItemPrefab);
|
|||
|
}
|
|||
|
|
|||
|
for(int i=0;i< m_Items.Count;i++)
|
|||
|
{
|
|||
|
GameObject.DestroyImmediate(m_Items[i]);
|
|||
|
}
|
|||
|
m_Items.Clear();
|
|||
|
m_bossInfo.Clear();
|
|||
|
Dictionary<int, int> scenes = new Dictionary<int, int>();
|
|||
|
for(int i=0;i<sceneBosss.Count;i++)
|
|||
|
{
|
|||
|
sceneBossInfo bossInfo = sceneBosss[i];
|
|||
|
if (m_bossInfo.ContainsKey(bossInfo.sceneID))
|
|||
|
{
|
|||
|
m_bossInfo[bossInfo.sceneID].Add(bossInfo);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
m_bossInfo[bossInfo.sceneID] = new List<sceneBossInfo>();
|
|||
|
m_bossInfo[bossInfo.sceneID].Add(bossInfo);
|
|||
|
}
|
|||
|
if(scenes.ContainsKey(bossInfo.sceneID)==false)
|
|||
|
{
|
|||
|
scenes[bossInfo.sceneID] = 1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int count = scenes[bossInfo.sceneID] + 1;
|
|||
|
scenes[bossInfo.sceneID] = count;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
int BOSSLeave = 0;
|
|||
|
foreach(var scene in scenes)
|
|||
|
{
|
|||
|
if(scene.Value>0)
|
|||
|
{
|
|||
|
CloneItem(scene.Key, RobberTotle == 0 ? scene.Value: RobberTotle);
|
|||
|
BOSSLeave++;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
KillOverTip.gameObject.SetActive(BOSSLeave <= 0);
|
|||
|
|
|||
|
if (BOSSLeave <= 0)
|
|||
|
{
|
|||
|
KillOverTip.text = StrDictionary.GetClientDictionaryString("#{22018}");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void ClearPrefab()
|
|||
|
{
|
|||
|
for (int index = 0; index < itemPrefabList.Count; index++)
|
|||
|
{
|
|||
|
GameObject.Destroy(itemPrefabList[index]);
|
|||
|
}
|
|||
|
itemPrefabList.Clear();
|
|||
|
}
|
|||
|
|
|||
|
public void CloneItem(int sceneID,int count)
|
|||
|
{
|
|||
|
if (cloneItem == null)
|
|||
|
return;
|
|||
|
GameObject item = GameObject.Instantiate(cloneItem) as GameObject;
|
|||
|
if (item == null)
|
|||
|
return;
|
|||
|
item.SetActive(true);
|
|||
|
item.transform.parent = cloneItem.transform.parent;
|
|||
|
item.transform.localPosition = cloneItem.transform.localPosition;
|
|||
|
item.transform.localScale = cloneItem.transform.localScale;
|
|||
|
m_Items.Add(item);
|
|||
|
Transform sceneChild = item.transform.Find("sceneName");
|
|||
|
if(sceneChild != null)
|
|||
|
{
|
|||
|
Text sceneName = sceneChild.GetComponent<Text>();
|
|||
|
if(sceneName != null)
|
|||
|
{
|
|||
|
Tab_SceneClass sceneInfo = TableManager.GetSceneClassByID(sceneID, 0);
|
|||
|
if(sceneInfo!=null)
|
|||
|
{
|
|||
|
sceneName.text = sceneInfo.Name;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
Transform LeaveNum = item.transform.Find("Leave");
|
|||
|
if (LeaveNum != null)
|
|||
|
{
|
|||
|
Text LeaveText = LeaveNum.GetComponent<Text>();
|
|||
|
if (LeaveText != null)
|
|||
|
{
|
|||
|
LeaveText.text = count.ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
Button btn = item.GetComponentInChildren<Button>();
|
|||
|
if(btn!=null)
|
|||
|
{
|
|||
|
btn.onClick.AddListener(delegate ()
|
|||
|
{
|
|||
|
//开始寻路
|
|||
|
FindBoss(sceneID);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void FindBoss(int sceneID)
|
|||
|
{
|
|||
|
if(GameManager.gameManager.RunningScene == sceneID)
|
|||
|
{
|
|||
|
var obj = ObjManager.Instance.FindObjCharacterInSceneByRoleID(m_CurrentBossRoleID,true,true);
|
|||
|
if (obj != null)
|
|||
|
{
|
|||
|
AutoSearchPoint point = new AutoSearchPoint(GameManager.gameManager.RunningScene, obj.Position.x, obj.Position.z, SceneData.SceneInst, AutoSearchPoint.ChangeMap_Type.WORLDMAP, SceneData.sceneGuildGuid);
|
|||
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetID = obj.ServerID;
|
|||
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = 1.5f;
|
|||
|
}
|
|||
|
UIManager.CloseUI(UIInfo.ActivePresious);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (m_bossInfo.ContainsKey(sceneID))
|
|||
|
{
|
|||
|
List<sceneBossInfo> bossInfos = m_bossInfo[sceneID];
|
|||
|
List<sceneBossInfo> finds = new List<sceneBossInfo>();
|
|||
|
for (int i=0;i<bossInfos.Count;i++)
|
|||
|
{
|
|||
|
if(bossInfos[i].insID == SceneData.SceneInst && GameManager.gameManager.RunningScene == sceneID)
|
|||
|
{
|
|||
|
finds.Add(bossInfos[i]);
|
|||
|
}
|
|||
|
}
|
|||
|
sceneBossInfo bossInfo;
|
|||
|
if(finds.Count > 3)
|
|||
|
{
|
|||
|
int index = UnityEngine.Random.Range(0, finds.Count);
|
|||
|
bossInfo = finds[index];
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int index = UnityEngine.Random.Range(0, bossInfos.Count);
|
|||
|
bossInfo = bossInfos[index];
|
|||
|
}
|
|||
|
if (bossInfos == null)
|
|||
|
return;
|
|||
|
Module.Log.LogModule.DebugLog(string.Format("Boss Info SceneID = {0} InsID = {1} PosX = {2} PosZ = {3} SercerID = {4}",bossInfo.sceneID,bossInfo.insID,bossInfo.PosX,bossInfo.PosY,bossInfo.ServerID));
|
|||
|
AutoSearchPoint point = new AutoSearchPoint(bossInfo.sceneID, bossInfo.PosX/100, bossInfo.PosY/100, bossInfo.insID,AutoSearchPoint.ChangeMap_Type.WORLDMAP,bossInfo.GuildGuid);
|
|||
|
if (GameManager.gameManager && GameManager.gameManager.AutoSearch)
|
|||
|
{
|
|||
|
GameManager.gameManager.AutoSearch.BuildPath(point);
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetID = bossInfo.ServerID;
|
|||
|
GameManager.gameManager.AutoSearch.Path.autoSearchRadius = 1.5f;
|
|||
|
GameManager.gameManager.AutoSearch.Path.AutoSearchTargetRoleID = m_CurrentBossRoleID;
|
|||
|
}
|
|||
|
UIManager.CloseUI(UIInfo.ActivePresious);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Ask_Info()
|
|||
|
{
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
|||
|
{
|
|||
|
CG_REQ_SEND_PACKET Packet = (CG_REQ_SEND_PACKET)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SEND_PACKET);
|
|||
|
Packet.SetReqType((int)CG_REQ_SEND_PACKET.REQ_TYPE.REQ_TYPE_GUILDROBBER_INFO);
|
|||
|
Packet.SendPacket();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
ActivityAskNpcInfo cmd = new ActivityAskNpcInfo();
|
|||
|
cmd.activity_type = (int)activeType;
|
|||
|
cmd.SendMsg();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Click_Fresh()
|
|||
|
{
|
|||
|
Ask_Info();
|
|||
|
}
|
|||
|
|
|||
|
//便捷组队
|
|||
|
public void Click_FastCreateTeam()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2179}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
UIManager.ShowUI(UIInfo.TeamCreateRoot, delegate (bool bSuccess, object param)
|
|||
|
{
|
|||
|
if (bSuccess)
|
|||
|
{
|
|||
|
Hashtable hash = new Hashtable();
|
|||
|
if(activeType == ActivityDataManager.Activity_Type.ACTIVITY_MISER)
|
|||
|
hash["index"] = 23;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_PACKVETCH)
|
|||
|
hash["index"] = 20;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITYH_LUCKSTAR)
|
|||
|
hash["index"] = 22;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
|||
|
hash["index"] = 1;
|
|||
|
Games.Events.EventDispatcher.Instance.SendMessage(Games.Events.EventId.SELECTTEAMCREATEWNDITEM, hash);
|
|||
|
}
|
|||
|
});
|
|||
|
Close();
|
|||
|
}
|
|||
|
public void Click_CreateTeam()
|
|||
|
{
|
|||
|
if (GameManager.gameManager.PlayerDataPool.IsHaveTeam())
|
|||
|
{
|
|||
|
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{2179}"));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
Tab_ActivityBase activityBase = null;
|
|||
|
var activityBases = TableManager.GetActivityBase().Values;
|
|||
|
foreach (var activity in activityBases)
|
|||
|
{
|
|||
|
if (activity != null && activity.ActivityServerType == (int)activeType)
|
|||
|
{
|
|||
|
activityBase = activity;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (activityBase == null)
|
|||
|
return;
|
|||
|
int minLevel = activityBase.Level;
|
|||
|
int maxLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|||
|
if (minLevel > maxLevel)
|
|||
|
maxLevel = minLevel;
|
|||
|
|
|||
|
int index = -1;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_MISER)
|
|||
|
index = 23;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_PACKVETCH)
|
|||
|
index = 20;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITYH_LUCKSTAR)
|
|||
|
index = 22;
|
|||
|
if (activeType == ActivityDataManager.Activity_Type.ACTIVITY_GUILDPROBBERS)
|
|||
|
index = 1;
|
|||
|
|
|||
|
var playerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
|||
|
TeamTargetRoot.SetDefaultLevel(index, playerLevel);
|
|||
|
GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(GameManager.gameManager.PlayerDataPool.TeamInfo.AutoTeamTargetDest, GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMin, GameManager.gameManager.PlayerDataPool.TeamInfo.LastTeamLevelMax);
|
|||
|
//GameManager.gameManager.PlayerDataPool.TeamInfo.CreaetTeam(index, minLevel, maxLevel);
|
|||
|
UIManager.ShowUI(UIInfo.TeamInfoRoot);
|
|||
|
Close();
|
|||
|
|
|||
|
}
|
|||
|
public void Close()
|
|||
|
{
|
|||
|
UIManager.CloseUI(UIInfo.ActivePresious);
|
|||
|
}
|
|||
|
}
|