示例#1
0
文件: Enemy.cs 项目: ky0jr/rpg
 void IDeath.OnDeath()
 {
     collider.enabled = false;
     OnDeathEvent?.Invoke();
     GameManager.Current.ScoreManager.AddScore(15);
     GameManager.Current.Death(this);
 }
示例#2
0
 public void Death()
 {
     //Debug.Log("One [" + info.Name + "] was killed");
     OnDeathEvent?.Invoke();
     QuestManager.Instance.UpdateUI();
     if (info.DropItems.Count > 0)
     {
         List <ItemInfo> lootItems = new List <ItemInfo>();
         foreach (DropItemInfo di in info.DropItems)
         {
             if (ZetanUtility.Probability(di.DropRate))
             {
                 if (!di.OnlyDropForQuest || (di.OnlyDropForQuest && QuestManager.Instance.HasOngoingQuestWithID(di.BindedQuest.ID)))
                 {
                     lootItems.Add(new ItemInfo(di.Item, Random.Range(1, di.Amount + 1)));
                 }
             }
         }
         if (lootItems.Count > 0)
         {
             LootAgent la = ObjectPool.Get(info.LootPrefab).GetComponent <LootAgent>();
             la.Init(lootItems, transform.position);
         }
     }
 }
示例#3
0
 public void DeathEvent()
 {
     OnDeathEvent?.Invoke(this);
     //如果猎人日志里面已经存在此怪物并且个数已经大于等于所需解锁个数。则pass(判断写到数据管理器中了)
     GameDataMgr.Instance.AddHunterItem(int.Parse(EnermyID.Replace("En", string.Empty)));
     Debug.Log(int.Parse(EnermyID.Replace("En", string.Empty)));
 }
示例#4
0
 protected void TriggerOnDeath()
 {
     if (OnDeathEvent != null)
     {
         OnDeathEvent.Invoke(this);
     }
 }
    public void TakeDamage(DamageInfo damageData)
    {
        if (IsDeath || affectedBy == WeaponType.None)
        {
            return;
        }

        bool canBeAffected = (affectedBy == WeaponType.All) || (damageData.data.weaponType == affectedBy);

        if (!canBeAffected)
        {
            return;
        }

        if (IsInvincible)
        {
            OnNegatedDamageEvent.Invoke();
            return;
        }

        currentHealth -= damageData.data.damage;

        if (currentHealth <= 0)
        {
            OnDeathEvent.Invoke(damageData);
            IsDeath = true;
        }
        else
        {
            OnDamageEvent.Invoke(currentHealth, maxHealth, damageData);
        }
    }
示例#6
0
 protected void TriggerDeathEvent()
 {
     if (OnDeathEvent != null)
     {
         OnDeathEvent.Invoke();
     }
 }
示例#7
0
 // Use this for initialization
 void Start()
 {
     _currentHealth = _maxHealth;
     if (OnDeath == null)
     {
         OnDeath = new OnDeathEvent();
     }
 }
示例#8
0
 protected void Die()
 {
     OnPreDeath();
     if (OnDeathEvent != null)
     {
         OnDeathEvent.Invoke();
     }
     Destroy(gameObject);
 }
示例#9
0
    private void ExecuteDeathEvents()
    {
        OnDeathEvent temp = (OnDeathEvent)eventTable["DeathEvent"];

        if (temp != null)
        {
            temp();
        }
    }
示例#10
0
    void ApplyCollision(Collision collision)
    {
        float forceMagnitude = collision.impulse.magnitude;

        //print(forceMagnitude.ToString());
        centreHealth -= forceMagnitude;
        if (centreHealth <= 0.0f)
        {
            OnDeathEvent?.Invoke(this);
        }
    }
示例#11
0
    public virtual void GetDamaged(int damage)
    {
        health -= (int)CalculateResistance(damage, unitDescirption.armorType);

        if (health <= 0)
        {
            OnDeathEvent?.Invoke();
            FindObjectOfType <SpawnManager>().RemoveDeadUnitFromList(gameObject);
            FindObjectOfType <GameManager>().OnKillMethod(gameObject);
            Destroy(this.gameObject);
        }
    }
