protected void OnArrived(Message msg)
        {
            var _msg = (MessageArrived)msg;
            //自己的entity
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.followPath.ownerEntity.entityID != entity.entityID)
            {
                return;
            }

            //到达终点, 但场景扩了, 需要继续往前走
            if (_msg.followPath.isArrivedEnd && extendSceneTime > 0)
            {
                --extendSceneTime;
                extendPathList.Add(entity.position);
                extendPathList.Add(entity.position + extendOffset);
                EntityVisitor.GodownPath(entity, extendPathList);
            }

            //单纯的到达终点
            if (_msg.followPath.isArrivedEnd)
            {
                isToStateVisitorGotoExitGateEntryQueue = true;
            }
        }
        protected void GotoFirstPathOfZoo(EntityVisitor entity)
        {
            var    startPos = entity.position;
            string pathName = Config.globalConfig.getInstace().FirstPathOfZoo;

            EntityVisitor.GotoStartOfPath(entity, pathName);
        }
        protected void OnVisitorWhereLeaveFromReply(Message msg)
        {
            var _msg   = msg as VisitorWhereLeaveFromReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            //地下走
            if (!_msg.isFromGround)
            {
                entity.entityFuncType       = (int)EntityFuncType.Visitor_From_Car;
                entity.groundParkingGroupID = Const.Invalid_Int;
                entity.groundParkingIdx     = Const.Invalid_Int;
                EntityVisitor.GodownPath(entity, pathOfLeaveZoo);
                return;
            }

            //地上走
            entity.entityFuncType             = (int)EntityFuncType.Visitor_From_GroundParking;
            entity.groundParkingGroupID       = _msg.groupID;
            entity.groundParkingIdx           = _msg.idx;
            isToStateVisitorGotoGroundParking = true;
        }
        protected void OnArrived(Message msg)
        {
            var _msg = msg as MessageArrived;

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            //自己的entity
            if (_msg.followPath.ownerEntity.entityID != entity.entityID)
            {
                return;
            }

            //先判断走到起点
            if (_msg.followPath.isArrivedEnd && !isArrivedStartOfPath)
            {
                isArrivedStartOfPath = true;
                EntityVisitor.GodownPath(entity, pathOfGotoLittleZoo);
                return;
            }

            if (_msg.followPath.isArrivedEnd && !isArrivedLittleZoo)
            {
                LogWarp.Log("到达动物栏,准备走向等待位");
                isArrivedLittleZoo      = true;
                entity.stayBuildingID   = this.stayBuildingID;
                entity.stayGroupID      = this.stayGroupID;
                isToEnterLittleZooApply = true;
                return;
            }
        }
Ejemplo n.º 5
0
        public override void Enter(int preStateName)
        {
            base.Enter(preStateName);

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoGroundParking.Enter", entity.entityID);
            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName);

            MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived);

#if UNITY_EDITOR
            if (entity.entityFuncType != (int)EntityFuncType.Visitor_From_GroundParking)
            {
                string e = string.Format("{0}这里必须是地面停车场来的游客", entity.entityID);
                throw new System.Exception(e);
            }
#endif
            //先走完基路
            isFinishedBasePath = false;
            EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().GroundParkingVistorBasePath);

            ////构建去地面停车场的路
            //List<Vector3> pathList = null;
            //var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx);
            //if (!GroundParingSpacePathManager.IsExist(pathUnit.visitorBackPath))
            //{
            //    pathList = GroundParingSpacePathManager.GenVisitorBackPath(entity.groundParkingGroupID, entity.groundParkingIdx);
            //    GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.VisitorBackPath, pathUnit, pathList, null);
            //}
            //pathList = pathUnit.visitorBackPath;

            //EntityVisitor.GodownPath(entity, pathList);
        }
Ejemplo n.º 6
0
        protected void OnAddVisitorToExitGateQueueApplyReply(Message msg)
        {
            var _msg = msg as AddVisitorToExitGateQueueApplyReply;

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            DebugFile.GetInstance().WriteKeyFile(_msg.entityID, "{0} 收到 {1}", _msg.entityID, msg);

            //出口排队申请失败,转从大门走状态
            if (!_msg.result)
            {
                isToStateVisitorLeaveFromZooEntry = true;
                return;
            }

            entity.ExitGateEntryID           = _msg.entryID;
            entity.indexInExitGateEntryQueue = _msg.indexInQueue;
            //从buildUp表中取第一段路
            //0 正
            //1 反
            var cell = Config.buildupConfig.getInstace().getCell(entity.stayBuildingID);

            EntityVisitor.GotoStartOfPath(entity, cell.outpath);
        }
        public override void Enter(int preStateName)
        {
            base.Enter(preStateName);

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoParking.Enter", entity.entityID);
            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName);

            MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived);

            Vector3 startPos = Vector3.zero;

            if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car)
            {
                PathManager.GetInstance().GetPathFirstPos(Config.globalConfig.getInstace().ShuttleVisitorLeavePath, ref startPos);
                entity.position = startPos;
                EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().ShuttleVisitorLeavePath);
                return;
            }

            PathManager.GetInstance().GetPathFirstPos(Config.globalConfig.getInstace().AdvertVisitorLeavePath, ref startPos);
            entity.position = startPos;
            EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().AdvertVisitorLeavePath);
        }
