Ejemplo n.º 1
0
        protected void ArrivedVisitorCar(FollowPathRightAngles followPath, EntityFuncType entityFuncType)
        {
            DebugFile.GetInstance().WriteKeyFile(followPath.ownerEntity.entityID, "{0} {1} ArrivedVisitorCar",
                                                 followPath.ownerEntity.entityID, entityFuncType);

            var entity = followPath.ownerEntity as EntityVisitorCar;

            EntityManager.GetInstance().RemoveFromEntityMovables(entity);

            // 生成游客
            LogWarp.Log("car -> visistor");
            switch (entityFuncType)
            {
            case EntityFuncType.VisitorCar_EnterZoo:
                //车到了,刷下游客停车场数量
                numShowParking--;
                ShowLeftParkingNum(numShowParking);
                SpawnVisitorFromCar.Send(VisitorStage.GotoZoo, EntityFuncType.Visitor_From_Car);
#if DEBUG_VISIT
                BroadcastNum.Send((int)GameMessageDefine.BroadcastVisitorNum, numGroundParkingCar + numUnderParkingCar, 0f, 0);
                BroadcastNum.Send((int)GameMessageDefine.BroadcastMaxVisitorNum, numMaxParking, 0f, 0);
#endif
                break;

            case EntityFuncType.VisitorCar_LeaveZoo:
                break;
            }
        }
        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)
            {
                EntityManager.GetInstance().RemoveFromEntityMovables(entity);

                //通知生成离开的汽车
                //MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                //通知生成离开的汽车
                if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car)
                {
                    DebugFile.GetInstance().WriteKeyFile("FromUnder_", "{0}", entity.entityID);
                    MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                }
            }
        }
