155 lines
4.6 KiB
C#
155 lines
4.6 KiB
C#
using Thousandto.Code.Center;
|
|
using Thousandto.Plugins.Common.UniScene;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
using SceneEditor.Proxy.Plugin;
|
|
using Thousandto.Code.Logic.LocalPlayerBT;
|
|
|
|
namespace Thousandto.Code.Logic
|
|
{
|
|
public class DynamicBlockerManager
|
|
{
|
|
private Dictionary<String, DynamicBlocker> _blocakers = new Dictionary<string, DynamicBlocker>();
|
|
public void ResetByScene(GameScene scene)
|
|
{
|
|
ClearData();
|
|
if (scene.DynamicBlockerRoot == null)
|
|
return;
|
|
|
|
for (int i = 0; i < scene.DynamicBlockerRoot.childCount; ++i)
|
|
{
|
|
var trans = scene.DynamicBlockerRoot.GetChild(i);
|
|
var blocker = trans.GetComponent<DynamicBlocker>();
|
|
if (blocker != null)
|
|
{
|
|
blocker.StateChangedCallBack = OnBlockStateChanged;
|
|
blocker.LoadModelCallBack = OnBlockModelLoaded;
|
|
_blocakers.Add(blocker.gameObject.name, blocker);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ClearData()
|
|
{
|
|
var iter = _blocakers.GetEnumerator();
|
|
while (iter.MoveNext())
|
|
{
|
|
iter.Current.Value.StateChangedCallBack = null;
|
|
}
|
|
_blocakers.Clear();
|
|
}
|
|
|
|
public DynamicBlocker FindBlocker(String name)
|
|
{
|
|
DynamicBlocker ret = null;
|
|
_blocakers.TryGetValue(name, out ret);
|
|
return ret;
|
|
}
|
|
|
|
//上线检测
|
|
public void OnlineTaskCheck()
|
|
{
|
|
//var iter = _blocakers.GetEnumerator();
|
|
//while (iter.MoveNext())
|
|
//{
|
|
// var db = iter.Current.Value;
|
|
// if (db.openCondition == DynamicBlocker.OpenCondition.TaskFinish)
|
|
// {
|
|
// int taskID = 0;
|
|
// if (int.TryParse(db.OpenConditionParam, out taskID))
|
|
// {
|
|
// if (GameCenter.RoleTaskSystem.IsFinished(taskID))
|
|
// {
|
|
// db.DoOpen();
|
|
// }
|
|
// else
|
|
// {
|
|
// db.DoClose();
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// db.DoOpen();
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
|
|
//检测任务完成
|
|
public void CheckFinishTask(int taskID)
|
|
{
|
|
var iter = _blocakers.GetEnumerator();
|
|
while (iter.MoveNext())
|
|
{
|
|
var db = iter.Current.Value;
|
|
if (db.openCondition == DynamicBlocker.OpenCondition.TaskFinish)
|
|
{
|
|
int outTaskID = 0;
|
|
if (int.TryParse(db.OpenConditionParam, out outTaskID) && outTaskID == taskID)
|
|
{
|
|
db.Open();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//设置阻挡状态
|
|
public void SetBlockerState(String name, bool state)
|
|
{
|
|
DynamicBlocker b = FindBlocker(name);
|
|
if (b != null)
|
|
{
|
|
if (state)
|
|
{
|
|
b.Open();
|
|
}
|
|
else
|
|
{
|
|
b.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
//阻挡状态改变
|
|
public void OnBlockStateChanged(DynamicBlocker blocker, DynamicBlocker.State state)
|
|
{
|
|
if (state == DynamicBlocker.State.Disable)
|
|
{
|
|
LocalPlayer lp = GameCenter.GameSceneSystem.GetLocalPlayer();
|
|
if (lp != null)
|
|
{
|
|
PlayerBT.Task.ReWriteTask();
|
|
}
|
|
}
|
|
}
|
|
|
|
//阻挡状态改变
|
|
public void OnBlockModelLoaded(DynamicBlocker db)
|
|
{
|
|
//if (db == null)
|
|
// return;
|
|
//if (db.openCondition == DynamicBlocker.OpenCondition.TaskFinish)
|
|
//{
|
|
// int taskID = 0;
|
|
// if (int.TryParse(db.OpenConditionParam, out taskID))
|
|
// {
|
|
// if (GameCenter.RoleTaskSystem.IsFinished(taskID))
|
|
// {
|
|
// db.DoOpen();
|
|
// }
|
|
// else
|
|
// {
|
|
// db.DoClose();
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// db.DoOpen();
|
|
// }
|
|
//}
|
|
}
|
|
}
|
|
}
|