Exemplo n.º 1
0
        public override bool OnMakeTrue(NodeData wData)
        {
            EntityWorkData workData    = wData as EntityWorkData;
            EnemyCom       enemyCom    = workData.MEntity.GetCom <EnemyCom>();
            SeekPathCom    seekPathCom = workData.MEntity.GetCom <SeekPathCom>();

            MapSensorData mapSensor = ECSLayerLocate.Info.GetWorldInfo <MapSensorData>(WorldInfoKey.MapInfo);

            bool value = MapHelp.CheckPointInArea(seekPathCom.CurrPos, enemyCom.GuardArea, mapSensor.PlayerMapPos);

            return(value);
        }
Exemplo n.º 2
0
        protected override void OnEnter(NodeData wData)
        {
            EntityWorkData workData    = wData as EntityWorkData;
            EnemyCom       seekPathCom = workData.MEntity.GetCom <EnemyCom>();

            Vector2Int targrtPos = Vector2Int.zero;

            if (seekPathCom.WanderPath[seekPathCom.WanderIndex] == null)
            {
                targrtPos = seekPathCom.SpawnPos;
            }
            else
            {
                targrtPos = seekPathCom.WanderPath[seekPathCom.WanderIndex];
            }
            //发送请求
            ParamData paramData = workData.GetReqParam(EntityReqId.EnemyWander);

            paramData.SetVect2Int(targrtPos);
            ECSLayerLocate.Request.PushEntityRequest(workData.MEntity.GetHashCode(), EntityReqId.EnemyWander);
        }
Exemplo n.º 3
0
        protected override int OnRunning(NodeData wData)
        {
            EntityWorkData workData    = wData as EntityWorkData;
            SeekPathCom    seekPathCom = workData.MEntity.GetCom <SeekPathCom>();
            EnemyCom       enemyCom    = workData.MEntity.GetCom <EnemyCom>();

            //没有达到目标点
            if (!seekPathCom.CurrPos.Equals(seekPathCom.TargetPos))
            {
                return(NodeState.EXECUTING);
            }

            if ((EntityReqId)workData.CurrReqId == EntityReqId.EnemyWander)
            {
                enemyCom.WanderIndex++;
                if (enemyCom.WanderIndex > enemyCom.WanderPath.Count - 1)
                {
                    enemyCom.WanderIndex = 0;
                }
                //ECSLocate.ECSLog.LogError("徘徊完成》》》》》》》》》》》》》");
            }
            workData.CurrReqId = 0;
            return(NodeState.FINISHED);
        }