Ejemplo n.º 3
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)
            {
                if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_Car)
                {
                    DebugFile.GetInstance().WriteKeyFile("FromUnder_", "{0}", entity.entityID);
                    MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnVisitorCarLeaveZoo);
                }
                else if (entity.entityFuncType == (int)EntityFuncType.Visitor_From_GroundParking)
                {
                    MessageGroundParkingSpace.Send((int)GameMessageDefine.BroadcastLetGroundParingCarLeave,
                                                   entity.groundParkingGroupID, entity.groundParkingIdx);
                }

                // 回POOL
                EntityManager.GetInstance().RemoveFromEntityMovables(entity);
            }
        }
        /// <summary>
        /// 卸载动物园游戏
        /// </summary>
        public void UnLoad()
        {
            this.callbacks = null;
            ////关闭主界面
            //PageMgr.ClosePage();

            CloseAllPage();

            //停止游戏
            GameModuleManager.GetInstance().Stop();
            //卸载module
            GameManager.GetInstance().UnLoadModule();
            //GameManager.GetInstance().RemoveAllTickPage();

            //卸载加载出来的实体
            EntityManager.GetInstance().Release();

            //卸载各pool
            PoolManager.GetInstance().Release();

            ResourceManager.GetInstance().Release();

            //全局数据释放
            GlobalDataManager.GetInstance().Release();
            //卸载场景

            Resources.UnloadUnusedAssets();
            System.GC.Collect();
        }
        protected void OnSpawnShuttle(Message msg)
        {
            var _msg = msg as SpawnShuttle;

            EntityShuttle entity = null;

            if (isRandomSpawn)
            {
                entity = EntityManager.GetInstance().GetRandomEntity(
                    ResType.Shuttle, EntityFuncType.Shuttle) as EntityShuttle;
            }
            else
            {
                entity = EntityManager.GetInstance().GenEntityGameObject(
                    6001, EntityFuncType.Shuttle) as EntityShuttle;
            }

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "Shuttle_{0}", entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);

            entity.SetVisistorList(_msg.shuttleVisitorList);

            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }
            entity.anim.Init(entity.mainGameObject);

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

            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }

            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineShuttle(entity);

                entity.fsmMachine.AddState(new StateShuttleGotoDynamicPath((int)ShuttleState.GotoDynamicPath,
                                                                           entity.fsmMachine));
                entity.fsmMachine.AddState(new StateShuttleGotoCalcPath((int)ShuttleState.GotoCalcPath,
                                                                        entity.fsmMachine));
                entity.fsmMachine.AddState(new StateShuttleGobackCalcPath((int)ShuttleState.GobackCalcPath,
                                                                          entity.fsmMachine));
                entity.fsmMachine.AddState(new StateShuttleGobackDynamicPath((int)ShuttleState.GobackDynamicPath,
                                                                             entity.fsmMachine));

                entity.fsmMachine.SetDefaultState((int)ShuttleState.GotoDynamicPath);
            }
            else
            {
                entity.fsmMachine.SetDefaultState((int)ShuttleState.GotoDynamicPath);
            }
            entity.Active();

            TracedCamera(entity, isTracedCar);
        }
        public override void Tick(int deltaTimeMS)
        {
            if (!this.CouldRun())
            {
                return;
            }

            EntityManager.GetInstance().Tick(deltaTimeMS);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 轮船开过来,下指定数量的游客
        /// </summary>
        /// <param name="maxSpawnVisitorNum"></param>
        public static void GetoffVisitor(int maxSpawnVisitorNum)
        {
            LogWarp.LogError("GetoffVisitor");
            EntityShip entity;

            int sceneID       = GlobalDataManager.GetInstance().playerData.playerZoo.currSceneID;
            int visitorpathID = Config.sceneConfig.getInstace().getCell(sceneID).visitorpath;

            Config.sceneaddvisitorCell sceneaddvisitorCell = Config.sceneaddvisitorConfig.getInstace().getCell(visitorpathID);

            switch (visitorpathID)
            {
            case 0:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Ship, EntityFuncType.Ship) as EntityShip;
                break;

            case 1:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Train, EntityFuncType.Train) as EntityShip;
                break;

            default:
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Ship, EntityFuncType.Ship) as EntityShip;
                break;
            }

            EntityManager.GetInstance().AddToEntityMovables(entity);
            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }
            entity.moveSpeed = sceneaddvisitorCell.movespeed;
            var path = PathManager.GetInstance().GetPath(sceneaddvisitorCell.intopath);

            entity.position = path[0];
            entity.followPath.Init(entity, path, path[0], 0, entity.moveSpeed, false);
            entity.maxSpawnVisitorNum    = maxSpawnVisitorNum;
            entity.visitorGetOffInterval = Math_F.FloatToInt1000(Config.globalConfig.getInstace().ShipVisitorGetOffInterval);
            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineShip(entity);

                entity.fsmMachine.AddState(new StateShipGoto((int)ShipState.Goto,
                                                             entity.fsmMachine));
                entity.fsmMachine.AddState(new StateShipGoback((int)ShipState.Goback,
                                                               entity.fsmMachine));

                entity.fsmMachine.SetDefaultState((int)ShipState.Goto);
            }
            else
            {
                entity.fsmMachine.GotoState((int)ShipState.Goto);
            }
            entity.Active();
        }
Ejemplo n.º 8
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
        }
        protected void OnArrived(Message msg)
        {
            var _msg = msg as MessageArrived;

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

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

            if (_msg.followPath.isArrivedEnd)
            {
                EntityManager.GetInstance().RemoveFromEntityMovables(_msg.followPath.ownerEntity);
            }
        }
Ejemplo n.º 10
0
        //protected bool ToStateShuttleGotoCalcPath()
        //{
        //    return isToStateShuttleGotoCalcPath;
        //}

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

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

            //单纯的到达终点
            if (_msg.followPath.isArrivedEnd)
            {
                //isToStateShuttleGotoCalcPath = true;
                EntityManager.GetInstance().RemoveFromEntityMovables(entity);
            }
        }
