public MainWindow() { this.timer = new FrameTimer(); this.InitKinect(); this.InitNetwork(); this.InitWindowObjectAsViewModel(); }
public AtlasTimer() { updateTimer = new FrameTimer(); drawTimer = new FrameTimer(); updateTimer.scale = 1; drawTimer.scale = 1; }
private static void Timer_OnFrameStart(FrameTimer timer, D2DDevice device) { device.BeginScene(); device.ClearScene(); device.DrawTextWithBackground(device.FPS.ToString(), new Point(10, 20), font, red, backgroundBrush); DrawRadarBackground(device, new Rectangle(100, 100, 400, 400), 10.0f); //for (int i = 0; i < 100; i++) //{ // DrawRadarBackground(device, new Rectangle(100, 100, 400, 400), 10.0f); //} device.EndScene(); }
/// <summary> /// Move the player a certain amount. /// </summary> /// <param name="translateAmount">A vector3 representing the offset to move the player.</param> public void updateMovement(Vector3 translateAmount) { calculateFacingDirection(translateAmount); //calculate if player is moving float xAmount = Mathf.Abs(translateAmount.x); float yAmount = Mathf.Abs(translateAmount.y); if (xAmount == 0 && yAmount == 0) { info.isMoving = false; } else { info.isMoving = true; } if (info.isMoving) { if (this.footstepTimer == null) { this.footstepTimer = new FrameTimer(15, null, false); this.footstepSound.pitch = Random.Range(0.5f, 1f); this.footstepSound.Play(); } if (this.footstepTimer.finished()) { this.footstepSound.pitch = Random.Range(0.5f, 1f); this.footstepSound.Play(); this.footstepTimer.lifespanRemaining = 15; } else { this.footstepTimer.tick(); Debug.Log(this.footstepTimer.lifespanRemaining); } } else { this.footstepSound.Stop(); this.footstepTimer = null; } //calculate animation; this.playAnimation(); this.gameObject.transform.position += translateAmount; }
protected override void Configure( ) { animationId = 8; soundId = 10; delay = new FrameTimer(8, false); ammo = 80; pellets = 1; spread = -0.6f; recoil = 0.5f; speed = 0.7f; power = 6; bounces = 0; piercing = false; muzzleOffset = new Vector2(11, 1); eject = true; ejectForce = 2; }
protected override void Configure( ) { animationId = 12; soundId = 19; delay = new FrameTimer(1); ammo = 1; pellets = 1; spread = 0f; recoil = 2; power = 4; bounces = 0; piercing = false; muzzleOffset = new Vector2(6, 0); eject = false; ejectForce = 0; speed = 0.6f; }
public ParticleArea() { InitializeComponent(); frameTimer = new DispatcherTimer(); FrameTimer.Tick += OnFrame; FrameTimer.Interval = TimeSpan.FromSeconds(1.0 / 60.0); FrameTimer.Start(); toAdd = new List <ParticleEmmitor>(); emmitors = new List <ParticleEmmitor>(); toRemove = new List <ParticleEmmitor>(); lastTick = Environment.TickCount; totalTicks = 0; LoadQuality(); }
public void MakeInvulnerable(float time, bool showIt) { if (isInvulnerable) { time = Mathf.Max(time, _invulnTimer.TimeLeft); } _invulnTimer = new FrameTimer(time, false); if (!showIt) { return; } Color pc = PlayerController.instance.bodyRenderer.color; PlayerController.instance.bodyRenderer.color = new Color(pc.r, pc.g, pc.r, 0.5f); }
private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device) { if (!_initializeGraphicObjects) { return; } if (!device.IsInitialized) { return; } if (device.IsDrawing) { return; } _initializeGraphicObjects = false; }
protected override void Configure( ) { animationId = 10; delay = new FrameTimer(60); ammo = 1; pellets = 1; spread = 0; recoil = 100; power = 4; bounces = 0; piercing = false; muzzleOffset = new Vector2(8, -1); eject = false; ejectForce = 3; fire = new FrameTimer(39); }
void Awake( ) { sprite = G.I.NewSprite(transform, 23); _rigidbody = gameObject.AddComponent <Rigidbody2D>(); _rigidbody.gravityScale = 0; _rigidbody.drag = 1; _rigidbody.freezeRotation = true; _rigidbody.mass = 1; _collider = gameObject.AddComponent <CircleCollider2D>(); _collider.radius = 0.45f; var physMat = new PhysicsMaterial2D(); physMat.friction = 0; physMat.bounciness = 0.4f; explode = new FrameTimer(45); particles = new FrameTimer(4, true); }
public Renderable(string title, Resolution windowSize, GraphicsDeviceOptions graphicsDeviceOptions, RenderOptions renderOptions) { WindowCreateInfo windowCI = new WindowCreateInfo() { X = 100, Y = 100, WindowWidth = windowSize.Horizontal, WindowHeight = windowSize.Vertical, WindowTitle = title }; _contextWindow = VeldridStartup.CreateWindow(ref windowCI); if (renderOptions.UsePreferredGraphicsBackend) { _graphicsDevice = VeldridStartup.CreateGraphicsDevice(_contextWindow, graphicsDeviceOptions, renderOptions.PreferredGraphicsBackend); } else { _graphicsDevice = VeldridStartup.CreateGraphicsDevice(_contextWindow, graphicsDeviceOptions); } _renderOptions = renderOptions; _contextWindow.Title = $"{title} / {_graphicsDevice.BackendType.ToString()}"; _factory = new DisposeCollectorResourceFactory(_graphicsDevice.ResourceFactory); _commandList = _factory.CreateCommandList(); _sceneRuntimeState = new SceneRuntimeDescriptor(); _modelPNTTBDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormalTextureTangentBitangent> >(); _modelPNDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionNormal> >(); _modelPTDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionTexture> >(); _modelPCDescriptorList = new List <ModelRuntimeDescriptor <VertexPositionColor> >(); _modelPDescriptorList = new List <ModelRuntimeDescriptor <VertexPosition> >(); PNTTBRuntimeGeometry = new GeometryDescriptor <VertexPositionNormalTextureTangentBitangent>(); PNRuntimeGeometry = new GeometryDescriptor <VertexPositionNormal>(); PTRuntimeGeometry = new GeometryDescriptor <VertexPositionTexture>(); PCRuntimeGeometry = new GeometryDescriptor <VertexPositionColor>(); PRuntimeGeometry = new GeometryDescriptor <VertexPosition>(); // Tick every millisecond _frameTimer = new FrameTimer(1.0); _running = false; }
private void InitWithoutDependencies() { #if UNITY_EDITOR Camera.main.orthographicSize *= 1.25f; #else Camera.main.orthographicSize *= 2.0f; #endif SaveUtil.InitializeSave(); SpaceUtil.Init(); // _ColorManager is a prefab field, and doesn't need initialized. _PoolManager.Init(in _ColorManager); WeaponResetTimer = new FrameTimer(InitialWeaponTime); WeaponRainTimer = new LoopingFrameTimer(WeaponRainTime); OneUpRainTimer = new LoopingFrameTimer(OneUpRainTime); OneUpRainTimer.TimeUntilActivation = InitialOneUpRainDelay; _PowerupMenu.Init(); _PowerupMenu.transform.position += new Vector3(0, 0, 0); VictimWasAutomatic = true; _GameOverGUI.Init(); _Scoreboard.Init(); SoundManager.Init(_AudioSource); SpriteBank.Init(); NotificationManager.Init(_Notification); DefaultBullet.StaticInit(); //DefaultExtraBullet.StaticInit(); DefaultBulletBuffs.Init(); _ParticleManager.Init(); #if !UNITY_EDITOR CanGameOver = true; #else CanGameOver = false; #endif }
/// <summary> /// Clear all textures/etc. destroy the current target objects, and then start from scratch. /// Necessary, if, for example, the RectTransform size has changed. /// Fairly performance-intensive - only call this if strictly necessary. /// </summary> public void HardUpdateDisplay() { var color = this.color; if (Application.isPlaying) { this.color = new Color(0, 0, 0, 0); //imageComponent.sprite = null; } DestroyResources(); Cleanup(); //UpdateDisplay(); FrameTimer.AtEndOfFrame(() => UpdateDisplay(), this); FrameTimer.DelayedCall(0.05f, () => { this.color = color; }, this, true); }
private void dash() { if (Input.GetKeyDown(KeyCode.Space) && _dashTimer == null && _dashCooldownTimer.CheckThisFrame()) { AudioManager.instance.PlaySFX(SoundEffect.PlayerDash); _currentMoveSpeed = dashSpeed; _dashTimer = new FrameTimer(dashDuration, false); animator.SetTrigger("dash"); PlayerHealthController.instance.MakeInvulnerable(dashInvulnDuration, false); } if (_dashTimer != null && _dashTimer.CheckThisFrame()) { _currentMoveSpeed = moveSpeed; _dashTimer = null; _dashCooldownTimer.Reset(); } }
public AppModel() { var angleInterval = 360.0 / PointsCount; Points = Enumerable.Range(0, PointsCount) .Select(_ => TimeSpan.FromSeconds(NumberHelper.NextDouble(1, 1 + SignalInterval.TotalSeconds))) .Select((t, i) => new PointObject(i, i * angleInterval) { NextSignalTime = t, NextThinkingTime = t + ThinkingOffset, }) .ToArray(); SignalTimes = new OrderedList <PointObject, TimeSpan>(p => p.NextSignalTime, Points); ThinkingTimes = new OrderedList <PointObject, TimeSpan>(p => p.NextThinkingTime, Points); FrameTimer = new FrameTimer(UpdateFrame, TimerInterval); }
public MessageItem(Grid upGrid, bool useOpacityEnter = false, bool noStartAnimation = false) { UseOpacityEnter = useOpacityEnter; NoStartAnimation = noStartAnimation; InitializeComponent(); UpGrid = upGrid; UpGrid.Children.Add(this); FrameTimer.Tick += new EventHandler(Entering); FrameTimer.Tick += new EventHandler(Label_ExitLabel_OpacityDynamic); FrameTimer.Tick += new EventHandler(Label_ExtendInfo_ColorDynamic); FrameTimer.Tick += new EventHandler(CheckFloat); FrameTimer.Tick += new EventHandler(Exiting); FrameTimer.Interval = new TimeSpan(0, 0, 0, 0, 10); FrameTimer.Start(); SecondTimer.Tick += new EventHandler(CheckCloseTimer); SecondTimer.Interval = new TimeSpan(0, 0, 1); SecondTimer.Start(); }
protected override void Configure( ) { animationId = 7; soundId = 27; delay = new FrameTimer(40); ammo = 10; pellets = 0; spread = 0.05f; recoil = 1; power = 2; bounces = 0; piercing = false; muzzleOffset = new Vector2(0, 0); speed = 1.3f; swing = new FrameTimer(12); }
public override void OnInspectorGUI() { ObjImage objecImage = target as ObjImage; Dictionary <ObjImage, Transform> targetPrefabs = new Dictionary <ObjImage, Transform>(); targetPrefabs = targets.ToDictionary(k => k as ObjImage, v => (v as ObjImage).ObjectPrefab); Dictionary <ObjImage, float> renderScales = targets.ToDictionary(k => k as ObjImage, v => (v as ObjImage).RenderScale); EditorGUI.BeginChangeCheck(); if (GUILayout.Button("Force Render")) { foreach (var t in targetPrefabs) { t.Key.HardUpdateDisplay(); } } EditorGUILayout.Space(); base.OnInspectorGUI(); if (!EditorGUI.EndChangeCheck()) { return; } foreach (var t in targetPrefabs) { if (t.Key.ObjectPrefab != t.Value || renderScales[t.Key] != t.Key.RenderScale) { t.Key.SetStarted(); t.Key.HardUpdateDisplay(); FrameTimer.AtEndOfFrame(() => t.Key.UpdateDisplay(), t.Key); } else { t.Key.UpdateDisplay(true); } } }
public void KeyPressedCore(Keys key) { if (key == Keys.Escape) { if (FrameTimer.Enabled) { FrameTimer.Stop(); } else { FrameTimer.Start(); } } //if (key == Keys.Enter) //{ // ResetGame(); //} }
private void _frameTimer_OnFrame(FrameTimer timer, D2DDevice device) { // the render loop will call device.BeginScene() and device.EndScene() for us if (!device.IsDrawing) { _initializeGraphicObjects = true; return; } device.ClearScene(); if (Config.focused) { if (vars.drawFOV == 1) { device.DrawCircle(vars.ScreenWidth / 2 + 1, vars.ScreenHeight / 2 + 1, Config.FOV, 1, _blueBrush); //Draw FOV circle } //Crosshair aimPunch Point centralPoint = new Point(vars.recoilX + 1, vars.recoilY + 1); device.DrawCrosshair(CrosshairStyle.Plus, centralPoint, 7, 1f, _greenBrush); for (int i = 0; i < Config.numberOfPlayers; i++) { if (Lists.team[i] == 2) { _emptyBrush = _redBrush; } else { _emptyBrush = _greenBrush; }; if (Lists.dormant[i] == 1) { _emptyBrush = _yellowBrush; } if (Lists.health[i] > 0 && vars.localClass.LocalPlayer != Lists.entityID[i] && Lists.entityID[i] != Lists.observer[i] && Lists.selectedBoneX[i] != 0) { device.OutlineCircle(Lists.selectedBoneX[i], Lists.selectedBoneY[i], Lists.distance[i] + 0.1f, 2.0f, _emptyBrush, _blackBrush); } } } }
protected override void OnAwake() { controls = new TestControls(); timer = new FrameTimer(); //ENABLE ALL ACTIONS BEFORE USING CALLBACKS, I DON'T KNOW WHY I HAVE TO DO IT, I JUST DO //controls.Keyboard.Move.Enable(); //controls.Keyboard.Jump.Enable(); controls.Keyboard.Move.performed += ctx => CallbackDirectionInput(ctx.ReadValue <Vector2>()); controls.Keyboard.Move.canceled += ctx => CallbackDirectionInput(ctx.ReadValue <Vector2>()); controls.Keyboard.Jump.performed += ctx => CallbackButtonInput(Button.W); controls.Keyboard.Jump.canceled += ctx => CallbackButtonInput(Button.W); controls.Keyboard.LightAttack.performed += ctx => CallbackButtonInput(Button.I); controls.Keyboard.LightAttack.canceled += ctx => CallbackButtonInput(Button.I); controls.Keyboard.MediumAttack.performed += ctx => CallbackButtonInput(Button.J); controls.Keyboard.MediumAttack.canceled += ctx => CallbackButtonInput(Button.J); }
private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device) { if (!_initializeGraphicObjects) { return; } if (!device.IsInitialized) { return; } if (device.IsDrawing) { return; } _backgroundColor = new D2DColor(0x24, 0x29, 0x2E, 0xFF); _font = _device.CreateFont(new FontOptions() { Bold = false, FontFamilyName = "Arial", FontSize = 16, Italic = false, WordWrapping = true }); // colors automatically normalize values to fit. you can use 1.0f but also 255.0f. _blackBrush = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF); _redBrush = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF); _greenBrush = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF); _blueBrush = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF); _gradient = new D2DLinearGradientBrush(device, new D2DColor(0, 0, 80), new D2DColor(0x88, 0, 125), new D2DColor(0, 0, 225)); // loads an image from resource bytes (.png in this case) _image = device.LoadImage(Properties.Resources.placeholder_image_bytes); _initializeGraphicObjects = false; }
// udp重连回调 private void OnUdpReconnected(uint conv, NErrorCode code) { if (code == NErrorCode.SUCCESS) { State = ConnectState.Connected; // 恢复线程 m_threadResetEvent.Set(); m_timerTick = FrameTimer.Create(Tick, 1, -1); } else { if (code == NErrorCode.ERROR && m_udpClient.DisconnectType == KDisconnectType.FromChange) { Reconnect(); } else { ConnectFailed(code); } } }
/// <summary> /// Load 되었을때 >> Aplication Init(); /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void InteractiveUI_Load(object sender, EventArgs e) { if (!GraphicManager.GetManager().InitDX(this.GraphicView)) { MessageBox.Show("Could not initialize Direct3D."); } GraphicManager.GetManager().RenderInit(); //60프레임으로 고정 VeiwFrameTimer = new FrameTimer(500); VeiwFrameTimer.AddTickEvent(() => { GraphicManager.GetManager().Render(); }); VeiwFrameTimer.Start(); SpotList = new List <Spot>(); HazardList = new List <Spot>(); }
public void Spawn(Sprite[] effect, Vector2 position, Vector2 velocity, int depthOffset = 0) { sprite.frames = effect; // sprite expects a valid frame number, length is the last frame + 1. sprite.returnTo = effect.Length - 1; sprite.Play(); sprite.depthOffset = depthOffset; this.position = position; sprite.transform.position = new Vector3( Mathf.Round(this.position.x * S.SIZE), Mathf.Round(this.position.y * S.SIZE) ); this.velocity = velocity; timer = new FrameTimer(effect.Length * AS.FRAME_DURATION); timer.Start(); active = true; sprite.Show(); }
public static void UpdateGameOver() { if (titleScrollTimer.DoThing()) { titleOffset += 1; if (titleOffset > gameOver.GetLength(0) - 10) { titleOffset = 0; titleScrollTimer = new FrameTimer(3000); state = State.Title; } } for (int i = 0; i < 10; i++) { for (int j = 0; j < 20; j++) { board[j, i] = gameOver[i + titleOffset, j]; } } while (Console.KeyAvailable) { char ch = Console.ReadKey(true).KeyChar; switch (ch) { case 'a': case 'd': case 's': titleOffset = 0; titleScrollTimer = new FrameTimer(3000); state = State.Title; break; } } }
public void Connect(string ipOrName, int port, Action <uint, NErrorCode> callback) { m_onConnected = callback; m_host = ipOrName; m_port = port; // UDP端口绑定 IPAddress[] addr = Dns.GetHostAddresses(ipOrName); if (addr == null || addr.Length == 0) { m_onConnected(0, NErrorCode.ERROR); return; } State = ConnectState.Connecting; m_udp = new UdpClient(addr[0].AddressFamily); m_udp.Connect(addr[0], port); m_timerConn = FrameTimer.Create(OnTimerCheckConn, 1, -1); // 发送连接请求 SendConnectRequest(); return; }
void SetupEngines() { // "The core of Svelto.ECS" ??? m_EnginesRoot = new EnginesRoot(new UnitySumbmissionEntityViewScheduler()); // Factory for creating all entities (?) m_EntityFactory = m_EnginesRoot.GenerateEntityFactory(); // ??? IEntityFunctions entityFunctions = m_EnginesRoot.GenerateEntityFunctions(); // Factory used to create Unity GameObjects (wrapper around GameObject.Instantiate) GameObjectFactory gameObjectFactory = new GameObjectFactory(); IRayCaster rayCaster = new RayCaster(); ITime time = new FrameTimer(); PlayerInputEngine playerInputEngine = new PlayerInputEngine(); AimingEngine aimingEngine = new AimingEngine(); GunShootingEngine gunShootingEngine = new GunShootingEngine(rayCaster); GunEffectsEngine gunEffectsEngine = new GunEffectsEngine(gameObjectFactory); ZombieSpawnerEngine zombieSpawnerEngine = new ZombieSpawnerEngine(gameObjectFactory, m_EntityFactory); ZombieMovementEngine zombieMovementEngine = new ZombieMovementEngine(time); ZombieAnimationEngine zombieAnimationEngine = new ZombieAnimationEngine(); HUDEngine hudEngine = new HUDEngine(); DeathEngine deathEngine = new DeathEngine(entityFunctions); m_EnginesRoot.AddEngine(playerInputEngine); m_EnginesRoot.AddEngine(aimingEngine); m_EnginesRoot.AddEngine(gunShootingEngine); m_EnginesRoot.AddEngine(gunEffectsEngine); m_EnginesRoot.AddEngine(zombieSpawnerEngine); m_EnginesRoot.AddEngine(zombieMovementEngine); m_EnginesRoot.AddEngine(zombieAnimationEngine); m_EnginesRoot.AddEngine(hudEngine); m_EnginesRoot.AddEngine(deathEngine); }
public ShogiWindow() { InitializeComponent(); ShogiControl.InitializeBindings(this); EffectManager = new EffectManager() { Background = this.visualBackground, }; ShogiControl.EffectManager = EffectManager; DataContext = Global.ShogiModel; Global.ShogiWindow = this; Closed += (_, __) => Global.ShogiWindow = null; EffectManager.ChangeMoveCount(1); this.timer = new FrameTimer( 30, timer_EnterFrame, Dispatcher); this.timer.Start(); }
/// <summary> /// Unity's Start() method. Used for initialization. /// </summary> protected override void Start() { base.Start(); var color = this.color; if (Application.isPlaying) { this.color = new Color(0, 0, 0, 0); //imageComponent.sprite = null; } FrameTimer.AtEndOfFrame(() => SetStarted(), this, true); FrameTimer.AtEndOfFrame(() => OnEnable(), this); // Some models (particularly, models with rigs) can cause Unity to crash if they are instantiated this early (for some reason) // as such, we must delay very briefly to avoid this before rendering FrameTimer.DelayedCall(0.01f, () => { Cleanup(); UpdateDisplay(); FrameTimer.DelayedCall(0.05f, () => { this.color = color; }, this, true); }, this, true); }
private void _frameTimer_OnFrameStarting(FrameTimer timer, D2DDevice device) { if (!_initializeGraphicObjects) { return; } if (!device.IsInitialized) { return; } if (device.IsDrawing) { return; } _backgroundColor = new D2DColor(0, 0, 0, 0); _font = _device.CreateFont(new FontOptions() { Bold = false, FontFamilyName = "Times New Roman", FontSize = 10, Italic = false, WordWrapping = true }); // colors automatically normalize values to fit. you can use 1.0f but also 255.0f. _blackBrush = device.CreateSolidColorBrush(0x0, 0x0, 0x0, 0xFF); _redBrush = device.CreateSolidColorBrush(0xFF, 0x0, 0x0, 0xFF); _greenBrush = device.CreateSolidColorBrush(0x0, 0xFF, 0x0, 0xFF); _blueBrush = device.CreateSolidColorBrush(0x0, 0x0, 0xFF, 0xFF); _initializeGraphicObjects = false; }