Skip to content

Commit

Permalink
update penempatan script
Browse files Browse the repository at this point in the history
  • Loading branch information
devteam21 committed Sep 23, 2021
1 parent 9bbafff commit f45a28b
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 22 deletions.
56 changes: 56 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
14 changes: 3 additions & 11 deletions Assets/Scripts/Bird.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public enum BirdState { Idle, Thrown, HitSomething }
public GameObject Parent;
public Rigidbody2D birdRigidbody;
public CircleCollider2D birdCollider;

private BirdState state;
private float minVelocity = 0.05f;
private bool flagDestroy = false;

public UnityAction OnBirdDestroyed = delegate { };
public UnityAction<Bird> OnBirdShot = delegate { };

public BirdState State { get => state; private set => state = value; }

private void Start()
Expand Down Expand Up @@ -46,12 +43,6 @@ private IEnumerator DestroyAfter(float timeInSecond)
Destroy(gameObject);
}

public void MoveTo(Vector2 target, GameObject parent)
{
gameObject.transform.SetParent(parent.transform);
gameObject.transform.position = target;
}

public void Shoot(Vector2 velocity, float distance, float speed)
{
birdCollider.enabled = true;
Expand All @@ -60,9 +51,10 @@ public void Shoot(Vector2 velocity, float distance, float speed)
OnBirdShot(this);
}

public virtual void OnTap()
public void MoveTo(Vector2 target, GameObject parent)
{

gameObject.transform.SetParent(parent.transform);
gameObject.transform.position = target;
}

private void OnDestroy()
Expand Down
2 changes: 2 additions & 0 deletions Assets/Scripts/Destroyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public class Destroyer : MonoBehaviour
{

private void OnTriggerEnter2D(Collider2D collision)
{
string collisionTag = collision.gameObject.tag;
Expand All @@ -12,4 +13,5 @@ private void OnTriggerEnter2D(Collider2D collision)
Destroy(collision.gameObject);
}
}
s
}
16 changes: 8 additions & 8 deletions Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,14 @@ private void Start()
shotBird = birds[0];
}

public void ChangeBird()
public void AssignTrail(Bird selectedBird)
{
trailController.SetBird(selectedBird);
StartCoroutine(trailController.SpawnTrails());
tapCollider.enabled = true;
}

public void ChangeBird()
{
tapCollider.enabled = false;

Expand All @@ -46,13 +53,6 @@ public void ChangeBird()
}
}

public void AssignTrail(Bird selectedBird)
{
trailController.SetBird(selectedBird);
StartCoroutine(trailController.SpawnTrails());
tapCollider.enabled = true;
}

public void CheckGameEnd(GameObject destroyedEnemy)
{
for (int i = 0; i < enemies.Count; i++)
Expand Down
6 changes: 4 additions & 2 deletions Assets/Scripts/SlingShooter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
using UnityEngine;

public class SlingShooter : MonoBehaviour

{
public CircleCollider2D collider;
private Vector2 startPos;
[SerializeField] private float radius = 0.75f;
[SerializeField] private float throwSpeed = 30f;

public CircleCollider2D collider;
private Vector2 startPos;
private Bird birdInSling;
public LineRenderer trajectoryRenderer;

Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/TrailController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ public class TrailController : MonoBehaviour
public GameObject Trail;
public Bird targetBird;
private List<GameObject> trails;

private void Start()

{
trails = new List<GameObject>();
}
Expand Down

0 comments on commit f45a28b

Please sign in to comment.