Example #1
0
    private void OnTriggerEnter(Collider other)
    {
        Debug.Log("colisiono con " + other.name);

        //If the player is hit
        FPSCameraAndMovController player = other.transform.GetComponent <FPSCameraAndMovController>();

        if (player != null)
        {
            player.TakeDamage(damage);
            impactPlayerSound.Play(other.transform);
            Destroy(this.gameObject);
            trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
        }

        //Hits another enemy
        EnemyBehavior enemy = other.transform.GetComponent <EnemyBehavior>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            impactPlayerSound.Play(other.transform);
            Destroy(this.gameObject);
            trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
        }

        //Hits a turret
        TurretBehavior turret = other.transform.GetComponent <TurretBehavior>();

        if (turret != null)
        {
            turret.TakeDamage(damage);
            impactPlayerSound.Play(other.transform);
            Destroy(this.gameObject);
            trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
        }


        //Bounce if possible
        if (other.gameObject.layer.Equals(14) && isBounceable)
        {
            //Debug.Log("rebote");
            //Bounce in the opposite direction and double velocity if we are in blademode and we swing
            playerGO.GetComponent <FPSCameraAndMovController>().PlayBounce();
            GetComponent <Rigidbody>().velocity = -GetComponent <Rigidbody>().velocity * 2.0f;
        }

        //If collides with anything else

        else
        {
            impactNoneSound.Play(other.transform);
            Destroy(this.gameObject);
            trayectorySound.Stop(FMOD.Studio.STOP_MODE.IMMEDIATE);
        }
    }
Example #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Enemy_Laser    eLaser = col.gameObject.GetComponent <Enemy_Laser> ();
        TurretBehavior turret = col.gameObject.GetComponent <TurretBehavior> ();
        AsteroidBig    big    = col.gameObject.GetComponent <AsteroidBig> ();
        AsteroidMed    med    = col.gameObject.GetComponent <AsteroidMed> ();
        AsteroidSmall  small  = col.gameObject.GetComponent <AsteroidSmall> ();

        if (eLaser)
        {
            eLaser.Hit();
            Destroy(gameObject);
            AudioSource.PlayClipAtPoint(destroyed, this.transform.position);
            Instantiate(debris, this.transform.position, Quaternion.identity);
        }

        if (big || med || small || turret || col.tag == "Wall")
        {
            Destroy(gameObject);
            AudioSource.PlayClipAtPoint(destroyed, this.transform.position);
            Instantiate(debris, this.transform.position, Quaternion.identity);
        }
    }
Example #3
0
 public void Unoccupy()
 {
     this.turret = null;
 }
Example #4
0
 public void Occupy( TurretBehavior _turret )
 {
     this.turret = _turret;
     this.turret.componentTower = this;
 }
Example #5
0
 public void Deactivate()
 {
     this.isActive = false;
     this.baseRenderer.enabled = false;
     this.turret = null;
 }
Example #6
0
 public void Activate()
 {
     this.isActive = true;
     this.baseRenderer.enabled = true;
     this.turret = null;
 }