Ejemplo n.º 1
0
        //called by Physics World just before rigid body is added to world.
        //the current rigid body properties are used to rebuild the rigid body.
        internal virtual bool _BuildCollisionObject()
        {
            BPhysicsWorld world = BPhysicsWorld.Get;

            if (m_collisionObject != null)
            {
                if (isInWorld && world != null)
                {
                    world.RemoveCollisionObject(this);
                }
            }

            // if (transform.localScale != Vector3.one)
            // {
            //     Log.Warning("The local scale on this collision shape is not one. Bullet physics does not support scaling on a rigid body world transform. Instead alter the dimensions of the CollisionShape.");
            // }

            Unit Unit = this.GetParent <Unit>();

            m_collisionShape = Unit.GetComponent <BCollisionShape>(); //必须用另一方式来赋值才行啊!!
            if (m_collisionShape == null)
            {
                Log.Warning("There was no collision shape component attached to this BRigidBody. ");
                return(false);
            }
            CollisionShape cs = m_collisionShape.GetCollisionShape;

            //rigidbody is dynamic if and only if mass is non zero, otherwise static

            if (m_collisionObject == null)
            {
                m_collisionObject = new CollisionObject();
                m_collisionObject.CollisionShape = cs;
                m_collisionObject.UserObject     = this;

                BulletSharp.Math.Matrix     worldTrans;
                BulletSharp.Math.Quaternion q = this.GetParent <Unit>().Quaternion.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = this.GetParent <Unit>().Position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.CollisionFlags = m_collisionFlags;
            }
            else
            {
                m_collisionObject.CollisionShape = cs;
                BulletSharp.Math.Matrix     worldTrans;
                BulletSharp.Math.Quaternion q = this.GetParent <Unit>().Quaternion.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = this.GetParent <Unit>().Position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.CollisionFlags = m_collisionFlags;
            }
            return(true);
        }
Ejemplo n.º 2
0
 public void Awake()
 {
     currCommands = new Dictionary <Type, Command>();
     unit         = GetParent <Unit>();
     if (unit == null)
     {
         Log.Debug("获取不到Unit");
     }
     simulaterComponent = Game.Scene.GetComponent <CommandSimulaterComponent>();
     unitState          = unit.GetComponent <UnitStateComponent>();
 }
Ejemplo n.º 3
0
        protected override async ETTask Run(Session session, Frame_ClickMap message)
        {
            Unit unit = Game.Scene.GetComponent <UnitComponent>().Get(message.Id);
            FrameMoveComponent moveComponent = unit.GetComponent <FrameMoveComponent>();
            Vector3            dest          = new Vector3(message.X / 1000f, 0, message.Z / 1000f);

            moveComponent.MoveToDest(dest, 1);
            moveComponent.Turn2D(dest - unit.Position);

            await ETTask.CompletedTask;
        }
Ejemplo n.º 4
0
        public override void OnExecute()
        {
#if SERVER
            ReplaceAttackBuffData replaceAttackBuffData = this.BuffData as ReplaceAttackBuffData;

            Unit unit = UnitComponent.Instance.Get(this.GetBuffTarget().Id);
            unit.GetComponent <CommonAttackComponent>().SetAttackReplaceInfo(this.BelongtoRuntimeTree.Id, replaceAttackBuffData.AttackReplaceInfo);
            unit.GetComponent <CommonAttackComponent>()
            .SetCancelAttackReplaceInfo(this.BelongtoRuntimeTree.Id, replaceAttackBuffData.CancelReplaceInfo);
            //TODO 从当前战斗Entity获取BattleEventSystem来Run事件
            if (this.BuffData.EventIds != null)
            {
                foreach (var eventId in this.BuffData.EventIds)
                {
                    Game.Scene.GetComponent <BattleEventSystem>().Run($"{eventId}{this.TheUnitFrom.Id}", this);
                    //Log.Info($"抛出了{this.MSkillBuffDataBase.theEventID}{this.theUnitFrom.Id}");
                }
            }
#endif


            this.BuffState = BuffState.Running;
        }