Ejemplo n.º 8
0
        public static List <int> GetVisitedLittleZooIDs(EntityVisitor entity, int groupID)
        {
            List <int> littleZooList = null;

            entity.visitedGroupMap.TryGetValue(groupID, out littleZooList);

            return(littleZooList);
        }
Ejemplo n.º 9
0
        protected void OnVisitorWhereLeaveFromReply(Message msg)
        {
            var _msg   = msg as VisitorWhereLeaveFromReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.entityID != entity.entityID)
            {
                return;
            }

#if UNITY_EDITOR
            if (entity.entityFuncType != (int)(EntityFuncType.Visitor_From_GroundParking))
            {
                string e = string.Format("{0} 这里只能是地上游客获得申请回复", entity.entityID);
                throw new System.Exception(e);
            }
#endif
            //地下走, 需要构建去地上观察路的路径的反路
            if (!_msg.isFromGround)
            {
                entity.entityFuncType       = (int)EntityFuncType.Visitor_From_Car;
                entity.groundParkingGroupID = Const.Invalid_Int;
                entity.groundParkingIdx     = Const.Invalid_Int;
                entity.pathList.Clear();
                entity.pathList.Add(entity.position);
                entity.pathList.AddRange(PathManager.GetInstance().GetPath(Config.globalConfig.getInstace().EntryQueueObservePath, true));
                EntityVisitor.GodownPath(entity, entity.pathList);
                return;
            }

            //地上游客地上走
            //需要判定当前的位置和分配的位置,如果不一致得先走到分配的位置
            var            pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(_msg.groupID, _msg.idx);
            List <Vector3> pathList = null;
#if UNITY_EDITOR
            if (!GroundParingSpacePathManager.IsExist(pathUnit.entryObservePath))
            {
                string e = string.Format("大门排队满了,分配的地面停车场游客居然没有回去的观察路线groupID={0}, idx = {1}",
                                         _msg.groupID, _msg.idx);
                throw new System.Exception(e);
            }
#endif
            pathList = pathUnit.entryObservePath;
            entity.pathList.Clear();
            entity.pathList.AddRange(pathList);
            entity.pathList.Reverse();
            if (entity.groundParkingGroupID == _msg.groupID && entity.groundParkingIdx == _msg.idx)
            {
                EntityVisitor.GodownPath(entity, entity.pathList, true);
                return;
            }
            entity.groundParkingGroupID = _msg.groupID;
            entity.groundParkingIdx     = _msg.idx;
            entity.pathList.Insert(0, entity.position);
            EntityVisitor.GodownPath(entity, entity.pathList, true);
            return;
        }
        protected void OnAddVisitorToEntryQueuePlaceHolderReply(Message msg)
        {
            var _msg = msg as AddVisitorToEntryQueuePlaceHolderReply;

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            //无论成功失败,都有入口ID
            entity.zooEntryID = _msg.entryID;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态 收到{1}", entity.entityID, msg);
            if (!_msg.result)
            {
                LogWarp.Log("入口所有排队满了, 准备离开, 转离开");
                DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 在VisitorGotoZooEntry状态 收到{1}入口所有排队满了, 准备离开, 转离开", entity.entityID, msg);
                this.isToVisitorStateLeaveZooEntryQueueFull = true;
                return;
            }

            isHold = true;
            Vector3        endPos         = UnityEngine.Vector3.zero;
            EntityFuncType entityFuncType = (EntityFuncType)(entity.entityFuncType);

            switch (entityFuncType)
            {
            case EntityFuncType.Visitor_From_Ship:
                entity.pathList.Clear();
                entity.pathList.Add(entity.position);
                endPos = UnityEngine.Vector3.zero;
                PathManager.GetInstance().GetPathLastPos(_msg.pathName, ref endPos);
                entity.pathList.Add(endPos);
                EntityVisitor.GodownPath(entity, entity.pathList);
                break;

            case EntityFuncType.Visitor_From_Car:
                EntityVisitor.GodownPath(entity, _msg.pathName, true);
                break;

            case EntityFuncType.Visitor_From_GroundParking:
                entity.pathList.Clear();
                entity.pathList.Add(entity.position);
                endPos = Vector3.zero;
                PathManager.GetInstance().GetPathLastPos(_msg.pathName, ref endPos);
                entity.pathList.Add(endPos);
                EntityVisitor.GodownPath(entity, entity.pathList, true);

                break;

            default:
                string e = string.Format("没有这种游客类型{0}", entityFuncType);
                throw new System.Exception(e);
            }
        }
