Пример #1
0
        public LogicState RunLogicStep(LogicState state)
        {
            Logger.Write($"Turn number {state.TurnNumber}");

            if (!state.IsInitialized)
            {
                var random = new Random(123);
                state.Map = new Map2D <int>(500, 500);
                for (var y = 0; y < state.Map.Height; y++)
                {
                    for (var x = 0; x < state.Map.Width; x++)
                    {
                        state.Map[x, y] = random.Next(1, 4);
                    }
                }

                state.IsInitialized = true;
            }

            state.TurnNumber++;

            Commands.Wait();

            return(state);
        }
Пример #2
0
        public void Draw(LogicState state, DrawingWindowState drawingWindowState)
        {
            _stopwatch.Restart();

            using (Bitmap.GetBitmapContext())
            {
                Bitmap.Clear();

                var renderer = new MapRenderer(16, 16);

                renderer.Render(state.Map, Bitmap, ImageProvider, drawingWindowState);
            }

            var elapsed = _stopwatch.ElapsedMilliseconds;

            if (elapsed > 150)
            {
                Logger.Write($"Drawing takes {elapsed}ms! Consider disabling it!");
            }
        }
Пример #3
0
 public void UpdateGraph(LogicState state)
 {
 }
Пример #4
0
        public static void Save(LogicState state, string serverName)
        {
            var json = state.ToJson();

            File.WriteAllText($@"logic-{serverName}.json", json);
        }