1
using System
.Collections
;
2 using System
.Collections
.Generic
;
6 public class YarnBullet
: MonoBehaviour
{
7 public float speed
= 2.5f
;
9 public EffectImpact ImpactEffect
;
11 private Vector3 Direction
;
15 //AudioSource[] audioSources = GetComponents<AudioSource>();
16 //explosion = audioSources[0];
17 ImpactEffect
.SetupPool();
18 Direction
= this.transform
.position
- GameObject
.FindGameObjectWithTag("Yarn_inside_container").transform
.position
;
23 float step
= speed
* Time
.deltaTime
;
25 transform
.Translate(Direction
.normalized
* step
,Space
.World
);
28 void OnCollisionEnter2D(Collision2D col
)
30 if (col
.collider
.CompareTag("EnemyA") ||
31 col
.collider
.CompareTag("EnemyB") ||
32 col
.collider
.CompareTag("EnemyC"))
34 col
.gameObject
.GetComponent
<Enemy
>().BulletCollision(this.tag
);
35 ImpactEffect
.ShowImpactEffect(this.transform
.position
, Vector3
.zero
);
39 if (col
.collider
.CompareTag("EnemyBShield"))
41 col
.transform
.parent
.GetComponent
<Enemy
>().BulletCollision(this.tag
);
42 ImpactEffect
.ShowImpactEffect(this.transform
.position
, Vector3
.zero
);
46 if (col
.gameObject
.layer
== LayerMask
.NameToLayer("Default"))
52 void OnTriggerEnter2D(Collider2D col
)
54 if (col
.CompareTag("OrderedTarget"))
56 ShootingOrder shootingOrderObject
= col
.transform
.parent
.gameObject
.GetComponent
<ShootingOrder
>();
58 if (col
.gameObject
.name
.Contains("Red"))
60 shootingOrderObject
.redShot
= true;
61 col
.gameObject
.GetComponent
<SpriteRenderer
>().color
= Color
.gray
;
63 else if (col
.gameObject
.name
.Contains("Yellow"))
65 shootingOrderObject
.yellowShot
= true;
66 col
.gameObject
.GetComponent
<SpriteRenderer
>().color
= Color
.gray
;
68 else if (col
.gameObject
.name
.Contains("Green"))
70 shootingOrderObject
.greenShot
= true;
71 col
.gameObject
.GetComponent
<SpriteRenderer
>().color
= Color
.gray
;
73 else if (col
.gameObject
.name
.Contains("Blue"))
75 shootingOrderObject
.blueShot
= true;
76 col
.gameObject
.GetComponent
<SpriteRenderer
>().color
= Color
.gray
;