Ejemplo n.º 11
0
 public static void GotoNextPos(EntityVisitor entity, Vector3 pos)
 {
     entity.pathList.Clear();
     entity.pathList.Add(entity.position);
     entity.pathList.Add(pos);
     entity.followPath.Init(entity, entity.pathList, entity.pathList[0], 0, entity.moveSpeed, false);
     entity.followPath.Run();
     LogWarp.Log("GotoNextPos ");
 }
Ejemplo n.º 12
0
        //public static bool IsApplyTooMuch(int groupID, Dictionary<int, int> applyRecord)
        //{
        //    List<int> sortedLittleZooID = null;
        //    if (!GlobalDataManager.GetInstance().logicTableGroup.sortedLittleZooIDs.TryGetValue(groupID, out sortedLittleZooID))
        //    {
        //        string e = string.Format("查不到 sortedLittleZooID {0}", groupID);
        //        throw new System.Exception(e);
        //    }

        //    int applyTime = 0;
        //    if (!applyRecord.TryGetValue(groupID, out applyTime))
        //    {
        //        applyTime = 0;
        //    }

        //    return applyTime >= sortedLittleZooID.Count;
        //}

        ////所在组是否都浏览过
        //public static bool IsVisitedAll(EntityVisitor entity, int GroupID, bool allowNoVisited = true)
        //{
        //    List<int> littleZooList = null;
        //    if (!entity.visitedGroupMap.TryGetValue(entity.wouldGotoBuildingGroupID, out littleZooList))
        //    {
        //        //都查不到组数据,肯定没浏览过
        //        if (allowNoVisited)
        //        {
        //            return false;
        //        }
        //        string e = string.Format("查不到浏览数据 {0}", entity.wouldGotoBuildingGroupID);
        //        throw new System.Exception(e);
        //    }
        //    if (littleZooList.Count <= 0)
        //    {
        //        if (allowNoVisited)
        //        {
        //            return false;
        //        }
        //        string e = string.Format("查不到浏览数据 {0}", entity.wouldGotoBuildingGroupID);
        //        throw new System.Exception(e);
        //    }

        //    List<int> sortedLittleZooID = null;
        //    if (!GlobalDataManager.GetInstance().logicTableGroup.sortedLittleZooIDs.TryGetValue(entity.wouldGotoBuildingGroupID, out sortedLittleZooID))
        //    {
        //        string e = string.Format("查不到 sortedLittleZooID {0}", entity.wouldGotoBuildingGroupID);
        //        throw new System.Exception(e);
        //    }

        //    if (littleZooList.Count > sortedLittleZooID.Count)
        //    {
        //        string e = string.Format("浏览数据异常 {0}", entity.wouldGotoBuildingGroupID);
        //        throw new System.Exception(e);
        //    }

        //    if (littleZooList.Count == sortedLittleZooID.Count)
        //    {
        //        return true;
        //    }

        //    return false;
        //}

        public static void GotoStartOfPath(EntityVisitor entity, string pathName)
        {
            var path = PathManager.GetInstance().GetPath(pathName);

            entity.pathList.Clear();
            entity.pathList.Add(entity.position);
            entity.pathList.Add(path[0]);
            entity.followPath.Init(entity, entity.pathList, entity.pathList[0], 0, entity.moveSpeed, false);
            entity.followPath.Run();
            LogWarp.LogFormat("GotoStartOfPath {0}", pathName);
        }
        protected void PrepareLeaveZoo(EntityVisitor entity)
        {
            LogWarp.Log("PrepareLeaveZoo");
            if (this.preStateName == (int)VisitorState.StayFirstPosInEntryQueue)
            {
                isToStateVisitorLeaveFromZooEntry = true;
                return;
            }

            isToStateVisitorLeaveNonLittleZoo = true;
        }
