Exemplo n.º 1
0
        public void AddBuffToSpecifiedUnit()
        {
            Unit unit = UnitComponent.Instance.Get(this.Unitid);

            foreach (var targetUnitId in NPBalckBoardRelationData.GetBlackBoardValue <List <long> >(this.BelongtoRuntimeTree.GetBlackboard()))
            {
                BuffDataInfo.AutoAddBuff(BelongtoRuntimeTree.BelongNP_DataSupportor, BuffDataInfo.BuffNodeId.Value, unit,
                                         UnitComponent.Instance.Get(targetUnitId), BelongtoRuntimeTree);
            }
        }
Exemplo n.º 2
0
        public void ChangeTargetSkillBBValue()
        {
            //Log.Info($"修改黑板键{m_NPBalckBoardRelationData.DicKey} 黑板值类型 {m_NPBalckBoardRelationData.NP_BBValueType}  黑板值:Bool:{m_NPBalckBoardRelationData.BoolValue.GetValue()}\n");
            Unit targetUnit = null;

            if (this.TargetUnitIsSelf)
            {
                targetUnit = Game.Scene.GetComponent <UnitComponent>()
                             .Get(this.Unitid);
            }
            else
            {
#if SERVER
                targetUnit = Game.Scene.GetComponent <UnitComponent>()
                             .Get(TargetUnitId.GetBlackBoardValue <long>(this.BelongtoRuntimeTree.GetBlackboard()));
#endif
            }

            List <NP_RuntimeTree> skillContent = targetUnit.GetComponent <SkillCanvasManagerComponent>()
                                                 .GetSkillCanvas(this.TargetSkillId.Value);

            foreach (var skillCanvas in skillContent)
            {
                //除自己之外
                if (skillCanvas == this.BelongtoRuntimeTree)
                {
                    return;
                }

                if (this.ValueGetType == ValueGetType.FromDataSet)
                {
                    this.NPBBValue_ValueToChange.SetBlackBoardValue(skillCanvas.GetBlackboard());
                }
                else
                {
                    this.NPBBValue_ValueToChange.SetBBValueFromThisBBValue(this.BelongtoRuntimeTree.GetBlackboard(), skillCanvas.GetBlackboard());
                }
            }
        }
        public void RunCommonAttackEvent()
        {
#if SERVER
            Unit unit = UnitComponent.Instance.Get(this.BelongtoRuntimeTree.BelongToUnitId);

            List <NP_RuntimeTree> targetSkillCanvas = unit.GetComponent <SkillCanvasManagerComponent>()
                                                      .GetSkillCanvas(SkillIdWillbeNotified.GetBlackBoardValue <long>(this.BelongtoRuntimeTree.GetBlackboard()));

            //注意这里一定不能引用本黑板中的Id数据,因为行为树的事件是下一帧才响应的,但是在当前帧的不久后的将来,本黑板相关数据可能会被重置!
            //List<long> attackIds = CachedUnitIdsForAttack.GetBlackBoardValue<List<long>>(this.BelongtoRuntimeTree.GetBlackboard());
            List <long> attackIds = new List <long>();
            foreach (var id in CachedUnitIdsForAttack.GetBlackBoardValue <List <long> >(this.BelongtoRuntimeTree.GetBlackboard()))
            {
                attackIds.Add(id);
            }
            foreach (var skillCanva in targetSkillCanvas)
            {
                skillCanva.GetBlackboard().Set("CastNormalAttack", true);
                skillCanva.GetBlackboard().Set("NormalAttackUnitIds", attackIds);
            }

            CDComponent.Instance.TriggerCD(this.BelongtoRuntimeTree.BelongToUnitId, "CommonAttack");
#endif
        }