예제 #1
0
파일: AreaMap.cs 프로젝트: Gvin/CodeMagic
        public void Update(ITurnProvider turnProvider)
        {
            objectPositionCache.Clear();

            using (PerformanceMeter.Start($"Map_UpdateCells_Early[{turnProvider.CurrentTurn}]"))
            {
                UpdateCells(UpdateOrder.Early);
            }

            mapLightLevelProcessor.ResetLightLevel(this);
            mapLightLevelProcessor.UpdateLightLevel(this);

            using (PerformanceMeter.Start($"Map_UpdateCells_Medium[{turnProvider.CurrentTurn}]"))
            {
                UpdateCells(UpdateOrder.Medium);
            }

            using (PerformanceMeter.Start($"Map_UpdateCells_Late[{turnProvider.CurrentTurn}]"))
            {
                UpdateCells(UpdateOrder.Late);
            }

            using (PerformanceMeter.Start($"Map_PostUpdateCells[{turnProvider.CurrentTurn}]"))
            {
                PostUpdateCells();
            }
        }
예제 #2
0
        public void SaveGame()
        {
            var turn = CurrentGame.Game.CurrentTurn;

            Log.Debug($"Saving started on turn {turn}");

            SaveData gameData;
            SaveData dataData;

            using (PerformanceMeter.Start($"Saving_GetSaveData[{turn}]"))
            {
                var gameDataBuilder = CurrentGame.Game.GetSaveData();
                gameData = gameDataBuilder.ConvertRawData(new JsonDataSerializer());
                var dataDataBuilder = GameData.Current.GetSaveData();
                dataData = dataDataBuilder.ConvertRawData(new JsonDataSerializer());
            }

            var gameSaveData = new GameSaveData
            {
                Version = GetGameVersion(),
                Game    = gameData,
                Data    = dataData
            };

            string json;

            using (PerformanceMeter.Start($"Saving_Serialization[{turn}]"))
            {
                json = JsonConvert.SerializeObject(gameSaveData);
            }

            using (PerformanceMeter.Start($"Saving_Writing[{turn}]"))
            {
                WriteSaveFile(json);
            }

            Log.Debug("Saving finished");
        }
예제 #3
0
        //TODO Отображение данных на графике.
        private void AddToChart(DateTime time)
        {
            PerformanceMeter.Start(string.Format("Время обновления {0} графиков", _graphSignals.Count));
            var rnd = new Random();

            foreach (var pair in _graphSignals)
            {
                //Берём значение параметра из таблицы
                pair.Value.Value = rnd.NextDouble(pair.Value.Min, pair.Value.Max);
                //pair.Value.Value = _values[pair.Key];
                //На график передаём нормированное.
                double value = pair.Value.Normal;
                //Если это реактивность
                if (pair.Key.Equals(Program.R1) ||
                    pair.Key.Equals(Program.R2))
                {
                    //То передаём абсолютное значение.
                    value = pair.Value.Value;
                }
                var mv = new MonitorValue(time, value, pair.Value.Max, pair.Value.Min);
                graphChart1.AddValue(mv, pair.Key);
            }
            PerformanceMeter.Stop();
        }