Ejemplo n.º 14
0
        protected void OnSendExitGateCheckinCDFinishReply(Message msg)
        {
            var _msg = msg as SendExitGateCheckinCDFinishReply;
            //生成摆渡车计数
            EntityVisitor entity = EntityManager.GetInstance().GetEntityMovable(_msg.entityID) as EntityVisitor;

            shuttleVisitorQueue.Enqueue(entity);
#if DEBUG_VISIT
            BroadcastNum.Send((int)GameMessageDefine.BroadcastShuttleVisistorNum, shuttleVisitorQueue.Count, 0f, 0);
#endif
        }
        /// <summary>
        /// 准备再次选择动物栏,可能因为所有组都浏览过了,会转向离开
        /// </summary>
        /// <param name="entity"></param>
        protected void PrepareChoseLittleZooAgain(EntityVisitor entity)
        {
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} Play {1}", entity.entityID, Config.globalConfig.getInstace().VisitorWalk);
            entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk);
            if (effGo != null)
            {
                effTrans.position = Const.Invisible_Postion;
            }

            isToVisitorStateChoseLittleZoo = true;
        }
        protected void MoveForward(EntityVisitor entity, float distance)
        {
            var startPos = entity.position;
            var endPos   = startPos;

            endPos.x -= distance;
            entity.pathList.Clear();
            entity.pathList.Add(startPos);
            entity.pathList.Add(endPos);
            float queueMoveSpeed = Config.globalConfig.getInstace().ZooVisitorQueueSpeed;

            entity.followPath.Init(entity, entity.pathList, startPos, 0, queueMoveSpeed, false);
            entity.followPath.Run();
        }
Ejemplo n.º 17
0
        protected void GotoVisitSeat(EntityVisitor entity, int littleZooID, int indexInVisitQueue)
        {
            LogWarp.Log("GotoVisitSeat");
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} Play {1}", entity.entityID, Config.globalConfig.getInstace().VisitorWalk);
            entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk);
            var littleZooBuildinPos = LittleZooBuildinPosManager.GetInstance().GetLittleZooBuildinPos(littleZooID);
            var endPos = littleZooBuildinPos.visitPosList[indexInVisitQueue];

            entity.pathList.Clear();
            entity.pathList.Add(entity.position);
            entity.pathList.Add(endPos);
            entity.followPath.Init(entity, entity.pathList, entity.position, 0, entity.moveSpeed, false);
            entity.followPath.Run();
        }
Ejemplo n.º 18
0
 public static void GodownPath(EntityVisitor entity, List <Vector3> path, bool isMoveToBegin = false)
 {
     if (path == null || path.Count <= 0)
     {
         string e = string.Format("路数据异常");
         throw new System.Exception(e);
     }
     if (isMoveToBegin)
     {
         entity.position = path[0];
     }
     entity.followPath.Init(entity, path, path[0], 0, entity.moveSpeed, false);
     entity.followPath.Run();
     LogWarp.LogFormat("GodownPath ");
 }
        public override void Enter(int preStateName)
        {
            base.Enter(preStateName);

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorGotoStartOfExitGateEntryPath.Enter", entity.entityID);
            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName);

            isToStateVisitorGotoExitGateEntryQueue = false;
            extendSceneTime = 0;

            MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived,
                                                this.OnArrived);
            MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastAfterExtendSceneAndModifiedPath,
                                                this.OnBroadcastAfterExtendSceneAndModifiedPath);
            MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastForwardOneStepInExitGateQueue,
                                                this.OnBroadcastForwardOneStepInExitGateQueue);

            var cellBuildUp = Config.buildupConfig.getInstace().getCell(entity.stayBuildingID);

            entity.pathList.Clear();
            Vector3 pos = Vector3.zero;

            if (PathManager.GetInstance().GetPathLastPos(cellBuildUp.outpath, ref pos))
            {
                entity.pathList.Add(pos);
            }

            var cellExitGate = Config.exitgateConfig.getInstace().getCell(entity.ExitGateEntryID);

            if (cellBuildUp.pathtype == 0)
            {
                PathManager.GetInstance().GetPathFirstPos(cellExitGate.positiveexitgate, ref pos);
            }
            else
            {
                PathManager.GetInstance().GetPathFirstPos(cellExitGate.negativeexitgate, ref pos);
            }

            entity.pathList.Add(pos);

            //LogWarp.LogErrorFormat("littlezoo={0}, outpath={1}, pathtype={2}, positive={3}, negative={4} ",
            //    entity.stayBuildingID, cellBuildUp.outpath, cellBuildUp.pathtype,
            //    cellExitGate.positiveexitgate, cellExitGate.negativeexitgate);

            EntityVisitor.GodownPath(entity, entity.pathList, true);
        }
