public void RandomId(out int id, List <IdWeight> idWeightList, System.Random rand) { id = -1; List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, idWeightList, 1); id = pickedIdList[0]; }
// void Start(){ // if (boxIdList.Count > 0) // { //// Debug.LogError(gameObject.transform.parent.parent.name); // List<IdWeight> idWeightList = new List<IdWeight>(); // for (int i = 0; i < boxIdList.Count; i++) // { //// Debug.LogError(boxIdList[i]); // idWeightList.Add(RandomDunGenUtil.GetChanceWeightFromStr(boxIdList[i])); // } // int seed = (int)(System.DateTime.UtcNow.Ticks%Int32.MaxValue+(int)(gameObject.transform.position.x+gameObject.transform.position.y+gameObject.transform.position.z)); // //Debug.LogError("seedint:"+seed); // System.Random rand = new System.Random(seed); // List<int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand,idWeightList, 1); // // RandomItemMgr.Instance.TryGenItem(pos, pickedIdList[0],rand); // } // } public void GenItem(List <IdWeight> idWeightList, System.Random rand) { if (idWeightList == null || idWeightList.Count == 0) { return; } List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, idWeightList, 1); RandomItemMgr.Instance.TryGenItem(pos, pickedIdList[0], rand); }
public void GenerateMonster(List <IdWeight> landMonsterId, List <IdWeight> waterMonsterId, int buff, System.Random rand, bool isTaskDungeon) { // if (RandomMonsterStrList.Count > 0) // { // List<IdWeight> idWeightList = new List<IdWeight>(); // for (int i = 0; i < RandomMonsterStrList.Count; i++) { // idWeightList.Add(RandomDunGenUtil.GetChanceWeightFromStr(RandomMonsterStrList[i])); // } // int seed = (int)(System.DateTime.UtcNow.Ticks%Int32.MaxValue); // System.Random rand = new System.Random(seed); // List<int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand,idWeightList, 1); // // PeEntity monster = MonsterEntityCreator.CreateMonster(pickedIdList[0], pos); // PESkEntity mp = monster.GetComponent<PESkEntity>(); // mp.deathEvent+=RandomDungenMgr.Instance.OpenLockedDoor; // RandomDungenMgrData.AddMonster(monster); // } //--to do:check water List <IdWeight> monsterList = new List <IdWeight> (); if (VFVoxelWater.self != null) { if (VFVoxelWater.self.IsInWater(pos)) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 1, 0))) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 4, 0))) { monsterList = waterMonsterId; } else { return; } } else { monsterList = landMonsterId; } } else { monsterList = landMonsterId; } } if (monsterList == null || monsterList.Count == 0) { return; } List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, monsterList, 1); MonsterEntityCreator.CreateDungeonMonster(pickedIdList[0], pos, RandomDungenMgrData.DungeonId, buff); }
protected override void OnInit() { _layerMaskToFootprint = 0; _layerToFootprintTerra = Pathea.Layer.VFVoxelTerrain; _layerToFootprintMetal = -1; _nonTerClipIds = _metalClipIds; if (Pathea.PeGameMgr.IsAdventure) { if (RandomDungenMgr.Instance != null && RandomDungenMgrData.dungeonBaseData != null && RandomDungenMgrData.InDungeon) { DungeonType dType = RandomDunGenUtil.GetDungeonType(); if (dType == DungeonType.Iron || dType == DungeonType.Cave) { _layerToFootprintTerra = -1; _layerToFootprintMetal = Pathea.Layer.SceneStatic; _nonTerClipIds = _stoneClipIds; } //if(dType == DungeonType.Cave) { // _layerToFootprintTerra = Pathea.Layer.SceneStatic; // _layerToFootprintMetal = -1; //} } } else if (Pathea.PeGameMgr.IsStory) { if (Pathea.PeGameMgr.IsSingle || Pathea.PeGameMgr.IsTutorial) { if (Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand) { _layerToFootprintTerra = -1; _layerToFootprintMetal = Pathea.Layer.SceneStatic; } } if (Pathea.PeGameMgr.IsMulti) { if (PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId != (int)Pathea.SingleGameStory.StoryScene.MainLand) { _layerToFootprintTerra = -1; _layerToFootprintMetal = Pathea.Layer.SceneStatic; } } } if (_layerToFootprintTerra >= 0) { _layerMaskToFootprint |= (1 << _layerToFootprintTerra); } if (_layerToFootprintMetal >= 0) { _layerMaskToFootprint |= (1 << _layerToFootprintMetal); } }
int GetEnvironmentBgMusic() { if (VCEditor.s_Active) { return(CreationMusicID); } else { PeEntity player = PeCreature.Instance.mainPlayer; if (player != null) { if (CSMain.Instance != null && CSMain.Instance.IsInAssemblyArea(player.position)) { return(PlayerBaseMusicID); } else { if (PeGameMgr.IsAdventure) { if (RandomDunGenUtil.IsInDungeon(player)) { if (RandomDunGenUtil.GetDungeonType() == DungeonType.Iron) { return(DungeonIronMusicID); } else { return(DungeonCaveMusicID); } } else if (VArtifactUtil.IsInNativeCampArea(player.position) >= 0) { return(NativeBaseMusicID); } } if (PeGameMgr.IsStory) { int soundID = PeMap.StaticPoint.Mgr.Instance.GetMapSoundID(player.position); if (soundID > 0) { return(soundID); } } } } } return(0); }
public static string GetRandomIsoTag(System.Random rand, List <IdWeight> weightPool) { if (weightPool == null || weightPool.Count == 0) { Debug.LogError("RandomDungeonDataBase.GetRandomIsoTag:no weight pool"); return(DungeonBaseData.isoTagList[DungeonBaseData.isoTagList.Count - 1]); } int pickedId = RandomDunGenUtil.PickIdFromWeightList(rand, weightPool, 1)[0]; if (pickedId < DungeonBaseData.isoTagList.Count) { return(DungeonBaseData.isoTagList[pickedId]); } return(DungeonBaseData.isoTagList[DungeonBaseData.isoTagList.Count - 1]); }
public void GenBoss(List <IdWeight> landMonsterId, List <IdWeight> waterMonsterId, int buff, System.Random rand, bool isTaskDungeon) { List <IdWeight> monsterList = new List <IdWeight> (); if (VFVoxelWater.self != null) { if (VFVoxelWater.self.IsInWater(pos)) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 1, 0))) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 4, 0))) { monsterList = waterMonsterId; } else { return; } } else { monsterList = landMonsterId; } } else { monsterList = landMonsterId; } } if (monsterList == null || monsterList.Count == 0) { return; } List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, monsterList, 1); MonsterEntityCreator.CreateDungeonMonster(pickedIdList[0], pos, RandomDungenMgrData.DungeonId, buff); // if(PeGameMgr.IsSingle&&monster!=null){ // PESkEntity mp = monster.GetComponent<PESkEntity>(); // mp.deathEvent+=RandomDungenMgr.Instance.OpenLockedDoor; // RandomDungenMgrData.AddMonster(monster); // //--to do add monsterBuff // if(buff!=0) // SkillSystem.SkEntity.MountBuff(monster.skEntity, buff, new List<int>(), new List<float>()); // } }
void InstantiateEntrance(Vector3 genPos, int level = -1) { if (level == -1) { level = RandomDunGenUtil.GetEntranceLevel(genPos); } DungeonBaseData bd = RandomDungeonDataBase.GetDataFromLevel(level); if (bd != null) { if (PeGameMgr.IsSingle) { GenDunEntrance(genPos, bd); } else { PlayerNetwork.mainPlayer.RequestGenDunEntrance(genPos, bd.id); } } }
public bool IsTerrainAvailable(IntVector2 GenPos, out Vector3 pos) { if (!VFDataRTGen.IsDungeonEntranceAvailable(GenPos)) { pos = Vector3.zero; return(false); } // int y = VFDataRTGen.GetPosHeight(GenPos,true); // // pos = new Vector3(GenPos.x,y+4,GenPos.y); // RaycastHit hit; // if (Physics.Raycast(pos, Vector3.down, out hit, 512, 1 << Pathea.Layer.VFVoxelTerrain)) // { // pos.y = hit.point.y; // }else{ // return false; // } bool result = RandomDunGenUtil.GetAreaLowestPos(GenPos, 10, out pos); return(result); }
public void GenBoss(List <IdWeight> landMonsterId, List <IdWeight> waterMonsterId, int buff, System.Random rand, bool isTaskDungeon) { List <IdWeight> monsterList = new List <IdWeight> (); if (VFVoxelWater.self != null) { if (VFVoxelWater.self.IsInWater(pos)) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 1, 0))) { if (VFVoxelWater.self.IsInWater(pos + new Vector3(0, 4, 0))) { monsterList = waterMonsterId; } else { return; } } else { monsterList = landMonsterId; } } else { monsterList = landMonsterId; } } if (monsterList == null || monsterList.Count == 0) { return; } List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, monsterList, 1); MonsterEntityCreator.CreateDungeonMonster(pickedIdList[0], pos, RandomDungenMgrData.DungeonId, buff); // if(PeGameMgr.IsSingle&&monster!=null&&buff!=0) // SkillSystem.SkEntity.MountBuff(monster.skEntity, buff, new List<int>(), new List<float>()); }
public float UpToWaterSurface(float fx, float fy, float fz) { if (Pathea.SingleGameStory.curType == Pathea.SingleGameStory.StoryScene.PajaShip || RandomDunGenUtil.IsDungeonPosY(fy)) { float rayLen = 20; RaycastHit hit; if (Physics.Raycast(new Vector3(fx, fy + rayLen, fz), Vector3.down, out hit, rayLen, 1 << Pathea.Layer.Water)) { return(Vector3.Distance(new Vector3(fx, fy, fz), hit.point)); } return(-1); } if (Pathea.PeGameMgr.IsMulti) { if (PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId != (int)Pathea.SingleGameStory.StoryScene.MainLand) // PlayerNetwork.MainPlayer._curSceneId == (int)Pathea.SingleGameStory.StoryScene.PajaShip) { float rayLen = 20; RaycastHit hit; if (Physics.Raycast(new Vector3(fx, fy + rayLen, fz), Vector3.down, out hit, rayLen, 1 << Pathea.Layer.Water)) { return(Vector3.Distance(new Vector3(fx, fy, fz), hit.point)); } return(-1); } } int x = Mathf.RoundToInt(fx); int y = Mathf.RoundToInt(fy); int z = Mathf.RoundToInt(fz); int cx = x >> VoxelTerrainConstants._shift; int cy = y >> VoxelTerrainConstants._shift; int cz = z >> VoxelTerrainConstants._shift; int yInChunk = y & VoxelTerrainConstants._mask; int idxBase = VFVoxelChunkData.OneIndex(x & VoxelTerrainConstants._mask, 0, z & VoxelTerrainConstants._mask) << VFVoxel.c_shift; int idx = idxBase + yInChunk * VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT; while (cy < 32) //tmp use 32 insread of 92 { VFVoxelChunkData chunk = _voxels.readChunk(cx, cy, cz); if (chunk == null || chunk.DataVT.Length < VFVoxel.c_VTSize) { return(c_fWaterLvl - fy); //return -1; } if (chunk.IsHollow) { byte vol = chunk.DataVT[0]; if (vol == 255) { cy++; yInChunk = 0; idx = idxBase; continue; } if (vol == 0) { return(-1); } return(c_fWaterLvl - fy); } byte[] data = chunk.DataVT; byte cVol, dVol; while (yInChunk < VoxelTerrainConstants._numVoxelsPerAxis) { cVol = data[idx]; if (cVol < 128) { dVol = data[idx - VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT]; if (dVol < 128) { return(-1); } float fHInChunk = (128 - dVol) / (float)(cVol - dVol) + yInChunk - 1; return(((cy << VoxelTerrainConstants._shift) + fHInChunk) - fy); } yInChunk++; idx += VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT; } cy++; yInChunk = 0; idx = idxBase; } return(-1); }
public bool IsInWater(float fx, float fy, float fz) { try{ if (Pathea.SingleGameStory.curType == Pathea.SingleGameStory.StoryScene.PajaShip || RandomDunGenUtil.IsDungeonPosY(fy)) { float rayLen = 50; return(Physics.Raycast(new Vector3(fx, fy + rayLen, fz), Vector3.down, rayLen, 1 << Pathea.Layer.Water)); } if (Pathea.PeGameMgr.IsMulti) { if (PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId != (int)Pathea.SingleGameStory.StoryScene.MainLand) // PlayerNetwork.MainPlayer._curSceneId == (int)Pathea.SingleGameStory.StoryScene.PajaShip) { float rayLen = 50; return(Physics.Raycast(new Vector3(fx, fy + rayLen, fz), Vector3.down, rayLen, 1 << Pathea.Layer.Water)); } } if (_voxels == null) { return(false); } int x = Mathf.RoundToInt(fx); int y = Mathf.RoundToInt(fy); int z = Mathf.RoundToInt(fz); int cx = x >> VoxelTerrainConstants._shift; int cy = y >> VoxelTerrainConstants._shift; int cz = z >> VoxelTerrainConstants._shift; VFVoxelChunkData chunk = _voxels.readChunk(cx, cy, cz); if (chunk == null || chunk.DataVT.Length < VFVoxel.c_VTSize) { return(c_fWaterLvl > fy); //return false; } byte cVol; if (chunk.IsHollow) { cVol = chunk.DataVT[0]; if (cVol == 0) { return(false); } if (cVol == 255) { return(true); } return(c_fWaterLvl > fy); } int idx = VFVoxelChunkData.OneIndex(x & VoxelTerrainConstants._mask, y & VoxelTerrainConstants._mask, z & VoxelTerrainConstants._mask); int idxVT = idx << VFVoxel.c_shift; cVol = chunk.DataVT[idxVT]; if (cVol == 0) { return(false); } if (cVol == 255) { return(true); } byte oVol; if (cVol < 128) { oVol = chunk.DataVT[idxVT - VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT]; if (oVol >= 128) { return(((128 - oVol) / (float)(cVol - oVol) + y - 1) > fy); } oVol = chunk.DataVT[idxVT + VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT]; if (oVol >= 128) { return(((128 - cVol) / (float)(oVol - cVol) + y) < fy); } return(false); } else { oVol = chunk.DataVT[idxVT - VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT]; if (oVol < 128) { return(((128 - oVol) / (float)(cVol - oVol) + y - 1) < fy); } oVol = chunk.DataVT[idxVT + VoxelTerrainConstants.VOXEL_ARRAY_AXIS_SIZE_VT]; if (oVol < 128) { return(((128 - cVol) / (float)(oVol - cVol) + y) > fy); } return(true); } } catch { //Debug.LogError("[WATER]:error on testing IsInWater:"+fx+","+fy+","+fz); } return(false); }
BehaveResult Tick(Tree sender) { if (!GetData <Data>(sender, ref m_Data)) { return(BehaveResult.Failure); } if (entity.IsDeath()) { return(BehaveResult.Failure); } if (!IsNpc || !IsNpcFollower || IsNpcFollowerWork || IsNpcFollowerCut) { if (IsOnVCCarrier) { GetOff(); } if (IsOnRail) { GetOffRailRoute(); } SetNpcState(ENpcState.UnKnown); return(BehaveResult.Failure); } SetNpcAiType(ENpcAiType.NpcFollower); PeTrans tr = NpcMaster.peEntity.peTrans; EatSth(); if (IsSkillCast) { SetNpcState(ENpcState.UnKnown); return(BehaveResult.Failure); } if (IsMotionRunning(PEActionType.HoldShield)) { EndAction(PEActionType.HoldShield); } if (!IsOnVCCarrier && !IsOnRail && Time.time - m_Data.StartSearchGatherTime > m_Data.SearchGatherTime) { if (CanCather())//|| LootItemDropPeEntity.HasLootEntity() { return(BehaveResult.Failure); } else { m_Data.StartSearchGatherTime = Time.time; } } if (entity.isRagdoll || entity.IsDeath()) { return(BehaveResult.Running); } Vector3 targetVelocity = Vector3.zero; PassengerCmpt passengerTarget = NpcMaster.Entity.passengerCmpt; if (passengerTarget != null && passengerTarget.IsOnVCCarrier) { //玩家在载具上NPC上车选座:跟随任务NPC优先 int index = passengerTarget.drivingController.FindEmptySeatIndex(); if (index >= 0 && !IsOnVCCarrier && (index - NpcMaster.RQFollowersIndex >= 0)) { GetOn(passengerTarget.drivingController, index); MoveToPosition(Vector3.zero); } else { //等到玩家entity移动速度 if (NpcMaster != null && NpcMaster.Entity.motionMove != null) { targetVelocity = NpcMaster.Entity.motionMove.velocity; } } } else if (passengerTarget != null && passengerTarget.IsOnRail) { Railway.Route route = Railway.Manager.Instance.GetRoute(passengerTarget.railRouteId); if (route != null && route.train != null && route.train.HasEmptySeat() && !IsOnRail) { GetOn(passengerTarget.railRouteId, entity.Id, true); } else { if (NpcMaster != null && NpcMaster.Entity.motionMove != null) { targetVelocity = NpcMaster.Entity.motionMove.velocity; } } } else { //玩家不在载具上时,NPC下载具 if (passengerTarget != null && !passengerTarget.IsOnVCCarrier && IsOnVCCarrier) { GetOff(); } //下轻轨 if (passengerTarget != null && !passengerTarget.IsOnRail && IsOnRail) { GetOffRailRoute(); } if (NpcMaster != null && NpcMaster.Entity.motionMove != null) { targetVelocity = NpcMaster.Entity.motionMove.velocity; } } Vector3 avoidDir0 = Vector3.zero; Vector3 avoidDir1 = Vector3.zero; Vector3 avoidDir2 = Vector3.zero; Vector3 avoidDir3 = Vector3.zero; bool _IsnearLeague = entity.NpcCmpt.HasNearleague; bool _IsBlockBrush = AiUtil.CheckBlockBrush(entity, out avoidDir0); bool _IsnearDig = AiUtil.CheckDig(entity, NpcMaster.Entity, out avoidDir1); bool _IsDragging = AiUtil.CheckDraging(entity, out avoidDir2); bool _IsNearCreation = AiUtil.CheckCreation(entity, out avoidDir3); bool _needAvoid = _IsnearLeague || _IsnearDig || _IsBlockBrush || _IsDragging || _IsNearCreation; //bool _needAvoid0 = _IsnearDig || _IsBlockBrush || _IsDragging || _IsNearCreation; bool _Isstay = IsNpcFollowerSentry && !_needAvoid; bool _IsOnCreation = IsOnVCCarrier || IsOnRail; bool _InfirR = m_Data.InRadius(position, tr.position, 0.0f, m_Data.firRadius, true); bool _InsndR = m_Data.InRadius(position, tr.position, m_Data.firRadius, m_Data.sndRadius, true); //bool _InthdR = m_Data.InRadius(position, tr.position, m_Data.sndRadius, m_Data.thdRadius * 2.0f, true); Vector3 avoidplayer = position - tr.trans.position; Vector3 avoid0 = avoidDir0 != Vector3.zero ? position - avoidDir0 : Vector3.zero; Vector3 avoid1 = avoidDir1 != Vector3.zero ? position - avoidDir1 : Vector3.zero; Vector3 avoid2 = avoidDir2 != Vector3.zero ? position - avoidDir2 : Vector3.zero; Vector3 avoid3 = avoidDir3 != Vector3.zero ? position - avoidDir3 : Vector3.zero; Vector3 _AvoidDir = avoidplayer + avoid0 + avoid1 + avoid2 + avoid3 + existent.forward; bool _IsInSpSence = RandomDunGenUtil.IsInDungeon(entity);//(Pathea.PeGameMgr.IsAdventure && RandomDungenMgr.Instance != null && RandomDungenMgrData.dungeonBaseData != null); //|| (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsSingle && Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand) //|| (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsTutorial && Pathea.SingleGameStory.curType != Pathea.SingleGameStory.StoryScene.MainLand) //|| (Pathea.PeGameMgr.IsStory && Pathea.PeGameMgr.IsMulti && PlayerNetwork.mainPlayer != null && PlayerNetwork.mainPlayer._curSceneId != (int)Pathea.SingleGameStory.StoryScene.MainLand); //在建筑内跟随:检测头上是否有碰撞,保持和玩家的Y值差,不用找点方式寻路 bool _underBlock = PETools.PEUtil.IsUnderBlock(entity); bool _IsForwardBlock = _IsInSpSence ? false : _underBlock?PETools.PEUtil.IsForwardBlock(entity, entity.peTrans.forward, 2.0f) : false; //NPC不在载具上时跟随 if (!_IsOnCreation) { //超出跟随距离snd_thd if (!_InfirR && !_InsndR) { if (GameConfig.IsMultiMode) { if (Stucking(1.0f) || IsNpcFollowerSentry) { Vector3 fixedPos = GetFixedPosition(PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward, tr.position, -tr.forward, tr.bound.size.y); if (PEUtil.CheckErrorPos(fixedPos)) { SetPosition(fixedPos); MoveToPosition(Vector3.zero); } } else { m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); } } else { if (Stucking(1.0f) || _IsForwardBlock) // || IsNpcFollowerStand 单人放哨时 不跟随传送原地待命 || !_canPointMove { Vector3 fixedPos = GetFixedPosition(PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward, tr.position, -tr.forward, tr.bound.size.y); float dy = Mathf.Abs(tr.position.y - fixedPos.y); if (PEUtil.CheckErrorPos(fixedPos) && dy <= 3.0f) { SetPosition(fixedPos); MoveToPosition(Vector3.zero); } } else { m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); } m_Data.startPralTime = Time.time; } } //在内圈 if (_InfirR && !m_Data.InRadius(position, tr.trans.position + m_Data.Anchor, m_Data.firRadius, m_Data.sndRadius, true)) { m_Data.ResetCalculated(); m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); m_Data.startPralTime = Time.time; } bool needCdTime = _IsInSpSence ? !_InsndR : true; if (needCdTime && Time.time - m_Data.startPralTime >= m_Data.waitPralTime) { m_Data.startPralTime = Time.time; m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); m_Data.ResetCalculatedDir(); } bool _nearAnchor = IsReached(position, tr.trans.position + m_Data.Anchor, true, 2.0f); bool _InPralCdTime = Time.time - m_Data.startPralTime < m_Data.waitPralTime; bool _moveWait = _InPralCdTime && _nearAnchor && !_needAvoid; // if (!_Isstay) { if (!_needAvoid) { if (_moveWait) { if (_IsForwardBlock || Stucking(1.0f)) { if (_IsInSpSence) { m_Data.ResetCalculatedDir(); } m_Data.GetCanMoveDirtion(entity, 30.0f); if (m_Data.GetAnchorDir() != Vector3.zero) { m_Data.ResetCalculated(); m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); FaceDirection(m_Data.GetAnchorDir()); } } StopMove(); m_Data.ResetCalculated(); } else { if (_IsForwardBlock || Stucking(1.0f)) { if (_IsInSpSence) { m_Data.ResetCalculatedDir(); } m_Data.GetCanMoveDirtion(entity, 30.0f); if (m_Data.GetAnchorDir() != Vector3.zero) { m_Data.ResetCalculated(); m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); FaceDirection(m_Data.GetAnchorDir()); } StopMove(); } else { Vector3 followPos = m_Data.GetFollowPosition(tr.trans, targetVelocity); Vector3 speedPos = _underBlock ? tr.trans.position : followPos; SpeedState speed = m_Data.CalculateSpeedState(PEUtil.SqrMagnitudeH(position, speedPos)); // if (speed == SpeedState.Walk && _needAvoid) speed = SpeedState.Run; if (IsReached(position, tr.trans.position + m_Data.Anchor, false)) { //on the bridgew Vector3 pos0 = tr.trans.position + m_Data.Anchor; float Y = pos0.y - position.y; float dy = Mathf.Abs(Y); if (dy >= 1.0f) { if (Y > 0) { pos0 = PETools.PEUtil.CorrectionPostionToStand(pos0); } else { pos0 = PETools.PEUtil.CorrectionPostionToStand(pos0, 6.0f, 8.0f); } SetPosition(pos0); m_Data.ResetCalculated(); m_Data.CalculateAnchor(position, PETools.PEUtil.MainCamTransform.position, -PETools.PEUtil.MainCamTransform.forward); } } MoveToPosition(followPos, speed); } } } else { m_Data.ResetCalculated(); m_Data.CalculateAnchor(position, tr.trans.position, _AvoidDir); //Vector3 pos = _AvoidDir * 5.0f + position; MoveDirection(_AvoidDir, SpeedState.Run); } } else { StopMove(); } } //有怪物时,NPC不在载具上即退出此行为-切换为攻击 if (attackEnemy != null && !IsOnVCCarrier && !IsOnRail) { return(BehaveResult.Failure); } return(BehaveResult.Running); }
public void GenItem(List <IdWeight> idWeightList, System.Random rand, List <ItemIdCount> specifiedItems = null) { List <int> pickedIdList = RandomDunGenUtil.PickIdFromWeightList(rand, idWeightList, 1); RandomItemMgr.Instance.TryGenRareItem(pos, pickedIdList[0], rand, specifiedItems); }
public static void LoadData() { // int id=0; // for(int level=0;level<LEVEL_MAX;level++){ // DungeonBaseData dbd = new DungeonBaseData (); // dbd.id=id++; // dbd.level=level; // dbd.landMonsterId = new List<IdWeight> (); // dbd.landMonsterId.Add(new IdWeight (104,50)); // dbd.landMonsterId.Add(new IdWeight (106,50)); // dbd.waterMonsterId = new List<IdWeight> (); //// dbd.waterMonsterId.Add(new IdWeight (21,50)); // dbd.waterMonsterId.Add(new IdWeight (16,100)); // dbd.monsterAmount =0.1f+level*0.05f; // dbd.monsterBuff =1; // dbd.itemId = new List<IdWeight> (); // dbd.itemId.Add(new IdWeight (76,50)); // dbd.itemId.Add(new IdWeight (80,50)); // dbd.itemAmount = 0.1f+level*0.05f; // dbd.rareItemId=new List<IdWeight> (); // dbd.rareItemId.Add(new IdWeight (71,50)); // dbd.rareItemId.Add(new IdWeight (74,50)); // dungeonData.Add(dbd.id,dbd); // if(!levelId.ContainsKey(level)) // levelId[level]= new List<int> (); // levelId[level].Add(dbd.id); // } SqliteDataReader reader = LocalDatabase.Instance.ReadFullTable("Rdungeon_monster_item"); while (reader.Read()) { DungeonBaseData dbd = new DungeonBaseData(); dbd.id = Convert.ToInt32(reader.GetString(reader.GetOrdinal("id"))); dbd.level = Convert.ToInt32(reader.GetString(reader.GetOrdinal("level"))); dbd.landMonsterId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("landmonsterid"))); dbd.waterMonsterId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("watermonsterid"))); dbd.monsterAmount = Convert.ToSingle(reader.GetString(reader.GetOrdinal("monsteramount"))); dbd.monsterBuff = Convert.ToInt32(reader.GetString(reader.GetOrdinal("monsterbuff"))); dbd.bossId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("bossid"))); dbd.bossWaterId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("bosswaterid"))); dbd.bossMonsterBuff = Convert.ToInt32(reader.GetString(reader.GetOrdinal("bossbuff"))); dbd.minBossId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("minbossid"))); dbd.minBossWaterId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("minbosswaterid"))); dbd.minBossMonsterBuff = Convert.ToInt32(reader.GetString(reader.GetOrdinal("minbossbuff"))); dbd.itemId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("itemid"))); dbd.itemAmount = Convert.ToSingle(reader.GetString(reader.GetOrdinal("itemamount"))); dbd.rareItemId = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("rareitemid"))); dbd.rareItemChance = Convert.ToSingle(reader.GetString(reader.GetOrdinal("rareitemchance"))); dbd.specifiedItems = ItemIdCount.ParseStringToList(reader.GetString(reader.GetOrdinal("specifieditems"))); dbd.dungeonFlowPath = reader.GetString(reader.GetOrdinal("dungeonflowpath")); dbd.type = Convert.ToInt32(reader.GetString(reader.GetOrdinal("type"))); dbd.rareItemTags = RandomDunGenUtil.GetIdWeightList(reader.GetString(reader.GetOrdinal("rareItemtags"))); dungeonData.Add(dbd.id, dbd); if (!levelId.ContainsKey(dbd.level)) { levelId[dbd.level] = new List <int> (); } levelId[dbd.level].Add(dbd.id); } DungeonBaseData.InitIsoTagList(); }
//task public void GenTaskEntrance(IntVector2 genXZ, int level = -1) { Vector3 genPos = RandomDunGenUtil.GetPosOnGround(genXZ); InstantiateEntrance(genPos, level); }