コード例 #1
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
        private void LogPositions(double time)
        {
            if (world.LoggingPositionObjectIds.Count == 0)
            {
                return;
            }


            Debugger.Log("Logging positions at " + CurrentTime);
            var engine = world.GetEngine <ICommonEngine>();
            var data   = world.LoggingPositionObjectIds
                         .Where(z => engine.ContainBody(z))
                         .ToDictionary(z => z, z => engine.GetAbsoluteLocation(z));

            var entry = new GameLogEntry
            {
                Time = CurrentTime,
                Type = GameLogEntryType.LocationCorrection,
                LocationCorrection = new LocationCorrectionLogEntry
                {
                    Locations = data
                }
            };

            AddEntry(entry);
        }
コード例 #2
0
        private void Play(GameLogEntry obj)
        {
            if (obj.Type == GameLogEntryType.EngineInvocation)
            {
                if (obj.EngineInvocation == null)
                {
                    throw new Exception("Line type is EngineInvocation, but the section EngineInvokation was empty");
                }
                if (!engines.ContainsKey(obj.EngineInvocation.EngineName))
                {
                    throw new Exception("Can not find engine with a name " + obj.EngineInvocation.EngineName);
                }
                var method = engines[obj.EngineInvocation.EngineName].GetType().GetMethod(obj.EngineInvocation.MethodName);
                if (method == null)
                {
                    throw new Exception("Can not find method " + obj.EngineInvocation.MethodName + " in the engine " + obj.EngineInvocation.EngineName);
                }
                object[] arguments = ParseArguments(obj.EngineInvocation.MethodName, obj.EngineInvocation.Arguments, method.GetParameters());
                method.Invoke(engines[obj.EngineInvocation.EngineName], arguments);
            }

            if (obj.Type == GameLogEntryType.LocationCorrection)
            {
                if (obj.LocationCorrection == null)
                {
                    throw new Exception("Line type is LocationCorrection, but the section LocationCorrection was empty");
                }
                foreach (var e in obj.LocationCorrection.Locations)
                {
                    if (!commonEngine.ContainBody(e.Key))
                    {
                        throw new Exception("Location update is defined for " + e.Key + " but it is absent at the map");
                    }
                    else
                    {
                        commonEngine.SetAbsoluteLocation(e.Key, e.Value);
                    }
                }
            }

            if (obj.Type == GameLogEntryType.ScoresUpdate)
            {
                if (obj.ScoresUpdate == null)
                {
                    throw new Exception("Line type is ScoresUpdate, but the section ScoresUpdate was empty");
                }

                ScoreProvider.UpdateScores(obj.ScoresUpdate);
            }
        }
コード例 #3
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
        public void AddOutgoingSensorData(string controllerId, object sensorData)
        {
            var entry = new GameLogEntry
            {
                Time = CurrentTime,
                Type = GameLogEntryType.OutgoingSensorData,
                OutgoingSensorData = new OutgoingSensorDataCommandLogEntry
                {
                    ControllerId = controllerId,
                    SensorData   = JObject.FromObject(sensorData)
                }
            };

            AddEntry(entry);
        }
コード例 #4
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
        public void AddIncomingCommand(string controllerId, object command)
        {
            var entry = new GameLogEntry
            {
                Time            = CurrentTime,
                Type            = GameLogEntryType.IncomingCommand,
                IncomingCommand = new IncomingCommandLogEntry
                {
                    Command      = JObject.FromObject(command),
                    ControllerId = controllerId
                }
            };

            AddEntry(entry);
        }
コード例 #5
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
        public void AddMethodInvocation(Type engine, string method, params object[] arguments)
        {
            var entry = new GameLogEntry
            {
                Time             = CurrentTime,
                Type             = GameLogEntryType.EngineInvocation,
                EngineInvocation = new EngineInvocationLogEntry
                {
                    EngineName = engine.Name,
                    MethodName = method,
                    Arguments  = arguments.Select(z => z.ToString()).ToArray()
                }
            };

            AddEntry(entry);
        }
コード例 #6
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
        private void Scores_ScoresChanged(string controllerId, int count, string reason, string type, int total)
        {
            var entry = new GameLogEntry
            {
                Time         = CurrentTime,
                Type         = GameLogEntryType.ScoresUpdate,
                ScoresUpdate = new ScoresUpdate
                {
                    ControllerId = controllerId,
                    Added        = count,
                    Reason       = reason,
                    Total        = total,
                    Type         = type,
                }
            };

            AddEntry(entry);
        }
コード例 #7
0
ファイル: LogWriter.cs プロジェクト: FoKycHuK/CVARC
 private void AddEntry(GameLogEntry entry)
 {
     log.Add(entry);
 }