protected void TickEnterCar(int deltaTimeMS) { if ((numUnderParkingCar + numGroundParkingCar) >= this.numMaxParking) { return; } ParkingSpace parkingSpace = null; this.enterCarAccumulativeTime += deltaTimeMS; if (this.enterCarAccumulativeTime >= this.enterCarSpawnInterval || !isSpawnEnterCar) { //保留超出部分 this.enterCarAccumulativeTime -= this.enterCarSpawnInterval; //生成 LogWarp.Log("SpawnEnterZooCar"); parkingSpace = groundParking.GetFreeParkingSpace(); if (parkingSpace == null) { int currGround = GetGroundParkingNumber(playerData.GetParkingCenterDataIDIndexOfDataIdx().parkingSpaceLevel); if (this.numMaxParking > currGround) { SpawnVisitorCar(EntityFuncType.VisitorCar_EnterZoo); ++numUnderParkingCar; this.isSpawnEnterCar = true; } } else { SpawnInGroundParkingCar(EntityFuncType.GroundParkingCar, parkingSpace); ++numGroundParkingCar; this.isSpawnEnterCar = true; } } }
public GroupParkingSpace(int groupID, int numParkingSpace) { this.groupID = groupID; for (int i = 0; i < numParkingSpace; i++) { var parkingSpace = new ParkingSpace(groupID, i); parkingspaces.Add(parkingSpace); } }
/// <summary> /// 得到指定停车位 /// </summary> /// <param name="groupID"></param> /// <param name="idx"></param> /// <returns></returns> public ParkingSpace GetSpace(int groupID, int idx) { ParkingSpace parkingSpace = null; GroupParkingSpace groupParkingSpace = null; if (groupParkingSpaceDic.TryGetValue(groupID, out groupParkingSpace)) { parkingSpace = groupParkingSpace.GetSpace(idx); } return(parkingSpace); }
/// <summary> /// 得到停好车的车位 /// </summary> /// <returns></returns> public ParkingSpace GetParkingSpace() { ParkingSpace parkingSpace = null; foreach (var val in groupParkingSpaceDic.Values) { parkingSpace = val.GetParkingSpace(); if (parkingSpace != null) { return(parkingSpace); } } return(parkingSpace); }
public ParkingSpace GetParkingSpace() { ParkingSpace parkingSpace = null; for (int i = 0; i < parkingspaces.Count; i++) { parkingSpace = parkingspaces[i]; if (parkingSpace.IsParking()) { return(parkingSpace); } } return(null); }
protected void OnVisitorWhereLeaveFromApply(Message msg) { //根据地上地下的车位数量随机从地上回还是地下回 var _msg = msg as VisitorWhereLeaveFromApply; #if UNITY_EDITOR if (numUnderParkingCar < 1 && numGroundParkingCar < 1) { string e = string.Format("{0} 申请离开时地上地下都没有车numUnderParkingCar={1},numGroundParkingCar={2}", _msg.entityID, numUnderParkingCar, numGroundParkingCar); throw new System.Exception(e); } #endif float p = (float)numGroundParkingCar / (float)(numGroundParkingCar + Mathf.Max(0, numUnderParkingCar)); float r = UnityEngine.Random.Range(0f, 1f); if (r > p) { //从地下走 DebugFile.GetInstance().WriteKeyFile("FromUnder", "{0}", _msg.entityID); this.numUnderParkingCar--; VisitorWhereLeaveFromReply.Send(_msg.entityID, false, 0, 0); return; } ParkingSpace parkingSpace = groundParking.GetParkingSpace(); if (parkingSpace == null) { //随机到地上,但地上没有停好的车,从地下走 DebugFile.GetInstance().WriteKeyFile("FromUnder", "{0}", _msg.entityID); this.numUnderParkingCar--; VisitorWhereLeaveFromReply.Send(_msg.entityID, false, 0, 0); return; } this.numGroundParkingCar--; parkingSpace.SetBeLocked(); VisitorWhereLeaveFromReply.Send(_msg.entityID, true, parkingSpace.groupID, parkingSpace.idx); }
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); } }