示例#12
0
 void Initialize()
 {
     onPlayerJoinEvent        = new OnPlayerJoinEvent();
     onPlayerLeaveEvent       = new OnPlayerLeaveEvent();
     onCharacterSelectEvent   = new OnCharacterSelectEvent();
     onCharacterDeSelectEvent = new OnCharacterDeSelectEvent();
     onHitEvent      = new OnHitEvent();
     onGrabEvent     = new OnGrabEvent();
     onDamageEvent   = new OnDamageEvent();
     onHitStunEvent  = new OnHitStunEvent();
     onEdgeGrabEvent = new OnEdgeGrabEvent();
     onDeathEvent    = new OnDeathEvent();
     onGameOverEvent = new OnGameOverEvent();
 }
示例#13
0
 public void Death()
 {
     //Debug.Log("One [" + info.Name + "] was killed");
     OnDeathEvent?.Invoke();
     if (info.DropItems && info.DropItems.IsValid)
     {
         var lootItems = info.DropItems.DoDrop();
         if (lootItems.Count > 0)
         {
             LootAgent la = ObjectPool.Get(info.LootPrefab).GetComponent <LootAgent>();
             la.Init(lootItems, transform.position);
         }
     }
 }
    public void TakeDamage(float value)
    {
        if (hp - value <= 0.0f)
        {
            hp = 0f;
        }
        else
        {
            hp = hp - value;
        }

        if (hp <= 0f)
        {
            OnDeathEvent?.Invoke();
        }
    }
示例#15
0
    public void IncrementDeath(int playerNum)
    {
        if (mainCamShake == null)
        {
            mainCamShake = FindObjectOfType <CameraShake>();
        }
        if (enableCamShakeOnDeath)
        {
            mainCamShake.ShakeScreen();
        }
        PlayerStats requiredPlayer = playersHashTable[playerNum];

        requiredPlayer.PlayerDeaths++;
        //Debug.Log(OnMuddledEvent.GetInvocationList().Length);
        OnDeathEvent?.Invoke(playerNum);        // let the respecive player know that they ded
    }
    void Update()
    {
        switch (currentLifeSpan)
        {
        case LifeSpan.Life:
            OnLifeEvent.Invoke();
            break;

        case LifeSpan.TimeSpan:
            OnTimeSpanEvent.Invoke();
            break;

        case LifeSpan.Death:
            OnDeathEvent.Invoke();
            break;
        }
    }
示例#17
0
    //Destroys the planet when runs out of life.
    void Death()
    {
        if (isStar)
        {
            return;
        }

        saveData.isAlive = false;
        hud.SetActive(false);
        gameObject.SetActive(false);

        //Invokes planet death event.
        OnDeathEvent?.Invoke();

        //Checks if the player wins the level.
        controller.level.curLevel.CheckForWin();
    }
示例#18
0
    public void SetHealthDelta(float delta)
    {
        if (delta <= 0 && IsInvincible)
        {
            return;
        }

        if (!IsInvincible && healthSprite.color != spriteColor)
        {
            healthSprite.color = spriteColor;
        }

        float current = Mathf.Clamp(healthTimeline.Value + delta, 0, maxHealth);

        healthTimeline.SetValue(new TimedFloat(GameTime.Instance.ElapsedTime, current));

        if (externalVar != null)
        {
            externalVar.Value = healthTimeline.Value;
        }

        if (current == 0)
        {
            OnDeathEvent?.Invoke();
            if (disableOnDeath)
            {
                gameObject.SetActive(false);
            }
        }
        else if (delta < 0 && actualIFrame > 0 && healthSprite != null && gameObject.activeInHierarchy)
        {
            if (invincibleAnim != null)
            {
                StopCoroutine(invincibleAnim);
            }
            lastInvincibleStart = GameTime.Instance.ElapsedTime;
            invincibleAnim      = InvincibleRoutine();
            StartCoroutine(invincibleAnim);
        }
    }