Ejemplo n.º 5
0
        public void Run(long id, int value)
        {
            ///20190621
            Unit unit = Game.Scene.GetComponent <MonsterUnitComponent>().Get(id);

            if (unit != null)
            {
                NumericComponent num = unit.GetComponent <NumericComponent>();
                int hb = num[NumericType.ValuationBase];
                int ha = num[NumericType.ValuationAdd];

                Console.WriteLine(" type/Hp/hb/ha: " + unit.UnitType + " :" + value + " / " + hb + " / " + ha);
            }
        }
Ejemplo n.º 6
0
        public ICommandResult Simulate(ICommandInput commandInput, Unit unit)
        {
            CommandInput_Move input_Move        = commandInput as CommandInput_Move;
            UnitPathComponent unitPathComponent = unit.GetComponent <UnitPathComponent>();

            PathfindingComponent pathfindingComponent = Game.Scene.GetComponent <PathfindingComponent>();

            unitPathComponent.ABPath = ComponentFactory.Create <ABPathWrap, Vector3, Vector3>(unit.Position, input_Move.clickPos);
            pathfindingComponent.Search(unitPathComponent.ABPath);

            CommandResult_Move result_Move = CommandGCHelper.GetCommandResult <CommandResult_Move>();

            result_Move.Path = unitPathComponent.ABPath.Result;
            // result_Move.dir = input_Move.moveDir;// 暂时就以输入的方向作为角色的方向
            return(result_Move);
        }
        public static void KeyMove(this CharacterControllerComponent self)
        {
            Unit unit = self.GetParent <Unit>();

            if (self.animatorComponent == null)
            {
                self.animatorComponent = unit.GetComponent <AnimatorComponent>();
            }

            if (self.isCanControl)
            {
                self.h = Input.GetAxis("Horizontal");    //获取水平方线   //默认 Horizontal a键 为 -1  d键为 1
                self.v = Input.GetAxis("Vertical");      //获取水平方线   //默认 Vertical s键 为 -1  w键为 1

                //if (Mathf.Abs(EngineerJoyStick.hv2.x) > 10.0f || Mathf.Abs(EngineerJoyStick.hv2.y) > 10.0f)
                //{
                //    self.h = EngineerJoyStick.hv2.x / EngineerJoyStick.mRadius;
                //    self.v = EngineerJoyStick.hv2.y / EngineerJoyStick.mRadius;
                //}
                //else
                //{
                //    self.h = Input.GetAxis("Horizontal");    //获取水平方线   //默认 Horizontal a键 为 -1  d键为 1
                //    self.v = Input.GetAxis("Vertical");      //获取水平方线    //默认 Vertical s键 为 -1  w键为 1
                //    //Debug.Log(" move.v: " + move.v );
                //}
            }

            if (self.IsGrounded())
            {
                self.moveDirection  = new Vector3(0, 0, self.v);
                self.moveDirection  = unit.GameObject.transform.TransformDirection(self.moveDirection);
                self.moveDirection *= self.moveSpeed;
                if (Input.GetButton("Jump"))
                {
                    self.moveDirection.y = self.jumpSpeed;
                }
            }

            self.moveDirection.y -= self.gravity * Time.deltaTime;
            self.Controller.Move(self.moveDirection * Time.deltaTime);
            unit.GameObject.transform.Rotate(new Vector3(0, self.h * self.roteSpeed, 0));

            self.animatorComponent.AnimSet(self.v);

            self.SetMap();
        }
