public static void Start() { FrameCount = 0; Object.Reset(); isPaused = false; isPlaying = true; MainLoop(); }
private static void PerformFrame() { ++FrameCount; if (isPlayingSnapshot) { if (FrameCount == allSnapshots.Count + 1) { End(); return; } List <Snapshot> snapshots; if (allSnapshots.TryGetValue(FrameCount, out snapshots)) { foreach (var snapshot in snapshots) { Object obj = Object.GetById(snapshot.ObjectId); if (obj != null) { obj.Load(snapshot); } else { int playerNumber = snapshot.GetInt("PlayerNumber"); var unit = UnitFactory.Create(0, playerNumber); entities.Add(unit); unit.Load(snapshot); } } } } else { SpawnUnits(); Logic(); //Combat(); Physics(); var snapshots = TakeSnapShot(); allSnapshots.Add(FrameCount, snapshots); } UpdateEvent(); }
private static void Physics() { for (int i = 0; i < entities.Count; i++) { //entities[i].PhysicsUpdate(); IMoveComponent mover = entities[i].GetComponent <IMoveComponent>(); if (mover != null) { ITargetDetector targetDetector = entities[i].GetComponent <ITargetDetector>(); if (targetDetector.Target == Object.NoId) { continue; } IEntity target = (IEntity)Object.GetById(targetDetector.Target); mover.MoveTowards(target.PositionX, target.PositionY); } } // TODO: Resolve physics. }