示例#19
0
 /// <summary>
 /// 设置血量变化
 /// </summary>
 /// <param name="amount">变化值</param>
 /// <param name="from">哪个玩家要改的(谁打的)</param>
 public void SetHealthAmount(float amount, PlayerManager from = null)
 {
     if (amount == 0 || lastPainFrame == Time.frameCount)        // 每一帧最多只接收一次伤害
     {
         return;
     }
     if (amount < 0)
     {
         isFeelPain    = true;
         timeElapsed   = feelPainTime;
         lastPainFrame = Time.frameCount;
     }
     CurrentHealth += amount;
     UpdateSlider();
     OnHealthChanged(from);
     if (IsDead)
     {
         OnDead(from);
         if (OnDeathEvent != null)
         {
             OnDeathEvent.Invoke(this, from);
         }
     }
 }
示例#20
0
 void Awake()
 {
     onValueChangeEvent = new OnValueChangeEvent();
     onDeathEvent       = new OnDeathEvent();
 }
示例#21
0
        public void Damage(float damage, Vector3 hitPoint, AttributeChangeCause cause = AttributeChangeCause.FORCED, Damageable attacker = null, DamageType type = DamageType.NONE)
        {
            //  Invoke a damage event
            DamageEvent e = new DamageEvent {
                cause = cause, victim = this, attacker = attacker, type = type, damage = damage
            };

            OnDamageEvent?.Invoke(this, e);
            if (e.cancel == true)
            {
                return;
            }                               //  return if the event has been cancelled by any subscriber

            bool hadImmunity   = false;
            bool hadWeakness   = false;
            bool hadResistance = false;

            //  Check for immunity
            for (int i = 0; i < immunities.Length; i++)
            {
                if (e.type == immunities[i])
                {
                    e.damage    = 0;
                    hadImmunity = true;
                    break;
                }
            }

            //  Modify any damage by any weaknesses or resistances
            if (e.damage > 0 && e.type != DamageType.NONE)
            {
                for (int i = 0; i < weaknesses.Length; i++)
                {
                    if (e.type == weaknesses[i])
                    {
                        e.damage   *= 2;
                        hadWeakness = true;
                        break;
                    }
                }

                for (int i = 0; i < resistances.Length; i++)
                {
                    if (e.type == resistances[i])
                    {
                        e.damage     /= 2;
                        hadResistance = true;
                        break;
                    }
                }
            }

            //  If the damage is enough to kill, invoke a death event
            if (GetAttributeValue(Attributes.HEALTH) - e.damage <= 0)
            {
                DeathEvent e2 = new DeathEvent {
                    cause = cause, victim = this, attacker = attacker
                };
                OnDeathEvent?.Invoke(this, e2);
                if (e2.cancel == true)
                {
                    return;
                }                                //  return if the event has been cancelled by any subscriber
            }

            //  Update health
            GetAttribute(Attributes.HEALTH).Modify(-e.damage);

            //  Send indicator
            Color indicatorColor = Color.gray * Color.gray;

            if (hadImmunity)
            {
                indicatorColor = Color.red;
            }
            if (hadWeakness)
            {
                indicatorColor = Color.white;
            }
            if (hadResistance)
            {
                indicatorColor = Color.yellow;
            }

            if (hitPoint == null)
            {
                UIMaster.SendFloatingIndicator(this.transform.position + this.transform.rotation * center, e.damage.ToString("#.0"), indicatorColor);
            }
            else
            {
                UIMaster.SendFloatingIndicator(hitPoint, e.damage.ToString("0.0"), indicatorColor);
            }
        }
示例#22
0
文件: Player.cs 项目: rmuqsith/rpg
 public void OnDeath()
 {
     OnDeathEvent?.Invoke();
 }
示例#23
0
 private void die()
 {
     Destroy(gameObject);
     OnDeathEvent.Invoke(this);
 }