コード例 #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        UnitLife life = collision.GetComponentInParent <UnitLife>();

        if (life)
        {
            if (!unitsHit.ContainsKey(collision.GetInstanceID()))
            {
                unitsHit.Add(collision.GetInstanceID(), life);
            }

            if (!collidedObjects.Contains(life))
            {
                collidedObjects.Add(life);
                life.onUnitsCollision(this.life);
                Transform exp = ParticleSpawner.instance.getReusable(exploshion).transform;
                exp.position = transform.position + Vector3.one * Random.Range(0, 0.1f);
            }

            //PlayerController.gold += goldDrop;
            //life.ApplyDamage(fireSystem.damage);
            if (suicider)
            {
                life.ApplyDamage(fireSystem.damage * 2);
                destroySelf();
            }
        }
    }
コード例 #2
0
    IEnumerator damageColliding()
    {
        while (true)
        {
            foreach (UnitLife life in unitsHit.Values)
            {
                life.onUnitsCollision(this.life);
                Transform exp = ParticleSpawner.instance.getReusable(exploshion).transform;
                exp.position = transform.position + Vector3.one * Random.Range(0, 0.1f);
                collidedObjects.Add(life);
            }
            yield return(new WaitForSeconds(0.2f));

            collidedObjects = new List <UnitLife>();
        }
    }