void SetupAudioController(IntVector4 node) { Vector3 position = node.ToVector3(); position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w), 0.0f, Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w)); int height = VoxelTerrainConstants._numVoxelsPerAxis << node.w; RaycastHit hitInfo; if (Physics.Raycast(position + Vector3.up * height, Vector3.down, out hitInfo, height, GameConfig.GroundLayer)) { float waterHeight; if (PETools.PEUtil.GetWaterSurfaceHeight(hitInfo.point, out waterHeight)) { position = hitInfo.point + Vector3.up * Random.Range(0.0f, waterHeight - hitInfo.point.y); } else { position = hitInfo.point + Vector3.up * Random.Range(0.5f, 5.0f); } int sid = AISpawnDataStory.GetEnvMusicID(GetMapID(position)); Transform parent = mAudioPoint != null ? mAudioPoint.transform : null; AudioController ctrl = AudioManager.instance.Create(position, sid, parent, false, false); envSounds.Add(ctrl); } }
IEnumerator Spawn(PlayerSleepData data) { while (true) { if (IsPlayerSleeping(data)) { Vector3 position = Vector3.zero; //GetSpawnPosition( //PlayerFactory.mMainPlayer.transform.position, //data.minRadius, //data.maxRadius); Quaternion rot = Quaternion.identity; //Quaternion.LookRotation(PlayerFactory.mMainPlayer.transform.position - position, Vector3.up); int pathID = 0; int typeID = (int)AiUtil.GetPointType(position); if (Application.loadedLevelName.Equals(GameConfig.MainSceneName)) { pathID = AISpawnDataStory.GetRandomPathIDFromType(typeID, position); } else if (Application.loadedLevelName.Equals(GameConfig.AdventureSceneName)) { int mapID = AiUtil.GetMapID(position); int areaID = AiUtil.GetAreaID(position); pathID = AISpawnDataAdvSingle.GetPathID(mapID, areaID, typeID); } AIResource.Instantiate(pathID, position, rot, OnSleepSpawned); } yield return(new WaitForSeconds(data.interval)); } }
protected override int GetCurrentBgMusicID() { Vector3 camPos = PETools.PEUtil.MainCamTransform.position; if (AiUtil.CheckPositionInCave(camPos, 128.0f, AiUtil.groundedLayer)) { return(836); } int x = (int)camPos.x; int z = (int)camPos.z; if (x <= Int32.MinValue) { Debug.LogError("x value too small!"); x = Int32.MinValue + 1; } if (z <= Int32.MinValue) { Debug.LogError("z value too small!"); z = Int32.MinValue + 1; } if (VFDataRTGen.IsSea(x, z)) { return(AISpawnDataStory.GetBackGroundMusic(new Color(255.0f / 255.0f, 100.0f / 255.0f, 150.0f / 255.0f, 255 / 255.0f))); } else { RandomMapType mapType = VFDataRTGen.GetXZMapType(x, z); switch (mapType) { case RandomMapType.GrassLand: return(AISpawnDataStory.GetBackGroundMusic(new Color(30.0f / 255.0f, 50.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Forest: return(AISpawnDataStory.GetBackGroundMusic(new Color(70.0f / 255.0f, 70.0f / 255.0f, 70.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Desert: return(AISpawnDataStory.GetBackGroundMusic(new Color(140.0f / 255.0f, 100.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Redstone: return(AISpawnDataStory.GetBackGroundMusic(new Color(170.0f / 255.0f, 70.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Rainforest: return(AISpawnDataStory.GetBackGroundMusic(new Color(90.0f / 255.0f, 90.0f / 255.0f, 90.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Mountain: return(AISpawnDataStory.GetBackGroundMusic(new Color(170.0f / 255.0f, 70.0f / 255.0f, 150.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Swamp: return(AISpawnDataStory.GetBackGroundMusic(new Color(100.0f / 255.0f, 50.0f / 255.0f, 50.0f / 255.0f, 255 / 255.0f))); case RandomMapType.Crater: return(AISpawnDataStory.GetBackGroundMusic(new Color(180.0f / 255.0f, 180.0f / 255.0f, 180.0f / 255.0f, 255 / 255.0f))); default: return(0); } } }
protected override int GetCurrentBgMusicID() { Vector3 camPos = PETools.PEUtil.MainCamTransform.position; if (AiUtil.CheckPositionInCave(camPos, 128.0f, AiUtil.groundedLayer)) { return(836); } Vector2 pos = new Vector2(camPos.x, camPos.z); return(AISpawnDataStory.GetBgMusicID(PeMappingMgr.Instance.GetAiSpawnMapId(pos))); }
static int GetMonsterProtoID(Vector3 pos, ref float fScale) { int pathID = 0, typeID = 0; typeID = (int)AiUtil.GetPointType(pos); if (PeGameMgr.IsStory) { int mapid = PeMappingMgr.Instance.GetAiSpawnMapId(new Vector2(pos.x, pos.z)); pathID = AISpeciesData.GetRandomAI(AISpawnDataStory.GetAiSpawnData(mapid, typeID)); } else if (PeGameMgr.IsAdventure) { int mapID = AiUtil.GetMapID(pos); int areaID = AiUtil.GetAreaID(pos); pathID = AISpawnDataAdvSingle.GetPathIDScale(mapID, areaID, typeID, ref fScale); } return(pathID); }
void SetupEffect(IntVector4 node) { Vector3 position = node.ToVector3(); position += new Vector3(Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w), 0.0f, Random.Range(0.0f, VoxelTerrainConstants._numVoxelsPerAxis << node.w)); int height = VoxelTerrainConstants._numVoxelsPerAxis << node.w; RaycastHit hitInfo; if (Physics.Raycast(position + Vector3.up * height, Vector3.down, out hitInfo, height, GameConfig.GroundLayer)) { float waterHeight; int type1 = -1; int type2 = -1; if (PETools.PEUtil.GetWaterSurfaceHeight(hitInfo.point, out waterHeight)) { if (Random.value < 0.3f) { type1 = 0; position = new Vector3(hitInfo.point.x, waterHeight, hitInfo.point.z); } else { type1 = 1; position = hitInfo.point + Vector3.up * Random.Range(0.0f, waterHeight - hitInfo.point.y); } } else { type1 = 2; position = hitInfo.point + Vector3.up * Random.Range(0.5f, 5.0f); } type2 = CalculateType(position); int effectID = AISpawnDataStory.GetEnvEffectID(GetMapID(position), type1, type2); Transform parent = mEffectPoint != null ? mEffectPoint.transform : null; EffectBuilder.EffectRequest req = EffectBuilder.Instance.Register(effectID, null, position, Quaternion.identity, parent); req.SpawnEvent += OnEffectSpawned; } }
int GetPathIDStory() { return(AISpawnDataStory.GetRandomPathIDFromType(typeID, position)); }