protected override bool CustomPrecondition(TBTWorkingData wData) { bool result = false; if (EntityFactory.MainHeroView == null || !EntityFactory.MainHeroView.IsValid) { return(result); } GuideWorkingData gData = wData as GuideWorkingData; int nDeadEntityID = gData.GuideDynamicBB.GetValue <int>(EGuideBBKey.DeadEntityID, -1); EntityView ev = EntityFactory.getEntityViewByID(nDeadEntityID); if (nDeadEntityID != -1 && ev != null) { int propertyID = ev.Property.GetNumProp(ENTITY_PROPERTY.PROPERTY_ID); result = propertyID == m_nPropertyID; } return(result); }
protected override bool CustomPrecondition(TBTWorkingData wData) { bool result = m_bDoOnce; if (!m_bDoOnce) { GuideWorkingData gData = wData as GuideWorkingData; Vector3 MonsterDeadPos = gData.GuideDynamicBB.GetValue <Vector3>(EGuideBBKey.DeadEntityID, Vector3.zero); if (MonsterDeadPos.magnitude != 0 && EntityFactory.MainHero != null) { result = (EntityFactory.MainHero.transform.position - MonsterDeadPos).sqrMagnitude <= m_nNearbySize; //清空下 if (result) { gData.GuideDynamicBB.SetValue(EGuideBBKey.DeadEntityID, Vector3.zero); m_bDoOnce = true; } } TLogger.PROFILE("判断玩家附近是否有敌方实体死亡(实体死亡会销毁比较难检测到):" + result); } return(result); }
public override bool IsTrue(TBTWorkingData wData) { BattleDecisionWorkingData decisionData = wData as BattleDecisionWorkingData; BattleUnit battleEntity = decisionData.owner; if (!battleEntity.IsCanDecision()) { return(false); } // 新的决策 AIBehaviorRequest request = decisionData.request; if (request == null) { return(true); } else { //上一个请求已经执行完成,就更新新请求 return(request.IsRequestCompleted()); } }
protected override int onExecute(TBTWorkingData wData) { GuideWorkingData gData = wData as GuideWorkingData; UGuideWidget widget0 = GuideManager.Instance.GetGuideWidget(gData.GuideCurrentNode, 0); if (widget0 != null && widget0.gameObject.activeInHierarchy && widget0.gameObject.activeSelf && !widget0.IsWidgetShow()) { widget0.Show(); } else if (widget0 == null) { UISystem.Instance.SendTargetWndMessage(WndID.WND_ID_PLAYERBUTTONFRAME, WndMsgID.WND_MSG_PLAYERBUTTONFRAME_WARHALLBUTTON_ADDGUIDEWIDGET, new UGuideWidgetMsgData((int)gData.GuideCurrentNode, 0, m_nEffectID, _bClickEvent: false)); } UGuideWidget widget1 = GuideManager.Instance.GetGuideWidget(gData.GuideCurrentNode, 1); if (widget1 != null && widget1.gameObject.activeInHierarchy && widget1.gameObject.activeSelf && !widget1.IsWidgetShow()) { widget1.Show(); } else if (widget1 == null) { UISystem.Instance.SendTargetWndMessage(WndID.WND_ID_WAR_MAIN_FRAME, WndMsgID.WND_MSG_WAR_MAIN_GAMEMODEBTN_ADDGUIDEWIDGET, new UGuideWidgetMsgData((int)gData.GuideCurrentNode, 1, m_nEffectID, _oUserData: m_nGameModeID, _bClickEvent: false)); } int result = TBTRunningStatus.EXECUTING; if (LogicDataCenter.lifeHeroDataManager.HistoryRecord.Count >= m_nMatchLimit) { result = base.onExecute(wData); } return(result); }
public virtual void Destroy(TBTWorkingData _data) { Transition(_data); GuideManager.Instance.RestoreGuideNodeConfigData(); }
protected override int onExecute(TBTWorkingData wData) { wData.As <GuideWorkingData>().GuideDynamicBB.SetValue(EGuideBBKey.LogicStepID, m_eGuideNodeID); return(base.onExecute(wData)); }
protected override void onEnter(TBTWorkingData wData) { base.onEnter(wData); UISystem.Instance.SendTargetWndMessage(m_eGuideActonWnd, m_eGuideActionMsgID, m_widgetMsgData); }
protected override int onExecute(TBTWorkingData wData) { return(TBTRunningStatus.EXECUTING); }
protected override void onEnter(TBTWorkingData wData) { GuideManager.Instance.SetNoviceGuideType(nStepID); }
protected override void onEnter(TBTWorkingData wData) { base.onEnter(wData); m_nStateParam.WorkingData = wData as GuideWorkingData; m_nStateParam.ActionLeaf = this; }
protected override int onExecute(TBTWorkingData wData) { return(TBTRunningStatus.FINISHED); }
protected override void onEnter(TBTWorkingData wData) { AIEntityWorkingData thisData = wData.As <AIEntityWorkingData>(); thisData.entityAnimation.Play("idle"); }
public abstract bool isTrue(TBTWorkingData wData);
public override bool IsTrue(/*in*/ TBTWorkingData wData) { return(GetChild <TBTPrecondition>(0).IsTrue(wData) ^ GetChild <TBTPrecondition>(1).IsTrue(wData)); }
protected virtual void onExit(TBTWorkingData wData, int runningStatus) { }
protected override void onEnter(TBTWorkingData wData) { AIEntityWorkingData thisData = wData.As <AIEntityWorkingData>(); thisData.entityAnimator.CrossFade("attack", 0.2f); }
protected override void onExit(TBTWorkingData wData, int runningStatus) { base.onExit(wData, runningStatus); }
protected override bool onEvaluate(TBTWorkingData wData) { return(base.onEvaluate(wData)); }
protected override void onEnter(TBTWorkingData wData) { m_MainHeroTrans = EntityFactory.MainHeroView.StateMachine.transform; InitSplineMesh(); }
protected override int onExecute(TBTWorkingData wData) { return(TurnToStatus); }
protected override void onEnter(TBTWorkingData wData) { SoundManager.CreateUISound(m_nSoundID); }
protected override void onExit(TBTWorkingData wData, int runningStatus) { BattleLog.Log("【NOD_CastAbility】onExit"); }
protected override void onEnter(TBTWorkingData wData) { base.onEnter(wData); InputManager.Available = m_bEnable; }
protected override int onExecute(TBTWorkingData wData) { BotWorkingData thisData = wData.As<BotWorkingData>(); //Debugger.LogErrorFormat("dis={0}, delta={1}, Name={2}, _TargetPos={3}, NodeWander.HashCode={4}", //Vector3.Distance(_TargetPos, thisData._Character.Head.transform.position), ConstValue._MinMoveDelta, thisData._Character.Name, _TargetPos, GetHashCode()); //Debugger.LogGreen("curtime=" + _CurSteerTime); Vector3 targetPos = _TargetPos; Vector3 currentPos = thisData._Character.Head.transform.position; float distToTarget = Vector3.Distance(targetPos, currentPos); if (distToTarget < thisData._Character.MoveMotion) { if (_InWander) { //Debugger.LogFormat("reach dest class={0}, method={1}", LogColor.Blue, false, LogUtil.GetCurClassName(), LogUtil.GetCurMethodName()); _CurSteerTime = _SteerGapTime; _InWander = false; _LastStepPoses.Clear(); } } // check enemy operation has a cool down time. if (_CurCheckTime > 0) { _CurCheckTime -= thisData._DeltaTime; } else { UnityEngine.Profiling.Profiler.BeginSample("NodeWander.onExecute CheckEnemy"); _CurCheckTime = _CheckGapTime; var player = (thisData._Character as Enemy); if (player != null) { player.CheckEnemy(); } UnityEngine.Profiling.Profiler.EndSample(); //Debugger.LogFormat("check enemy class={0}, method={1}", LogColor.Brown, false, LogUtil.GetCurClassName(), LogUtil.GetCurMethodName()); } // wait for next wander command if (_CurSteerTime > 0) { _CurSteerTime -= thisData._DeltaTime; } else { if (!_InWander) { //Debugger.LogFormat("generate pos class={0}, method={1}", LogColor.Cyan, false, LogUtil.GetCurClassName(), LogUtil.GetCurMethodName()); GenerateTargetPos(thisData._Character.Head.transform.position, wData); _InWander = true; } } if (_InWander) { //Debugger.LogFormat("steer to class={0}, method={1}", LogColor.Green, false, LogUtil.GetCurClassName(), LogUtil.GetCurMethodName()); UnityEngine.Profiling.Profiler.BeginSample("NodeWander.onExecute InWander"); var motion = (_TargetPos - thisData._Character.Head.transform.position).normalized * thisData._Character.MoveSpeed * Singleton._DelayUtil.Timer.DeltaTime; bool rs = thisData._Character.Move(motion); if (!rs) { if (_InWander) { _CurSteerTime = _SteerGapTime; _InWander = false; _LastStepPoses.Clear(); } } if (_LastStepPoses.Count == _MaxRecordStepCount) { int nearCount = 0; foreach (var item in _LastStepPoses) { if (Vector3.Distance(item, thisData._Character.Head.transform.position) < thisData._Character.MoveMotion / 2f) { nearCount += 1; } } if (nearCount >= 2) { //Debug.LogErrorFormat("nearCount name={0}, peek={1}, dist={2}, delta={3}", // _Character.Name, _LastStepPoses.Peek(), // Vector3.Distance(_LastStepPoses.Peek(), _Character.Head.transform.position), // _Character.MoveMotion); if (_InWander) { _CurSteerTime = _SteerGapTime; _InWander = false; _LastStepPoses.Clear(); } } } Assert.IsTrue(_LastStepPoses.Count <= _MaxRecordStepCount); if (_LastStepPoses.Count == _MaxRecordStepCount) { _LastStepPoses.Dequeue(); } _LastStepPoses.Enqueue(thisData._Character.Head.transform.position); UnityEngine.Profiling.Profiler.EndSample(); } return TBTRunningStatus.EXECUTING; }
protected override int onExecute(TBTWorkingData wData) { EntityEventHelper.Instance.SendCommand(EntityFactory.MainHeroID, m_eCommandID, m_nParam, m_strParam); return(base.onExecute(wData)); }
protected T getUserContexData <T>(TBTWorkingData wData) where T : class, new() { return(getContext <TBTActionLeafContext>(wData).getUserData <T>()); }
protected override void onTransition(TBTWorkingData wData) { base.onTransition(wData); }
//-------------------------------------------------------- // inherented by children- protected virtual void onEnter(/*in*/ TBTWorkingData wData) { }
protected override void onTransition(TBTWorkingData wData) { base.onTransition(wData); m_bRunning = false; }
protected virtual int onExecute(TBTWorkingData wData) { return(TBTRunningStatus.FINISHED); }