protected void GotoFirstPathOfZoo(EntityVisitor entity)
        {
            var    startPos = entity.position;
            string pathName = Config.globalConfig.getInstace().FirstPathOfZoo;

            EntityVisitor.GotoStartOfPath(entity, pathName);
        }
예제 #2
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);
        }
        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);
        }