Ejemplo n.º 20
0
        public override void Enter(int preStateName)
        {
            base.Enter(preStateName);

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorLeaveZooEntryQueueFull.Enter", entity.entityID);
            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName);
            entity.moveSpeed = Config.globalConfig.getInstace().ZooVisitorBackSpeed;
            MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived);
            MessageManager.GetInstance().Regist((int)GameMessageDefine.VisitorWhereLeaveFromReply, this.OnVisitorWhereLeaveFromReply);

            //走回去的路,广告游客(ship)没有停车场逻辑,地下游客走地下, 地上游客走申请
            EntityFuncType entityFuncType = (EntityFuncType)(entity.entityFuncType);

            switch (entityFuncType)
            {
            case EntityFuncType.Visitor_From_Ship:
                EntityVisitor.GodownPath(entity, PathManager.GetInstance().GetPath(
                                             Config.globalConfig.getInstace().AdvertVisitorOut));
                break;

            case EntityFuncType.Visitor_From_Car:
                //这里没有走申请,得发个消息,让底下停车场数量-1
                MessageInt.Send((int)GameMessageDefine.DirectMinusOneUnderParkingNum, entity.entityID);
                EntityVisitor.GodownReversePath(entity, Config.globalConfig.getInstace().EntryQueueObservePath);
                break;

            case EntityFuncType.Visitor_From_GroundParking:
                VisitorWhereLeaveFromApply.Send(entity.entityID);
                break;

            default:
                string e = string.Format("没有这种游客类型{0}", entityFuncType);
                throw new System.Exception(e);
            }

            //生成愤怒表情
            var pool = PoolManager.GetInstance().GetGameObjectPool(9301);

            expGo             = pool.New();
            expTrans          = expGo.transform;
            expTrans.position = entity.position;
            ExpressionScaleAnim(expTrans, Config.globalConfig.getInstace().ExpressionScaleOrg,
                                Config.globalConfig.getInstace().ExpressionScaleMax,
                                Config.globalConfig.getInstace().ExpressionScaleDuration,
                                Config.globalConfig.getInstace().ExpressionDuration);
        }
Ejemplo n.º 21
0
        public static void RecordVisitedLittleZoo(EntityVisitor entity, int groupID, int littleZooID)
        {
            List <int> littleZooList = null;

            if (!entity.visitedGroupMap.TryGetValue(groupID, out littleZooList))
            {
                littleZooList = new List <int>();
                entity.visitedGroupMap.Add(groupID, littleZooList);
            }
            if (littleZooList.Contains(littleZooID))
            {
                string e = string.Format("{0} 重复记录观光 {1}", entity.entityID, littleZooID);
                throw new System.Exception(e);
            }
            littleZooList.Add(littleZooID);
        }
Ejemplo n.º 22
0
        public static void GodownPath(EntityVisitor entity, string pathName, bool isMoveToBegin = false)
        {
            var path = PathManager.GetInstance().GetPath(pathName);

            if (path == null || path.Count <= 0)
            {
                string e = string.Format("路 {0} 数据异常", pathName);
                throw new System.Exception(e);
            }
            if (isMoveToBegin)
            {
                entity.position = path[0];
            }
            entity.followPath.Init(entity, path, path[0], 0, entity.moveSpeed, false);
            entity.followPath.Run();
            LogWarp.LogFormat("GodownPath {0}", pathName);
        }
Ejemplo n.º 23
0
        protected void GotoFirstPathOfZoo(EntityVisitor entity)
        {
            float   zooFirstPosOffset = Config.globalConfig.getInstace().ZooFirstPosOffset;
            var     startPos          = entity.position;
            var     midPos            = startPos + GlobalDataManager.GetInstance().SceneForward *zooFirstPosOffset;
            Vector3 endPos            = Vector3.zero;
            bool    retCode           = PathManager.GetInstance().GetPathFirstPos(Config.globalConfig.getInstace().FirstPathOfZoo, ref endPos);

#if UNITY_EDITOR
            if (!retCode)
            {
                string e = string.Format("取{0} 得起点异常", Config.globalConfig.getInstace().FirstPathOfZoo);
                throw new System.Exception(e);
            }
#endif
            entity.pathList.Clear();
            entity.pathList.Add(startPos);
            entity.pathList.Add(midPos);
            entity.pathList.Add(endPos);
            EntityVisitor.GodownPath(entity, entity.pathList);
        }
        //        public static bool AddVisitorToLittleZooApply(
//            EntityVisitor entity, bool isFirstApply, Dictionary<int, LittleZoo> littleZooMap,
//            ref int groupID, ref int littleZooID, ref bool isCrossGroup, List<int> openedLittleZooIDs,
//            List<int> freeLittleZooIDs, List<int> wouldGotoLittleZooIDs,
//            List<int> wouldGotoWeights, List<int> crossGroupIDs)
//        {
//            bool applyResult = false;
//            int nextGroupID = Const.Invalid_Int;
//            if (isFirstApply)
//            {
//                groupID = GlobalDataManager.GetInstance().logicTableGroup.sortedGroupID[0];
//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }
//            }

//            //判定goto概率
//            applyResult = WouldGotoGroupByGotoweight(groupID);
//            if (!applyResult)
//            {
//                return applyResult;
//            }