Ejemplo n.º 8
0
        public bool CheckUnitKilledBySpecialMethodAction()
        {
            Unit unit = UnitComponent.Instance.Get(this.TargetUnitId.GetBlackBoardValue <long>(this.BelongtoRuntimeTree.GetBlackboard()));
            //伤害栈顶数据为指定数据且攻击者是自己即返回true,否则返回false
            Stack <OperateData> operateDataStack = unit.GetComponent <OperatesComponent>().GetOperateDatas(OperatesComponent.OperateType.BeDamaged);

            if (operateDataStack != null)
            {
                OperateData stackTopItem = operateDataStack.Peek();
                if (stackTopItem.OperateCaster == UnitComponent.Instance.Get(this.Unitid) &&
                    (stackTopItem as DamageData).CustomData == this.SpecialInfo)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 为一个Unit分配阵营
        /// </summary>
        public void AllocRoleCamp(Unit unit)
        {
            B2S_RoleCastComponent b2SRoleCastComponent = unit.GetComponent <B2S_RoleCastComponent>();

            if (b2SRoleCastComponent == null)
            {
                return;
            }
            if (TianZaiCount > this.HuiYueCount)
            {
                b2SRoleCastComponent.RoleCamp = RoleCamp.HuiYue;
                HuiYueCount++;
            }
            else
            {
                b2SRoleCastComponent.RoleCamp = RoleCamp.TianZai;
                HuiYueCount--;
            }
        }
        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
                //TODO 这里先默许目标为碰撞体归属的Unit Id(施法者Unit Id)
                targetUnit = Game.Scene.GetComponent <UnitComponent>()
                             .Get(Game.Scene.GetComponent <UnitComponent>()
                                  .Get(this.Unitid).GetComponent <B2SC>());
#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 async ETVoid MoveAsync(List <Vector3> path)
        {
            if (path.Count == 0)
            {
                return;
            }

            if (moveTcs != null)
            {
                moveTcs = null;
            }
            float speed = unit.GetComponent <NumericComponent>().GetAsFloat(NumericType.MoveSpeed);


            // 第一个点是unit的当前位置,所以不用发送
            for (int i = 1; i < path.Count; ++i)
            {
                Vector3 v3 = path[i];
                await MoveTo(v3, speed);
            }
        }
Ejemplo n.º 12
0
        public void FixedUpdate()
        {
            if (unit == UnitComponent.Instance.MyUnit)
            {
                return;                                       //本机直接走预测/回滚路线
            }
            if (!haveInited)
            {
                return;
            }
            if (unitStatesDic.Count == 0)
            {
                return;
            }

            if (remoteEstimatedFrame > remoteActualFrame)
            {
                return;
            }

            //AdjustRemoteEstimatedFrame();

            //float applyProgress = Mathf.Clamp01((float)(remoteEstimatedFrame - preActualFrame) / (remoteActualFrame - preActualFrame));//应用的进度,上一次实际帧和这一次实际帧之间

            //应用模拟的结果
            foreach (var v in unitStatesDic[remoteActualFrame])
            {
                switch (v)
                {
                case CommandResult_Move result_Move:
                    unit.GetComponent <CharacterMoveComponent>().MoveAsync(result_Move.Path).Coroutine();
                    continue;
                }
            }
            remoteEstimatedFrame++;
        }
        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
        }
Ejemplo n.º 14
0
        public void Run(long id, float value)
        {
            Unit unit = UnitComponent.Instance.Get(id);

            unit.GetComponent <UnitPathComponent>().PlayRunAnimationByMoveSpeed();
        }
        public override void Run(NumericType nt, long destUnitId, float updateValue)
        {
#if !SERVER
            if (GlobalConfigComponent.Instance.networkPlayMode)
            {
                return;
            }
#endif
            Unit             unit             = UnitComponent.Instance.Get(destUnitId);
            NumericComponent numericComponent = unit.GetComponent <NumericComponent>();

            CharacterStateComponent unitStateComponent = unit.GetComponent <CharacterStateComponent>();
            if (!unitStateComponent.Get(SpecialStateType.Die))
            {
                return;  //角色已经死亡,不再受到任何属性影响
            }
            switch (nt)
            {
            case NumericType.HP:

                int value    = numericComponent.GetAsInt(NumericType.HP) + Mathf.RoundToInt(updateValue);
                int maxValue = numericComponent.GetAsInt(NumericType.HPMax_Final);
                value = Mathf.Clamp(value, 0, maxValue);
                numericComponent.Set(NumericType.HP, value);
                Game.EventSystem.Run(EventIdType.HPChanged, destUnitId);
                if (value == 0)
                {
                    Game.EventSystem.Run(EventIdType.OnUnitDie, destUnitId);
                }
                break;

            case NumericType.MP:
                value    = numericComponent.GetAsInt(NumericType.MP) + Mathf.RoundToInt(updateValue);
                maxValue = numericComponent.GetAsInt(NumericType.MPMax_Final);
                value    = Mathf.Clamp(value, 0, maxValue);
                numericComponent.Set(NumericType.MP, value);
                Game.EventSystem.Run(EventIdType.MPChanged, destUnitId);
                break;

            //case NumericType.HPMax_Pct:
            //case NumericType.HP_LeechRate:
            //case NumericType.MPMax_Pct:
            //case NumericType.MP_LeechRate:
            //case NumericType.HitRate:
            //case NumericType.CritDamagePct:
            //case NumericType.CritRate:
            //case NumericType.DodgeRate:
            //case NumericType.FinalDamage_AddPct:
            //case NumericType.FinalDamage_ReducePct:
            //    //这些全都是百分比的值(float)
            //    float fvalue = numericComponent.GetAsFloat(nt) + updateValue;
            //    numericComponent.Set(nt, fvalue);
            //break;
            case NumericType.HP_LosePct:
            case NumericType.HP_RemainPct:
            case NumericType.MP_LosePct:
            case NumericType.MP_RemainPct:
            case NumericType.HP_LoseValue:
            case NumericType.MP_LoseValue:
                Log.Error("这些属性不应该被直接改变,它们是间接被改变的值");
                break;

            default:
                float fvalue = numericComponent.GetAsFloat(nt) + updateValue;
                numericComponent.Set(nt, fvalue);
                break;
            }
        }
Ejemplo n.º 16
0
        public void Awake()
        {
            otherPlayers = new List <Unit>();
            Game.Scene.GetComponent <GlobalConfigComponent>().networkPlayMode = false;
            Game.EventSystem.Run(EventIdType.LoadAssets);
            {
                UnitData playerData = new UnitData();
                playerData.groupIndex = GroupIndex.Player;
                playerData.layerMask  = UnitLayerMask.ALL;
                playerData.unitLayer  = UnitLayer.Character;
                playerData.unitTag    = UnitTag.Player;
                //创建主角
                Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, playerData);
                v.Position = new UnityEngine.Vector3(-10, 0, -10);
                UnitComponent.Instance.MyUnit = v;
                v.AddComponent <CameraComponent>();
                v.AddComponent <CommandComponent>();
                var input = v.AddComponent <InputComponent>();
                var list  = v.GetComponent <ActiveSkillComponent>().skillList.Keys.ToArray();
                input.AddSkillToHotKey("Q", list[0]);
                input.AddSkillToHotKey("W", list[1]);
                input.AddSkillToHotKey("E", list[2]);
                BattleEventHandler.LoadAssets(v);
            }
            UnitData monsterData = new UnitData();

            monsterData.groupIndex = GroupIndex.Monster;
            monsterData.layerMask  = UnitLayerMask.ALL;
            monsterData.unitLayer  = UnitLayer.Character;
            monsterData.unitTag    = UnitTag.Monster;
            {
                //创建怪物
                Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData);
                v.Position = new UnityEngine.Vector3(4.2f, 4, -15);
                v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up);
                //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f });

                BattleEventHandler.LoadAssets(v);
                otherPlayers.Add(v);
            }
            {
                //创建怪物
                Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData);
                v.Position = new UnityEngine.Vector3(-10, 0, 11);
                v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up);
                //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f });

                BattleEventHandler.LoadAssets(v);
                otherPlayers.Add(v);
            }
            {
                //创建怪物
                Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData);
                v.Position = new UnityEngine.Vector3(-10, 0, 15);
                v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up);
                //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f });

                BattleEventHandler.LoadAssets(v);
                otherPlayers.Add(v);
            }

            //这里准备其他角色施放技能的参数
        }
