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; }
/// <summary> /// 构建倒车转弯控制点 /// </summary> /// <param name="follow"></param> protected void ResetRacToReverse(FollowPathSuperMarketSimply follow) { var entity = follow.ownerEntity as EntityGroundParkingCar; var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx); List <RightAnglesControllNode> backRac = null; if (!GroundParingSpacePathManager.IsExist(pathUnit.inPathBackRac)) { backRac = GroundParingSpacePathManager.GenBackRac(follow.ctrList); GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.InPathBackRac, pathUnit, null, backRac); } follow.ctrList = pathUnit.inPathBackRac; }
/// <summary> /// 构建倒车路径 /// </summary> /// <param name="follow"></param> protected void ResetPathToReverse(FollowPathSuperMarketSimply follow) { var entity = follow.ownerEntity as EntityGroundParkingCar; var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx); List <Vector3> reversePath = null; if (!GroundParingSpacePathManager.IsExist(pathUnit.inPathReverse)) { reversePath = GroundParingSpacePathManager.GenReversePath(follow.pathPosList); GroundParingSpacePathManager.GetInstance().AddPath( GroundParingSpacePathType.InPathReverse, pathUnit, reversePath, null); } follow.pathPosList = pathUnit.inPathReverse; }
public virtual void Init(EntityMovable ownerEntity, int groupID, int idx, List <Vector3> pathPosList, Vector3 orgPos, int nextPosIdx, float speed) { if (this.IsRunning()) { string e = string.Format("{0} {1} FollowPathRightAngles非法初始化", ownerEntity.entityID, ownerEntity.mainGameObject.GetInstanceID()); throw new System.Exception(e); } this.ownerEntity = ownerEntity; this.pathPosList = pathPosList; this.orgPos = orgPos; this.nextPosIdx = nextPosIdx; this.nextPos = this.pathPosList[this.nextPosIdx]; this.speed = speed * 0.001f; this.orgRotation = this.ownerEntity.mainGameObject.transform.rotation; this.isArrivedEnd = false; idxCtr = 0; //停止旋转CD turnCD.Stop(); this.turnSpeed = CalcTurnSpeed(this.speed); //因为知道角度是90度所以cd是旋转cd恒定的 turnCDVal = Math_F.FloatToInt(cornerAngle / this.turnSpeed); var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(groupID, idx); if (!GroundParingSpacePathManager.IsExist(pathUnit.inPathRac)) { ctrList = GroundParingSpacePathManager.GenRAC(pathPosList, this.turnOffset); GroundParingSpacePathManager.GetInstance().AddPath( GroundParingSpacePathType.InPathRac, pathUnit, null, ctrList); } ctrList = pathUnit.inPathRac; this.groupID = groupID; this.idx = idx; isForward = true; //先把朝向转到第一个后点 ownerEntity.LookAt(ctrList[0].backPos); }
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); } }
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); }
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); } }
public override void Enter(int preStateName) { //LogWarp.Log("VisitorGotoZooEntry.Enter"); base.Enter(preStateName); isToVisitorStateLeaveZooEntryQueueFull = false; isToVisitorStateEntryQueue = false; //isStartGotoEntry = false; isArrivedObservePos = false; var entity = (this.fsmCtr as FSMMachineVisitor).ownerEntity; DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} VisitorGotoZooEntry.Enter", entity.entityID); DebugFile.GetInstance().MarkGameObject(entity.mainGameObject, "visitor_{0}_{1}_{2}", entity.entityID, (VisitorState)this.preStateName, (VisitorState)this.stateName); entity.Reset(); DebugFile.GetInstance().WriteKeyFile(entity.entityID, "{0} Play {1}, {2}, {3}", entity.entityID, Config.globalConfig.getInstace().VisitorWalk, entity.mainGameObject.GetInstanceID(), entity.anim.animation.gameObject.GetInstanceID() ); entity.PlayActionAnim(Config.globalConfig.getInstace().VisitorWalk); MessageManager.GetInstance().Regist((int)GameMessageDefine.AddVisitorToEntryQueuePlaceHolderReply, this.OnAddVisitorToEntryQueuePlaceHolderReply); MessageManager.GetInstance().Regist((int)UFrameBuildinMessage.Arrived, this.OnArrived); MessageManager.GetInstance().Regist((int)GameMessageDefine.BroadcastForwardOneStepInEntryGateQueue, OnBroadcastForwardOneStepInExitGateQueue); //去观察点 string pathName; EntityFuncType entityFuncType = (EntityFuncType)(entity.entityFuncType); switch (entityFuncType) { case EntityFuncType.Visitor_From_Ship: pathName = Config.globalConfig.getInstace().AdvertVisitorInto_2; EntityVisitor.GodownPath(entity, pathName, true); break; case EntityFuncType.Visitor_From_Car: pathName = Config.globalConfig.getInstace().EntryQueueObservePath; EntityVisitor.GodownPath(entity, pathName, true); break; case EntityFuncType.Visitor_From_GroundParking: //LogWarp.LogErrorFormat("entityID={0} StateVisitorGotoZooEntry groupID={1}, idx={2}", entity.entityID, entity.groundParkingGroupID, entity.groundParkingIdx); var pathUnit = GroundParingSpacePathManager.GetInstance().GetPathUnit(entity.groundParkingGroupID, entity.groundParkingIdx); List <Vector3> pathList = null; if (!GroundParingSpacePathManager.IsExist(pathUnit.entryObservePath)) { pathList = GroundParingSpacePathManager.GenObservePath(entity.groundParkingGroupID, entity.groundParkingIdx); GroundParingSpacePathManager.GetInstance().AddPath(GroundParingSpacePathType.EntryObservePath, pathUnit, pathList, null); } pathList = pathUnit.entryObservePath; entity.pathList.Clear(); entity.pathList.AddRange(pathList); EntityVisitor.GodownPath(entity, entity.pathList, true); ///*新手引导阶段 添加跟随对象 不做步骤调用(仅限于步骤9)*/ if (GlobalData.GlobalDataManager.GetInstance().playerData.playerZoo.isGuide == true) { UIGuidePage uIGuidePage = PageMgr.GetPage <UIGuidePage>(); if (uIGuidePage == null) { string e1 = string.Format("新手引导界面 PageMgr.allPages里 UIGuidePage 为空"); throw new System.Exception(e1); } //LogWarp.LogError("测试: entity.mainGameObject.name " + entity.mainGameObject.name+ " uIGuidePage.procedure= "+ uIGuidePage.procedure); if (uIGuidePage.newBieGuild_step == NewBieGuild.Step_9 && uIGuidePage.number == 0) { uIGuidePage.entity = entity; uIGuidePage.number = 1; } } break; default: string e = string.Format("没有这种游客类型{0}", entityFuncType); throw new System.Exception(e); } }