示例#1
0
    public virtual void TakeDamage(WeaponInfo info)
    {
        double rng = EntityInfo.rng.NextDouble();

        DamageReport report = new DamageReport();

        report.Crit = rng <= info.CritChance;
        report.SetIncoming(info);

        Health -= report.TotalIncoming();

        // report damage taken
        if (DamageReport != null)
        {
            DamageReport.Invoke(this, report);
        }

        if (Health <= 0)
        {
            Destroy(gameObject);

            if (DamagePrefab != null)
            {
                Destroy(Instantiate(DamagePrefab, transform.position, transform.rotation, null), 5f);

                if (UnityEngine.Random.Range(0, 1) < 0.5f)
                {
                    GameObject spawn = Instantiate(Loot, transform.position, transform.rotation, null);
                    spawn.GetComponent <PickupItem>().roll = BaseRoller.RollItem(120);
                }
            }
        }
    }
示例#2
0
 void Start()
 {
     spawn = Instantiate(item, transform.position, transform.rotation, null);
     spawn.GetComponent <PickupItem>().roll = BaseRoller.RollItem(100);
 }