コード例 #1
0
ファイル: World.cs プロジェクト: MatthewGoff/ADangerousLand
        /*
         * Transition a chunk from its state in the last fixed update to its state
         * in this fixed update. If there has been a change of state execute the
         * appropriate logic.
         */
        private void TransitionChunkState(Chunk chunk)
        {
            if (chunk.NextState != chunk.State)
            {
                if (chunk.NextState == ChunkState.Occupied)
                {
                    if (!chunk.InitializingLocality && !chunk.LocalityInitialized)
                    {
                        chunk.InitializingLocality = true;
                        WorldInitializer newInitializer = new WorldInitializer
                        {
                            World      = this,
                            ChunkIndex = chunk.ChunkIndex,
                        };
                        WorldInitializers.Enqueue(newInitializer);
                    }
                }
                if (chunk.NextState == ChunkState.Inactive)
                {
                    chunk.Sleep();
                }
                if (chunk.NextState == ChunkState.SpawningGrounds)
                {
                    chunk.WakeEnemies();
                    chunk.SpawnEnemies();
                }

                chunk.State = chunk.NextState;
            }
        }
コード例 #2
0
ファイル: World.cs プロジェクト: MatthewGoff/ADangerousLand
 private void UpdateWorldInitializers()
 {
     if (WorldInitializers.Count != 0)
     {
         WorldInitializer currentInitializer = WorldInitializers.Peek();
         currentInitializer.Update();
         if (currentInitializer.IsDone)
         {
             WorldInitializers.Dequeue();
         }
         else if (!currentInitializer.IsRunning)
         {
             currentInitializer.Start();
         }
     }
 }