//            //获得这组开放的动物栏
//            applyResult = GetOpenedLittleZooIDs(groupID, openedLittleZooIDs);
//            if (!applyResult)
//            {
//                return applyResult;
//            }

//            applyResult = GetFreeLittleZooIDs(openedLittleZooIDs, littleZooMap, freeLittleZooIDs);
//            if (!applyResult)
//            {
//                applyResult = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID);
//                isCrossGroup = true;
//                groupID = nextGroupID;

//                if (!applyResult)
//                {
//                    return applyResult;
//                }

//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }

//                if (!crossGroupIDs.Contains(nextGroupID))
//                {
//                    crossGroupIDs.Add(nextGroupID);
//                }

//                return AddVisitorToLittleZooApply(entity, false, littleZooMap, ref groupID,
//                    ref littleZooID, ref isCrossGroup, openedLittleZooIDs, freeLittleZooIDs, wouldGotoLittleZooIDs,
//                    wouldGotoWeights, crossGroupIDs);
//            }

//            //从有空位的中筛选出没有浏览过的
//            applyResult = GetWouldGotoLittleZooIDs(entity, groupID, freeLittleZooIDs, wouldGotoLittleZooIDs);
//            if (!applyResult)
//            {
//                applyResult = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID);
//                isCrossGroup = true;
//                groupID = nextGroupID;

//                if (!applyResult)
//                {
//                    return applyResult;
//                }

//                if (!crossGroupIDs.Contains(groupID))
//                {
//                    crossGroupIDs.Add(groupID);
//                }

//                if (!crossGroupIDs.Contains(nextGroupID))
//                {
//                    crossGroupIDs.Add(nextGroupID);
//                }

//                return AddVisitorToLittleZooApply(entity, false, littleZooMap, ref groupID,
//                    ref littleZooID, ref isCrossGroup, openedLittleZooIDs, freeLittleZooIDs, wouldGotoLittleZooIDs,
//                    wouldGotoWeights, crossGroupIDs);
//            }

//            applyResult = GetWouldGotoWeights(groupID, wouldGotoLittleZooIDs, wouldGotoWeights);
//#if UNITY_EDITOR
//            if (!applyResult)
//            {
//                string e = string.Format("{0} GetWouldGotoWeights 异常", entity.entityID);
//                throw new System.Exception(e);
//            }
//#endif
//            int idx = Const.Invalid_Int;
//            Math_F.TableProbability(wouldGotoWeights, ref idx);

