private static void SpawnAIPlayerFor(AISpawnPoint spawnPoint) { if (AIPlayerExistsFor(spawnPoint)) { Debug.LogWarning("Could not spawn AI player for: " + spawnPoint); return; } BattlePlayer battlePlayer = ObjectPoolManager.Create <BattlePlayer>(GamePrefabs.Instance.PlayerPrefab, spawnPoint.transform.position, Quaternion.identity, parent: ArenaManager.Instance.LoadedArena.GameObject); // spawn player with substitute AI GameConstants.Instance.ConfigureWithSubstitutePlayerAI(battlePlayer); battlePlayer.SetSkin(GameConstants.Instance.EnemySkin); RecyclablePrefab recyclablePrefab = battlePlayer.GetComponent <RecyclablePrefab>(); Action <RecyclablePrefab> onCleanupCallback = null; onCleanupCallback = (RecyclablePrefab unused) => { recyclablePrefab.OnCleanup -= onCleanupCallback; RemovePlayer(spawnPoint); }; recyclablePrefab.OnCleanup += onCleanupCallback; spawnPointMap_[spawnPoint] = battlePlayer; }
void LoadStaticSpawnPoints() { if (Application.loadedLevelName.Equals(GameConfig.MainSceneName)) { GameObject obj = new GameObject("StaticPoints"); obj.transform.parent = transform; foreach (KeyValuePair <int, AISpawnPoint> pair in AISpawnPoint.s_spawnPointData) { AISpawnPoint point = pair.Value; point.spPoint = SPPoint.InstantiateSPPoint <SPPoint>(point.Position, Quaternion.Euler(point.euler), IntVector4.Zero, obj.transform, 0, point.resId, point.isActive, false, false, false, false, null, point.OnSpawned); point.spPoint.name = ("Static id = " + point.id + " , " + "path id = " + point.resId + " : ") + point.spPoint.name; } } }
void LoadStaticPoints(IntVector4 node) { List <SPPoint> spawnPoints = AISpawnPoint.GetPoints(node); foreach (SPPoint point in spawnPoints) { point.index = nextIndex; RegisterSPPoint(point); } }
private static void RemovePlayer(AISpawnPoint spawnPoint) { spawnPointMap_.Remove(spawnPoint); if (ShouldRespawn) { respawnCoroutines_.Add(CoroutineWrapper.DoAfterDelay(kRespawnDelay, () => { SpawnAIPlayerFor(spawnPoint); })); } }
void Awake() { instance = this; mNoise = new SimplexNoise((long)(RandomMapConfig.RandomMapID + RandomMapConfig.RandSeed)); if (Application.loadedLevelName.Equals(GameConfig.MainSceneName)) { AISpawnPoint.Reset(); LoadStaticSpawnPoints(); } }
public void Fill(int cntNpc, int cntMonster) { Vector3 center = RectIdxToCenterPos(_idx); bool bAvailable = false; SceneEntityPosAgent agent; System.Random rand = new System.Random(); for (int i = 0; i < cntNpc; i++) { Vector3 point = !PeGameMgr.randomMap ? GetEntityPoint(center, out bAvailable) : GetNpcPointInRndTer(center, out bAvailable); if (bAvailable) { if (VFDataRTGen.IsTownConnectionType(Mathf.RoundToInt(point.x), Mathf.RoundToInt(point.z))) { agent = NpcEntityCreator.CreateAgent(point); agent.spInfo = _rndNpcAgentInfo; _posRndNpcAgents.Add(agent); // npc entity would not be destroyed by scene } else { if (rand.NextDouble() < 0.25) { agent = NpcEntityCreator.CreateAgent(point); agent.spInfo = _rndNpcAgentInfo; _posRndNpcAgents.Add(agent); // npc entity would not be destroyed by scene } } } } for (int i = 0; i < cntMonster; i++) { Vector3 point = GetEntityPoint(center, out bAvailable); if (bAvailable && null == AIErodeMap.IsInErodeArea2D(point)) { _posRndMonsterAgents.Add(MonsterEntityCreator.CreateAgent(point)); } } SceneMan.AddSceneObjs(_posRndNpcAgents); SceneMan.AddSceneObjs(_posRndMonsterAgents); if (PeGameMgr.IsStory) { _posFixedMonsterIds = AISpawnPoint.Find(center.x - EntityCreationRadius, center.z - EntityCreationRadius, center.x + EntityCreationRadius, center.z + EntityCreationRadius); if (_posFixedMonsterIds.Count > 0) { SceneEntityCreatorArchiver.Instance.AddFixedSpawnPointToScene(_posFixedMonsterIds); } } else if (PeGameMgr.IsSingleAdventure) { SceneEntityPosRect.AddProcedualBossSpawnPointToScene(_idx); } }
private void Init4FixedSpawnPoint() { foreach (KeyValuePair <int, AISpawnPoint> pair in AISpawnPoint.s_spawnPointData) { AISpawnPoint pt = pair.Value; int protoId = pt.resId; if (pt.isGroup) { protoId |= EntityProto.IdGrpMask; } FixedSpawnPointInfo info = new FixedSpawnPointInfo(); info._bActive = pt.active; info._needCD = pt.refreshtime; info._agent = MonsterEntityCreator.CreateAgent(pt.Position, protoId, Vector3.one, Quaternion.Euler(pt.euler)); info._agent.spInfo = new AgentInfo(pair.Key); info._agent.FixPos = pt.fixPosition; _fixedSpawnPointInfos[pair.Key] = info; } }
private static bool AIPlayerExistsFor(AISpawnPoint spawnPoint) { return(spawnPointMap_.ContainsKey(spawnPoint)); }