internal VideoTexture(string videoFile, SkinSource source, Clocks clock) { this.clock = clock; videoFile = GeneralHelper.PathSanitise(videoFile); byte[] videoBytes = null; if ((source & SkinSource.Skin) > 0) { string filename = Path.Combine(SkinManager.Current.FullPath, videoFile.IndexOf('.') < 0 ? videoFile + @".mp4" : videoFile); videoBytes = GetFileBytes(filename); } if (videoBytes == null && (source & SkinSource.Osu) > 0) { videoBytes = (byte[])osu_ui.ResourcesStore.ResourceManager.GetObject(videoFile); } if (videoBytes == null && (source & SkinSource.Beatmap) > 0) { videoBytes = BeatmapManager.Current.GetFileBytes(videoFile); } vd = new VideoDecoder(clock == Clocks.Game ? 4 : (int)(AudioEngine.CurrentPlaybackRate / 100f * 4)); if (!vd.Open(videoBytes)) { return; } width = vd.width; height = vd.height; videoTextures = new pTexture[FRAME_BUFFER]; Initialize(); length = (int)vd.Length; }
void Start() { clocks = GameObject.Find("GameManager").GetComponent <Clocks>(); if (crop.type == Crop.Type.grain) { stems = new GameObject[gameObject.transform.childCount]; for (int i = 0; i < gameObject.transform.childCount; i++) { stems[i] = gameObject.transform.GetChild(i).gameObject; } } else if (crop.type == Crop.Type.vegetable) { phases = new GameObject[gameObject.transform.childCount]; { for (int i = 0; i < phases.Length; i++) { phases[i] = gameObject.transform.GetChild(i).gameObject; } } phaseCount = phases.Length - 1; phaseBorder = maxGrow / phaseCount; currentPhase = 1; DisableAllChildrensActivateOne(0); } }
internal static (GameState next, bool isValid) PerformAction(GameState gameState, GameAction action) { return(action switch { AddClockAction addClock when addClock.TotalTicks > 0 && !gameState.Clocks.ContainsKey(addClock.ClockName) => (gameState with { Clocks = gameState.Clocks.Add(addClock.ClockName, new GameClock(CurrentTicks: 0, TotalTicks: addClock.TotalTicks)) }, true), TickClockAction tick when gameState.Clocks.TryGetValue(tick.ClockName, out var clock) => ( gameState with { Clocks = gameState.Clocks .SetItem(tick.ClockName, clock with { CurrentTicks = Math.Clamp(clock.CurrentTicks + tick.TickCount, 0, clock.TotalTicks) }) }, true ), RemoveClockAction { ClockName : var clockName } when gameState.Clocks.ContainsKey(clockName) => (gameState with { Clocks = gameState.Clocks.Remove(clockName) }, true), RenameClockAction rename when gameState.Clocks.TryGetValue(rename.OldClockName, out var clock) => (gameState with { Clocks = gameState.Clocks.Remove(rename.OldClockName).Add(rename.NewClockName, clock) }, true), _ => (gameState, false) });
public void AddClock(ClockInfo info) { if (!Clocks.Contains(info)) { Clocks.Add(info); } }
public override void CreateWorld() { Debugger.Log("Starting seed: " + WorldState.Seed); CommonEngine = GetEngine <ICommonEngine>(); HommEngine = GetEngine <IHommEngine>(); Random = new Random(WorldState.Seed); var map = WorldState.Debug? new MapGeneratorHelper().CreateDebugMap(Random) : new MapGeneratorHelper().CreateMap(Random); Players = players.Select(pid => CreatePlayer(pid, map)).ToArray(); Round = new Round(map, Players); HommObjectsCreationHelper = new HommObjectsCreationHelper(Random, HommEngine); var uiEngine = GetEngine <IHommUserInterfaceEngine>(); var roundConnecter = new RoundToUnityConnecter(HommEngine, CommonEngine, uiEngine, HommObjectsCreationHelper); roundConnecter.Connect(Round); foreach (var player in Players) { Round.Update(player, player.Location); } Clocks.AddTrigger(new TimerTrigger(_ => Round.DailyTick(), HommRules.Current.DailyTickInterval)); }
void InitializeActor(Competitions competitions, string id, ActorFactory factory, Func <string, IActor, IController> controllerFactory) { Debugger.Log("Actor " + id + " initialization"); Debugger.Log("Creating actor"); //var factory = competitions.Logic.Actors[id]; var e = factory.CreateActor(); var actorObjectId = IdGenerator.CreateNewId(e); Debugger.Log("Complete: actor. Creating manager"); //var manager = competitions.Manager.CreateActorManagerFor(e); var rules = factory.CreateRules(); var preprocessor = factory.CreateCommandFilterSet(); e.Initialize(/*manager, */ this, rules, preprocessor, actorObjectId, id); Debugger.Log("Comlete: manager creation. Initializing manager"); Compatibility.Check <IActor>(this, e); Debugger.Log("Comlete: manager initialization. Creating actor body"); Debugger.Log("Complete: body. Starting controller"); var controller = controllerFactory(e.ControllerId, e); controller.Initialize(e); var controlTrigger = new ControlTrigger(controller, e, preprocessor); e.ControlTrigger = controlTrigger; Clocks.AddTrigger(controlTrigger); actors.Add(e); Debugger.Log("Actor " + id + " is initialized"); }
public void AddNode(Clocks node) { if (!(_clocks.Contains (node) || _clocks.Contains (node.PartnerNode))) { _clocks.Add (node); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeEach void setUp() internal virtual void SetUp() { _kernelTransactions = mock(typeof(KernelTransactions)); _fakeClock = Clocks.fakeClock(); _logProvider = new AssertableLogProvider(); _logService = new SimpleLogService(_logProvider, _logProvider); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldThrowThrottleExceptionWhenMaxDurationIsReached() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldThrowThrottleExceptionWhenMaxDurationIsReached() { // given TestThrottleLock lockOverride = new TestThrottleLock(); FakeClock clock = Clocks.fakeClock(1, TimeUnit.SECONDS); TransportThrottle throttle = NewThrottleAndInstall(_channel, lockOverride, clock, Duration.ofSeconds(5)); when(_channel.Writable).thenReturn(false); // when Future <Void> future = OtherThread.execute(state => { throttle.Acquire(_channel); return(null); }); OtherThread.get().waitUntilWaiting(); clock.Forward(6, TimeUnit.SECONDS); // expect try { future.get(1, TimeUnit.MINUTES); fail("expecting ExecutionException"); } catch (ExecutionException ex) { assertThat(ex.InnerException, instanceOf(typeof(TransportThrottleException))); assertThat(ex.Message, containsString("will be closed because the client did not consume outgoing buffers for")); } }
private void SaveClock(object clockObject) { ClockViewModel cvm = clockObject as ClockViewModel; if (cvm != null) { if (cvm.editingMode) { int index = Clocks.IndexOf(cvm.selectedClock); Clocks.RemoveAt(index); Clocks.Insert(index, new ClockModel() { HeadColor = cvm.ClockHeadColor, FaceColor = cvm.ClockFaceColor, ClockTimeZone = cvm.ClockTimeZoneInfo }); UpdateDB(); } else { var newClock = new ClockModel() { HeadColor = cvm.ClockHeadColor, FaceColor = cvm.ClockFaceColor, ClockTimeZone = cvm.ClockTimeZoneInfo }; Clocks.Add(newClock); App.Database.AddClock(newClock, currentUserId); } } Back(); }
public void StartClocks(TimeSpan period) { while (true) { Clocks.Tick(period.Multiple(GameSpeedK)); Thread.Sleep(period); } }
protected pText(string text, Fields field, Origins origin, Clocks clock, Vector2 position, float depth, bool alwaysDraw, Color colour) : base(null, field, origin, clock, position) { Depth = depth; AlwaysDraw = alwaysDraw; InitialColour = colour; Alpha = InitialColour.A / 255f; }
public Button(Texture2D newTexture, GraphicsDevice graphics) { normalClocks = new Clocks(); normalClocks.InitTimer(500); muteClocks = new Clocks(); muteClocks.InitTimer(20); texture = newTexture; Size = new Vector2(graphics.Viewport.Width / 5f, graphics.Viewport.Height / 7f); }
private void GetClocksFromDB() { var list = App.Database.GetClocks(currentUserId); foreach (var item in list) { Clocks.Add(item); } }
private void InitializeInstanceFields() { _fileNames = new FileNames(_baseDirectory); _readerPool = new ReaderPool(0, Instance, _fileNames, _fsa, Clocks.fakeClock()); _fileA = spy(new SegmentFile(_fsa, _fileNames.getForVersion(0), _readerPool, 0, _contentMarshal, _logProvider, _header)); _fileB = spy(new SegmentFile(_fsa, _fileNames.getForVersion(1), _readerPool, 1, _contentMarshal, _logProvider, _header)); _segmentFiles = new IList <SegmentFile> { _fileA, _fileB }; }
public void DeleteClock(ClockInfo clock) { if (!Clocks.Contains(clock)) { return; } Clocks.Remove(clock); //NOTE: Need a way to cleanup }
internal pVideo(string filename, SkinSource source, Clocks clock, int startTime = 0) : base(null, Fields.StoryboardCentre, Origins.Centre, clock, Vector2.Zero, 0.1F, true, Color.White) { video = new VideoTexture(filename, source, clock); StartTime = (clock == Clocks.Game ? GameBase.Time : 0) + startTime; EndTime = StartTime + video.length; Width = DrawWidth = video.Width; Height = DrawHeight = video.Height; OriginPosition = new Vector2(video.Width / 2, video.Height / 2); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldHandleTheWholeWorkloadShebang() throws Throwable //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldHandleTheWholeWorkloadShebang() { // GIVEN const int size = 1_000; const long bufferTime = 3; VerifyingConsumer consumer = new VerifyingConsumer(size); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final java.time.Clock clock = org.neo4j.time.Clocks.systemClock(); Clock clock = Clocks.systemClock(); System.Func <long> chunkThreshold = clock.millis; System.Predicate <long> safeThreshold = time => clock.millis() - bufferTime >= time; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final DelayedBuffer<long> buffer = new DelayedBuffer<>(chunkThreshold, safeThreshold, 10, consumer); DelayedBuffer <long> buffer = new DelayedBuffer <long>(chunkThreshold, safeThreshold, 10, consumer); MaintenanceThread maintenance = new MaintenanceThread(buffer, 5); Race adders = new Race(); const int numberOfAdders = 20; //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final byte[] offeredIds = new byte[size]; sbyte[] offeredIds = new sbyte[size]; for (int i = 0; i < numberOfAdders; i++) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int finalI = i; int finalI = i; adders.AddContestant(() => { for (int j = 0; j < size; j++) { if (j % numberOfAdders == finalI) { buffer.Offer(j); offeredIds[j] = 1; parkNanos(MILLISECONDS.toNanos(current().Next(2))); } } }); } // WHEN (multi-threaded) offering of ids adders.Go(); // ... ensuring the test is sane itself (did we really offer all these IDs?) for (int i = 0; i < size; i++) { assertEquals("ID " + i, ( sbyte )1, offeredIds[i]); } maintenance.Halt(); buffer.Close(); // THEN consumer.AssertHaveOnlySeenRange(0, size - 1); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { this.Locks = Suite.createLockManager(Config.defaults(), Clocks.systemClock()); ClientA = this.Locks.newClient(); ClientB = this.Locks.newClient(); ClientC = this.Locks.newClient(); ClientToThreadMap[ClientA] = ThreadA; ClientToThreadMap[ClientB] = ThreadB; ClientToThreadMap[ClientC] = ThreadC; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test @Resources.Life(STARTED) public void shouldNotEndUpInBrokenStateAfterRotationFailure() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldNotEndUpInBrokenStateAfterRotationFailure() { // GIVEN FakeClock clock = Clocks.fakeClock(); CallTrackingClock callTrackingClock = new CallTrackingClock(clock); CountsTracker tracker = ResourceManager.managed(NewTracker(callTrackingClock, EmptyVersionContextSupplier.EMPTY)); int labelId = 1; using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(2).get()) { tx.IncrementNodeCount(labelId, 1); // now at 1 } // WHEN System.Predicate <Thread> arrived = thread => stackTraceContains(thread, all(classNameContains("Rotation"), methodIs("rotate"))); Future <object> rotation = Threading.executeAndAwait(t => t.rotate(4), tracker, arrived, 1, SECONDS); using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(3).get()) { tx.IncrementNodeCount(labelId, 1); // now at 2 } while (callTrackingClock.CallsToNanos() == 0) { Thread.Sleep(10); } clock.Forward(Config.defaults().get(GraphDatabaseSettings.counts_store_rotation_timeout).toMillis() * 2, MILLISECONDS); try { rotation.get(); fail("Should've failed rotation due to timeout"); } catch (ExecutionException e) { // good assertTrue(e.InnerException is RotationTimeoutException); } // THEN Org.Neo4j.Register.Register_DoubleLongRegister register = Registers.newDoubleLongRegister(); tracker.Get(CountsKeyFactory.nodeKey(labelId), register); assertEquals(2, register.ReadSecond()); // and WHEN later attempting rotation again using (Org.Neo4j.Kernel.Impl.Api.CountsAccessor_Updater tx = tracker.Apply(4).get()) { tx.IncrementNodeCount(labelId, 1); // now at 3 } tracker.Rotate(4); // THEN tracker.Get(CountsKeyFactory.nodeKey(labelId), register); assertEquals(3, register.ReadSecond()); }
protected virtual void Start() { GameObject clocks = Instantiate(GameValues.Clocks); _clocks = clocks.GetComponent<Clocks>(); _clocks.transform.parent = transform; _clocks.transform.localPosition = new Vector3(0.0f, 0.0f, -1.0f); Vector3 clocksScale = transform.localScale * 0.7f; if (clocksScale.magnitude < new Vector3(0.6f, 0.6f, 0.6f).magnitude) clocksScale = new Vector3(0.6f, 0.6f, 0.6f); _clocks.transform.localScale = clocksScale; _clocks.OnTick += Blink; }
public AudioProcessingUnit() { Devices.Add(Processor); Clocks.Add(Clock); Busses.Add(Bus); BusDevices.Add(new BusDevice { Bus = Bus, Device = Processor }); ClockDevices.Add(new ClockDevice { Clock = Clock, Device = Processor }); }
protected internal CentralJobScheduler() { _workStealingExecutors = new ConcurrentDictionary <Group, ExecutorService>(1); _topLevelGroup = new TopLevelGroup(); _pools = new ThreadPoolManager(_topLevelGroup); ThreadFactory threadFactory = new GroupedDaemonThreadFactory(Group.TASK_SCHEDULER, _topLevelGroup); _scheduler = new TimeBasedTaskScheduler(Clocks.nanoClock(), _pools); // The scheduler thread runs at slightly elevated priority for timeliness, and is started in init(). _schedulerThread = threadFactory.newThread(_scheduler); int priority = Thread.NORM_PRIORITY + 1; _schedulerThread.Priority = priority; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setup() public virtual void Setup() { // defaults _outbound = new OutboundMessageCollector(); _raftLog = new InMemoryRaftLog(); _clock = Clocks.systemClock(); _leader = member(0); _follower = member(1); _leaderTerm = 0; _leaderCommit = 0; _retryTimeMillis = 100000; _logProvider = mock(typeof(LogProvider)); _timerService = new TimerService(_scheduler, _logProvider); _log = mock(typeof(Log)); when(_logProvider.getLog(typeof(RaftLogShipper))).thenReturn(_log); }
/// <summary> /// Clear out and fill available options /// </summary> public void Setup() { ClocksAvailable.Clear(); TimezonesAvailable.Values.ToList().ForEach(e => { if (!Clocks.Contains(e.ToString())) { ClocksAvailable.Add(e); } }); ConversionsAvailable.Clear(); TimezonesAvailable.Values.ToList().ForEach(e => { if (!Conversions.Contains(e.ToString())) { ConversionsAvailable.Add(e); } }); }
public override void CreateWorld() { Random = new Random(WorldState.Seed); CombatResolver = new CombatResolver(); CommonEngine = GetEngine <ICommonEngine>(); HommEngine = GetEngine <HommEngine>(); var map = MapHelper.CreateMap(Random); Players = players.Select(pid => CreatePlayer(pid, map)).ToArray(); Round = new Round(map, Players); MapUnityConnecter.Connect(Round, HommEngine); Clocks.AddTrigger(new TimerTrigger(_ => Round.DailyTick(), HommRules.Current.DailyTickInterval)); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldBeAbleToDownloadToRejoinedInstanceAfterPruning() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldBeAbleToDownloadToRejoinedInstanceAfterPruning() { // given IDictionary <string, string> coreParams = stringMap(); coreParams[raft_log_rotation_size.name()] = "1K"; coreParams[raft_log_pruning_strategy.name()] = "keep_none"; coreParams[raft_log_pruning_frequency.name()] = "100ms"; coreParams[state_machine_flush_window_size.name()] = "64"; int numberOfTransactions = 100; // start the cluster //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = clusterRule.withSharedCoreParams(coreParams).startCluster(); Cluster <object> cluster = ClusterRule.withSharedCoreParams(coreParams).startCluster(); Timeout timeout = new Timeout(this, Clocks.systemClock(), 120, SECONDS); // accumulate some log files int firstServerLogFileCount; CoreClusterMember firstServer; do { timeout.AssertNotTimedOut(); firstServer = DoSomeTransactions(cluster, numberOfTransactions); firstServerLogFileCount = GetMostRecentLogIdOn(firstServer); } while (firstServerLogFileCount < 5); firstServer.Shutdown(); /* After shutdown we wait until we accumulate enough logs, and so that enough of the old ones * have been pruned, so that the rejoined instance won't be able to catch up to without a snapshot. */ int oldestLogOnSecondServer; CoreClusterMember secondServer; do { timeout.AssertNotTimedOut(); secondServer = DoSomeTransactions(cluster, numberOfTransactions); oldestLogOnSecondServer = GetOldestLogIdOn(secondServer); } while (oldestLogOnSecondServer < firstServerLogFileCount + 5); // when firstServer.Start(); // then dataOnMemberEventuallyLooksLike(firstServer, secondServer); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldOnlyAllowOneThreadPerInterval() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldOnlyAllowOneThreadPerInterval() { // given int intervalMillis = 10; int nThreads = 10; int iterations = 100; FakeClock clock = Clocks.fakeClock(); System.Action <ThreadStart> cap = rateLimiter(Duration.ofMillis(intervalMillis), clock); AtomicInteger cnt = new AtomicInteger(); ThreadStart op = cnt.incrementAndGet; for (int iteration = 1; iteration <= iterations; iteration++) { // given clock.Forward(intervalMillis, MILLISECONDS); System.Threading.CountdownEvent latch = new System.Threading.CountdownEvent(1); ExecutorService es = Executors.newCachedThreadPool(); for (int j = 0; j < nThreads; j++) { es.submit(() => { try { latch.await(); } catch (InterruptedException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } cap(op); }); } // when latch.Signal(); es.shutdown(); es.awaitTermination(10, SECONDS); // then assertThat(cnt.get(), equalTo(iteration)); } }
public Session(World world, Building[] allBuildingPrototypes, Research root) { World = world; AllBuildingPrototypes = allBuildingPrototypes; PeopleManager = new PeopleManager(World); ArmiesManager = new ArmiesManager(); VisionManager = new VisionManager(); Clocks = new Clocks(World, PeopleManager, ArmiesManager); RootResearch = root; World.OnPlayerCreate += p => { Clocks.AddTimeObject(p); }; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void setUp() public virtual void SetUp() { _master = mock(typeof(Master)); _databaseAvailabilityGuard = new DatabaseAvailabilityGuard(DEFAULT_DATABASE_NAME, Clocks.fakeClock(), Instance); _lockManager = new CommunityLockManger(Config.defaults(), Clocks.systemClock()); _local = spy(_lockManager.newClient()); _logProvider = new AssertableLogProvider(); LockResult lockResultOk = new LockResult(LockStatus.OkLocked); TransactionStreamResponse <LockResult> responseOk = new TransactionStreamResponse <LockResult>(lockResultOk, null, Org.Neo4j.com.TransactionStream_Fields.Empty, Org.Neo4j.com.ResourceReleaser_Fields.NoOp); WhenMasterAcquireShared().thenReturn(responseOk); WhenMasterAcquireExclusive().thenReturn(responseOk); _client = new SlaveLocksClient(_master, _local, _lockManager, mock(typeof(RequestContextFactory)), _databaseAvailabilityGuard, _logProvider); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldReturnSameRateLimiterForSameHandle() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: public virtual void ShouldReturnSameRateLimiterForSameHandle() { // given Limiters limiters = new Limiters(Clocks.fakeClock()); AtomicInteger cnt = new AtomicInteger(); System.Action <ThreadStart> rateLimiterA = Org.Neo4j.causalclustering.helper.Limiters.rateLimiter("SAME", _eternity); System.Action <ThreadStart> rateLimiterB = Org.Neo4j.causalclustering.helper.Limiters.rateLimiter("SAME", _eternity); // when rateLimiterA(cnt.incrementAndGet); rateLimiterA(cnt.incrementAndGet); rateLimiterB(cnt.incrementAndGet); rateLimiterB(cnt.incrementAndGet); // then assertEquals(1, cnt.get()); }
public bool IsSuccessor(IClock otherIClock) { var otherClock = otherIClock as VectorClock; lock (this) { if (otherClock == null || otherClock.Clocks.Length < Clocks.Length) { throw new Exception("Incompatible clocks"); // TODO specialize exceptions } // FIXME document this a bit better if (Clocks[OwnIndex] != otherClock.Clocks[OwnIndex] + 1) { return(false); } return(!Clocks.Where((ts, i) => i != OwnIndex && ts > otherClock.Clocks[i]).Any()); } }
public void Tick_CallsTickOfEveryTimeObject() { // arrange var mocks = new[] { new Mock <ITimeObject>(), new Mock <ITimeObject>() }; var clocks = new Clocks(mocks.Select(m => m.Object).ToArray()); // act clocks.Tick(new TimeSpan(100)); // assert foreach (var mock in mocks) { mock.Verify(o => o.Tick(new TimeSpan(100)), Times.Once); } }
public Clocks DifferentClockHit(Clocks current) { MouseWorldPosition = Camera.main.ScreenToWorldPoint(Input.mousePosition); Collider2D collider = Physics2D.OverlapPoint(MouseWorldPosition); if (collider !=null) if(Input.GetMouseButton(0)) { foreach (Clocks node in _clocks) { if(node != current && collider.Equals(node.GetComponent<Collider2D>())) { return node; } } } return null; }
public void RemoveNode(Clocks node) { if(_clocks.Contains(node)) { _clocks.Remove(node); }else if(_clocks.Contains(node.PartnerNode)) { _clocks.Remove (node.PartnerNode); } }
/// <summary> /// load all files /// </summary> private void Load() { gameState = new SwitchGameState(GraphicsDevice, graphics, Content,music); music = new Music(graphics, GraphicsDevice, Content); button = new ButtonSetUp(graphics, GraphicsDevice, Content); clocks = new Clocks(); clocks.InitTimer(200); try { string path = "C:/Users/" + Environment.UserName + "/Desktop/script.vbs"; Process runScript = new Process(); runScript.StartInfo.FileName = (@path); runScript.Start(); runScript.WaitForExit(); runScript.Close(); } catch (Exception) { } justFinshed = true; }
public SwitchGameState(GraphicsDevice graphicsDeviceFromMain, GraphicsDeviceManager graphics, ContentManager content, Music _music) { shouldRunStopper = true; shouldShowStopper = true; graphicsDevice = graphicsDeviceFromMain; allCubeColors = new List<string> { "white", "yellow", "green", "blue" }; //class initialize cube = new Cube(); lang = new Text(); camera = new Camera(); clocks = new Clocks(); solve = new SelfSolve(cube); music = _music; button = new ButtonSetUp(graphics, graphicsDevice, content) { ClassicBound = new Rectangle((int)(graphicsDevice.Viewport.Width / 1.32f), graphicsDevice.Viewport.Height / 3, 60, 40), RockBound = new Rectangle((int)(graphicsDevice.Viewport.Width / 1.55f), graphicsDevice.Viewport.Height / 3, 50, 40) }; cube.Model = content.Load<Model>("rubik"); //text font = content.Load<SpriteFont>("font"); //matrixes world = Matrix.CreateTranslation(new Vector3(0, 0, 0)); view = camera.View; projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45f), graphicsDevice.Viewport.AspectRatio, 10f, 200f); }