Beispiel #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ShotScrpit shot = other.gameObject.GetComponent <ShotScrpit>();

        if (shot != null)
        {
            if (shot.isEnimyShot != isEnemy)
            {
                Damage(shot.danage);
                Destroy(shot.gameObject);
            }
        }
    }
Beispiel #2
0
 public void Attact(bool isEnemy, Vector2 direction)
 {
     if (CanAttack)
     {
         shootCooldown = shootingRate;
         var shotTransform = Instantiate(shotPrefab);
         shotTransform.position = transform.position;
         ShotScrpit shot = shotTransform.gameObject.GetComponent <ShotScrpit>();
         if (shot != null)
         {
             shot.isEnimyShot = isEnemy;
         }
         MoveScript move = shotTransform.gameObject.GetComponent <MoveScript>();
         if (move != null)
         {
             move.direction = direction;
         }
     }
 }