Ejemplo n.º 11
0
        protected void TickShuttleVisistorNum(int deltaTimeMS)
        {
            this.shuttleaccumulativeTime += deltaTimeMS;
            if (shuttleVisitorQueue.Count >= ExitGateModule.GetMaxShuttleVisitor() && shuttleaccumulativeTime >= maxShuttleInterval)
            {
                shuttleVisitorList.Clear();
                for (int i = 0; i < ExitGateModule.GetMaxShuttleVisitor(); i++)
                {
                    var entity = shuttleVisitorQueue.Dequeue();
                    EntityManager.GetInstance().RemoveFromEntityMovables(entity);
                    var shuttleVisitor = new ShuttleVisitor();
                    shuttleVisitor.Init(entity.entityID, (EntityFuncType)entity.entityFuncType);
                    shuttleVisitorList.Add(shuttleVisitor);
                }
                //MessageManager.GetInstance().Send((int)GameMessageDefine.SpawnShuttle);
                SpawnShuttle.Send(shuttleVisitorList);
                shuttleaccumulativeTime -= maxShuttleInterval;
#if DEBUG_VISIT
                BroadcastNum.Send((int)GameMessageDefine.BroadcastShuttleVisistorNum, shuttleVisitorQueue.Count, 0f, 0);
#endif
            }
        }
        /// <summary>
        /// 加载动物
        /// </summary>
        /// <param name="littleZooID">加载动物栏ID</param>
        /// <param name="animalID">动物ID</param>
        /// <param name="animalWanderradius"></param>
        /// <param name="animalWanderoffset"></param>
        public static void LoadAnimal(int littleZooID, int animalID, float animalWanderradius, float[] animalWanderoffset, int senceID = -1)
        {
            var cellAnimalUp = Config.animalupConfig.getInstace().getCell(animalID);

            var entity = EntityManager.GetInstance().GenEntityGameObject(cellAnimalUp.resourceload, EntityFuncType.Animal_Wander) as EntityAnimalWander;

            entity.animalID = animalID;
            playerAnimalGoToResourceID.Add(animalID, entity.entityID);

            Vector3 offset = Vector3.zero;

            offset.x = animalWanderoffset[0];
            offset.y = animalWanderoffset[1];
            offset.z = animalWanderoffset[2];

            var littleZooBuildinPos = LittleZooBuildinPosManager.GetInstance().GetLittleZooBuildinPos(littleZooID);
            int idx       = FindArrayRangIndex(littleZooID, animalID);
            var animalPos = littleZooBuildinPos.animalPosList[idx];

            entity.position = animalPos;

            // PathWander
            if (entity.pathWander == null)
            {
                entity.pathWander = new UFrame.BehaviourFloat.PathWander();
            }
            entity.pathWander.Init(entity,
                                   PathManager.GetInstance().GetPath(cellAnimalUp.walkingpath),
                                   cellAnimalUp.animalwanderspeed);

            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }
            entity.anim.Init(entity.mainGameObject);

            entity.Active();
            EntityManager.GetInstance().AddToEntityMovables(entity);
        }
Ejemplo n.º 13
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);
            }
        }
