Example #1
0
        public IEnumerable <int> RegenerateEntry()
        {
            const int regenerateBase     = 3000;
            const int regenerateInterval = 5000;

            while (true)
            {
                if (_spawnedCount < _context.Data.World.Config.maxNpcCount)
                {
                    Interlocked.Increment(ref _spawnedCount);

                    // Npc를 새로 만들고, 주변에 알려준다.
                    var newNpc = _context.NewGameObject(ObjectType.Npc);
                    _context.AddGameObject(newNpc);
                    _context.BroadcastPacket(newNpc.ToSpawnPacket());
                    Logger.Write("Npc[{0}] is spawned!", newNpc.Name);

                    // NpcAi를 생성하고, Coroutine에 등록한다.
                    var newAi = new EachAi(this, newNpc);
                    _context.AddEntry(newAi.AiLogicEntry);
                }

                var nextInterval = _random.Next(regenerateInterval) + regenerateBase;
                yield return(nextInterval);
            }
        }
Example #2
0
        public void Restore(GameObject npc)
        {
            var newAi = new EachAi(this, npc);

            _context.AddEntry(newAi.AiLogicEntry);

            ++_spawnedCount;
        }