Ejemplo n.º 17
0
        public void FixedUpdate()
        {
            //TODO; 和上一次服务器确认帧相差多少之后,提示网络有问题
            simulateFrame++;
            //先上传这一帧的操作,同时缓存操作,然后客户端自己模拟操作的结果
            if (collectedNewInput)
            {
                collectedNewInput            = false;
                cacheCommands[simulateFrame] = new List <Command>();
                cacheCommands[simulateFrame].AddRange(currCommands.Values);
                currCommands.Clear();
                foreach (var v in cacheCommands[simulateFrame])
                {
                    switch (v.commandInput)
                    {
                    case CommandInput_Move input_Move:



                        CommandResult_Move result_Move = simulaterComponent.commandSimulaters[input_Move.GetType()].Simulate(input_Move, unit) as CommandResult_Move;
                        v.commandResult = result_Move;

                        //再预测这一帧的结果
                        unit.GetComponent <CharacterMoveComponent>().MoveAsync(result_Move.Path).Coroutine();

                        //单机模式不发送网络消息
                        if (!Game.Scene.GetComponent <GlobalConfigComponent>().networkPlayMode)
                        {
                            break;
                        }
                        Log.Debug("frame : " + simulateFrame + "  本地预测的路径: " + result_Move.Path.ListToString <Vector3>());
                        inputInfo_Move.Frame  = simulateFrame;
                        inputInfo_Move.AimPos = input_Move.clickPos.ToV3Info();
                        ETModel.Game.Scene.GetComponent <SessionComponent>().Session.Send(inputInfo_Move);

                        break;

                    case CommandInput_UseSkill input_UseSkill:

                        CommandResult_UseSkill result_UseSkill = simulaterComponent.commandSimulaters[input_UseSkill.GetType()].Simulate(input_UseSkill, unit) as CommandResult_UseSkill;
                        v.commandResult = result_UseSkill;

                        if (!Game.Scene.GetComponent <GlobalConfigComponent>().networkPlayMode)
                        {
                            //单机的话本地直接做决定了
                            unit.GetComponent <ActiveSkillComponent>().tcs?.SetResult(result_UseSkill.success);
                            break;
                        }

                        switch (input_UseSkill.bufferValue)
                        {
                        case BufferValue_Pos value_Pos:
                            Input_UseSkill_Pos.Frame          = simulateFrame;
                            Input_UseSkill_Pos.SkillId        = input_UseSkill.skillId;
                            Input_UseSkill_Pos.PipelineSignal = input_UseSkill.pipelineSignal;

                            Input_UseSkill_Pos.AimPos = value_Pos.aimPos.ToV3Info();
                            ETModel.Game.Scene.GetComponent <SessionComponent>().Session.Send(Input_UseSkill_Pos);
                            break;

                        case BufferValue_Dir value_Dir:
                            Input_UseSkill_Dir.Frame          = simulateFrame;
                            Input_UseSkill_Dir.SkillId        = input_UseSkill.skillId;
                            Input_UseSkill_Dir.PipelineSignal = input_UseSkill.pipelineSignal;

                            Input_UseSkill_Dir.AimDir = value_Dir.dir.ToV3Info();
                            ETModel.Game.Scene.GetComponent <SessionComponent>().Session.Send(Input_UseSkill_Dir);
                            break;

                        case BufferValue_TargetUnits value_TargetUnits:
                            Input_UseSkill_Tar.Frame          = simulateFrame;
                            Input_UseSkill_Tar.SkillId        = input_UseSkill.skillId;
                            Input_UseSkill_Tar.PipelineSignal = input_UseSkill.pipelineSignal;

                            Input_UseSkill_Tar.UnitId = value_TargetUnits.targets[0].Id;
                            ETModel.Game.Scene.GetComponent <SessionComponent>().Session.Send(Input_UseSkill_Tar);
                            break;

                        default:
                            break;
                        }

                        break;
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public void Run(long id, float value)
        {
            Unit unit = UnitComponent.Instance.Get(id);

            unit.GetComponent <MoveComponent>().CorrectMoveSpeed();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 创建一个行为树实例,默认存入Unit的NP_RuntimeTreeManager中
        /// </summary>
        /// <param name="unit">行为树所归属unit</param>
        /// <param name="nPDataId">行为树数据id</param>
        /// <returns></returns>
        public static NP_RuntimeTree CreateNpRuntimeTree(Unit unit, long nPDataId)
        {
            NP_DataSupportor npDataSupportor =
                Game.Scene.GetComponent <NP_TreeDataRepository>().GetNP_TreeData_DeepCopyBBValuesOnly(nPDataId);

            NP_RuntimeTree tempTree =
                ComponentFactory.Create <NP_RuntimeTree, NP_DataSupportor, long>(npDataSupportor, unit.Id);

            long rootId = npDataSupportor.NpDataSupportorBase.NPBehaveTreeDataId;

            unit.GetComponent <NP_RuntimeTreeManager>().AddTree(tempTree.Id, rootId, tempTree);

            //Log.Info($"运行时id为{theRuntimeTreeID}");
            //配置节点数据
            foreach (var nodeDateBase in npDataSupportor.NpDataSupportorBase.NP_DataSupportorDic)
            {
                switch (nodeDateBase.Value.NodeType)
                {
                case NodeType.Task:
                    try
                    {
                        nodeDateBase.Value.CreateTask(unit.Id, tempTree);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"{e}-----{nodeDateBase.Value.NodeDes}");
                        throw;
                    }

                    break;

                case NodeType.Decorator:
                    try
                    {
                        nodeDateBase.Value.CreateDecoratorNode(unit.Id, tempTree,
                                                               npDataSupportor.NpDataSupportorBase.NP_DataSupportorDic[nodeDateBase.Value.LinkedIds[0]].NP_GetNode());
                    }
                    catch (Exception e)
                    {
                        Log.Error($"{e}-----{nodeDateBase.Value.NodeDes}");
                        throw;
                    }

                    break;

                case NodeType.Composite:
                    try
                    {
                        List <Node> temp = new List <Node>();
                        foreach (var linkedId in nodeDateBase.Value.LinkedIds)
                        {
                            temp.Add(npDataSupportor.NpDataSupportorBase.NP_DataSupportorDic[linkedId].NP_GetNode());
                        }

                        nodeDateBase.Value.CreateComposite(temp.ToArray());
                    }
                    catch (Exception e)
                    {
                        Log.Error($"{e}-----{nodeDateBase.Value.NodeDes}");
                        throw;
                    }

                    break;
                }
            }

            //配置根结点
            tempTree.SetRootNode(npDataSupportor.NpDataSupportorBase.NP_DataSupportorDic[rootId].NP_GetNode() as Root);

            //配置黑板数据
            Dictionary <string, ANP_BBValue> bbvaluesManager = tempTree.GetBlackboard().GetDatas();

            foreach (var bbValues in npDataSupportor.NpDataSupportorBase.NP_BBValueManager)
            {
                bbvaluesManager.Add(bbValues.Key, bbValues.Value);
            }

            return(tempTree);
        }
Ejemplo n.º 20
0
 public void Awake()
 {
     hotKeyToSkill        = new Dictionary <string, HotKeyState>();
     parent               = GetParent <Unit>();
     ActiveSkillComponent = parent.GetComponent <ActiveSkillComponent>();
 }
        public void SetUnitIdTheColliderBelongTo()
        {
#if SERVER
            //这里默许碰撞体自身带有B2S_ColliderComponent
            Unit selfUnit = UnitComponent.Instance.Get(this.Unitid);
            this.BelongtoRuntimeTree.GetBlackboard().Set(NpBlackBoardRelationData.BBKey, selfUnit.GetComponent <B2S_ColliderComponent>().BelongToUnit.Id);
#endif
        }
Ejemplo n.º 22
0
        public void CancelAttackAction()
        {
            Unit unit = UnitComponent.Instance.Get(this.Unitid);

            unit.GetComponent <CommonAttackComponent>().CancelAttackWithOutResetAttackTarget();
        }