//            littleZooID = wouldGotoLittleZooIDs[idx];
//            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} TableProbability group={1}, nextgroup={2} littlezoo={3}",
//                entity.entityID, groupID, nextGroupID, littleZooID);
//            return true;
//        }

        /// <summary>
        /// 从空闲列表中剔除浏览过的
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="groupID"></param>
        /// <param name="freeLittleZooIDs"></param>
        /// <param name="wouldGotoLittleZooIDs"></param>
        /// <returns></returns>
        public static bool GetWouldGotoLittleZooIDs(EntityVisitor entity, int groupID, List <int> freeLittleZooIDs, List <int> wouldGotoLittleZooIDs)
        {
            wouldGotoLittleZooIDs.Clear();

            var visitedLittleZooIDs = EntityVisitor.GetVisitedLittleZooIDs(entity, groupID);
            int freeLittleZooID     = Const.Invalid_Int;

            for (int i = 0; i < freeLittleZooIDs.Count; i++)
            {
                freeLittleZooID = freeLittleZooIDs[i];
                if (visitedLittleZooIDs == null ||
                    visitedLittleZooIDs.Count == 0 ||
                    visitedLittleZooIDs.IndexOf(freeLittleZooID) < 0)
                {
                    //没有浏览过
                    wouldGotoLittleZooIDs.Add(freeLittleZooID);
                }
            }

            return(wouldGotoLittleZooIDs.Count > 0);
        }
        protected void OnVisitorGetRandomLittleZooReply(Message msg)
        {
            var _msg   = msg as VisitorGetRandomLittleZooReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (entity.entityID != _msg.entityID)
            {
                return;
            }

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, " {0}", _msg);

            if (!_msg.result)
            {
                DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 申请失败,准备离开", entity.entityID);
                PrepareLeaveZoo(entity);
                return;
            }

            this.stayBuildingID = _msg.littleZooID;
            this.stayGroupID    = _msg.groupID;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, " GetPath {0} -> {1}", entity.stayBuildingID, _msg.littleZooID);

            this.pathOfGotoLittleZoo = EntityVisitor.GetPath(entity.stayBuildingID, _msg.littleZooID);
            if (string.IsNullOrEmpty(pathOfGotoLittleZoo))
            {
                string e = string.Format("{0}没有找到路{1} -> {2} !!!!!!!!!!", entity.entityID, entity.stayBuildingID, _msg.littleZooID);
                throw new System.Exception(e);
            }
            //LogWarp.LogFormat("动物栏{0}, 等待位获得成功, 排号{1}, 路径{2}", _msg.littleZooID, _msg.indexInQueue, pathOfGotoLittleZoo);

            if (this.isArrivedStartOfPath)
            {
                EntityVisitor.GodownPath(entity, pathOfGotoLittleZoo);
                return;
            }

            EntityVisitor.GotoStartOfPath(entity, pathOfGotoLittleZoo);
        }
        public override void Enter(int preStateName)
        {
            base.Enter(preStateName);

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} StateVisitorLeaveFromZooEntry.Enter", entity.entityID);
            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName);

            isArrivedStartOfPathTo1000        = false;
            isArrivedEndOfPathTo1000          = false;
            isToStateVisitorGotoGroundParking = false;

            var playdata = GlobalDataManager.GetInstance().playerData;

            entryBuildingID = GlobalDataManager.GetInstance().logicTableGroup.GetSingleBuildingID(playdata.playerZoo.currSceneID, BuildingType.EntryGate);

            entity.moveSpeed = Config.globalConfig.getInstace().ZooVisitorBackSpeed;

            MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, OnArrived);
            MessageManager.GetInstance().Regist((int)GameMessageDefine.VisitorWhereLeaveFromReply, this.OnVisitorWhereLeaveFromReply);

            pathOfLeaveZoo = Config.globalConfig.getInstace().NaturalVisitorOut_1;
            //选当前所在位置到1000的路,走过去。
            if (entity.stayBuildingID == entryBuildingID)
            {
                LogWarp.LogFormat("{0}  刚入口排队结束进入动物后就返回!", entity.entityID);
                isArrivedStartOfPathTo1000 = true;
                EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().EntryGoBackPath);
                return;
            }

            pathOfTo1000 = EntityVisitor.GetPath(entity.stayBuildingID, entryBuildingID);
            if (string.IsNullOrEmpty(pathOfTo1000))
            {
                string e = string.Format("StateVisitorLeaveNonLittleZoo 没找到{0}->{1}的路!!!!", entity.stayBuildingID, 1000);
                throw new Exception(e);
            }
            EntityVisitor.GotoStartOfPath(entity, pathOfTo1000);
        }
