-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExtraWind.cs
37 lines (33 loc) · 941 Bytes
/
ExtraWind.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ExtraWind : MonoBehaviour {
private WindController wind;
private bool activatedWind;
public AudioClip sound;
void Start(){
wind = GameObject.FindObjectOfType<WindController>();
}
void Update () {
transform.Translate(Vector2.down * Time.deltaTime, Space.World);
}
void OnTriggerEnter2D (Collider2D collision){
if(collision.gameObject.tag == "Ball"){
activatedWind = wind.activateTime;
Ball ball = collision.gameObject.GetComponent<Ball>();
var isMoovin = ball.isMooving;
if (isMoovin){
if(!activatedWind){
AudioSource.PlayClipAtPoint(sound, transform.position);
wind.ActivateWind();
Destroy(gameObject);
}else if (activatedWind){
wind.timeEnabled -= wind.windEnableTime;
Destroy(gameObject);
}
}else{
Destroy(gameObject);
}
}
}
}