public void SetHealth(int hp, int hpmax) { if (HP <= 0 && hp > 0) { OnRevive?.Invoke(this); } BaseInst.SetHealth(hp, hpmax); if (hp <= 0) { if (IsSpawned && !IsPlayer) { World.DespawnList_NPC.AddVob(this); } if (unconTimer != null && unconTimer.Started) { unconTimer.Stop(); } } if (hp <= 0) { _Uncon = Unconsciousness.None; OnDeath?.Invoke(this); sOnDeath?.Invoke(this); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { if (OnSpaceDown != null) { // mainPlane.FireOnce(); OnSpaceDown.Invoke(); } } else if (Input.GetKey(KeyCode.Space)) { // mainPlane.FireStart(); if (OnSpace != null) { OnSpace.Invoke(); } } else if (Input.GetKeyDown(KeyCode.J)) { OnRevive.Invoke(); Debug.Log("revive2"); } else if (Input.GetKeyDown(KeyCode.Escape)) { Esc(); } if (OnMovement != null) { OnMovement.Invoke(new Vector3(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"), 0)); } }
private void RPCRevive() { _agent.isStopped = false; GetComponent <Collider>().isTrigger = false; isDowned = false; _shader.SetFloat("PercentDisintegrated", 0f); OnRevive?.Invoke(); }
private void Revive() { GameIsOver = false; availableRevives -= 1; Debug.Log($"Player has revived. Remaining Revives: {availableRevives}"); OnRevive?.Invoke(); }
public void Heal(float health) { Lost -= health; OnHeal?.Invoke(); if (Lost <= 0f) { Lost = 0f; if (!IsAlive) { IsAlive = true; OnRevive?.Invoke(); } } }
public virtual void StartRound() { OnStartRound?.Invoke(); Clear(); StartRoundTime = (int)Math.Round(Math.PI / speed * 72 * 3 * SZR); StartRotation = 2D * Math.PI * R.NextDouble(); MVP.Hide(); Program.Map.spawnOrb(); Sort(); OnRevive?.Invoke(); if (HEADS[ActiveKeys[0]].Points > 0) { Leader = ActiveKeys[0]; } phase = Phases.STARTROUND; }
public void SetHealth(int hp, int hpmax) { if (this.HP <= 0 && hp > 0) { OnRevive?.Invoke(this); } this.BaseInst.SetHealth(hp, hpmax); pSetHealth(hp, hpmax); if (hp <= 0) { this.uncon = Unconsciousness.None; OnDeath?.Invoke(this); sOnDeath?.Invoke(this); } }
protected override bool OnApplyHeal(Heal heal) { bool isAlive = !Hp.IsEmpty; if (isAlive) { hp.Add(heal.Get(this)); OnHealed?.Invoke(this); return(true); } else if (canBeRevived) { hp.Add(heal.Get(this)); OnRevive?.Invoke(this); return(true); } return(false); }
void Start() { rigidbody = GetComponent <Rigidbody>(); if (rigidbody == null) { rigidbody = gameObject.AddComponent <Rigidbody>(); rigidbody.freezeRotation = true; rigidbody.collisionDetectionMode = CollisionDetectionMode.Continuous; } capsuleCollider = GetComponent <CapsuleCollider>(); if (capsuleCollider == null) { capsuleCollider = gameObject.AddComponent <CapsuleCollider>(); capsuleCollider.height = 1.6f; capsuleCollider.center = new Vector3(0, 0.8f, 0); } model = Instantiate(Resources.Load <GameObject>("Models/" + modelName), transform).transform; GetStat(Stat.Name.HEALTH).MaxValue = 100f; GetStat(Stat.Name.MANA).MaxValue = 100f; GetStat(Stat.Name.STAMINA).MaxValue = 100f; GetStat(Stat.Name.RAGE).MaxValue = 10f; GetStat(Stat.Name.FOCUS).MaxValue = 10f; GetStat(Stat.Name.HEALTH).OnChange += delegate(float newValue, float oldValue, float diff, float maxValue) { if (oldValue >= 0f && newValue <= 0f) { OnDie?.Invoke(this); } else if (oldValue <= 0f && newValue >= 0f) { OnRevive?.Invoke(this); } }; }
/// <summary> /// Method called when this object gets back from the deads. /// </summary> protected virtual void Revive() { OnRevive?.Invoke(); gameObject.layer = layerBeforeDeath; }
public void revive() => OnRevive?.Invoke();