Ejemplo n.º 14
0
        public override void WhenArrivedEnd()
        {
            var follow = (this.fsmCtr as FSMFollowPathSuperMarketSimply).owner;

            if (!isFinishedBack)
            {
                isFinishedBack = true;
                //LogWarp.LogError("完成倒车,准备离开");

                //生成离开的路

                var            pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(follow.groupID, follow.idx);
                List <Vector3> outPath  = null;
                List <RightAnglesControllNode> outRac = null;
                if (!GroundParingSpacePathManager.IsExist(pathUnit.outPath))
                {
                    outPath = GroundParingSpacePathManager.GenOutPath(follow.groupID, follow.idx);
                    GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.OutPath, pathUnit, outPath, null);

                    outRac = GroundParingSpacePathManager.GenRAC(outPath, follow.turnOffset);
                    GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.OutPathRac, pathUnit, null, outRac);
                }
                follow.pathPosList = pathUnit.outPath;
                follow.ctrList     = pathUnit.outPathRac;

                follow.idxCtr = 0;
                //设置方向为反
                follow.isForward = true;

                MessageGroundParkingSpace.Send((int)GameMessageDefine.LetGroundParingCarLeave, follow.groupID, follow.idx);

                return;
            }

            // 回POOL
            EntityManager.GetInstance().RemoveFromEntityMovables(follow.ownerEntity);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 地下停车场的车
        /// </summary>
        /// <param name="entityFuncType"></param>
        protected void SpawnVisitorCar(EntityFuncType entityFuncType)
        {
            EntityVisitorCar entity = null;

            //if (isRandomCar)
            {
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Car, entityFuncType) as EntityVisitorCar;
            }
            //else
            //{
            //    entity = EntityManager.GetInstance().GenEntityGameObject(2, EntityFuncType.VisitorCar_EnterZoo) as EntityVisitorCar;
            //}

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "car_{0}_{1}_{2}", entity.mainGameObject.GetInstanceID(), entityFuncType, entity.entityID);
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 生成 {1}", entity.entityID, entity.mainGameObject.GetInstanceID());
            DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} 生成 {1}", entity.mainGameObject.GetInstanceID(), entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);
            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }

            entity.anim.Init(entity.mainGameObject);
            if (entity.followPath == null)
            {
                //entity.followPath = new FollowPath();
                entity.followPath = new FollowPathRightAngles();
            }

            //从表里取速度
            entity.moveSpeed = Config.globalConfig.getInstace().ZooCarSpeed;

            //从表里取路径
            string pathName = "";

            switch (entityFuncType)
            {
            case EntityFuncType.VisitorCar_EnterZoo:
                pathName = globalConfig.getInstace().NaturalVisitorInto;
                break;

            case EntityFuncType.VisitorCar_LeaveZoo:
                pathName = globalConfig.getInstace().NaturalVisitorOut_2;
                break;

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

            var path = PathManager.GetInstance().GetPath(pathName);

            entity.position = path[0];
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 移动位置到路径起点{1}, pos {2}", entity.entityID, entity.mainGameObject.GetInstanceID(), path[0]);
            DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} 移动位置到路径起点{1}, pos {2}", entity.mainGameObject.GetInstanceID(), entity.entityID, path[0]);

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 沿着路径{1}出发", entity.entityID, pathName);
            //entity.followPath.Init(entity, path.ToArray(), path[0], 0, entity.moveSpeed, false);
            entity.followPath.Init(entity, pathName, path, path[0], 0, entity.moveSpeed);
            entity.Active();
        }
        protected void OnSpawnVisitorFromGroundParking(Message msg)
        {
            var _msg = msg as SpawnVisitorFromGroundParking;
            //path_touristcar_intoupline
            //"path_tourist_intoupline";
            //var path = PathManager.GetInstance().GetPath("path_touristcar_intoupline");
            //var carBaseLinePos = path[_msg.groupID];
            //var lastCorner = carBaseLinePos - GlobalDataManager.GetInstance().SceneForward * (8 + _msg.idx * 5);
            //var visitorBaseLinePos = PathManager.GetInstance().GetPath("path_tourist_intoupline")[_msg.idx];
            //LogWarp.LogErrorFormat("{0}-{1}:{2},{3}", _msg.groupID, _msg.idx, lastCorner, visitorBaseLinePos);

            EntityVisitor entity = null;

            //VisitorState defaultState = VisitorState.EnterZoo;

            //switch (_msg.stage)
            //{
            //    case VisitorStage.GotoZoo:
            //        //defaultState = VisitorState.EnterZoo;
            //        defaultState = VisitorState.GotoZooEntry;
            //        break;
            //    case VisitorStage.GotoParking:
            //        defaultState = VisitorState.GotoParking;
            //        break;
            //    default:
            //        string e = string.Format("VisitorStage 异常{0}", _msg.stage);
            //        throw new System.Exception(e);
            //}

            if (isRandomSpawn)
            {
                //entity = EntityManager.GetInstance().GetRandomEntity(
                //    ResType.Visitor, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GetRandomEntity(
                    ResType.Visitor, _msg.funcType) as EntityVisitor;
            }
            else
            {
                //entity = EntityManager.GetInstance().GenEntityGameObject(
                //    101, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GenEntityGameObject(
                    101, _msg.funcType) as EntityVisitor;
            }
            entity.groundParkingGroupID = _msg.groupID;
            entity.groundParkingIdx     = _msg.idx;
            //LogWarp.LogErrorFormat("{0} visitor SpawnModule groupID={1}, idx={2}", entity.entityID,
            //    entity.groundParkingGroupID, entity.groundParkingIdx);

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_ground_{0}", entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);

            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }
            //entity.anim.Init(entity.mainGameObject);
            entity.InitAnim();

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

            if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true)
            {
                UIGuidePage uIGuidePage = PageMgr.GetPage <UIGuidePage>();
                if (uIGuidePage != null && uIGuidePage.newBieGuild_step <= NewBieGuild.Step_4)
                {
                    entity.moveSpeed = Config.globalConfig.getInstace().GuideZooVisitorSpeed;
                }
            }


            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }

            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineVisitor(entity);
                //entity.fsmMachine.AddState(new StateVisitorEnterZoo((int)VisitorState.EnterZoo,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoZooEntry((int)VisitorState.GotoZooEntry,
                                                                        entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveZooEntryQueueFull((int)VisitorState.LeaveZooEntryQueueFull,
                                                                                  entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEntryQueue((int)VisitorState.EntryQueue,
                                                                      entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayFirstPosInEntryQueue((int)VisitorState.StayFirstPosInEntryQueue,
                                                                                    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorChoseLittleZoo((int)VisitorState.ChoseLittleZoo,
                                                                          entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEnterLittleZooApply((int)VisitorState.EnterLittleZooApply,
                                                                               entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorStayWaitSeat((int)VisitorState.StayWaitSeat,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayVisitSeat((int)VisitorState.StayVisitSeat,
                                                                         entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveNonLittleZoo((int)VisitorState.LeaveNonLittleZoo,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorCrossGroupPath((int)VisitorState.CrossGroupPath,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveFromZooEntry((int)VisitorState.LeaveFromZooEntry,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoStartOfExitGateEntryPath((int)VisitorState.GotoStartOfExitGateEntryPath,
                //    entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoExitGateEntryQueue((int)VisitorState.GotoExitGateEntryQueue,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoParking((int)VisitorState.GotoParking,
                                                                       entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoGroundParking((int)VisitorState.GotoGroundParking,
                                                                             entity.fsmMachine));

                entity.fsmMachine.SetDefaultState((int)VisitorState.GotoZooEntry);
            }
            else
            {
                //LogWarp.LogError("pool游客");
                //entity.fsmMachine.GotoState((int)VisitorState.GotoZooEntry);

                entity.fsmMachine.GotoState((int)VisitorState.GotoZooEntry);
            }
            entity.Active();
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} Play {1}", entity.entityID, Config.globalConfig.getInstace().VisitorWalk);
            entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk);
        }
        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);
                }
            }
        }
        protected void OnSpawnVisitorFromCar(Message msg)
        {
            var           _msg   = msg as SpawnVisitorFromCar;
            EntityVisitor entity = null;

            VisitorState defaultState = VisitorState.GotoZooEntry;

            switch (_msg.stage)
            {
            case VisitorStage.GotoZoo:
                //defaultState = VisitorState.EnterZoo;
                defaultState = VisitorState.GotoZooEntry;
                break;

            case VisitorStage.GotoParking:
                defaultState = VisitorState.GotoParking;
                break;

            default:
                string e = string.Format("VisitorStage 异常{0}", _msg.stage);
                throw new System.Exception(e);
            }

            if (isRandomSpawn)
            {
                //entity = EntityManager.GetInstance().GetRandomEntity(
                //    ResType.Visitor, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GetRandomEntity(
                    ResType.Visitor, _msg.funcType) as EntityVisitor;
            }
            else
            {
                //entity = EntityManager.GetInstance().GenEntityGameObject(
                //    101, EntityFuncType.Visitor_From_Car) as EntityVisitor;
                entity = EntityManager.GetInstance().GenEntityGameObject(
                    101, _msg.funcType) as EntityVisitor;
            }

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}", entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);

            //LogWarp.LogError("测试:  生成游客  name=  "+ entity.mainGameObject.name);


            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }
            //entity.anim.Init(entity.mainGameObject);
            entity.InitAnim();

            entity.moveSpeed = Config.globalConfig.getInstace().ZooVisitorSpeed;
            if (entity.followPath == null)
            {
                entity.followPath = new FollowPath();
            }

            if (entity.fsmMachine == null)
            {
                entity.fsmMachine = new FSMMachineVisitor(entity);
                //entity.fsmMachine.AddState(new StateVisitorEnterZoo((int)VisitorState.EnterZoo,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoZooEntry((int)VisitorState.GotoZooEntry,
                                                                        entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveZooEntryQueueFull((int)VisitorState.LeaveZooEntryQueueFull,
                                                                                  entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEntryQueue((int)VisitorState.EntryQueue,
                                                                      entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayFirstPosInEntryQueue((int)VisitorState.StayFirstPosInEntryQueue,
                                                                                    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorChoseLittleZoo((int)VisitorState.ChoseLittleZoo,
                                                                          entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorEnterLittleZooApply((int)VisitorState.EnterLittleZooApply,
                                                                               entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorStayWaitSeat((int)VisitorState.StayWaitSeat,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorStayVisitSeat((int)VisitorState.StayVisitSeat,
                                                                         entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveNonLittleZoo((int)VisitorState.LeaveNonLittleZoo,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorCrossGroupPath((int)VisitorState.CrossGroupPath,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorLeaveFromZooEntry((int)VisitorState.LeaveFromZooEntry,
                                                                             entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoStartOfExitGateEntryPath((int)VisitorState.GotoStartOfExitGateEntryPath,
                //    entity.fsmMachine));
                //entity.fsmMachine.AddState(new StateVisitorGotoExitGateEntryQueue((int)VisitorState.GotoExitGateEntryQueue,
                //    entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoParking((int)VisitorState.GotoParking,
                                                                       entity.fsmMachine));
                entity.fsmMachine.AddState(new StateVisitorGotoGroundParking((int)VisitorState.GotoGroundParking,
                                                                             entity.fsmMachine));


                entity.fsmMachine.SetDefaultState((int)defaultState);
            }
            else
            {
                //LogWarp.LogError("pool游客");
                //entity.fsmMachine.GotoState((int)VisitorState.GotoZooEntry);

                entity.fsmMachine.GotoState((int)defaultState);
            }
            entity.Active();
            //entity.fsmMachine.Run();
            entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk);

            TracedCamera(entity, isTracedVisitor);
        }
        protected void OnVisitorGetRandomLittleZooApply(Message msg)
        {
            var _msg   = msg as VisitorGetRandomLittleZooApply;
            var entity = EntityManager.GetInstance().GetEntityMovable(_msg.entityID) as EntityVisitor;

            int groupID = entity.stayGroupID;

            if (_msg.isFirstApply)
            {
                //groupID = GlobalDataManager.GetInstance().logicTableGroup.sortedGroupID[0];
                var playerData = GlobalDataManager.GetInstance().playerData;
                groupID = GlobalDataManager.GetInstance().logicTableGroup.GetSortedGroupIDs(sceneID)[0];
            }

            openedLittleZooIDs.Clear();

            bool retCode     = false;
            int  nextGroupID = Const.Invalid_Int;

            while (true)
            {
                retCode = GetOpenedLittleZooIDs(groupID, openedLittleZooIDs);
                if (!retCode)
                {
                    //失败
                    VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null);
                    return;
                }

                //wouldGotoLittleZooIDs = //从开放的动物栏中 剔除 去过的
                retCode = GetWouldGotoLittleZooIDs(entity, groupID, openedLittleZooIDs, wouldGotoLittleZooIDs);
                if (!retCode)
                {
                    //retCode = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(groupID, ref nextGroupID);
                    retCode = GlobalDataManager.GetInstance().logicTableGroup.GetNextGroupID(sceneID, groupID, ref nextGroupID);
                    if (!retCode)
                    {
                        //找下一组失败
                        VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null);
                        return;
                    }
                    groupID = nextGroupID;
                }
                else
                {
                    break;
                }
            }

            //构建 wouldGotoLittleZooIDs 对应的权重
            retCode = GetWouldGotoWeights(groupID, wouldGotoLittleZooIDs, wouldGotoWeights);
            if (!retCode)
            {
                //失败
                VisitorGetRandomLittleZooReply.Send(_msg.entityID, false, Const.Invalid_Int, Const.Invalid_Int, false, null);
                return;
            }

            int idx = Const.Invalid_Int;

            Math_F.TableProbability(wouldGotoWeights, ref idx);

            int littleZooID = wouldGotoLittleZooIDs[idx];

            EntityVisitor.RecordVisitedLittleZoo(entity, groupID, littleZooID);

            VisitorGetRandomLittleZooReply.Send(_msg.entityID, true, groupID, littleZooID, false, null);
        }
Ejemplo n.º 20
0
        protected void SpawnInGroundParkingCar(EntityFuncType entityFuncType, ParkingSpace parkingSpace)
        {
            EntityGroundParkingCar entity = null;

            //if (isRandomCar)
            {
                entity = EntityManager.GetInstance().GetRandomEntity(ResType.Car, entityFuncType) as EntityGroundParkingCar;
            }
            //else
            //{
            //    entity = EntityManager.GetInstance().GenEntityGameObject(2, EntityFuncType.VisitorCar_EnterZoo) as EntityGroundParkingCar;
            //}

            DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "car_{0}_{1}_{2}", entity.mainGameObject.GetInstanceID(), entityFuncType, entity.entityID);
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 生成 {1}", entity.entityID, entity.mainGameObject.GetInstanceID());
            DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} 生成 {1}", entity.mainGameObject.GetInstanceID(), entity.entityID);

            EntityManager.GetInstance().AddToEntityMovables(entity);
            if (entity.anim == null)
            {
                entity.anim = new SimpleAnimation();
            }

            entity.anim.Init(entity.mainGameObject);
            if (entity.followPath == null)
            {
                entity.followPath = new FollowPathSuperMarketSimply();
            }

            //从表里取速度
            entity.moveSpeed = Config.globalConfig.getInstace().ZooCarSpeed;

            if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true)
            {
                UIGuidePage uIGuidePage = PageMgr.GetPage <UIGuidePage>();
                if (uIGuidePage == null && GlobalDataManager.GetInstance().playerData.GetLittleZooModuleData(1001).littleZooTicketsLevel < 5)
                {
                    entity.moveSpeed = Config.globalConfig.getInstace().GuideZooCarSpeed;
                }
                else if (uIGuidePage == null && GlobalDataManager.GetInstance().playerData.GetLittleZooModuleData(1001).littleZooTicketsLevel >= 5)
                {
                    GlobalDataManager.GetInstance().playerData.playerZoo.isGuide = false;
                }
            }


            entity.groundParkingGroupID = parkingSpace.groupID;
            entity.groundParkingIdx     = parkingSpace.idx;

            string pathName = "";

            switch (entityFuncType)
            {
            case EntityFuncType.GroundParkingCar:
                //pathName = globalConfig.getInstace().NaturalVisitorInto;
                pathName = string.Format("InGroundParking_{0}_{1}", parkingSpace.groupID, parkingSpace.idx);

                break;

            //case EntityFuncType.VisitorCar_LeaveZoo:
            //    pathName = globalConfig.getInstace().NaturalVisitorOut_2;
            //    break;
            default:
                string e = string.Format("car 没有这种功能类型{0}", entityFuncType);
                throw new System.Exception(e);
            }
            int sceneID = GlobalDataManager.GetInstance().playerData.playerZoo.currSceneID;

            Config.parkingCell parkingCell = GlobalDataManager.GetInstance().logicTableParkingData.GetParkingCell(sceneID);
            //var path = PathManager.GetInstance().GetPath(pathName);
            //var path = CalcPathManager.GenInGroundParkingSpacePath(ps.groupID, ps.idx, 8f, 5f, 7f, -1);
            var            pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(parkingSpace.groupID, parkingSpace.idx);
            List <Vector3> path     = null;

            if (!GroundParingSpacePathManager.IsExist(pathUnit.inPath))
            {
                //path = GroundParingSpacePathManager.GenInPath(parkingSpace.groupID, parkingSpace.idx, 8f, 5f, 7f, -1);
                path = GroundParingSpacePathManager.GenInPath(parkingSpace.groupID, parkingSpace.idx,
                                                              Config.globalConfig.getInstace().GroundParkingFristSpaceOffset,
                                                              Config.globalConfig.getInstace().GroundParkingSpace,
                                                              Config.globalConfig.getInstace().GroundParkingSpacePosOffset,
                                                              parkingCell.openseatdir[parkingSpace.groupID]);

                GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.InPath, pathUnit, path, null);
            }
            path = pathUnit.inPath;

            entity.position = path[0];
            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 移动位置到路径起点{1}, pos {2}", entity.entityID, entity.mainGameObject.GetInstanceID(), path[0]);
            DebugFile.GetInstance().WriteKeyFile(entity.mainGameObject.GetInstanceID(), "{0} 移动位置到路径起点{1}, pos {2}", entity.mainGameObject.GetInstanceID(), entity.entityID, path[0]);

            DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} 沿着路径{1}出发", entity.entityID, pathName);
            //entity.followPath.Init(entity, path.ToArray(), path[0], 0, entity.moveSpeed, false);
            entity.followPath.Init(entity, parkingSpace.groupID, parkingSpace.idx, path, path[0], 0, entity.moveSpeed);
            entity.Active();
            //ps.parkingCar = entity;
            //TracedCamera(entity);
            parkingSpace.SetBeLocked(entity);

            /*若是新手引导阶段,附加跟随对象 不调用步骤*/
            if (GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true)
            {
                DelayedOperationNewbieGuideStage(entity);
            }
        }