/// <summary> /// Initiates a bluetooth scan /// </summary> public void BeginScanForDice() { if (_state != State.Idle) { Debug.LogError("Die Manager not ready to start scanning"); return; } if (dieCreationFunc == null) { Debug.LogError("Die Manager - No die creation factory registered"); return; } // Begin scanning _state = State.Scanning; // Notify of all the already known advertising dice foreach (var die in _dice.Values) { if (die.state == Die.State.Advertising) { onDieDiscovered?.Invoke(die.die); } } BluetoothLEHardwareInterface.ScanForPeripheralsWithServices(new string[] { serviceGUID }, OnDeviceDiscovered, null, false, true); }
private IEnumerator DieCoroutine() { yield return(new WaitForSeconds(1f)); isDead = true; dieEvent.Invoke(this); ParticleSystem particles = GetComponentInChildren <ParticleSystem>(); particles.Play(); ShockWave sw = Instantiate(dieShockWavePrefab); sw.transform.position = this.transform.position; }
private void Die() { die = true; DieEvent.Invoke(); dieSound.Play(); animator.SetTrigger("Die"); }
public void Die() { if (DieEvent != null) { DieEvent.Invoke(this, new EventArgs()); } }
public void SetHp(float points) { Currenthealth = points; if (Currenthealth <= 0) { DieEvent?.Invoke(); } ChangeView(); }
public void Damage(float damage) { Currenthealth -= damage; if (Currenthealth <= 0) { DieEvent?.Invoke(); } ChangeHealthEvent?.Invoke(Currenthealth); }
public void Damage(float value) { Hitpoints = Mathf.Max(0f, Hitpoints - value); HitpointsChangeEvent?.Invoke(Hitpoints); if (Hitpoints <= 0f) { DieEvent?.Invoke(); Kill(); } }
void OnDeviceDisconnected(string address) { // Check that this isn't an error-triggered disconnect, if it is, skip sending messages to the die if (_dice.TryGetValue(address, out Die die)) { System.Action <Die> finishDisconnect = (d) => { // Notify the die! d.die.OnDisconnected(); onDieDisconnected?.Invoke(d.die); _dice.Remove(address); }; switch (die.state) { case Die.State.Disconnecting: // This is perfectly okay finishDisconnect(die); break; case Die.State.Advertising: Debug.LogError("Disconnecting " + die.die.name + " is in incorrect state " + die.state); break; case Die.State.Connecting: case Die.State.Connected: Debug.LogWarning("Die " + die.die.name + " disconnected before subscribing"); finishDisconnect(die); break; case Die.State.Subscribing: Debug.LogWarning("Die " + die.die.name + " disconnected while subscribing"); // Clear error handler etc... onBluetoothError -= OnCharacteristicSubscriptionError; finishDisconnect(die); // Only kick off the next subscription IF this was the 'current' subscription attempt // Otherwise there will still be a subscription success/fail event and we'll trigger // the next one then. StartNextSubscribeToCharacteristic(); break; case Die.State.Ready: default: finishDisconnect(die); break; } } else { Debug.LogError("Unknown die " + address + " disconnected!"); } }
protected virtual void Die() { alive = false; DieEvent?.Invoke(this); #if DEBUG Debug.Log($"{this.GetInstanceID()} | {this.name} died."); #endif Destroy(this.gameObject); }
public void Damage(float damage) { if (Currenthealth - damage <= 0) { DieEvent?.Invoke(); } else { PhotonView?.RPC("DamageRPC", RpcTarget.All, damage); } }
private void OnCollisionEnter(Collision collision) { PlayerController pc = collision.collider.GetComponent <PlayerController>(); if (pc != null && isAlive) { pc.guy.currentHealth = Mathf.Clamp(pc.guy.currentHealth + health, 0, pc.guy.maxHealth); isAlive = false; DieEvent?.Invoke(this.gameObject); Destroy(this.gameObject); } }
public void Damage(float value) { _health = Mathf.Max(0f, _health - value); ChangeHealthEvent?.Invoke(_health); if (_health > 0f) { return; } DieEvent?.Invoke(); }
public void ElecticDamage(float value) { Hitpoints = Mathf.Max(0f, Hitpoints - (value - value * (ElecticResistance / 100))); ChangeEvent?.Invoke(Hitpoints); if (Hitpoints > 0f) { return; } DieEvent?.Invoke(); }
public void PureDamage(float value) { Hitpoints = Mathf.Max(0f, Hitpoints - value); ChangeEvent?.Invoke(Hitpoints); if (Hitpoints > 0f) { return; } DieEvent?.Invoke(); }
public void FireDamage(float value) { Hitpoints = Mathf.Max(0f, Hitpoints - (value - value * (FireResistance / 100))); StartCoroutine(TickDamageRoutine(value)); ChangeEvent?.Invoke(Hitpoints); if (Hitpoints > 0f) { return; } DieEvent?.Invoke(); }
private void LateUpdate() { if (!(CurrentHealth < 0)) { return; } DieEvent.Invoke(gameObject); OnDie.Invoke(); if (DestroyObjOnDie) { Destroy(gameObject); } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag(ground)) { isOnGround = true; playerAnimator.SetBool("IsJumping", false); playerAnimator.SetBool("IsRunning", true); } else if (collision.gameObject.CompareTag(enemy)) { DieEvent?.Invoke(); gameObject.SetActive(false); } }
private IEnumerator TickDamageRoutine(float damageValue) { { yield return(new WaitForSeconds(1)); for (int i = _timer; i > 0; i--) { Hitpoints -= (damageValue * 0.05f); if (Hitpoints <= 0) { DieEvent?.Invoke(); } yield return(new WaitForSeconds(1)); } } }
public void Die() { if (isPlayer) { Debug.LogWarning("GAME OVER!"); this.transform.position = spawnPoint.position; Spawner.SCORE_POINTS = 0; currentHealth = maxHealth; } else { DieEvent?.Invoke(this.gameObject); GameObject go = GameObject.Instantiate(shutteredCapsule); go.transform.position = this.transform.position; Destroy(this.gameObject); } }
public void IceDamage(float value) { Hitpoints = Mathf.Max(0f, Hitpoints - (value - value * (IceResistance / 100))); var movement = GetComponentInParent <Movement>(); if (movement.Speed > 0) { movement.SetSpeed(movement.Speed - (movement.Speed * 0.1f)); } ChangeEvent?.Invoke(Hitpoints); if (Hitpoints > 0f) { return; } DieEvent?.Invoke(); }
private void OnMouseDown() { if (!_isFreezed) { clicksToDestroy--; HitEvent?.Invoke(); if (clicksToDestroy <= 0) { gameProxy.AddScore(score); DieEvent?.Invoke(); explodable.generateFragments(); foreach (var fragment in explodable.fragments) { fragment.AddComponent <ObjectCleaner>(); } gameProxy.AddTime(timeAddedOnDestroy); gameProxy.ExplosionForce.doExplosion(transform.position); explodable.explode(); } } }
public bool Hit(IEnumerable <ContactPoint2D> contactPoints) { var topHit = true; foreach (var contact in contactPoints) { if (Vector2.Dot(contact.normal, Vector2.up) < 0.7f) { topHit = false; break; } } if (topHit) { Collider.enabled = false; DieEvent?.Invoke(); PlayDeathSound(); Animator.SetTrigger(Die1); } return(topHit); }
public void Die(Transform visualTransform = null) { IsDead = true; if (questId > 0) { NpcInteractableEvent?.Invoke(questId); } DieEvent?.Invoke(this); if (visualTransform != null) { var chest = Instantiate(chestInWorld, visualTransform.position, quaternion.identity); foreach (var item in DropItems) { chest.itemProps.Add(new ItemProp { item = item.item.GetCopy(), amount = item.amount }); } chest.PopUp(visualTransform.position); } IncomeEvent?.Invoke(Income); gameObject.SetActive(!IsDead); }
void OnCharacteristicSubscriptionChanged(string characteristic) { Die sub = _dice.Values.FirstOrDefault(d => d.state == Die.State.Subscribing); if (sub != null) { // Clean up error handler onBluetoothError -= OnCharacteristicSubscriptionError; sub.state = Die.State.Ready; sub.die.OnConnected(); onDieConnected?.Invoke(sub.die); StartNextSubscribeToCharacteristic(); } else { sub = _dice.Values.FirstOrDefault(d => d.state == Die.State.Disconnecting); if (sub == null) { Debug.LogError("Subscription success but no subscribing die"); } } }
void OnDieDisconnected(Central.IDie die) { onDieDisconnected?.Invoke((Die)die); }
void OnDieReady(Central.IDie die) { onDieConnected?.Invoke((Die)die); }
void Die() { DieEvent?.Invoke(); Destroy(gameObject); }
public void Die() { Push(); DieEvent?.Invoke(this); }
// 死亡 public void PlayerDie() { OnDie.Invoke(); GetComponent <PlayerShooting>().enabled = false; }
private void Dead() { DieEvent?.Invoke(parametersSO.team); Destroy(this); }