Ejemplo n.º 27
0
        protected void OnArrived(Message msg)
        {
            var _msg = (MessageArrived)msg;

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            //自己的entity
            if (_msg.followPath.ownerEntity.entityID != entity.entityID)
            {
                return;
            }

            if (_msg.followPath.isArrivedEnd && !isFinishedBasePath)
            {
                isFinishedBasePath = true;
                //构建去地面停车场的路
                List <Vector3> pathList = null;
                var            pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx);
                if (!GroundParingSpacePathManager.IsExist(pathUnit.visitorBackPath))
                {
                    pathList = GroundParingSpacePathManager.GenVisitorBackPath(entity.groundParkingGroupID, entity.groundParkingIdx);
                    GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.VisitorBackPath, pathUnit, pathList, null);
                }
                pathList = pathUnit.visitorBackPath;
                EntityVisitor.GodownPath(entity, pathList);

                return;
            }

            if (_msg.followPath.isArrivedEnd)
            {
                MessageGroundParkingSpace.Send((int)GameMessageDefine.BroadcastLetGroundParingCarLeave,
                                               entity.groundParkingGroupID, entity.groundParkingIdx);

                // 回POOL
                EntityManager.GetInstance().RemoveFromEntityMovables(entity);
            }
        }
        protected void GoToOrgPosOfQueue(EntityVisitor entity)
        {
            var cellBuildUp = Config.buildupConfig.getInstace().getCell(entity.stayBuildingID);

            var cellExitGate = Config.exitgateConfig.getInstace().getCell(entity.ExitGateEntryID);

            entity.pathList.Clear();
            if (cellBuildUp.pathtype == 0)
            {
                entity.pathList.AddRange(PathManager.GetInstance().GetPath(cellExitGate.positiveexitgate));
            }
            else
            {
                entity.pathList.AddRange(PathManager.GetInstance().GetPath(cellExitGate.negativeexitgate));
            }

            finishQueueStep = entity.indexInExitGateEntryQueue;
            float   queuePosX = (float)(cellExitGate.maxnumofperqueue - entity.indexInExitGateEntryQueue);
            Vector3 queuePos  = entity.pathList[entity.pathList.Count - 1];

            queuePos.x -= queuePosX;
            entity.pathList.Add(queuePos);
            EntityVisitor.GodownPath(entity, entity.pathList);
        }
        protected void OnVisitorGetVisitSeatReply(Message msg)
        {
            var _msg   = msg as VisitorGetVisitSeatReply;
            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            if (_msg.entityID != entity.entityID)
            {
                return;
            }

            if (!_msg.result)
            {
                isToStateChoseLittleZoo = true;
                return;
            }
            entity.indexInVisitQueue = _msg.idxOfQueue;
            entity.pathList.Clear();
            entity.pathList.Add(entity.position);
            var     buildinPos = LittleZooBuildinPosManager.GetInstance().GetLittleZooBuildinPos(entity.stayBuildingID);
            Vector3 visitPos   = buildinPos.visitPosList[_msg.idxOfQueue];

            entity.pathList.Add(visitPos);
            EntityVisitor.GodownPath(entity, entity.pathList, false);
        }
        protected void OnArrived(Message msg)
        {
            var _msg = (MessageArrived)msg;

            var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity;

            //自己的entity
            if (_msg.followPath.ownerEntity.entityID != entity.entityID)
            {
                return;
            }

            var entityFuncType = (EntityFuncType)entity.entityFuncType;

            //到达离开的起点,向1000走
            if (_msg.followPath.isArrivedEnd && !isArrivedStartOfPathTo1000)
            {
                isArrivedStartOfPathTo1000 = true;
                EntityVisitor.GodownPath(entity, pathOfTo1000);
                return;
            }

            //向动物园外走(已经走到1000了)
            if (_msg.followPath.isArrivedEnd && !isArrivedEndOfPathTo1000)
            {
                DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 往回走", entity.entityID);
                isArrivedEndOfPathTo1000 = true;

                //switch(entityFuncType)
                //{
                //    case EntityFuncType.Visitor_From_Ship:
                //        EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().AdvertVisitorLeavePath);
                //        break;
                //    case EntityFuncType.Visitor_From_Car:
                //        EntityVisitor.GodownPath(entity, pathOfLeaveZoo);
                //        break;
                //    case EntityFuncType.Visitor_From_GroundParking:
                //        EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().GroundParkingVistorBasePath);
                //        break;
                //    default:
                //        string e = string.Format("没有这种游客类型{0}", entityFuncType);
                //        throw new System.Exception(e);
                //}

                //如果是广告游客直接离开
                //非广告游客请求是从地面还是地下走
                switch (entityFuncType)
                {
                case EntityFuncType.Visitor_From_Ship:
                    EntityVisitor.GodownPath(entity, Config.globalConfig.getInstace().AdvertVisitorLeavePath);
                    break;

                case EntityFuncType.Visitor_From_Car:
                case EntityFuncType.Visitor_From_GroundParking:
                    VisitorWhereLeaveFromApply.Send(entity.entityID);
                    break;

                default:
                    string e = string.Format("没有这种游客类型{0}", entityFuncType);
                    throw new System.Exception(e);
                }

                return;
            }

            if (_msg.followPath.isArrivedEnd)
            {
                //LogWarp.Log("结束离开");
                //DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 回收", entity.entityID);
                //EntityManager.GetInstance().RemoveFromEntityMovables(entity);

                ////通知生成离开的汽车
                //if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car)
                //{
                //    MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                //}

                //switch (entityFuncType)
                //{
                //    case EntityFuncType.Visitor_From_Car:
                //        //EntityManager.GetInstance().RemoveFromEntityMovables(entity);
                //        ////通知生成离开的汽车
                //        //MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                //        //break;
                //    case EntityFuncType.Visitor_From_GroundParking:
                //        //转向走向地面停车场
                //        //isToStateVisitorGotoGroundParking = true;
                //        VisitorWhereLeaveFromApply.Send(entity.entityID);
                //        break;
                //    case EntityFuncType.Visitor_From_Ship:
                //        EntityManager.GetInstance().RemoveFromEntityMovables(entity);
                //        break;
                //    default:
                //        string e = string.Format("没有这种游客类型{0}", entityFuncType);
                //        throw new System.Exception(e);
                //}

                //地下游客清除自己,通知生成离开的车
                //广告游客清除自己
                //地上游客,不可能,是异常
                switch (entityFuncType)
                {
                case EntityFuncType.Visitor_From_Ship:
                    EntityManager.GetInstance().RemoveFromEntityMovables(entity);
                    break;

                case EntityFuncType.Visitor_From_Car:
                    DebugFile.GetInstance().WriteKeyFile("FromUnder_", "{0}", entity.entityID);
                    EntityManager.GetInstance().RemoveFromEntityMovables(entity);
                    ////通知生成离开的汽车
                    MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                    break;

                default:
                    string e = string.Format("这里不可能出现这种游客类型{0}", entityFuncType);
                    throw new System.Exception(e);
                }
            }
        }