public GlobalStreamThread GetGlobalStreamThread() { var stateManager = new GlobalStateManager(topology, adminClient, configuration); var context = new GlobalProcessorContext(configuration, stateManager); stateManager.SetGlobalProcessorContext(context); var globalStateUpdateTask = new GlobalStateUpdateTask(stateManager, topology, context); return(new GlobalStreamThread(threadClientId, globalConsumer, configuration, globalStateUpdateTask)); }
/// <summary> /// Stops the server and releases all related resources /// </summary> public void Dispose() { Clock.Dispose(); AreaManager.Dispose(); ConnectionManager.Dispose(); LandscapeManager.Dispose(); Services.Dispose(); GlobalStateManager.Dispose(); Scheduler.Dispose(); EntityManager.Dispose(); }
void Start() { heart = 2; power = 2; timer = 0; currentTimer = 5; rigidBody = GetComponent <Rigidbody>(); myTransform = transform; animator = GetComponent <Animator>(); startPos = transform.position; globalManager = GameObject.Find("Manager").GetComponent <GlobalStateManager>(); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else if (instance != this) { Destroy(this.gameObject); } }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; DontDestroyOnLoad(this.gameObject); } }
public void Run(string[] args) { System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyGlobalExceptionHandler); if (args.Contains("-console")) { Logger.Info <SactaProxyApp>("Arrancando en Modo Consola. Pulsa 'q' para salir..."); var app = new SactaProxy(); app.StartOnConsole(args); char key; while ((key = Console.ReadKey(true).KeyChar) != 'q') { // Por si se quieren simular acciones mediante el teclado... #if DEBUG switch (key) { case 's': GlobalStateManager.DebugMainStandbyModeSet(false, false); break; case 'p': GlobalStateManager.DebugMainStandbyModeSet(true, true); break; case 'r': GlobalStateManager.DebugMainStandbyModeSet(true, false); break; case '0': app.Reset(); break; } #endif } app.StopOnConsole(); Logger.Info <SactaProxyApp>("Fin del Programa."); } else { ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new SactaProxy() }; ServiceBase.Run(ServicesToRun); } }
public void SetUp() { mockKafkaSupplier = new SyncKafkaSupplier(); var consumerConfig = new ConsumerConfig(); consumerConfig.GroupId = "global-consulmer"; var globalConsumer = mockKafkaSupplier.GetConsumer(consumerConfig, null); streamConfigMock = new Mock <IStreamConfig>(); streamConfigMock.Setup(c => c.StateDir).Returns($"./{Guid.NewGuid().ToString()}"); streamConfigMock.Setup(c => c.ApplicationId).Returns("app"); kvStoreMock = CreateMockStore <IKeyValueStore <object, object> >(kvStoreName); otherStoreMock = CreateMockStore <IKeyValueStore <object, object> >(otherStoreName); var globalStateStores = new Dictionary <string, IStateStore>() { { kvStoreMock.Object.Name, kvStoreMock.Object }, { otherStoreMock.Object.Name, otherStoreMock.Object } }; var storesToTopics = new Dictionary <string, string>() { { kvStoreMock.Object.Name, kvStoreTopic }, { otherStoreMock.Object.Name, otherStoreTopic } }; topology = new ProcessorTopology( null, new Dictionary <string, IProcessor>(), new Dictionary <string, IProcessor>(), new Dictionary <string, IProcessor>(), new Dictionary <string, IStateStore>(), globalStateStores, storesToTopics, new List <string>()); adminClientMock = new Mock <IAdminClient>(); RegisterPartitionInAdminClient(kvStoreTopic); RegisterPartitionInAdminClient(otherStoreTopic); stateManager = new GlobalStateManager(globalConsumer, topology, adminClientMock.Object, streamConfigMock.Object ); context = new GlobalProcessorContext( streamConfigMock.Object, stateManager, new StreamMetricsRegistry()); stateManager.SetGlobalProcessorContext(context); }
public TaskSynchronousTopologyDriver(string clientId, InternalTopologyBuilder topologyBuilder, IStreamConfig configuration, IStreamConfig topicConfiguration, IKafkaSupplier supplier, CancellationToken token) { this.configuration = configuration; this.configuration.ClientId = clientId; this.topicConfiguration = topicConfiguration; metricsRegistry = new StreamMetricsRegistry(clientId, MetricsRecordingLevel.DEBUG); this.token = token; builder = topologyBuilder; this.supplier = supplier ?? new SyncKafkaSupplier(); this.supplier.MetricsRegistry = metricsRegistry; producer = this.supplier.GetProducer(configuration.ToProducerConfig()) as SyncProducer; foreach (var sourceTopic in builder .GetSourceTopics()) { var part = new TopicPartition(sourceTopic, 0); var taskId = builder.GetTaskIdFromPartition(part); if (partitionsByTaskId.ContainsKey(taskId)) { partitionsByTaskId[taskId].Add(part); } else { partitionsByTaskId.Add(taskId, new List <TopicPartition> { part }); } } ProcessorTopology globalTaskTopology = topologyBuilder.BuildGlobalStateTopology(); hasGlobalTopology = globalTaskTopology != null; if (hasGlobalTopology) { var globalConsumer = this.supplier.GetGlobalConsumer(configuration.ToGlobalConsumerConfig($"{clientId}-global-consumer")); var adminClient = this.supplier.GetAdmin(configuration.ToAdminConfig($"{clientId}-admin")); var stateManager = new GlobalStateManager(globalConsumer, globalTaskTopology, adminClient, configuration); globalProcessorContext = new GlobalProcessorContext(configuration, stateManager, metricsRegistry); stateManager.SetGlobalProcessorContext(globalProcessorContext); globalTask = new GlobalStateUpdateTask(stateManager, globalTaskTopology, globalProcessorContext); globalTask.Initialize(); } }
/// <summary> /// Updates Player 2's movement and facing rotation using the arrow keys and drops bombs using Enter or Return /// </summary> public void UpdatePlayer2Movement() { if (Input.GetKey(KeyCode.UpArrow)) { //Up movement rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, moveSpeed); myTransform.rotation = Quaternion.Euler(0, 0, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.LeftArrow)) { //Left movement rigidBody.velocity = new Vector3(-moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 270, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.DownArrow)) { //Down movement rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, -moveSpeed); myTransform.rotation = Quaternion.Euler(0, 180, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.RightArrow)) { //Right movement rigidBody.velocity = new Vector3(moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 90, 0); //animator.SetBool ("Walking", true); } if (canDropBombs && (Input.GetKeyDown(KeyCode.KeypadEnter) || Input.GetKeyDown(KeyCode.Return))) { Bomb.playerNum = 2; if (GlobalStateManager.i < GlobalStateManager.expOrder.Length) { GlobalStateManager.EnOrder(Bomb.playerNum); } else { Debug.Log("Can't EnOrder"); } //Drop Bomb. For Player 2's bombs, allow both the numeric enter as the return key or players //without a numpad will be unable to drop bombs DropBomb(); } }
private Animator animator; //动画组件 // Use this for initialization void Start() { //初始化 bombNums = 2; bombPower = 2; MoveSpeed = 5.0f; operation = MenuManager.choose ? Operation.FirstView : Operation.ThirdView; GlobalManager = GameObject.Find("Global State Manager").GetComponent <GlobalStateManager>(); rigidBody = GetComponent <Rigidbody>(); myTransform = transform; animator = myTransform.Find("PlayerModel").GetComponent <Animator>(); if (playerNumber == 1) { BombPlace = GameObject.Find("PlayerBombs/Player1").transform; } else { BombPlace = GameObject.Find("PlayerBombs/Player2").transform; } switch (operation) { case Operation.FirstView: { //Camera.main.enabled = false; if (playerNumber == 1) { _camera.rect = new Rect(0, 0, 0.5f, 1); } else { _camera.rect = new Rect(0.5f, 0, 0.5f, 1); } break; } case Operation.ThirdView: { //Camera.main.enabled = true; _camera.enabled = false; break; } } }
/// <summary> /// Updates Player 1's movement and facing rotation using the WASD keys and drops bombs using Space /// </summary> private void UpdatePlayer1Movement() { if (Input.GetKey(KeyCode.W)) { //Up movement rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, moveSpeed); myTransform.rotation = Quaternion.Euler(0, 0, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.A)) { //Left movement rigidBody.velocity = new Vector3(-moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 270, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.S)) { //Down movement rigidBody.velocity = new Vector3(rigidBody.velocity.x, rigidBody.velocity.y, -moveSpeed); myTransform.rotation = Quaternion.Euler(0, 180, 0); //animator.SetBool ("Walking", true); } if (Input.GetKey(KeyCode.D)) { //Right movement rigidBody.velocity = new Vector3(moveSpeed, rigidBody.velocity.y, rigidBody.velocity.z); myTransform.rotation = Quaternion.Euler(0, 90, 0); //animator.SetBool ("Walking", true); } if (canDropBombs && Input.GetKeyDown(KeyCode.Space)) { Bomb.playerNum = 1; if (GlobalStateManager.i < GlobalStateManager.expOrder.Length) { GlobalStateManager.EnOrder(Bomb.playerNum); } else { Debug.Log("Can't EnOrder"); } //Drop bomb DropBomb(); } }
private void Explode() { // 爆弾の位置に爆発エフェクトを作成 Instantiate(explosionPrefab, transform.position, Quaternion.identity); // 爆弾を非表示にする GetComponent <MeshRenderer>().enabled = false; //爆風を広げる CreateExplosions(Vector3.forward); // 上に広げる CreateExplosions(Vector3.right); // 右に広げる CreateExplosions(Vector3.back); // 下に広げる CreateExplosions(Vector3.left); // 左に広げる this.gameObject.SetActive(false); exploded = true; GlobalStateManager.DeOrder(); // 0.3 秒後に非表示にした爆弾を削除 Destroy(gameObject, 0.3f); }
public void SetUp() { streamConfigMock = new Mock <IStreamConfig>(); streamConfigMock.Setup(x => x.MetadataRequestTimeoutMs).Returns(1); kvStoreMock = CreateMockStore <IKeyValueStore <object, object> >(kvStoreName); otherStoreMock = CreateMockStore <IKeyValueStore <object, object> >(otherStoreName); var globalStateStores = new Dictionary <string, IStateStore>() { { kvStoreMock.Object.Name, kvStoreMock.Object }, { otherStoreMock.Object.Name, otherStoreMock.Object } }; var storesToTopics = new Dictionary <string, string>() { { kvStoreMock.Object.Name, kvStoreTopic }, { otherStoreMock.Object.Name, otherStoreTopic } }; topology = new ProcessorTopology( null, new Dictionary <string, IProcessor>(), new Dictionary <string, IProcessor>(), new Dictionary <string, IProcessor>(), new Dictionary <string, IStateStore>(), globalStateStores, storesToTopics); adminClientMock = new Mock <IAdminClient>(); RegisterPartitionInAdminClient(kvStoreTopic); RegisterPartitionInAdminClient(otherStoreTopic); stateManager = new GlobalStateManager( topology, adminClientMock.Object, streamConfigMock.Object ); }
protected void MainProcessing() { Logger.Info <SactaProxy>("Arrancando Servicio."); MainTaskSync = new System.Threading.ManualResetEvent(false); EventThread.Start(); MainTaskConfigured = ConfigureService(); StartWebServer(); History.Add(HistoryItems.ServiceStarted); do { EventThread.Enqueue("MainProcessing", () => { try { if (MainTaskConfigured == false) { StopManagers(true); StopWebServer(); MainTaskConfigured = ConfigureService(); StartWebServer(); } GlobalStateManager.MainStandbyCheck((isDual, isMain) => { if (isDual) { if (isMain && !PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo DUAL-MAIN"); History.Add(HistoryItems.ServiceInMode, "", "", "Master"); StartManagers(); } else if (!isMain && PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo DUAL-STANDBY"); History.Add(HistoryItems.ServiceInMode, "", "", "Standby"); StopManagers(); } } else { if (!PS.IsStarted) { //Logger.Info<SactaProxy>("Entrando en Modo SINGLE"); History.Add(HistoryItems.ServiceInMode, "", "", "Simple"); StartManagers(); } } }); } catch { } }); }while (MainTaskSync.WaitOne(TimeSpan.FromSeconds(2)) == false); StopManagers(true); StopWebServer(); History.Add(HistoryItems.ServiceEnded); EventThread.ControlledStop(); Logger.Info <SactaProxy>("Servicio Detenido."); }
/// <summary> /// Create new instance of the Server class /// </summary> public ServerCore( XmlSettingsManager <ServerSettings> settingsManager, WorldGenerator worldGenerator, IUsersStorage usersStorage, IChunksStorage chunksStorage, IEntityStorage entityStorage, ICustomStorage customStorage, EntityFactory entityFactory, WorldParameters wp ) { // dependency injection SettingsManager = settingsManager; UsersStorage = usersStorage; EntityStorage = entityStorage; CustomStorage = customStorage; EntityFactory = entityFactory; WorldParameters = wp; if (SettingsManager.Settings == null) { SettingsManager.Load(); } var settings = SettingsManager.Settings; ConnectionManager = new ConnectionManager(SettingsManager.Settings.ServerPort); Scheduler = new ScheduleManager(); UtopiaTime startTime = CustomStorage.GetVariable <UtopiaTime>("GameTimeElapsed"); Clock = new Clock(this, startTime, TimeSpan.FromMinutes(20)); LandscapeManager = new ServerLandscapeManager( this, chunksStorage, worldGenerator, EntityFactory, settings.ChunkLiveTimeMinutes, settings.CleanUpInterval, settings.SaveInterval, settings.ChunksCountLimit, wp); EntityManager = new EntityManager(this); AreaManager = new AreaManager(this); DynamicIdHelper.SetMaxExistsId(EntityStorage.GetMaximumId()); Services = new ServiceManager(this); PerformanceManager = new PerformanceManager(AreaManager); CommandsManager = new CommandsManager(this); ChatManager = new ChatManager(this); GlobalStateManager = new GlobalStateManager(this); LoginManager = new LoginManager(this, EntityFactory); EntitySpawningManager = new EntitySpawningManager(this, worldGenerator.EntitySpawningControler); EntityGrowingManager = new Managers.EntityGrowingManager(this); }