public void Update() { if (Health <= 0) { Destroyed?.Invoke(this); } }
void OnVisualsChanged(object sender, VisualChangeEventArgs e) { if (_animateStatus) { StatusText.Text = string.Format(CultureInfo.InvariantCulture, "{0} live visuals of {1} total", grid.LiveVisualCount, _totalVisuals); int tick = Environment.TickCount; if (e.Added != 0 || e.Removed != 0) { addedPerSecond += e.Added; removedPerSecond += e.Removed; if (tick > lastTick + 100) { Created.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation( Math.Min(addedPerSecond, 450), new Duration(TimeSpan.FromMilliseconds(100)))); CreatedLabel.Text = addedPerSecond.ToString(CultureInfo.InvariantCulture) + " created"; addedPerSecond = 0; Destroyed.BeginAnimation(Rectangle.WidthProperty, new DoubleAnimation( Math.Min(removedPerSecond, 450), new Duration(TimeSpan.FromMilliseconds(100)))); DestroyedLabel.Text = removedPerSecond.ToString(CultureInfo.InvariantCulture) + " disposed"; removedPerSecond = 0; } } if (tick > lastTick + 1000) { lastTick = tick; } } }
public API(string ip, FadeProxyClient proxy, Mode mode = Mode.BOT) { _ip = ip; this.mode = mode; // Depedency injection Account = new Account(this); _proxy = proxy; _remoteClient = new RemoteClient(this); _vanillaClient = new VanillaClient(this, proxy, _remoteClient); Account.LoginSucceed += (s, e) => Connect(); _vanillaClient.AuthFailed += (s, e) => AuthFailed?.Invoke(s, e); _vanillaClient.Disconnected += (s, e) => Disconnected?.Invoke(s, e); _vanillaClient.HeroInited += (s, e) => { HeroInited?.Invoke(s, e); if (LoginTime == DateTime.MinValue) { LoginTime = DateTime.Now; } }; _vanillaClient.Attacked += (s, e) => Attacked?.Invoke(s, e); _vanillaClient.ShipMoving += (s, e) => ShipMoving?.Invoke(s, e); _vanillaClient.Destroyed += (s, e) => Destroyed?.Invoke(s, e); }
public override void Destroy() { explosionSprite.Hide(); current = State.Dead; Destroyed?.Invoke(this, null); removeQueue.Enqueue(new Tuple <int, GameObject>(Id, this)); }
public void StartWork() { _isWorking = true; while (_isWorking) { if (_rnd.NextDouble() <= _crashProbability && !IsBroken) { IsBroken = true; Broken?.Invoke(this); _hpTimer = new Timer(TimeSpan.FromSeconds(HP).TotalMilliseconds); _hpTimer.Elapsed += (o, e) => { Destroyed?.Invoke(this); StopWork(); _hpTimer?.Stop(); }; _hpTimer.Start(); return; } if (!IsBroken && Store.CurrentVolume < Store.Capacity) { Store.AddIron(1); } Thread.Sleep(1000); } }
private IEnumerator DoSink() { Vector3 pos = transform.localPosition; Vector3 sinkPos = pos - new Vector3(0, m_config.SinkHeight, 0); // Randomize sail falling left/right Quaternion startRot = transform.rotation; Vector3 randRotation = startRot.eulerAngles + new Vector3(0, 0, Helpers.RandBool() ? -50.0f : 50.0f); Quaternion targRot = Quaternion.Euler(randRotation); float time = 0.0f; while (time < m_config.DropTime) { time += Time.deltaTime; float t = Mathf.Clamp01(time / m_config.DropTime); transform.rotation = Quaternion.Slerp(startRot, targRot, t); t = m_config.SinkCurve.Evaluate(t); transform.localPosition = Vector3.LerpUnclamped(pos, sinkPos, t); yield return(null); } Destroyed?.Invoke(this); Destroy(gameObject); }
private void Update() { if (_navigator.AppState == AppStates.Gameplay) { Points -= _appSettings.PointLossSpeed * Time.deltaTime; if (Points <= 0f) { Destroyed.SafelyInvoke(this); } } if (Application.isEditor) { if (Input.GetKeyDown(KeyCode.Minus)) { Points -= 25f; Debug.Log("Removing points"); } if (Input.GetKeyDown(KeyCode.Equals)) { Points += 25f; Debug.Log("Adding points"); } } }
/// <summary> /// Called when graphics device has been detected to be internally destroyed. /// </summary> protected internal virtual void OnDestroyed() { Destroyed?.Invoke(this, EventArgs.Empty); ReleaseComObject(ref nativeDeviceChild); NativeResource = null; }
public void Ride() { Destroyed += delegate { Console.WriteLine("The Bike is broken, repair it first"); Console.ReadKey(); }; if (IsBroken) { Destroyed?.Invoke(); return; } Random rand = new Random(); Console.WriteLine("Riding for 1 hour..."); Thread.Sleep(1000); Distance += Speed; int chance = rand.Next(1, 4); IsBroken = chance == 2 ? true : false; if (IsBroken) { Console.Clear(); Destroyed?.Invoke(); } }
public void Destroy() { if (IsDestroyed) { return; } IsDestroyed = true; // Remove players foreach (var member in Members.Values.ToList()) { RemovePlayer(member.Extension); } if (GameSpawnTask != null) { GameSpawnTask.StatusChanged -= OnSpawnServerStatusChanged; GameSpawnTask.KillSpawnedProcess(); } if (Destroyed != null) { Destroyed.Invoke(this); } }
public virtual void TakeDamage(float damage) { if (!isAlive || damage <= 0.0f) { return; } if (SupportRange.InSupportRange(gameObject)) { damage *= 0.75f; } HeroUIScript.Damage(damage * (1.0f - dmgDamp * 0.01f), transform.position + Vector3.up * 10.0f); currHP -= damage * (1.0f - dmgDamp * 0.01f); Attacked?.Invoke(); if (currHP <= 0.0f) { currHP = 0.0f; isAlive = false; if (!(this is PortalInfo)) { gameObject.SetActive(false); if (destroyable) { Destroy(gameObject, 1.0f); } } Destroyed?.Invoke(); } }
public void Destroy() { Vector3 dropPosition = this.transform.position; Debug.Log("Bang!"); Destroyed?.Invoke(); /*float minAngle = Mathf.Atan2(-6f - dropPosition.x, dropPosition.y) * 6 * Mathf.PI; * float maxAngle = Mathf.Atan2(6f - dropPosition.x, dropPosition.y) * 6 * Mathf.PI; * * int rocketsInBB = UnityEngine.Random.Range(2, 4); * do * { * float finalAngle = UnityEngine.Random.Range(minAngle, maxAngle); * Debug.LogError($"Angle: {finalAngle}"); * * Quaternion spawnRotation = this.transform.rotation * Quaternion.Euler(0, finalAngle, 0); * Instantiate(enemyRocket, dropPosition, spawnRotation); * rocketsInBB--; * * } while (rocketsInBB != 0);*/ float finalAngle = -20; for (int i = 0; i < rocketsInBB; i++) { Quaternion spawnRotation = this.transform.rotation * Quaternion.Euler(0, finalAngle, 0); Instantiate(enemyRocket, dropPosition, spawnRotation); finalAngle += 20; } Destroy(gameObject); }
public void ApplyDamage(int dmg, Attack.DamageTypes damageType) { this.hitsTaken++; int damageAfterModifiers = dmg; for (int i = 0; i < this.modifiers.Count; i++) { damageAfterModifiers = this.modifiers[i].Apply(damageAfterModifiers, damageType); } this.HP = Mathf.Max(this.HP - damageAfterModifiers, 0); // Fire events if (this.HP <= 0) { if (Destroyed != null) { Destroyed.Invoke(this); } } else { if (TookDamage != null) { TookDamage.Invoke(this, damageAfterModifiers, this.HP); } } }
public void Damage(float damage) { if (IsDestroyed) { return; } health = Mathf.Max(0, health - damage); if (IsDestroyed) { bodyRenderer.gameObject.SetActive(false); Transform modelTransform = bodyRenderer.transform; brokenTable = Instantiate(brokenTablePrefab, modelTransform.position, modelTransform.rotation, transform); Destroyed?.Invoke(); if (IsTablesDestroyed()) { OnTablesDestroyed?.Invoke(); } } else { float healthFraction = health / maxHealth; // should never be zero here int damageIndex = Mathf.FloorToInt((1f - healthFraction) * damageStates.Length); bodyRenderer.sharedMaterial = damageStates[damageIndex]; } }
public void Destroy() { if (IsDestroyed) { return; } IsDestroyed = true; Parent?.RemoveChild(this); foreach (var component in _components.ToArray()) { component.Destroy(); } foreach (var child in _children.ToArray()) { child.Destroy(); } Destroyed?.Invoke(this); Interlocked.Decrement(ref Scene.NumberNodes); }
public void Destroy() { //Debug.Log("Bang!"); Destroyed?.Invoke(); //trailRenderer.transform.parent = null; //Destroy(trailRenderer.gameObject, 13); Destroy(gameObject); }
public void Dispose() { m_App.Documents.DocumentActivated -= OnDocumentActivated; m_Model.StorageReadAvailable -= OnStorageReadAvailable; m_Model.StorageWriteAvailable -= OnStorageWriteAvailable; Destroyed?.Invoke(this); }
public void Destroy() { IsDestroyed = true; Velocity = Vector2.Zero; Destroyed?.Invoke(); }
public void Destroy() { var oldContent = Content; Content = oldContent.Loot.GetInstance(this); oldContent.Hide(); Destroyed?.Invoke(this); }
public void Handle(Destroyed e) { var index = _elastic.Get <Responses.Index>(e.AccountId); _elastic.Delete <Responses.Index>(e.AccountId); _manager.Publish(index.Source, ChangeType.DELETE); }
void OnDestroy() { if (!closing) { Destroyed.Raise(this, new GameObjectArgs(gameObject)); Destroyed = null; } }
/// <summary> /// Removes this SpaceObject from the world. /// </summary> public void Destroy() { Destroyed?.Invoke(this); WorldContext.SpaceObjects.Remove(this); Location.RemoveSpaceObject(this); WorldContext = null; }
private void ChangeEnergy(int delta) { Energy += delta; if (Energy <= 0) { Destroyed?.Invoke(this, EventArgs.Empty); } }
public void SetShowPredictiobCondition() { if (Convert.ToBoolean(PlayerPrefs.GetInt("IsTriesEnded")) == false) { string predictionText = _dataSaver.Predictions.ElementAt(UnityEngine.Random.Range(0, _dataSaver.Predictions.Count())); Destroyed?.Invoke(predictionText); } }
public void ChangeEnergy(int delta) { _Energy += delta; if (_Energy < 0) { Destroyed?.Invoke(this, EventArgs.Empty); } }
void IVirtualDesktopNotification.VirtualDesktopDestroyed(IVirtualDesktop pDesktopDestroyed, IVirtualDesktop pDesktopFallback) { var args = new VirtualDesktopDestroyEventArgs(FromComObject(pDesktopDestroyed), FromComObject(pDesktopFallback)); if (Destroyed != null) { Destroyed.Invoke(this, args); } }
private IEnumerator DestroyDelay(float delay) { _canDestroy = false; Destroyed?.Invoke(); yield return(new WaitForSeconds(delay)); _canDestroy = true; ReadyToDestroy?.Invoke(); }
public void ChangeEnergyShip(int delta) { _EnergyShip += delta; if (_EnergyShip < 0) { Destroyed.Invoke(this, EventArgs.Empty); } }
private void Destroy(bool ev) { visible = false; Protocol.DiePacket(id).Send(level, this as Player); level.bodies.Remove(this); if (ev) { Destroyed.Raise(level.server, this); } }
public void Damage(float damage) { health -= damage; if (health <= 0) { Destroyed?.Invoke(); Destroy(gameObject); } }