Ejemplo n.º 1
0
 public void Death()
 {
     GameMaster.CountKill();
     transform.localScale = Vector3.one;
     ObjectsPool.Spawn(GameMaster.enemyFX, GameMaster.idPool_enemyDeathFX, transform.position, transform.rotation).GetComponent <AudioSource>().Play();
     ObjectsPool.Despawn(GameMaster.idPool_enemies, gameObject);
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Destroys the projectile immediatly.
    /// </summary>
    protected virtual void DestroyProjectile()
    {
        // Stop all active coroutines.
        StopAllCoroutines();

        // Object pool despawn
        ObjectsPool.Despawn(this.gameObject);
    }
Ejemplo n.º 3
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     //If the weight hits the player, despawn it and remove one life
     if (coll.gameObject.tag == "Player")
     {
         ObjectsPool.Despawn(this.gameObject);
         GameController.Damage(1);
     }
 }
Ejemplo n.º 4
0
    IEnumerator Play()
    {
        if (fx != null)
        {
            fx.Play();
        }
        yield return(new WaitForSeconds(timeLife));

        ObjectsPool.Despawn(idPool, gameObject);
        yield return(null);
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Destroys the projectile immediatly.
    /// </summary>
    protected virtual void DestroyProjectile()
    {
        // Stop all active coroutines.
        StopAllCoroutines();

        // Set back the original size, so there are no scaling problems after respawning
        this.transform.localScale = originalSize;

        // Object pool despawn
        ObjectsPool.Despawn(this.gameObject);
    }
Ejemplo n.º 6
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Kill and deactivate the player
        if (other.tag == "Player")
        {
            GameController.Damage(5);
            other.gameObject.SetActive(false);
        }

        //Despawn the weight
        if (other.tag == "Weight")
        {
            ObjectsPool.Despawn(other.gameObject);
        }
    }
Ejemplo n.º 7
0
    void OnTriggerEnter2D(Collider2D col)
    {
        //If the col has the tag 'Line' despawn and put it back in the pool
        if (col.tag == "Line")
        {
            ObjectsPool.Despawn(col.gameObject);
        }

        //If the col has the tag 'Platform', destroy it
        if (col.tag == "Platform")
        {
            Destroy(col.gameObject);
        }

        //If the col has the tag 'Player', remove all lives
        if (col.tag == "Player")
        {
            GameController.Damage(5);
        }
    }
Ejemplo n.º 8
0
    void Deactivate()
    {
        BoxCollider box = GetComponent <BoxCollider>();

        if (box != null)
        {
            Destroy(box);
        }

        SkinnedMeshRenderer renderer = GetComponent <SkinnedMeshRenderer>();

        if (renderer != null)
        {
            Destroy(renderer);
            attachedRenderer = gameObject.AddComponent <MeshRenderer>();

            attachedFilter = gameObject.AddComponent <MeshFilter>();
        }

        MeshFilter filter = GetComponent <MeshFilter>();

        if (filter == null)
        {
            attachedFilter = gameObject.AddComponent <MeshFilter>();
        }

        if (attachedRigid != null)
        {
            attachedRigid.angularDrag = 0.0f;
            attachedRigid.drag        = 0.0f;
            attachedRigid.useGravity  = true;
        }

        if (gameObject != null)
        {
            ObjectsPool.Despawn(gameObject);
        }
    }
Ejemplo n.º 9
0
    void Update()
    {
        //Enable if this weight is spawned after the spawner reaches a position past x
        if (thisTransform.position.x > 49)
        {
            this.gameObject.SetActive(true);
        }
        else
        {
            this.gameObject.SetActive(false);
        }

        //Get all the objects in a radius tagged Line
        Collider2D[] colliders = Physics2D.OverlapCircleAll(thisTransform.position, 0.7f);

        //Dispawn the lines hit
        foreach (Collider2D col in colliders)
        {
            if (col.tag == "Line")
            {
                ObjectsPool.Despawn(col.gameObject);
            }
        }
    }
Ejemplo n.º 10
0
    private IEnumerator Destroy()
    {
        yield return(new WaitForSeconds(time));

        ObjectsPool.Despawn(gameObject);
    }
Ejemplo n.º 11
0
 public static void Despawn(this GameObject objToDespawn)
 {
     ObjectsPool.Despawn(objToDespawn);
 }
Ejemplo n.º 12
0
 void DisableObj()
 {
     ObjectsPool.Despawn(GameMaster.idPool_bullet, gameObject);
 }