| usingSystem.Collections; |
| usingSystem.Collections.Generic; |
| usingUnityEngine; |
| |
| publicclassShipCollector:MonoBehaviour |
| { |
| |
| privateGameObjectsattelite; |
| publicintcollectionstatus=0; |
| privateGameObjectCollectionMessage; |
| privateAnimatorcollectionAnimator; |
| publicboolcollect=false; |
| publicboolcollidertriggered=false; |
| publicstringVictory; |
| |
| // Start is called before the first frame update |
| voidStart() |
| { |
| sattelite=GameObject.FindWithTag("Debris"); |
| CollectionMessage=GameObject.FindWithTag("CollectionMessage"); |
| collectionAnimator=CollectionMessage.GetComponent<Animator>(); |
| |
| } |
| |
| // Update is called once per frame |
| voidUpdate() |
| { |
| |
| } |
| |
| voidOnTriggerEnter2D(Collider2Dother) |
| { |
| if(other.gameObject.CompareTag("CollectionArea")) |
| { |
| |
| collect=true; |
| collectionstatus=0; |
| collecting(); |
| |
| /* collectionAnimator.SetInteger("Status", 1); |
| collectionAnimator.SetInteger("Status", 2); |
| collectionAnimator.SetInteger("Status", 3); |
| collectionAnimator.SetInteger("Status", 4); |
| collectionAnimator.SetInteger("Status", 5); |
| Destroy(sattelite); |
| */ |
| |
| } |
| else{ |
| collect=false; |
| } |
| |
| |
| } |
| |
| voidOnTriggerExit2D(Collider2Dother) |
| { |
| if(other.gameObject.CompareTag("CollectionArea")) |
| { |
| |
| collect=false; |
| collectionstatus=0; |
| collectionAnimator.SetInteger("Status",0); |
| |
| } |
| |
| } |
| |
| privatevoidcollecting(){ |
| |
| if(collectionstatus<5&&collect==true){ |
| collectionstatus++; |
| collectionAnimator.SetInteger("Status",collectionstatus); |
| } |
| elseif(collect==true){ |
| Destroy(sattelite); |
| collect=false; |
| Application.LoadLevel(Victory); |
| } |
| |
| |
| Invoke("collecting",1f); |
| |
| } |
| |
| |
| |
| |
| |
| } |